Mercurial > hg
changeset 8886:0593c5b5b1f0
convert/svn: stop returning unicode revision identifiers
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 21 Jun 2009 23:17:02 +0200 |
parents | 2c184bd2b37a |
children | 0332f8b44e54 |
files | hgext/convert/subversion.py tests/svn/encoding.svndump tests/svn/svndump-encoding.sh |
diffstat | 3 files changed, 79 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Sun Jun 21 23:04:02 2009 +0200 +++ b/hgext/convert/subversion.py Sun Jun 21 23:17:02 2009 +0200 @@ -10,7 +10,7 @@ import tempfile import urllib -from mercurial import strutil, util +from mercurial import strutil, util, encoding from mercurial.i18n import _ # Subversion stuff. Works best with very recent Python SVN bindings @@ -50,6 +50,9 @@ path = os.path.normpath(os.path.abspath(path)) if os.name == 'nt': path = '/' + util.normpath(path) + # Module URL is later compared with the repository URL returned + # by svn API, which is UTF-8. + path = encoding.tolocal(path) return 'file://%s' % urllib.quote(path) return path @@ -226,7 +229,7 @@ self.rootmodule = self.module self.commits = {} self.paths = {} - self.uuid = svn.ra.get_uuid(self.ra).decode(self.encoding) + self.uuid = svn.ra.get_uuid(self.ra) except SubversionException: ui.traceback() raise NoRepo("%s does not look like a Subversion repo" % self.url) @@ -253,8 +256,8 @@ self.head = self.latest(self.module, latest) if not self.head: - raise util.Abort(_('no revision found in module %s') % - self.module.encode(self.encoding)) + raise util.Abort(_('no revision found in module %s') + % self.module) self.last_changed = self.revnum(self.head) self._changescache = None @@ -314,8 +317,8 @@ self.module += '/' + trunk self.head = self.latest(self.module, self.last_changed) if not self.head: - raise util.Abort(_('no revision found in module %s') % - self.module.encode(self.encoding)) + raise util.Abort(_('no revision found in module %s') + % self.module) # First head in the list is the module's head self.heads = [self.head] @@ -333,8 +336,7 @@ continue brevid = self.latest(module, self.last_changed) if not brevid: - self.ui.note(_('ignoring empty branch %s\n') % - branch.encode(self.encoding)) + self.ui.note(_('ignoring empty branch %s\n') % branch) continue self.ui.note(_('found branch %s at %d\n') % (branch, self.revnum(brevid))) @@ -511,16 +513,13 @@ self.convertfp.flush() def revid(self, revnum, module=None): - if not module: - module = self.module - return u"svn:%s%s@%s" % (self.uuid, module.decode(self.encoding), - revnum) + return 'svn:%s%s@%s' % (self.uuid, module or self.module, revnum) def revnum(self, rev): return int(rev.split('@')[-1]) def revsplit(self, rev): - url, revnum = rev.encode(self.encoding).rsplit('@', 1) + url, revnum = rev.rsplit('@', 1) revnum = int(revnum) parts = url.split('/', 1) uuid = parts.pop(0)[4:] @@ -786,7 +785,7 @@ desc=log, parents=parents, branch=branch, - rev=rev.encode('utf-8')) + rev=rev) self.commits[rev] = cset # The parents list is *shared* among self.paths and the
--- a/tests/svn/encoding.svndump Sun Jun 21 23:04:02 2009 +0200 +++ b/tests/svn/encoding.svndump Sun Jun 21 23:17:02 2009 +0200 @@ -1,6 +1,6 @@ SVN-fs-dump-format-version: 2 -UUID: 64cf20ed-79ff-4f10-8aaf-041d1993b42e +UUID: 7ec0009b-ac71-43a6-9416-7fc295ee5ca1 Revision-number: 0 Prop-content-length: 56 @@ -9,7 +9,7 @@ K 8 svn:date V 27 -2009-06-21T10:05:28.031033Z +2009-06-21T15:50:22.535630Z PROPS-END Revision-number: 1 @@ -27,7 +27,7 @@ K 8 svn:date V 27 -2009-06-21T10:05:28.108227Z +2009-06-21T15:50:22.584588Z PROPS-END Node-path: branches @@ -72,7 +72,7 @@ K 8 svn:date V 27 -2009-06-21T10:05:29.109026Z +2009-06-21T15:50:23.143007Z PROPS-END Node-path: trunk/à @@ -125,7 +125,7 @@ K 8 svn:date V 27 -2009-06-21T10:05:32.061964Z +2009-06-21T15:50:26.088415Z PROPS-END Node-path: trunk/è @@ -167,7 +167,7 @@ K 8 svn:date V 27 -2009-06-21T10:05:33.096353Z +2009-06-21T15:50:27.162784Z PROPS-END Node-path: trunk/è @@ -178,3 +178,53 @@ Node-action: delete +Revision-number: 5 +Prop-content-length: 120 +Content-length: 120 + +K 7 +svn:log +V 18 +branch to branché +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2009-06-21T15:50:30.079728Z +PROPS-END + +Node-path: branches/branché +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 4 +Node-copyfrom-path: trunk + + +Revision-number: 6 +Prop-content-length: 121 +Content-length: 121 + +K 7 +svn:log +V 19 +branch to branchée +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2009-06-21T15:50:33.072456Z +PROPS-END + +Node-path: branches/branchée +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 5 +Node-copyfrom-path: branches/branché + +
--- a/tests/svn/svndump-encoding.sh Sun Jun 21 23:04:02 2009 +0200 +++ b/tests/svn/svndump-encoding.sh Sun Jun 21 23:17:02 2009 +0200 @@ -35,6 +35,16 @@ svn rm trunk/è svn rm trunk/ù svn ci -m 'remove files' + +# Create branches with and from weird names +svn up +svn cp trunk branches/branché +echo a > branches/branché/a +svn ci -m 'branch to branché' +svn up +svn cp branches/branché branches/branchée +echo a >> branches/branché/a +svn ci -m 'branch to branchée' cd .. svnadmin dump svn-repo > ../encoding.svndump