Commit e7730b50 authored by Dan Villiom Podlaski Christiansen's avatar Dan Villiom Podlaski Christiansen
Browse files

export: optimise and simplify the search a bit by not using contexts

parent b8a0d8002006
Pipeline #58901 passed with stages
in 20 minutes and 47 seconds
......@@ -648,9 +648,5 @@
)
)
to_export = (
repo[node]
for node in map(repo.changelog.node, ancestors)
if not hex(node) in self._map_hg
)
export = []
......@@ -656,5 +652,9 @@
todo_total = len(repo) - len(self._map_hg)
topic = b'searching'
unit = b'commits'
with repo.ui.makeprogress(
b'searching', b'commits', len(ancestors)
) as progress:
for rev in ancestors:
extra = repo.changelog.changelogrevision(rev).extra
node = repo.changelog.node(rev)
progress.increment(item=short(node))
......@@ -660,8 +660,7 @@
with repo.ui.makeprogress(topic, unit, todo_total) as progress:
export = []
for ctx in to_export:
progress.increment(item=short(ctx.node()))
if ctx.extra().get(b'hg-git', None) != b'octopus':
export.append(ctx)
if (
hex(node) not in self._map_hg
and extra.get(b'hg-git', None) != b'octopus'
):
export.append(node)
......@@ -667,5 +666,5 @@
total = len(export)
total = len(export)
self.ui.note(_(b"exporting %d changesets\n") % total)
......@@ -677,8 +676,7 @@
# 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 = export[0].p1()
pnode = pctx.node()
pnode = repo.changelog.parents(export[0])[0]
if pnode == nullid:
gitcommit = None
else:
......@@ -687,10 +685,10 @@
gitcommit = self.git[gitsha]
exporter = hg2git.IncrementalChangesetExporter(
self.repo, pctx, self.git.object_store, gitcommit
self.repo, repo[pnode], self.git.object_store, gitcommit
)
mapsavefreq = self.ui.configint(b'hggit', b'mapsavefrequency')
with self.repo.ui.makeprogress(
b'exporting', total=total
) as progress:
......@@ -691,12 +689,12 @@
)
mapsavefreq = self.ui.configint(b'hggit', b'mapsavefrequency')
with self.repo.ui.makeprogress(
b'exporting', total=total
) as progress:
for i, ctx in enumerate(export, 1):
progress.increment(item=short(ctx.node()))
self.export_hg_commit(ctx.node(), exporter)
for i, node in enumerate(export, 1):
progress.increment(item=short(node))
self.export_hg_commit(node, exporter)
if mapsavefreq and i % mapsavefreq == 0:
self.save_map(self.map_file)
......
......@@ -69,7 +69,9 @@
$ fn_hg_commit -A -m baz
$ hg push || cat $TESTTMP/dulwich.log
\r (no-eol) (esc)
searching commits 1/1 daf1ae153bf8 [=============>]\r (no-eol) (esc)
searching commits 1/3 c4d188f6e13d [===> ]\r (no-eol) (esc)
searching commits 2/3 221dd250e933 [========> ]\r (no-eol) (esc)
searching commits 3/3 daf1ae153bf8 [=============>]\r (no-eol) (esc)
\r (no-eol) (esc)
\r (no-eol) (esc)
exporting 1/1 daf1ae153bf8 [=====================>]\r (no-eol) (esc)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment