1 # Note: Changes to this file should also be made in the hg-git
2 # repository in the hggit directory.
7 def get_git_author(ctx):
8 # hg authors might not have emails
11 # check for git author pattern compliance
12 regex = re.compile('^(.*?) \<(.*?)\>(.*)$')
13 a = regex.match(author)
18 if len(a.group(3)) > 0:
19 name += ' ext:(' + urllib.quote(a.group(3)) + ')'
20 author = name + ' <' + email + '>'
22 author = author + ' <none@none>'
24 if 'author' in ctx.extra():
25 author = apply_delta(author, ctx.extra()['author'])
29 def get_git_parents(ctx):
30 def is_octopus_part(ctx):
31 return ctx.extra().get('hg-git', None) in ('octopus', 'octopus-done')
34 if ctx.extra().get('hg-git', None) == 'octopus-done':
35 # implode octopus parents
37 while is_octopus_part(part):
38 (p1, p2) = part.parents()
39 assert not is_octopus_part(p1)
44 parents = ctx.parents()
48 def get_git_message(ctx):
51 message = ctx.description() + "\n"
52 if 'message' in extra:
53 message = apply_delta(message, extra['message'])
55 # HG EXTRA INFORMATION
58 if not ctx.branch() == 'default':
60 extra_message += "branch : " + ctx.branch() + "\n"
64 if f not in ctx.manifest():
66 rename = ctx.filectx(f).renamed()
68 renames.append((rename[0], f))
72 for oldfile, newfile in renames:
73 extra_message += "rename : " + oldfile + " => " + newfile + "\n"
75 for key, value in extra.iteritems():
76 if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git'):
80 extra_message += "extra : " + key + " : " + urllib.quote(value) + "\n"
83 message += "\n--HG--\n" + extra_message