--- a/mercurial/tags.py Tue Mar 28 06:08:12 2017 +0200
+++ b/mercurial/tags.py Tue Mar 28 06:23:28 2017 +0200
@@ -95,17 +95,10 @@
_updatetags(cachetags, alltags)
return alltags
- seen = set() # set of fnode
- fnodes = []
for head in reversed(heads): # oldest to newest
assert head in repo.changelog.nodemap, \
"tag cache returned bogus head %s" % short(head)
-
- fnode = tagfnode.get(head)
- if fnode and fnode not in seen:
- seen.add(fnode)
- fnodes.append(fnode)
-
+ fnodes = _filterfnodes(tagfnode, reversed(heads))
alltags = _tagsfromfnodes(ui, repo, fnodes)
# and update the cache (if necessary)
@@ -113,6 +106,21 @@
_writetagcache(ui, repo, valid, alltags)
return alltags
+def _filterfnodes(tagfnode, nodes):
+ """return a list of unique fnodes
+
+ The order of this list matches the order of "nodes". Preserving this order
+ is important as reading tags in different order provides different
+ results."""
+ seen = set() # set of fnode
+ fnodes = []
+ for no in nodes: # oldest to newest
+ fnode = tagfnode.get(no)
+ if fnode and fnode not in seen:
+ seen.add(fnode)
+ fnodes.append(fnode)
+ return fnodes
+
def _tagsfromfnodes(ui, repo, fnodes):
"""return a tagsmap from a list of file-node