Mercurial > hg
diff hgext/convert/convcmd.py @ 6131:fddeeb00f8d1
convert: improve cycles detection message
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 16 Feb 2008 11:55:33 +0100 |
parents | 516d8ffede7c |
children | 5b159ebb19cf |
line wrap: on
line diff
--- a/hgext/convert/convcmd.py Sat Feb 16 12:46:28 2008 +0100 +++ b/hgext/convert/convcmd.py Sat Feb 16 11:55:33 2008 +0100 @@ -18,6 +18,14 @@ from mercurial import hg, util from mercurial.i18n import _ +orig_encoding = 'ascii' + +def recode(s): + if isinstance(s, unicode): + return s.encode(orig_encoding, 'replace') + else: + return s.decode('utf-8').encode(orig_encoding, 'replace') + source_converters = [ ('cvs', convert_cvs), ('git', convert_git), @@ -156,7 +164,11 @@ for c in children.get(n, []): if c not in pendings: pendings[c] = [p for p in parents[c] if p not in self.map] - pendings[c].remove(n) + try: + pendings[c].remove(n) + except ValueError: + raise util.Abort(_('cycle detected between %s and %s') + % (recode(c), recode(n))) if not pendings[c]: # Parents are converted, node is eligible actives.insert(0, c) @@ -251,12 +263,6 @@ def convert(self): - def recode(s): - if isinstance(s, unicode): - return s.encode(orig_encoding, 'replace') - else: - return s.decode('utf-8').encode(orig_encoding, 'replace') - try: self.source.before() self.dest.before() @@ -307,8 +313,6 @@ self.source.after() self.map.close() -orig_encoding = 'ascii' - def convert(ui, src, dest=None, revmapfile=None, **opts): global orig_encoding orig_encoding = util._encoding