changeset 43752:657bdb724b47

localrepo: extract handling of some special value in __getitem__ The value "tip" should always be accessible, otherwise there is some problematic bug in the lower level. So we can access this outside of the general try/catch. If it fails some wider and actual big is in play. Differential Revision: https://phab.mercurial-scm.org/D7475
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 21 Nov 2019 17:54:25 +0100
parents 6237cb11753e
children 2276a9a1c037
files mercurial/localrepo.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Nov 21 17:53:08 2019 +0100
+++ b/mercurial/localrepo.py	Thu Nov 21 17:54:25 2019 +0100
@@ -1533,14 +1533,16 @@
         # dealing with some special values
         if changeid == b'null':
             return context.changectx(self, nullrev, nullid)
+        if changeid == b'tip':
+            node = self.changelog.tip()
+            rev = self.changelog.rev(node)
+            return context.changectx(self, rev, node)
+
         # dealing with arbitrary values
         try:
             if isinstance(changeid, int):
                 node = self.changelog.node(changeid)
                 rev = changeid
-            elif changeid == b'tip':
-                node = self.changelog.tip()
-                rev = self.changelog.rev(node)
             elif changeid == b'.':
                 # this is a hack to delay/avoid loading obsmarkers
                 # when we know that '.' won't be hidden