# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2021-02-16 13:13:42 # Node ID 75832107ec07034e44d2fe3e1f375ed325d86abb # Parent 6fc57680cfd64aa4f1843b44402c6661aed7cb9d 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 diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -777,6 +777,15 @@ class hgtagsfnodescache(object): 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 @@ class hgtagsfnodescache(object): except error.LookupError: # No .hgtags file on this revision. fnode = nullid - - self._writeentry(offset, properprefix, fnode) return fnode def setfnode(self, node, fnode):