tags: introduce a function to return a valid fnodes list from revs
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 28 Mar 2017 05:06:56 +0200
changeset 31993 bfb826c350d4
parent 31992 3e47a40d7a7a
child 31994 b36318e6d2ef
tags: introduce a function to return a valid fnodes list from revs This will get used to compare tags between two set of revisions during a transaction (pre and post heads). The end goal is to be able to track tags movement in transaction hooks.
mercurial/tags.py
--- a/mercurial/tags.py	Fri Apr 14 14:25:06 2017 +0200
+++ b/mercurial/tags.py	Tue Mar 28 05:06:56 2017 +0200
@@ -78,6 +78,18 @@
 # The most recent changeset (in terms of revlog ordering for the head
 # setting it) for each tag is last.
 
+def fnoderevs(ui, repo, revs):
+    """return the list of '.hgtags' fnodes used in a set revisions
+
+    This is returned as list of unique fnodes. We use a list instead of a set
+    because order matters when it comes to tags."""
+    unfi = repo.unfiltered()
+    tonode = unfi.changelog.node
+    nodes = [tonode(r) for r in revs]
+    fnodes = _getfnodes(ui, repo, nodes[::-1]) # reversed help the cache
+    fnodes = _filterfnodes(fnodes, nodes)
+    return fnodes
+
 def findglobaltags(ui, repo):
     '''Find global tags in a repo: return a tagsmap