First release translation for Vietnamese
[git.git] / git-svn.perl
index 427da9e7a1a10ad9949eaa0c97d7fd0aa3436c3e..c84842ff0383c6929d8169834944ec1ad2bb7346 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/perl
 # Copyright (C) 2006, Eric Wong <normalperson@yhbt.net>
 # License: GPL v2 or later
 use 5.008;
@@ -41,11 +41,28 @@ sub fatal (@) { print STDERR "@_\n"; exit 1 }
 # repository decides to close the connection which we expect to be kept alive.
 $SIG{PIPE} = 'IGNORE';
 
+# Given a dot separated version number, "subtract" it from
+# the SVN::Core::VERSION; non-negaitive return means the SVN::Core
+# is at least at the version the caller asked for.
+sub compare_svn_version {
+       my (@ours) = split(/\./, $SVN::Core::VERSION);
+       my (@theirs) = split(/\./, $_[0]);
+       my ($i, $diff);
+
+       for ($i = 0; $i < @ours && $i < @theirs; $i++) {
+               $diff = $ours[$i] - $theirs[$i];
+               return $diff if ($diff);
+       }
+       return 1 if ($i < @ours);
+       return -1 if ($i < @theirs);
+       return 0;
+}
+
 sub _req_svn {
        require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
        require SVN::Ra;
        require SVN::Delta;
-       if ($SVN::Core::VERSION lt '1.1.0') {
+       if (::compare_svn_version('1.1.0') < 0) {
                fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
        }
 }
@@ -89,7 +106,7 @@ my ($_stdin, $_help, $_edit,
        $_message, $_file, $_branch_dest,
        $_template, $_shared,
        $_version, $_fetch_all, $_no_rebase, $_fetch_parent,
-       $_merge, $_strategy, $_dry_run, $_local,
+       $_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
        $_prefix, $_no_checkout, $_url, $_verbose,
        $_git_format, $_commit_url, $_tag, $_merge_info, $_interactive);
 $Git::SVN::_follow_parent = 1;
@@ -238,6 +255,7 @@ my %cmd = (
                          'local|l' => \$_local,
                          'fetch-all|all' => \$_fetch_all,
                          'dry-run|n' => \$_dry_run,
+                         'preserve-merges|p' => \$_preserve_merges,
                          %fc_opts } ],
        'commit-diff' => [ \&cmd_commit_diff,
                           'Commit a diff between two trees',
@@ -1474,7 +1492,7 @@ sub cmd_info {
        }
        ::_req_svn();
        $result .= "Repository UUID: $uuid\n" unless $diff_status eq "A" &&
-               ($SVN::Core::VERSION le '1.5.4' || $file_type ne "dir");
+               (::compare_svn_version('1.5.4') <= 0 || $file_type ne "dir");
        $result .= "Revision: " . ($diff_status eq "A" ? 0 : $rev) . "\n";
 
        $result .= "Node Kind: " .
@@ -1575,6 +1593,7 @@ sub rebase_cmd {
        push @cmd, '-v' if $_verbose;
        push @cmd, qw/--merge/ if $_merge;
        push @cmd, "--strategy=$_strategy" if $_strategy;
+       push @cmd, "--preserve-merges" if $_preserve_merges;
        @cmd;
 }
 
@@ -5464,7 +5483,7 @@ sub _auth_providers () {
 
        # earlier 1.6.x versions would segfault, and <= 1.5.x didn't have
        # this function
-       if ($SVN::Core::VERSION gt '1.6.12') {
+       if (::compare_svn_version('1.6.12') > 0) {
                my $config = SVN::Core::config_get_config($config_dir);
                my ($p, @a);
                # config_get_config returns all config files from
@@ -5623,7 +5642,7 @@ sub get_log {
        # drop it.  Therefore, the receiver callback passed to it
        # is made aware of this limitation by being wrapped if
        # the limit passed to is being wrapped.
-       if ($SVN::Core::VERSION le '1.2.0') {
+       if (::compare_svn_version('1.2.0') <= 0) {
                my $limit = splice(@args, 3, 1);
                if ($limit > 0) {
                        my $receiver = pop @args;
@@ -5655,7 +5674,8 @@ sub trees_match {
 
 sub get_commit_editor {
        my ($self, $log, $cb, $pool) = @_;
-       my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef, 0) : ();
+
+       my @lock = (::compare_svn_version('1.2.0') >= 0) ? (undef, 0) : ();
        $self->SUPER::get_commit_editor($log, $cb, @lock, $pool);
 }
 
@@ -5673,7 +5693,7 @@ sub gs_do_update {
        my (@pc) = split m#/#, $path;
        my $reporter = $self->do_update($rev_b, (@pc ? shift @pc : ''),
                                        1, $editor, $pool);
-       my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
+       my @lock = (::compare_svn_version('1.2.0') >= 0) ? (undef) : ();
 
        # Since we can't rely on svn_ra_reparent being available, we'll
        # just have to do some magic with set_path to make it so
@@ -5723,7 +5743,7 @@ sub gs_do_switch {
        $ra ||= $self;
        $url_b = escape_url($url_b);
        my $reporter = $ra->do_switch($rev_b, '', 1, $url_b, $editor, $pool);
-       my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
+       my @lock = (::compare_svn_version('1.2.0') >= 0) ? (undef) : ();
        $reporter->set_path('', $rev_a, 0, @lock, $pool);
        $reporter->finish_report($pool);