Mercurial > hg > hg-git
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 <durham@fb.com> |
---|---|
date | Thu, 11 Jun 2015 13:56:16 -0700 (2015-06-11) |
parents | efcefc3522bd |
children | 3246f2fab625 |
files | hggit/git_handler.py tests/test-clone.t |
diffstat | 2 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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/