Patchwork D7475: localrepo: extract handling of some special value in __getitem__

login
register
mail settings
Submitter phabricator
Date Nov. 22, 2019, 9:19 a.m.
Message ID <differential-rev-PHID-DREV-4cam6473qcufql7b6546-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43412/
State Superseded
Headers show

Comments

phabricator - Nov. 22, 2019, 9:19 a.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-devel

Patch

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