Mercurial > public > mercurial-scm > hg
diff hgext/convert/subversion.py @ 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 | bd93d0e0d317 |
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