summaryrefslogtreecommitdiff
path: root/contrib/remote-helpers/git-remote-hg
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/remote-helpers/git-remote-hg')
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg32
1 files changed, 23 insertions, 9 deletions
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 92d994e..eb89ef6 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -51,8 +51,8 @@ import time as ptime
#
NAME_RE = re.compile('^([^<>]+)')
-AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
-EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
+AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
+EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')
RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)')
@@ -316,8 +316,7 @@ def fixup_user_git(user):
else:
m = EMAIL_RE.match(user)
if m:
- name = m.group(1)
- mail = m.group(2)
+ mail = m.group(1)
else:
m = NAME_RE.match(user)
if m:
@@ -416,6 +415,9 @@ def get_repo(url, alias):
local_path = os.path.join(dirname, 'clone')
if not os.path.exists(local_path):
hg.share(myui, shared_path, local_path, update=False)
+ else:
+ # make sure the shared path is always up-to-date
+ util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path)
repo = hg.repository(myui, local_path)
try:
@@ -538,7 +540,7 @@ def export_ref(repo, name, kind, head):
print "commit %s" % ref
print "mark :%d" % (note_mark)
- print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
+ print "committer remote-hg <> %d %s" % (ptime.time(), gittz(ptime.timezone))
desc = "Notes for %s\n" % (name)
print "data %d" % (len(desc))
print desc
@@ -703,6 +705,11 @@ def get_merge_files(repo, p1, p2, files):
f = { 'ctx' : repo[p1][e] }
files[e] = f
+def c_style_unescape(string):
+ if string[0] == string[-1] == '"':
+ return string.decode('string-escape')[1:-1]
+ return string
+
def parse_commit(parser):
from_mark = merge_mark = None
@@ -742,6 +749,7 @@ def parse_commit(parser):
f = { 'deleted' : True }
else:
die('Unknown file command: %s' % line)
+ path = c_style_unescape(path)
files[path] = f
# only export the commits if we are on an internal proxy repo
@@ -1159,6 +1167,16 @@ def main(args):
global dry_run
global notes, alias
+ marks = None
+ is_tmp = False
+ gitdir = os.environ.get('GIT_DIR', None)
+
+ if len(args) < 3:
+ die('Not enough arguments.')
+
+ if not gitdir:
+ die('GIT_DIR not set')
+
alias = args[1]
url = args[2]
peer = None
@@ -1179,16 +1197,12 @@ def main(args):
if alias[4:] == url:
is_tmp = True
alias = hashlib.sha1(alias).hexdigest()
- else:
- is_tmp = False
- gitdir = os.environ['GIT_DIR']
dirname = os.path.join(gitdir, 'hg', alias)
branches = {}
bmarks = {}
blob_marks = {}
parsed_refs = {}
- marks = None
parsed_tags = {}
filenodes = {}
fake_bmark = None