# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1475495028 25200
#      Mon Oct 03 04:43:48 2016 -0700
# Node ID d0ce6eaebe7b5279d16c1aab7f9bd4aefb471681
# Parent  a128b9a53b5a0fc0b3275d4865c50801bd529f14
githandler: respect mapsavefrequency during export

When importing changesets, hggit uses the config knob hggit.mapsavefrequency to
determine how often to save the mapfile. This allows a user to interrupt the
import without losing all progress.

This patch adds this same functionality to the export mechanism.

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -459,9 +459,13 @@
         exporter = hg2git.IncrementalChangesetExporter(
             self.repo, pctx, self.git.object_store, gitcommit)
 
+        mapsavefreq = self.ui.configint('hggit', 'mapsavefrequency', 0)
         for i, ctx in enumerate(export):
             self.ui.progress('exporting', i, total=total)
             self.export_hg_commit(ctx.node(), exporter)
+            if mapsavefreq and i % mapsavefreq == 0:
+                self.ui.debug(_("saving mapfile\n"))
+                self.save_map(self.map_file)
         self.ui.progress('exporting', None, total=total)
 
     def set_commiter_from_author(self, commit):