remote-hg: add support to push URLs

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
maint
Felipe Contreras 2012-11-04 03:13:26 +01:00 committed by Jeff King
parent b4e956f7ef
commit ffaf84c663
1 changed files with 12 additions and 2 deletions

View File

@ -9,12 +9,13 @@
# Then you can clone with: # Then you can clone with:
# git clone hg::/path/to/mercurial/repo/ # git clone hg::/path/to/mercurial/repo/


from mercurial import hg, ui, bookmarks, context from mercurial import hg, ui, bookmarks, context, util


import re import re
import sys import sys
import os import os
import json import json
import shutil


NAME_RE = re.compile('^([^<>]+)') NAME_RE = re.compile('^([^<>]+)')
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]+)>$') AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]+)>$')
@ -574,6 +575,12 @@ def main(args):
url = args[2] url = args[2]
peer = None peer = None


if alias[4:] == url:
is_tmp = True
alias = util.sha1(alias).hexdigest()
else:
is_tmp = False

gitdir = os.environ['GIT_DIR'] gitdir = os.environ['GIT_DIR']
dirname = os.path.join(gitdir, 'hg', alias) dirname = os.path.join(gitdir, 'hg', alias)
branches = {} branches = {}
@ -604,6 +611,9 @@ def main(args):
die('unhandled command: %s' % line) die('unhandled command: %s' % line)
sys.stdout.flush() sys.stdout.flush()


marks.store() if not is_tmp:
marks.store()
else:
shutil.rmtree(dirname)


sys.exit(main(sys.argv)) sys.exit(main(sys.argv))