changeset 43771:6237cb11753e

localrepo: extract handling of some special value in __getitem__ The value "null" will always be present in a repository. So this lookup should always succeed and do not need to be in the general try/catch. Differential Revision: https://phab.mercurial-scm.org/D7474
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 21 Nov 2019 17:53:08 +0100
parents 9c83d28776af
children 657bdb724b47
files mercurial/localrepo.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Nov 17 03:27:51 2019 +0100
+++ b/mercurial/localrepo.py	Thu Nov 21 17:53:08 2019 +0100
@@ -1530,14 +1530,14 @@
                 if i not in self.changelog.filteredrevs
             ]
 
+        # dealing with some special values
+        if changeid == b'null':
+            return context.changectx(self, nullrev, nullid)
         # dealing with arbitrary values
         try:
             if isinstance(changeid, int):
                 node = self.changelog.node(changeid)
                 rev = changeid
-            elif changeid == b'null':
-                node = nullid
-                rev = nullrev
             elif changeid == b'tip':
                 node = self.changelog.tip()
                 rev = self.changelog.rev(node)