# HG changeset patch # User Siddharth Agarwal <sid0@fb.com> # Date 1417335984 28800 # Sun Nov 30 00:26:24 2014 -0800 # Node ID 5fa9649c4ef6abf2d877b0a52e8432ae580eb6f2 # Parent 64fa5ea18b89f823339fe002a75d78edf5d235af git_handler: iterate over contexts, not nodes This prepares for an upcoming patch. In theory, we could pass the context into export_hg_commit, but there's some encoding shenanigans going on there that I don't want to delve into. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -376,9 +376,10 @@ ## CHANGESET CONVERSION METHODS def export_git_objects(self): - clnode = self.repo.changelog.node - nodes = [clnode(n) for n in self.repo] - export = [node for node in nodes if not hex(node) in self._map_hg] + repo = self.repo + clnode = repo.changelog.node + nodes = [clnode(n) for n in repo] + export = [repo[node] for node in nodes if not hex(node) in self._map_hg] total = len(export) if not total: return @@ -391,7 +392,7 @@ # and therefore export, is in topological order. By definition, # export[0]'s parents must be present in Git, so we start the # incremental exporter from there. - pctx = self.repo[export[0]].p1() + pctx = export[0].p1() pnode = pctx.node() if pnode == nullid: gitcommit = None @@ -406,15 +407,14 @@ exporter = hg2git.IncrementalChangesetExporter( self.repo, pctx, self.git.object_store, gitcommit) - for i, rev in enumerate(export): + for i, ctx in enumerate(export): self.ui.progress('exporting', i, total=total) - ctx = self.repo.changectx(rev) state = ctx.extra().get('hg-git', None) if state == 'octopus': self.ui.debug("revision %d is a part " "of octopus explosion\n" % ctx.rev()) continue - self.export_hg_commit(rev, exporter) + self.export_hg_commit(ctx.node(), exporter) self.ui.progress('exporting', None, total=total)