# HG changeset patch # User Siddharth Agarwal <sid0@fb.com> # Date 1417336950 28800 # Sun Nov 30 00:42:30 2014 -0800 # Node ID 4b5a18d2fa104e766c8cf3e63b2c363cdeb588a1 # Parent 5fa9649c4ef6abf2d877b0a52e8432ae580eb6f2 git_handler.export_git_objects: filter out octopus explosions earlier hg-git translates octopus merges into a series of merges, called an octopus explosion. The intermediate octopus explosion commits are not recorded in the mapfile -- only the final commit is. This means that they show up in the export list and have to then be detected and filtered out. Don't initialize the incremental exporter with octopus explosion commits. Previously, if there were octopus merges early in the history, we'd initialize the incremental exporter with the first one's parent, then calculate the diff of that against the first commit we actually cared about exporting. That's slow and wasteful. For a particular real-world repo with one octopus merge 1/3 of the way in history, this is a 10x improvement for 'hg gexport' with one commit to export -- 60 seconds to 6. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -380,6 +380,8 @@ 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] + export = [ctx for ctx in export + if ctx.extra().get('hg-git', None) != 'octopus'] total = len(export) if not total: return @@ -410,10 +412,6 @@ for i, ctx in enumerate(export): self.ui.progress('exporting', i, total=total) 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(ctx.node(), exporter) self.ui.progress('exporting', None, total=total)