@matheusbsbs / matheus-bagliano / commits / 1ef626b4b6
Fork 0

git-svn: fix SVN 1.1.x compatibility

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>

Eric Wong committed Jan 17, 2009 at 22:11 UTC 1ef626b4b6c70fc13062faafdccb2f0da7578a29
2 files changed +25 -3
git-svn.perl
+14 -1
@@ -4130,10 +4130,23 @@ sub DESTROY {
4130 # do not call the real DESTROY since we store ourselves in $RA
4131 }
4132
4133 +# get_log(paths, start, end, limit,
4134 +# discover_changed_paths, strict_node_history, receiver)
4135 sub get_log {
4136 my ($self, @args) = @_;
4137 my $pool = SVN::Pool->new;
4136 - splice(@args, 3, 1) if ($SVN::Core::VERSION le '1.2.0');
4138 +
4139 + # the limit parameter was not supported in SVN 1.1.x, so we
4140 + # drop it. Therefore, the receiver callback passed to it
4141 + # is made aware of this limitation by being wrapped if
4142 + # the limit passed to is being wrapped.
4143 + if ($SVN::Core::VERSION le '1.2.0') {
4144 + my $limit = splice(@args, 3, 1);
4145 + if ($limit > 0) {
4146 + my $receiver = pop @args;
4147 + push(@args, sub { &$receiver(@_) if (--$limit >= 0) });
4148 + }
4149 + }
4150 my $ret = $self->SUPER::get_log(@args, $pool);
4151 $pool->clear;
4152 $ret;
t/t9129-git-svn-i18n-commitencoding.sh
+11 -2
@@ -15,8 +15,17 @@ compare_git_head_with () {
15 }
16
17 compare_svn_head_with () {
18 - LC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \
19 - sed -e 1,3d -e "/^-\{1,\}\$/d" >current &&
18 + # extract just the log message and strip out committer info.
19 + # don't use --limit here since svn 1.1.x doesn't have it,
20 + LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e '
21 + use bytes;
22 + $/ = ("-"x72) . "\n";
23 + my @x = <STDIN>;
24 + @x = split(/\n/, $x[1]);
25 + splice(@x, 0, 2);
26 + $x[-1] = "";
27 + print join("\n", @x);
28 + ' > current &&
29 test_cmp current "$1"
30 }
31