diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2013-04-22 16:55:15 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-22 15:25:54 -0700 |
commit | 68d4f4f3e952f63d256dd11b1336a3782d8c1226 (patch) | |
tree | 92f201664799cc77252c4ab5e99623d681cd58a8 /contrib | |
parent | remote-hg: add support for tag objects (diff) | |
download | tgif-68d4f4f3e952f63d256dd11b1336a3782d8c1226.tar.xz |
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 <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/remote-helpers/git-remote-hg | 33 |
1 files changed, 32 insertions, 1 deletions
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 |