14 May 2012 01:13
[PATCH] canonicalize svn paths even more awesomely
# HG changeset patch # User Bryan O'Sullivan <bryano@...> # Date 1336950787 -7200 # Node ID 35ce6a107d55c07bb8f1ee90aaf1a36205e99fe7 # Parent 1673e412619d93332c28d2d04e6fa51d766900aa 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. diff -r 1673e412619d -r 35ce6a107d55 hgsubversion/svnwrap/svn_swig_wrapper.py --- a/hgsubversion/svnwrap/svn_swig_wrapper.py Mon May 14 00:58:58 2012 +0200 +++ b/hgsubversion/svnwrap/svn_swig_wrapper.py Mon May 14 01:13:07 2012 +0200 <at> <at> -572,6 +572,9 <at> <at> 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) diff -r 1673e412619d -r 35ce6a107d55 tests/fixtures/addspecial.sh --- a/tests/fixtures/addspecial.sh Mon May 14 00:58:58 2012 +0200 +++ b/tests/fixtures/addspecial.sh Mon May 14 01:13:07 2012 +0200 <at> <at> -22,6 +22,14 <at> <at> ln -s a fnord svn add fnord svn ci -msymlink fnord +mkdir 'spacy name' +echo a > 'spacy name/spacy file' +svn add 'spacy name' +svn ci -mspacy 'spacy name' +svn up +echo b > 'spacy name/surprise ~' +svn add 'spacy name/surprise ~' +svn ci -mtilde 'spacy name' svn up ../.. echo foo > exe chmod +x exe diff -r 1673e412619d -r 35ce6a107d55 tests/fixtures/addspecial.svndump --- a/tests/fixtures/addspecial.svndump Mon May 14 00:58:58 2012 +0200 +++ b/tests/fixtures/addspecial.svndump Mon May 14 01:13:07 2012 +0200 <at> <at> -1,6 +1,6 <at> <at> SVN-fs-dump-format-version: 2 -UUID: c8aac64d-a89b-4b18-8be4-1648446ccf98 +UUID: 01df53ad-5d72-4756-8742-f669dc98f791 Revision-number: 0 Prop-content-length: 56 <at> <at> -9,17 +9,13 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:44.718813Z +2012-05-13T22:22:43.218190Z PROPS-END Revision-number: 1 Prop-content-length: 118 Content-length: 118 -K 7 -svn:log -V 17 -initial structure K 10 svn:author V 6 <at> <at> -27,7 +23,11 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:45.074954Z +2012-05-13T22:22:44.112163Z +K 7 +svn:log +V 17 +initial structure PROPS-END Node-path: branches <at> <at> -52,10 +52,6 <at> <at> Prop-content-length: 103 Content-length: 103 -K 7 -svn:log -V 3 -ci1 K 10 svn:author V 6 <at> <at> -63,7 +59,11 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:46.061349Z +2012-05-13T22:22:45.111247Z +K 7 +svn:log +V 3 +ci1 PROPS-END Node-path: trunk/a <at> <at> -83,10 +83,6 <at> <at> Prop-content-length: 111 Content-length: 111 -K 7 -svn:log -V 10 -branch foo K 10 svn:author V 6 <at> <at> -94,7 +90,11 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:49.059324Z +2012-05-13T22:22:48.110257Z +K 7 +svn:log +V 10 +branch foo PROPS-END Node-path: branches/foo <at> <at> -108,10 +108,6 <at> <at> Prop-content-length: 107 Content-length: 107 -K 7 -svn:log -V 7 -symlink K 10 svn:author V 6 <at> <at> -119,7 +115,11 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:50.080078Z +2012-05-13T22:22:49.115096Z +K 7 +svn:log +V 7 +symlink PROPS-END Node-path: branches/foo/fnord <at> <at> -139,13 +139,9 <at> <at> link a Revision-number: 5 -Prop-content-length: 111 -Content-length: 111 +Prop-content-length: 105 +Content-length: 105 -K 7 -svn:log -V 10 -executable K 10 svn:author V 6 <at> <at> -153,7 +149,82 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:52.082785Z +2012-05-13T22:22:50.119266Z +K 7 +svn:log +V 5 +spacy +PROPS-END + +Node-path: branches/foo/spacy name +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: branches/foo/spacy name/spacy file +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b +Content-length: 12 + +PROPS-END +a + + +Revision-number: 6 +Prop-content-length: 105 +Content-length: 105 + +K 10 +svn:author +V 6 +bryano +K 8 +svn:date +V 27 +2012-05-13T22:22:52.123367Z +K 7 +svn:log +V 5 +tilde +PROPS-END + +Node-path: branches/foo/spacy name/surprise ~ +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 3b5d5c3712955042212316173ccf37be +Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b +Content-length: 12 + +PROPS-END +b + + +Revision-number: 7 +Prop-content-length: 111 +Content-length: 111 + +K 10 +svn:author +V 6 +bryano +K 8 +svn:date +V 27 +2012-05-13T22:22:54.129462Z +K 7 +svn:log +V 10 +executable PROPS-END Node-path: branches/foo/exe <at> <at> -173,14 +244,10 <at> <at> foo -Revision-number: 6 +Revision-number: 8 Prop-content-length: 105 Content-length: 105 -K 7 -svn:log -V 5 -merge K 10 svn:author V 6 <at> <at> -188,7 +255,11 <at> <at> K 8 svn:date V 27 -2012-05-13T12:00:55.062876Z +2012-05-13T22:22:57.111370Z +K 7 +svn:log +V 5 +merge PROPS-END Node-path: trunk <at> <at> -200,14 +271,14 <at> <at> K 13 svn:mergeinfo V 17 -/branches/foo:3-5 +/branches/foo:3-7 PROPS-END Node-path: trunk/exe Node-kind: file Node-action: add -Node-copyfrom-rev: 5 +Node-copyfrom-rev: 7 Node-copyfrom-path: branches/foo/exe Text-copy-source-md5: d3b07384d113edec49eaa6238ad5ff00 Text-copy-source-sha1: f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 <at> <at> -216,9 +287,16 <at> <at> Node-path: trunk/fnord Node-kind: file Node-action: add -Node-copyfrom-rev: 5 +Node-copyfrom-rev: 7 Node-copyfrom-path: branches/foo/fnord Text-copy-source-md5: c118dba188202a1efc975bef6064180b Text-copy-source-sha1: 41f94e4692313bf7f7c92aa600002f1dff93d6bf +Node-path: trunk/spacy name +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 7 +Node-copyfrom-path: branches/foo/spacy name + + -- -- You received this message because you are subscribed to the Google Groups "hgsubversion" group. To post to this group, send email to hgsubversion@... To unsubscribe from this group, send email to hgsubversion+unsubscribe@... For more options, visit this group at http://groups.google.com/group/hgsubversion?hl=en.
RSS Feed