# HG changeset patch # User Durham Goode # Date 1434056176 25200 # Node ID 6aa31a3b0506247e054b99c3a92ff6e15bb3bad8 # Parent efcefc3522bd92e14362ad661f49cc3037919269 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. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -703,10 +703,14 @@ 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) + 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 diff --git a/tests/test-clone.t b/tests/test-clone.t --- a/tests/test-clone.t +++ b/tests/test-clone.t @@ -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/