remote-bzr: add support to push URLs
Just like in remote-hg. 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
aa9384566161a242ad0ca2563e613736edf38fe9
1 file changed
+13
-3
contrib/remote-helpers/git-remote-bzr
+13
-3
@@ -32,7 +32,7 @@ import os
32
import json
33
import re
34
import StringIO
35
-import atexit
35
+import atexit, shutil, hashlib
36
37
NAME_RE = re.compile('^([^<>]+)')
38
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
@@ -719,11 +719,11 @@ def main(args):
719
global blob_marks
720
global parsed_refs
721
global files_cache
722
+ global is_tmp
723
724
alias = args[1]
725
url = args[2]
726
726
- prefix = 'refs/bzr/%s' % alias
727
tags = {}
728
filenodes = {}
729
blob_marks = {}
@@ -731,6 +731,13 @@ def main(args):
731
files_cache = {}
732
marks = None
733
734
+ if alias[5:] == url:
735
+ is_tmp = True
736
+ alias = hashlib.sha1(alias).hexdigest()
737
+ else:
738
+ is_tmp = False
739
+
740
+ prefix = 'refs/bzr/%s' % alias
741
gitdir = os.environ['GIT_DIR']
742
dirname = os.path.join(gitdir, 'bzr', alias)
743
@@ -759,7 +766,10 @@ def main(args):
766
def bye():
767
if not marks:
768
return
762
- marks.store()
769
+ if not is_tmp:
770
+ marks.store()
771
+ else:
772
+ shutil.rmtree(dirname)
773
774
atexit.register(bye)
775
sys.exit(main(sys.argv))