190 self.filemapmode = active |
190 self.filemapmode = active |
191 |
191 |
192 class mercurial_source(converter_source): |
192 class mercurial_source(converter_source): |
193 def __init__(self, ui, path, rev=None): |
193 def __init__(self, ui, path, rev=None): |
194 converter_source.__init__(self, ui, path, rev) |
194 converter_source.__init__(self, ui, path, rev) |
|
195 self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors', False) |
|
196 self.ignored = {} |
195 self.saverev = ui.configbool('convert', 'hg.saverev', True) |
197 self.saverev = ui.configbool('convert', 'hg.saverev', True) |
196 try: |
198 try: |
197 self.repo = hg.repository(self.ui, path) |
199 self.repo = hg.repository(self.ui, path) |
198 # try to provoke an exception if this isn't really a hg |
200 # try to provoke an exception if this isn't really a hg |
199 # repo, but some other bogus compatible-looking url |
201 # repo, but some other bogus compatible-looking url |
251 def getchanges(self, rev): |
253 def getchanges(self, rev): |
252 ctx = self.changectx(rev) |
254 ctx = self.changectx(rev) |
253 parents = self.parents(ctx) |
255 parents = self.parents(ctx) |
254 if not parents: |
256 if not parents: |
255 files = util.sort(ctx.manifest().keys()) |
257 files = util.sort(ctx.manifest().keys()) |
256 return [(f, rev) for f in files], {} |
258 return [(f, rev) for f in files if f not in self.ignored], {} |
257 if self._changescache and self._changescache[0] == rev: |
259 if self._changescache and self._changescache[0] == rev: |
258 m, a, r = self._changescache[1] |
260 m, a, r = self._changescache[1] |
259 else: |
261 else: |
260 m, a, r = self.repo.status(parents[0], ctx.node())[:3] |
262 m, a, r = self.repo.status(parents[0], ctx.node())[:3] |
261 changes = [(name, rev) for name in m + a + r] |
263 # getcopies() detects missing revlogs early, run it before |
262 return util.sort(changes), self.getcopies(ctx, m + a) |
264 # filtering the changes. |
|
265 copies = self.getcopies(ctx, m + a) |
|
266 changes = [(name, rev) for name in m + a + r |
|
267 if name not in self.ignored] |
|
268 return util.sort(changes), copies |
263 |
269 |
264 def getcopies(self, ctx, files): |
270 def getcopies(self, ctx, files): |
265 copies = {} |
271 copies = {} |
266 for name in files: |
272 for name in files: |
267 try: |
273 if name in self.ignored: |
268 copynode = ctx.filectx(name).renamed()[0] |
274 continue |
269 if self.keep(copynode): |
275 try: |
270 copies[name] = copynode |
276 copysource, copynode = ctx.filectx(name).renamed() |
|
277 if copysource in self.ignored or not self.keep(copynode): |
|
278 continue |
|
279 copies[name] = copysource |
271 except TypeError: |
280 except TypeError: |
272 pass |
281 pass |
|
282 except revlog.LookupError, e: |
|
283 if not self.ignoreerrors: |
|
284 raise |
|
285 self.ignored[name] = 1 |
|
286 self.ui.warn(_('ignoring: %s\n') % e) |
273 return copies |
287 return copies |
274 |
288 |
275 def getcommit(self, rev): |
289 def getcommit(self, rev): |
276 ctx = self.changectx(rev) |
290 ctx = self.changectx(rev) |
277 parents = [hex(p) for p in self.parents(ctx)] |
291 parents = [hex(p) for p in self.parents(ctx)] |
295 i = 0 |
309 i = 0 |
296 changes = [], ctx.manifest().keys(), [] |
310 changes = [], ctx.manifest().keys(), [] |
297 else: |
311 else: |
298 i = i or 0 |
312 i = i or 0 |
299 changes = self.repo.status(parents[i], ctx.node())[:3] |
313 changes = self.repo.status(parents[i], ctx.node())[:3] |
|
314 changes = [[f for f in l if f not in self.ignored] for l in changes] |
300 |
315 |
301 if i == 0: |
316 if i == 0: |
302 self._changescache = (rev, changes) |
317 self._changescache = (rev, changes) |
303 |
318 |
304 return changes[0] + changes[1] + changes[2] |
319 return changes[0] + changes[1] + changes[2] |