changeset 46652:75832107ec07

hgtagsfnodes: refactor code to compute fnode into separate fn I plan to use this code at one more place while fixing a bug caused by an invalid fnode present in cache. Differential Revision: https://phab.mercurial-scm.org/D10013
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 16 Feb 2021 18:43:42 +0530
parents 6fc57680cfd6
children 9306a16ca964
files mercurial/tags.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/tags.py	Wed Feb 10 17:24:54 2021 +0530
+++ b/mercurial/tags.py	Tue Feb 16 18:43:42 2021 +0530
@@ -777,6 +777,15 @@
                 return False
             return None
 
+        fnode = self._computefnode(node)
+        self._writeentry(offset, properprefix, fnode)
+        return fnode
+
+    def _computefnode(self, node):
+        """Finds the tag filenode for a node which is missing or invalid
+        in cache"""
+        ctx = self._repo[node]
+        rev = ctx.rev()
         fnode = None
         cl = self._repo.changelog
         p1rev, p2rev = cl._uncheckedparentrevs(rev)
@@ -804,8 +813,6 @@
             except error.LookupError:
                 # No .hgtags file on this revision.
                 fnode = nullid
-
-        self._writeentry(offset, properprefix, fnode)
         return fnode
 
     def setfnode(self, node, fnode):