Patchwork D10013: hgtagsfnodes: refactor code to compute fnode into separate fn

login
register
mail settings
Submitter phabricator
Date Feb. 17, 2021, 7:43 p.m.
Message ID <differential-rev-PHID-DREV-ivccexad7nlrbyyaq3ww-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48328/
State Superseded
Headers show

Comments

phabricator - Feb. 17, 2021, 7:43 p.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I plan to use this code at one more place while fixing a bug caused by an
  invalid fnode present in cache.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10013

AFFECTED FILES
  mercurial/tags.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -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):