From 68d4f4f3e952f63d256dd11b1336a3782d8c1226 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Mon, 22 Apr 2013 16:55:15 -0500 Subject: remote-hg: custom method to write tags The one from mercurial is meant for users, on top of the latest tip. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/git-remote-hg | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index 4a1c637c08..f5e4ba7787 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -724,6 +724,37 @@ def parse_tag(parser): parsed_tags[name] = (tagger, data) +def write_tag(repo, tag, node, msg, author): + tip = repo['tip'] + + def getfilectx(repo, memctx, f): + try: + fctx = tip.filectx(f) + data = fctx.data() + except error.ManifestLookupError: + data = "" + content = data + "%s %s\n" % (hghex(node), tag) + return context.memfilectx(f, content, False, False, None) + + p1 = tip.hex() + p2 = '\0' * 20 + if not author: + author = (None, 0, 0) + user, date, tz = author + + ctx = context.memctx(repo, (p1, p2), msg, + ['.hgtags'], getfilectx, + user, (date, tz), {}) + + tmp = encoding.encoding + encoding.encoding = 'utf-8' + + tagnode = repo.commitctx(ctx) + + encoding.encoding = tmp + + return tagnode + def do_export(parser): global parsed_refs, bmarks, peer @@ -762,7 +793,7 @@ def do_export(parser): if mode == 'git': if not msg: msg = 'Added tag %s for changeset %s' % (tag, hghex(node[:6])); - parser.repo.tag([tag], node, msg, False, author[0], {}) + write_tag(parser.repo, tag, node, msg, author) else: parser.repo.tag([tag], node, None, True, None, {}) print "ok %s" % ref -- cgit v1.2.3