[PATCH 1 of 4 NEW-CONCEPT] tags: introduce a function to return a valid fnodes list from revs

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Mar 30 15:03:39 UTC 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1490670416 -7200
#      Tue Mar 28 05:06:56 2017 +0200
# Node ID f6e7b8a14f4a94db6742410331db752112c76b82
# Parent  dea2a17cbfd00bf08ee87b3e44b1c71499189f89
# EXP-Topic tags
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r f6e7b8a14f4a
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.

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -78,6 +78,18 @@ from . import (
 # 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
 


More information about the Mercurial-devel mailing list