Code

git-svn: fix SVN 1.1.x compatibility
authorEric Wong <normalperson@yhbt.net>
Sun, 18 Jan 2009 06:11:44 +0000 (22:11 -0800)
committerEric Wong <normalperson@yhbt.net>
Sun, 18 Jan 2009 23:38:28 +0000 (15:38 -0800)
The get_log() function in the Perl SVN API introduced the limit
parameter in 1.2.0.  However, this got discarded in our SVN::Ra
compatibility layer when used with SVN 1.1.x.  We now emulate
the limit functionality in older SVN versions by preventing the
original callback from being called if the given limit has been
reached.  This emulation is less bandwidth efficient, but SVN
1.1.x is becoming rarer now.

Additionally, the --limit parameter in svn(1) uses the
aforementioned get_log() functionality change in SVN 1.2.x.
t9129 no longer depends on --limit to work and instead uses
Perl to parse out the commit message.

Thanks to Tom G. Christensen for the bug report.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl
t/t9129-git-svn-i18n-commitencoding.sh

index e3e125b098f63e3c7fc434770e7281981bb8940b..71b8ef426500019f9a2687b6c420bdbff0b625eb 100755 (executable)
@@ -4130,10 +4130,23 @@ sub DESTROY {
        # do not call the real DESTROY since we store ourselves in $RA
 }
 
+# get_log(paths, start, end, limit,
+#         discover_changed_paths, strict_node_history, receiver)
 sub get_log {
        my ($self, @args) = @_;
        my $pool = SVN::Pool->new;
-       splice(@args, 3, 1) if ($SVN::Core::VERSION le '1.2.0');
+
+       # the limit parameter was not supported in SVN 1.1.x, so we
+       # 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') {
+               my $limit = splice(@args, 3, 1);
+               if ($limit > 0) {
+                       my $receiver = pop @args;
+                       push(@args, sub { &$receiver(@_) if (--$limit >= 0) });
+               }
+       }
        my $ret = $self->SUPER::get_log(@args, $pool);
        $pool->clear;
        $ret;
index 8a9dde44d57b792d7142f082aa18274a13d532f3..9c7b1ad18bca943e6c5b6e50f55d914ccadbfce8 100755 (executable)
@@ -15,8 +15,17 @@ compare_git_head_with () {
 }
 
 compare_svn_head_with () {
-       LC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \
-               sed -e 1,3d -e "/^-\{1,\}\$/d" >current &&
+       # extract just the log message and strip out committer info.
+       # don't use --limit here since svn 1.1.x doesn't have it,
+       LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e '
+               use bytes;
+               $/ = ("-"x72) . "\n";
+               my @x = <STDIN>;
+               @x = split(/\n/, $x[1]);
+               splice(@x, 0, 2);
+               $x[-1] = "";
+               print join("\n", @x);
+       ' > current &&
        test_cmp current "$1"
 }