[PATCH] convert: support non annotated tags in git backend
Edouard Gomez
ed.gomez at free.fr
Wed Mar 14 00:17:13 UTC 2012
# HG changeset patch
# User Edouard Gomez <ed.gomez at free.fr>
# Date 1331684025 -3600
# Node ID 3bd38773b291093cb6490aeabddd2b820e1975e9
# Parent 60cc3a0d224972e0fca00fe93f0488b5e4a60c7c
convert: support non annotated tags in git backend
Do not blindly filter out non ending ^{} tags. The new logic
is:
- if both "tag" and "tag^{}" exist, "tag^{}" is what we want
- if only "tag" exists, "tag" is fine
diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -143,20 +143,30 @@
def gettags(self):
tags = {}
+ alltags = {}
fh = self.gitopen('git ls-remote --tags "%s"' % self.path)
prefix = 'refs/tags/'
+
+ # Build complete list of tags, both annotated and bare ones
for line in fh:
line = line.strip()
- if not line.endswith("^{}"):
- continue
node, tag = line.split(None, 1)
if not tag.startswith(prefix):
continue
- tag = tag[len(prefix):-3]
- tags[tag] = node
+ alltags[tag[len(prefix):]] = node
if fh.close():
raise util.Abort(_('cannot read tags from %s') % self.path)
+ # Filter out tag objects for annotated tag refs
+ for tag in alltags:
+ if tag.endswith('^{}'):
+ tags[tag[:-3]] = alltags[tag]
+ else:
+ if tag + '^{}' in alltags:
+ continue
+ else:
+ tags[tag] = alltags[tag]
+
return tags
def getchangedfiles(self, version, i):
More information about the Mercurial-devel
mailing list