Skip to content
Snippets Groups Projects
Commit 6aa31a3b authored by Durham Goode's avatar Durham Goode
Browse files

gitimport: add save frequency config

If the importer encountered an error half way through a large import, all the
commits are saved, but the mapfile is not written, so the process starts over
from the beginning when run again.

This adds the option for a config value that will save the map file every X
commits. I thought about just hard coding this to 100 or something, but doing it
this way seems a little less invasive.
parent efcefc35
No related branches found
No related tags found
No related merge requests found
......@@ -703,7 +703,8 @@
else:
self.ui.status(_("no changes found\n"))
mapsavefreq = self.ui.configint('hggit', 'mapsavefrequency', 0)
for i, csha in enumerate(commits):
self.ui.progress('importing', i, total=total, unit='commits')
commit = commit_cache[csha]
self.import_git_commit(commit)
......@@ -706,7 +707,10 @@
for i, csha in enumerate(commits):
self.ui.progress('importing', i, total=total, unit='commits')
commit = commit_cache[csha]
self.import_git_commit(commit)
if mapsavefreq and i % mapsavefreq == 0:
self.ui.debug(_("saving mapfile\n"))
self.save_map(self.map_file)
self.ui.progress('importing', None, total=total, unit='commits')
# TODO if the tags cache is used, remove any dangling tag references
......
......@@ -54,6 +54,12 @@
summary: add alpha
clone with mapsavefreq set
$ rm -rf hgrepo-b
$ hg clone -r beta gitrepo hgrepo-b --config hggit.mapsavefrequency=1 --debug | grep saving
saving mapfile
saving mapfile
clone empty repo
$ git init empty
Initialized empty Git repository in $TESTTMP/empty/.git/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment