41
41
# repository decides to close the connection which we expect to be kept alive.
42
42
$SIG {PIPE } = ' IGNORE' ;
43
43
44
+ # Given a dot separated version number, "subtract" it from
45
+ # the SVN::Core::VERSION; non-negaitive return means the SVN::Core
46
+ # is at least at the version the caller asked for.
47
+ sub compare_svn_version {
48
+ my (@ours ) = split (/ \. / , $SVN::Core::VERSION );
49
+ my (@theirs ) = split (/ \. / , $_ [0]);
50
+ my ($i , $diff );
51
+
52
+ for ($i = 0; $i < @ours && $i < @theirs ; $i ++) {
53
+ $diff = $ours [$i ] - $theirs [$i ];
54
+ return $diff if ($diff );
55
+ }
56
+ return 1 if ($i < @ours );
57
+ return -1 if ($i < @theirs );
58
+ return 0;
59
+ }
60
+
44
61
sub _req_svn {
45
62
require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
46
63
require SVN::Ra;
47
64
require SVN::Delta;
48
- if ($SVN::Core::VERSION lt ' 1.1.0' ) {
65
+ if (::compare_svn_version( ' 1.1.0' ) < 0 ) {
49
66
fatal " Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION )" ;
50
67
}
51
68
}
@@ -1474,7 +1491,7 @@ sub cmd_info {
1474
1491
}
1475
1492
::_req_svn();
1476
1493
$result .= " Repository UUID: $uuid \n " unless $diff_status eq " A" &&
1477
- ($SVN::Core::VERSION le ' 1.5.4' || $file_type ne " dir" );
1494
+ (::compare_svn_version( ' 1.5.4' ) <= 0 || $file_type ne " dir" );
1478
1495
$result .= " Revision: " . ($diff_status eq " A" ? 0 : $rev ) . " \n " ;
1479
1496
1480
1497
$result .= " Node Kind: " .
5464
5481
5465
5482
# earlier 1.6.x versions would segfault, and <= 1.5.x didn't have
5466
5483
# this function
5467
- if ($SVN::Core::VERSION gt ' 1.6.12' ) {
5484
+ if (::compare_svn_version( ' 1.6.12' ) > 0 ) {
5468
5485
my $config = SVN::Core::config_get_config($config_dir );
5469
5486
my ($p , @a );
5470
5487
# config_get_config returns all config files from
@@ -5623,7 +5640,7 @@ sub get_log {
5623
5640
# drop it. Therefore, the receiver callback passed to it
5624
5641
# is made aware of this limitation by being wrapped if
5625
5642
# the limit passed to is being wrapped.
5626
- if ($SVN::Core::VERSION le ' 1.2.0' ) {
5643
+ if (::compare_svn_version( ' 1.2.0' ) <= 0 ) {
5627
5644
my $limit = splice (@args , 3, 1);
5628
5645
if ($limit > 0) {
5629
5646
my $receiver = pop @args ;
@@ -5655,7 +5672,8 @@ sub trees_match {
5655
5672
5656
5673
sub get_commit_editor {
5657
5674
my ($self , $log , $cb , $pool ) = @_ ;
5658
- my @lock = $SVN::Core::VERSION ge ' 1.2.0' ? (undef , 0) : ();
5675
+
5676
+ my @lock = (::compare_svn_version(' 1.2.0' ) >= 0) ? (undef , 0) : ();
5659
5677
$self -> SUPER::get_commit_editor($log , $cb , @lock , $pool );
5660
5678
}
5661
5679
@@ -5673,7 +5691,7 @@ sub gs_do_update {
5673
5691
my (@pc ) = split m # /# , $path ;
5674
5692
my $reporter = $self -> do_update($rev_b , (@pc ? shift @pc : ' ' ),
5675
5693
1, $editor , $pool );
5676
- my @lock = $SVN::Core::VERSION ge ' 1.2.0' ? (undef ) : ();
5694
+ my @lock = (::compare_svn_version( ' 1.2.0' ) >= 0) ? (undef ) : ();
5677
5695
5678
5696
# Since we can't rely on svn_ra_reparent being available, we'll
5679
5697
# just have to do some magic with set_path to make it so
@@ -5723,7 +5741,7 @@ sub gs_do_switch {
5723
5741
$ra ||= $self ;
5724
5742
$url_b = escape_url($url_b );
5725
5743
my $reporter = $ra -> do_switch($rev_b , ' ' , 1, $url_b , $editor , $pool );
5726
- my @lock = $SVN::Core::VERSION ge ' 1.2.0' ? (undef ) : ();
5744
+ my @lock = (::compare_svn_version( ' 1.2.0' ) >= 0) ? (undef ) : ();
5727
5745
$reporter -> set_path(' ' , $rev_a , 0, @lock , $pool );
5728
5746
$reporter -> finish_report($pool );
5729
5747
0 commit comments