git-svn: use SVN 1.7 to canonicalize when possible
No change on SVN 1.6. The tests all pass with SVN 1.6 if canonicalize_url() does nothing, so tests passing doesn't have much meaning. The tests are so messed up right now with SVN 1.7 it isn't really useful to check. They will be useful later. [ew: commit title] Signed-off-by: Eric Wong <normalperson@yhbt.net>
Michael G. Schwern committed
Jul 28, 2012 at 02:38 UTC
82009f304826fcaf3188fb422769a7974ae78afa
1 file changed
+16
perl/Git/SVN/Utils.pm
+16
@@ -3,6 +3,8 @@ package Git::SVN::Utils;
3
use strict;
4
use warnings;
5
6
+use SVN::Core;
7
+
8
use base qw(Exporter);
9
10
our @EXPORT_OK = qw(
@@ -100,6 +102,20 @@ API as a URL.
102
=cut
103
104
sub canonicalize_url {
105
+ my $url = shift;
106
+
107
+ # The 1.7 way to do it
108
+ if ( defined &SVN::_Core::svn_uri_canonicalize ) {
109
+ return SVN::_Core::svn_uri_canonicalize($url);
110
+ }
111
+ # There wasn't a 1.6 way to do it, so we do it ourself.
112
+ else {
113
+ return _canonicalize_url_ourselves($url);
114
+ }
115
+}
116
+
117
+
118
+sub _canonicalize_url_ourselves {
119
my ($url) = @_;
120
$url =~ s#^([^:]+://[^/]*/)(.*)$#$1 . canonicalize_path($2)#e;
121
return $url;