[PATCH 6/7] Switch path canonicalization to use the SVN API.
- From
Michael G. Schwern <schwern@pobox.com>
- Date
- Jul 28, 2012, 09:38 UTC
- Message-ID
- <1343468312-72024-7-git-send-email-schwern@pobox.com>
- In-Reply-To
- <1343468312-72024-1-git-send-email-schwern@pobox.com>
From: "Michael G. Schwern" <schwern@pobox.com>
All tests pass with SVN 1.6. SVN 1.7 remains broken, not worrying about it yet.
SVN changed its path canonicalization API between 1.6 and 1.7. http://svnbook.red-bean.com/en/1.6/svn.developer.usingapi.html#svn.developer.usingapi.urlpath http://svnbook.red-bean.com/en/1.7/svn.developer.usingapi.html#svn.developer.usingapi.urlpath
The SVN API does not accept foo/.. but it also doesn't canonicalize it. We have to do it ourselves. --- perl/Git/SVN/Utils.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/perl/Git/SVN/Utils.pm b/perl/Git/SVN/Utils.pm index 6c8ae53..7ae6fac 100644 --- a/perl/Git/SVN/Utils.pm +++ b/perl/Git/SVN/Utils.pm @@ -86,6 +86,27 @@ sub _collapse_dotdot { sub canonicalize_path { + my $path = shift; + + # The 1.7 way to do it + if ( defined &SVN::_Core::svn_dirent_canonicalize ) { + $path = _collapse_dotdot($path); + return SVN::_Core::svn_dirent_canonicalize($path); + } + # The 1.6 way to do it + elsif ( defined &SVN::_Core::svn_path_canonicalize ) { + $path = _collapse_dotdot($path); + return SVN::_Core::svn_path_canonicalize($path); + } + # No SVN API canonicalization is available, do it ourselves + else { + $path = _canonicalize_path_ourselves($path); + return $path; + } +} + + +sub _canonicalize_path_ourselves { my ($path) = @_; my $dot_slash_added = 0; if (substr($path, 0, 1) ne "/") {
-- 1.7.11.3