##// END OF EJS Templates
convert: improve cycles detection message
Patrick Mezard -
r6131:fddeeb00 default
parent child Browse files
Show More
@@ -18,6 +18,14 b' import os, shutil'
18 18 from mercurial import hg, util
19 19 from mercurial.i18n import _
20 20
21 orig_encoding = 'ascii'
22
23 def recode(s):
24 if isinstance(s, unicode):
25 return s.encode(orig_encoding, 'replace')
26 else:
27 return s.decode('utf-8').encode(orig_encoding, 'replace')
28
21 29 source_converters = [
22 30 ('cvs', convert_cvs),
23 31 ('git', convert_git),
@@ -156,7 +164,11 b' class converter(object):'
156 164 for c in children.get(n, []):
157 165 if c not in pendings:
158 166 pendings[c] = [p for p in parents[c] if p not in self.map]
159 pendings[c].remove(n)
167 try:
168 pendings[c].remove(n)
169 except ValueError:
170 raise util.Abort(_('cycle detected between %s and %s')
171 % (recode(c), recode(n)))
160 172 if not pendings[c]:
161 173 # Parents are converted, node is eligible
162 174 actives.insert(0, c)
@@ -251,12 +263,6 b' class converter(object):'
251 263
252 264 def convert(self):
253 265
254 def recode(s):
255 if isinstance(s, unicode):
256 return s.encode(orig_encoding, 'replace')
257 else:
258 return s.decode('utf-8').encode(orig_encoding, 'replace')
259
260 266 try:
261 267 self.source.before()
262 268 self.dest.before()
@@ -307,8 +313,6 b' class converter(object):'
307 313 self.source.after()
308 314 self.map.close()
309 315
310 orig_encoding = 'ascii'
311
312 316 def convert(ui, src, dest=None, revmapfile=None, **opts):
313 317 global orig_encoding
314 318 orig_encoding = util._encoding
General Comments 0
You need to be logged in to leave comments. Login now