[svk-devel] [PATCH] escaping spaces in paths

Michael Hendricks michael at ndrix.org
Thu Mar 1 12:03:50 EST 2007


When a checkout path has spaces in the depot path, committing directly
to the mirror causes an error because the space is not escaped when the
depot path is converted into a URL.  Unfortunately, I'm in a bit of a
rush right now and can't write tests or flesh out the patch fully
(that's why I didn't commit it).  The patch is at the bottom of this
email.

The original stack backtrace follows.  Specifically see the
SVK::Mirror::Backend::SVNRa::_new_ra line (third one down):

michael at ginosko$ SVKSVNBACKTRACE=1 svk ci -F svk-commitaH5Fr.tmp 
Commit into mirrored path: merging back directly.
Merging back to mirror source http://scswks91/svn.
Bad URL passed to RA layer: Malformed URL for repository at /Users/michael/dev/svk/trunk/lib/SVK/Command.pm line 192
        SVK::Command::__ANON__('_p_svn_error_t=SCALAR(0x1b4a518)') called at /usr/local/svn/perl/darwin-thread-multi-2level//SVN/Ra.pm line 121
        SVN::Ra::new('SVN::Ra', 'url', 'http://scswks91/svn', 'auth', '_p_svn_auth_baton_t=SCALAR(0x1b4a678)', 'config', 'HASH(0x1b4a20c)', 'url', 'http://scswks91/svn/mhendric/trunk/State/FY06 data', ...) called at /Users/michael/dev/svk/trunk/lib/SVK/Mirror/Backend/SVNRa.pm line 329
        SVK::Mirror::Backend::SVNRa::_new_ra('SVK::Mirror::Backend::SVNRa=HASH(0x1b2d6f0)', 'url', 'http://scswks91/svn/mhendric/trunk/State/FY06 data') called at /Users/michael/dev/svk/trunk/lib/SVK/Mirror/Backend/SVNRa.pm line 598
        SVK::Mirror::Backend::SVNRa::get_commit_editor('SVK::Mirror::Backend::SVNRa=HASH(0x1b2d6f0)', '/mhendric/trunk/State/FY06 data', 'Added the latest error report...', 'CODE(0x1b2cb8c)') called at /Users/michael/dev/svk/trunk/lib/SVK/Mirror.pm line 359
        SVK::Mirror::get_merge_back_editor('SVK::Mirror=HASH(0x1b2cb08)', '/mhendric/trunk/State/FY06 data', 'Added the latest error report...', 'CODE(0x1b2cb8c)') called at /Users/michael/dev/svk/trunk/lib/SVK/Path.pm line 252
        SVK::Path::get_editor('SVK::Path=HASH(0x1aa4720)', 'ignore_mirror', 'undef', 'check_only', 'undef', 'callback', 'CODE(0x1ad1920)', 'message', 'Added the latest error report...', ...) called at /Users/michael/dev/svk/trunk/lib/SVK/Command/Commit.pm line 253
        SVK::Command::Commit::get_editor('SVK::Command::Commit=HASH(0x1a63e70)', 'SVK::Path=HASH(0x1aa4720)', 'CODE(0x1ad1920)') called at /Users/michael/dev/svk/trunk/lib/SVK/Command/Commit.pm line 583
        SVK::Command::Commit::run('SVK::Command::Commit=HASH(0x1a63e70)', 'SVK::Path::Checkout=HASH(0x1a5d6b4)') called at /Users/michael/dev/svk/trunk/lib/SVK/Command.pm line 221
        eval {...} called at /Users/michael/dev/svk/trunk/lib/SVK/Command.pm line 219
        eval {...} called at /Users/michael/dev/svk/trunk/lib/SVK/Command.pm line 199
        SVK::Command::run_command('SVK::Command::Commit=HASH(0x1a63e70)') called at /Users/michael/perl/lib/perl5/site_perl/App/CLI.pm line 79
        App::CLI::dispatch('SVK::Command', 'xd', 'SVK::XD=HASH(0x18af26c)', 'output', 'undef') called at /Users/michael/dev/svk/trunk/lib/SVK/Command.pm line 163
        eval {...} called at /Users/michael/dev/svk/trunk/lib/SVK/Command.pm line 163
        SVK::Command::invoke('SVK::Command', 'SVK::XD=HASH(0x18af26c)', 'ci', 'undef', '-F', 'svk-commitaH5Fr.tmp') called at /Users/michael/dev/svk/trunk/bin/svk line 139


Patching locally against mirror source http://code.bestpractical.com/svk.
==== Patch <-> level 1
Source: [No source]
Target: 4ccb8a5b-8ae0-0310-9b02-86531366991d:/trunk:2301
        (http://code.bestpractical.com/svk)
Log:
Escape spaces in paths that become URLs
=== lib/SVK/Mirror/Backend/SVNRa.pm
==================================================================
--- lib/SVK/Mirror/Backend/SVNRa.pm	(revision 2301)
+++ lib/SVK/Mirror/Backend/SVNRa.pm	(patch - level 1)
@@ -595,7 +595,8 @@
 sub get_commit_editor {
     my ($self, $path, $msg, $committed) = @_;
     die loc("relayed merge back not supported yet.\n") if $self->_relayed;
-    $self->{commit_ra} = $self->_new_ra( url => $self->mirror->url.$path );
+    ( my $escaped_path = $path ) =~ s{ }{%20}g;
+    $self->{commit_ra} = $self->_new_ra( url => $self->mirror->url.$escaped_path );
 
     # XXX: add error check for get_commit_editor here, auth error happens here
     return SVN::Delta::Editor->new(

==== BEGIN SVK PATCH BLOCK ====
Version: svk v2.0.0 (darwin)

eJyFk1Fr2zAQx/M82HfQhgvdgxvZshU7pSYMupdtZXTtYE9Gls+pqWMbWelaqm4L2x76rXdS0myM
jBiE0d39f3c6nd6oi+NZYLKMGi+g5uOnt9PpB6Hl1QHuPG6grHWnvNg0cAONx0zTzb3ItGIB6NVC
zUFnWYDiZC0+dYInSGQZhdBdO3ipg+VaAXiB4bOJmYVmxlBqAnR2PbS56jqN+JDREJ25LUk23QC5
ldrw2IaHXhCt48tagcR8d7ayunCojZxZebyR/4nDiC2H7eBMLGeMR3F59rHCLSvawULLBjZ+XyuF
fbQ59zHZlhnvYIbhP8zxayGvoS1dDfvY0ZbNn1pe1Q14LPgPFU1n5+KoX7hy9uHjNd55Rd83d7mG
W11Co4VLyUJTAUspTdKoLGU0CYukQmKVJDGlggeTBI/McZLORqPV44vV4+fnt6PVz2L0/Xb049vq
18tDsrgjHgxS9FDmvdBX5IR47v+KnHwlwz15uD8I6cP8+BnBzxugqfzsXnaLBQ6fEg82fm3MW/iC
lkOyVA05yZ7MC9cAP0Pr0TbTLPp7Gl3PNgeCshQypbgqXsSFmPAJjXkq00BWFRSlm0mWmlNHIkMv
JAykbokteiD6SmhSANYH5PL83YDhfpaFxl60e1AX7o1Np5dtfQNqEM0BN3gRVo1Dr+AGN8tlXeJD
G2u1bK/Xt4Q5uYmkLBIRF34igPqUBdRPCxr6CY9ZwDhP06D8DeJiToc=
==== END SVK PATCH BLOCK ====

-- 
Michael


More information about the svk-devel mailing list