hgtagsfnodes: refactor code to compute fnode into separate fn
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 16 Feb 2021 18:43:42 +0530
changeset 46652 75832107ec07
parent 46651 6fc57680cfd6
child 46653 9306a16ca964
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
mercurial/tags.py
--- 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):