changeset 917:6aa31a3b0506

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.
author Durham Goode <>
date Thu, 11 Jun 2015 13:56:16 -0700
parents efcefc3522bd
children 3246f2fab625
files hggit/ tests/test-clone.t
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/
+++ b/hggit/
@@ -703,10 +703,14 @@
             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]
+            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
--- 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/