Skip to content

Commit 2594a79

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e8e813 commit 2594a79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import json
1818
import shutil
1919
import subprocess
2020
import urllib
21+
import atexit
2122

2223
#
2324
# If you want to switch to hg-git compatibility mode:
@@ -791,7 +792,7 @@ def main(args):
791792
global prefix, dirname, branches, bmarks
792793
global marks, blob_marks, parsed_refs
793794
global peer, mode, bad_mail, bad_name
794-
global track_branches, force_push
795+
global track_branches, force_push, is_tmp
795796

796797
alias = args[1]
797798
url = args[2]
@@ -833,6 +834,7 @@ def main(args):
833834
bmarks = {}
834835
blob_marks = {}
835836
parsed_refs = {}
837+
marks = None
836838

837839
repo = get_repo(url, alias)
838840
prefix = 'refs/hg/%s' % alias
@@ -860,9 +862,13 @@ def main(args):
860862
die('unhandled command: %s' % line)
861863
sys.stdout.flush()
862864

865+
def bye():
866+
if not marks:
867+
return
863868
if not is_tmp:
864869
marks.store()
865870
else:
866871
shutil.rmtree(dirname)
867872

873+
atexit.register(bye)
868874
sys.exit(main(sys.argv))

0 commit comments

Comments
 (0)