Mercurial > hg
comparison hgext/convert/git.py @ 16259:589aab2ca716
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
author | Edouard Gomez <ed.gomez@free.fr> |
---|---|
date | Wed, 14 Mar 2012 01:13:45 +0100 |
parents | 11aad09a6370 |
children | ba42eb722bb3 |
comparison
equal
deleted
inserted
replaced
16256:c655e4acaa82 | 16259:589aab2ca716 |
---|---|
141 rev=version) | 141 rev=version) |
142 return c | 142 return c |
143 | 143 |
144 def gettags(self): | 144 def gettags(self): |
145 tags = {} | 145 tags = {} |
146 alltags = {} | |
146 fh = self.gitopen('git ls-remote --tags "%s"' % self.path) | 147 fh = self.gitopen('git ls-remote --tags "%s"' % self.path) |
147 prefix = 'refs/tags/' | 148 prefix = 'refs/tags/' |
149 | |
150 # Build complete list of tags, both annotated and bare ones | |
148 for line in fh: | 151 for line in fh: |
149 line = line.strip() | 152 line = line.strip() |
150 if not line.endswith("^{}"): | |
151 continue | |
152 node, tag = line.split(None, 1) | 153 node, tag = line.split(None, 1) |
153 if not tag.startswith(prefix): | 154 if not tag.startswith(prefix): |
154 continue | 155 continue |
155 tag = tag[len(prefix):-3] | 156 alltags[tag[len(prefix):]] = node |
156 tags[tag] = node | |
157 if fh.close(): | 157 if fh.close(): |
158 raise util.Abort(_('cannot read tags from %s') % self.path) | 158 raise util.Abort(_('cannot read tags from %s') % self.path) |
159 | |
160 # Filter out tag objects for annotated tag refs | |
161 for tag in alltags: | |
162 if tag.endswith('^{}'): | |
163 tags[tag[:-3]] = alltags[tag] | |
164 else: | |
165 if tag + '^{}' in alltags: | |
166 continue | |
167 else: | |
168 tags[tag] = alltags[tag] | |
159 | 169 |
160 return tags | 170 return tags |
161 | 171 |
162 def getchangedfiles(self, version, i): | 172 def getchangedfiles(self, version, i): |
163 changes = [] | 173 changes = [] |