remote-bzr: fix bad state issue

Carried from remote-hg. 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 26, 2013 at 16:12 UTC d6bb9136c93baddf0ee5052638591bd881b19f77
1 file changed +6
contrib/remote-helpers/git-remote-bzr
+6
@@ -32,6 +32,7 @@ import os
32 import json
33 import re
34 import StringIO
35 +import atexit
36
37 NAME_RE = re.compile('^([^<>]+)')
38 AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
@@ -728,6 +729,7 @@ def main(args):
729 blob_marks = {}
730 parsed_refs = {}
731 files_cache = {}
732 + marks = None
733
734 gitdir = os.environ['GIT_DIR']
735 dirname = os.path.join(gitdir, 'bzr', alias)
@@ -754,6 +756,10 @@ def main(args):
756 die('unhandled command: %s' % line)
757 sys.stdout.flush()
758
759 +def bye():
760 + if not marks:
761 + return
762 marks.store()
763
764 +atexit.register(bye)
765 sys.exit(main(sys.argv))