##// END OF EJS Templates
convert: refactor hg getchanges and caching
Mads Kiilerich -
r22299:98aafdf4 default
parent child Browse files
Show More
@@ -301,7 +301,7 class mercurial_source(converter_source)
301 raise NoRepo(_("%s is not a local Mercurial repository") % path)
301 raise NoRepo(_("%s is not a local Mercurial repository") % path)
302 self.lastrev = None
302 self.lastrev = None
303 self.lastctx = None
303 self.lastctx = None
304 self._changescache = None
304 self._changescache = None, None
305 self.convertfp = None
305 self.convertfp = None
306 # Restrict converted revisions to startrev descendants
306 # Restrict converted revisions to startrev descendants
307 startnode = ui.config('convert', 'hg.startrev')
307 startnode = ui.config('convert', 'hg.startrev')
@@ -360,22 +360,20 class mercurial_source(converter_source)
360 ctx = self.changectx(rev)
360 ctx = self.changectx(rev)
361 parents = self.parents(ctx)
361 parents = self.parents(ctx)
362 if not parents:
362 if not parents:
363 files = sorted(ctx.manifest())
363 files = copyfiles = ctx.manifest()
364 # getcopies() is not needed for roots, but it is a simple way to
364 else:
365 # detect missing revlogs and abort on errors or populate
365 if self._changescache[0] == rev:
366 # self.ignored
367 self.getcopies(ctx, parents, files)
368 return [(f, rev) for f in files if f not in self.ignored], {}
369 if self._changescache and self._changescache[0] == rev:
370 m, a, r = self._changescache[1]
366 m, a, r = self._changescache[1]
371 else:
367 else:
372 m, a, r = self.repo.status(parents[0].node(), ctx.node())[:3]
368 m, a, r = self.repo.status(parents[0].node(), ctx.node())[:3]
373 # getcopies() detects missing revlogs early, run it before
369 files = m + a + r
374 # filtering the changes.
370 copyfiles = m + a
375 copies = self.getcopies(ctx, parents, m + a)
371 # getcopies() is also run for roots and before filtering so missing
376 changes = [(name, rev) for name in m + a + r
372 # revlogs are detected early
377 if name not in self.ignored]
373 copies = self.getcopies(ctx, parents, copyfiles)
378 return sorted(changes), copies
374 changes = [(f, rev) for f in files if f not in self.ignored]
375 changes.sort()
376 return changes, copies
379
377
380 def getcopies(self, ctx, parents, files):
378 def getcopies(self, ctx, parents, files):
381 copies = {}
379 copies = {}
General Comments 0
You need to be logged in to leave comments. Login now