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

mail settings
Submitter Pierre-Yves David
Date March 30, 2017, 3:03 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/19849/
State Deferred
Headers show


Pierre-Yves David - March 30, 2017, 3:03 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1490670416 -7200
#      Tue Mar 28 05:06:56 2017 +0200
# Node ID f6e7b8a14f4a94db6742410331db752112c76b82
# Parent  dea2a17cbfd00bf08ee87b3e44b1c71499189f89
# EXP-Topic tags
# Available At
#              hg pull -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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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