remote-hg: fix bad state issue
The problem reportedly happened after doing a push that fails, the abort causes the state of remote-hg to go bad, this happens because remote-hg's marks are not stored, but 'git fast-export' marks are. Ensure that the marks are _always_ stored. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 11, 2013 at 07:23 UTC
2594a79ea9d34053384d514afd5dcaaaeed15480
1 file changed
+7
-1
contrib/remote-helpers/git-remote-hg
+7
-1
@@ -18,6 +18,7 @@ import json
18
import shutil
19
import subprocess
20
import urllib
21
+import atexit
22
23
#
24
# If you want to switch to hg-git compatibility mode:
@@ -791,7 +792,7 @@ def main(args):
792
global prefix, dirname, branches, bmarks
793
global marks, blob_marks, parsed_refs
794
global peer, mode, bad_mail, bad_name
794
- global track_branches, force_push
795
+ global track_branches, force_push, is_tmp
796
797
alias = args[1]
798
url = args[2]
@@ -833,6 +834,7 @@ def main(args):
834
bmarks = {}
835
blob_marks = {}
836
parsed_refs = {}
837
+ marks = None
838
839
repo = get_repo(url, alias)
840
prefix = 'refs/hg/%s' % alias
@@ -860,9 +862,13 @@ def main(args):
862
die('unhandled command: %s' % line)
863
sys.stdout.flush()
864
865
+def bye():
866
+ if not marks:
867
+ return
868
if not is_tmp:
869
marks.store()
870
else:
871
shutil.rmtree(dirname)
872
873
+atexit.register(bye)
874
sys.exit(main(sys.argv))