remote-hg: add support to push URLs
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
Felipe Contreras committed
Nov 4, 2012 at 03:13 UTC
ffaf84c6631e1ee381ca0d04b363ee5c82fe20ac
1 file changed
+12
-2
contrib/remote-helpers/git-remote-hg
+12
-2
@@ -9,12 +9,13 @@
9
# Then you can clone with:
10
# git clone hg::/path/to/mercurial/repo/
11
12
-from mercurial import hg, ui, bookmarks, context
12
+from mercurial import hg, ui, bookmarks, context, util
13
14
import re
15
import sys
16
import os
17
import json
18
+import shutil
19
20
NAME_RE = re.compile('^([^<>]+)')
21
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]+)>$')
@@ -574,6 +575,12 @@ def main(args):
575
url = args[2]
576
peer = None
577
578
+ if alias[4:] == url:
579
+ is_tmp = True
580
+ alias = util.sha1(alias).hexdigest()
581
+ else:
582
+ is_tmp = False
583
+
584
gitdir = os.environ['GIT_DIR']
585
dirname = os.path.join(gitdir, 'hg', alias)
586
branches = {}
@@ -604,6 +611,9 @@ def main(args):
611
die('unhandled command: %s' % line)
612
sys.stdout.flush()
613
607
- marks.store()
614
+ if not is_tmp:
615
+ marks.store()
616
+ else:
617
+ shutil.rmtree(dirname)
618
619
sys.exit(main(sys.argv))