YA subversion canonical path assertion failure

Issue #347 resolved
Bryan O'Sullivan
created an issue

Someone checked in a file named "svn-commit.tmp~". We turn this into "svn-commit.tmp%7E", and when issuing a proplist2, cause svn to barf.

Comments (3)

  1. Bryan O'Sullivan reporter
    • changed status to open

    Here's the fix. I believe that @David Schleimer has a test case that exposes the bug. We'll roll the two into a single patch.

    diff --git a/hgsubversion/svnwrap/svn_swig_wrapper.py b/hgsubversion/svnwrap/svn_swig_wrapper.py
    --- a/hgsubversion/svnwrap/svn_swig_wrapper.py
    +++ b/hgsubversion/svnwrap/svn_swig_wrapper.py
    @@ -572,6 +572,9 @@
             if not path or path == '.':
                 return self.svn_url
             assert path[0] != '/', path
    -        return '/'.join((self.svn_url,
    -                         urllib.quote(path).rstrip('/'),
    -                         ))
    +        path = path.rstrip('/')
    +        try:
    +            # new in svn 1.7
    +            return core.svn_uri_canonicalize(self.svn_url + '/' + path)
    +        except AttributeError:
    +            return self.svn_url + '/' + urllib.quote(path)
    
  2. Patrick Mézard

    It looks you fixed it in the changeset below. Closing.

    changeset:   904:b6b1365e3489
    user:        Bryan O'Sullivan <bryano@fb.com>
    date:        Mon May 14 01:13:07 2012 +0200
    files:       hgsubversion/svnwrap/svn_swig_wrapper.py tests/fixtures/addspecial.sh tests/fixtures/addspecial.svndump
    description:
    canonicalize svn paths even more awesomely
    
    It turns out that SVN has bizarre path canonicalization rules that
    are sort of close to what urllib.quote does, but different in
    peculiar ways, and 1.7 suddenly cares deeply about canonicality.
    For instance, space (' ') maps to %20, but '~' stays unchanged
    instead of turning into %7e.
    
    Along with its new policy of frequent beatings administered to users
    of its bindings, SVN 1.7 introduces a function that idempotently
    canonicalizes URIs, which I found sort of by accident, because
    that's how you learn about SVN API changes.
    
    Older versions of SVN are less anal, so urllib.quote continues to
    work fine for them.
    
    
  3. Log in to comment