##// 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 from mercurial import hg, util
18 from mercurial import hg, util
19 from mercurial.i18n import _
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 source_converters = [
29 source_converters = [
22 ('cvs', convert_cvs),
30 ('cvs', convert_cvs),
23 ('git', convert_git),
31 ('git', convert_git),
@@ -156,7 +164,11 b' class converter(object):'
156 for c in children.get(n, []):
164 for c in children.get(n, []):
157 if c not in pendings:
165 if c not in pendings:
158 pendings[c] = [p for p in parents[c] if p not in self.map]
166 pendings[c] = [p for p in parents[c] if p not in self.map]
167 try:
159 pendings[c].remove(n)
168 pendings[c].remove(n)
169 except ValueError:
170 raise util.Abort(_('cycle detected between %s and %s')
171 % (recode(c), recode(n)))
160 if not pendings[c]:
172 if not pendings[c]:
161 # Parents are converted, node is eligible
173 # Parents are converted, node is eligible
162 actives.insert(0, c)
174 actives.insert(0, c)
@@ -251,12 +263,6 b' class converter(object):'
251
263
252 def convert(self):
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 try:
266 try:
261 self.source.before()
267 self.source.before()
262 self.dest.before()
268 self.dest.before()
@@ -307,8 +313,6 b' class converter(object):'
307 self.source.after()
313 self.source.after()
308 self.map.close()
314 self.map.close()
309
315
310 orig_encoding = 'ascii'
311
312 def convert(ui, src, dest=None, revmapfile=None, **opts):
316 def convert(ui, src, dest=None, revmapfile=None, **opts):
313 global orig_encoding
317 global orig_encoding
314 orig_encoding = util._encoding
318 orig_encoding = util._encoding
General Comments 0
You need to be logged in to leave comments. Login now