# HG changeset patch # User Martin von Zweigbergk # Date 1538695660 25200 # Node ID 5c3585a588458a70338fb112708c9b0cd2af2526 # Parent f84d7ed3bb354a30763b4ca22f236cf1a61083d0 repo: create changectx in a single place in localrepo.__getitem__ Differential Revision: https://phab.mercurial-scm.org/D4885 diff -r f84d7ed3bb35 -r 5c3585a58845 mercurial/localrepo.py --- a/mercurial/localrepo.py Thu Oct 04 16:06:36 2018 -0700 +++ b/mercurial/localrepo.py Thu Oct 04 16:27:40 2018 -0700 @@ -1222,26 +1222,21 @@ if isinstance(changeid, int): node = self.changelog.node(changeid) rev = changeid - return context.changectx(self, rev, node) elif changeid == 'null': node = nullid rev = nullrev - return context.changectx(self, rev, node) elif changeid == 'tip': node = self.changelog.tip() rev = self.changelog.rev(node) - return context.changectx(self, rev, node) elif changeid == '.': # this is a hack to delay/avoid loading obsmarkers # when we know that '.' won't be hidden node = self.dirstate.p1() rev = self.unfiltered().changelog.rev(node) - return context.changectx(self, rev, node) elif len(changeid) == 20: try: node = changeid rev = self.changelog.rev(changeid) - return context.changectx(self, rev, node) except error.FilteredLookupError: changeid = hex(changeid) # for the error message raise @@ -1260,12 +1255,13 @@ elif len(changeid) == 40: node = bin(changeid) rev = self.changelog.rev(node) - return context.changectx(self, rev, node) else: raise error.ProgrammingError( "unsupported changeid '%s' of type %s" % (changeid, type(changeid))) + return context.changectx(self, rev, node) + except (error.FilteredIndexError, error.FilteredLookupError): raise error.FilteredRepoLookupError(_("filtered revision '%s'") % pycompat.bytestr(changeid))