comparison mercurial/localrepo.py @ 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 998dd6a8fd98
comparison
equal deleted inserted replaced
43751:6237cb11753e 43752:657bdb724b47
1531 ] 1531 ]
1532 1532
1533 # dealing with some special values 1533 # dealing with some special values
1534 if changeid == b'null': 1534 if changeid == b'null':
1535 return context.changectx(self, nullrev, nullid) 1535 return context.changectx(self, nullrev, nullid)
1536 if changeid == b'tip':
1537 node = self.changelog.tip()
1538 rev = self.changelog.rev(node)
1539 return context.changectx(self, rev, node)
1540
1536 # dealing with arbitrary values 1541 # dealing with arbitrary values
1537 try: 1542 try:
1538 if isinstance(changeid, int): 1543 if isinstance(changeid, int):
1539 node = self.changelog.node(changeid) 1544 node = self.changelog.node(changeid)
1540 rev = changeid 1545 rev = changeid
1541 elif changeid == b'tip':
1542 node = self.changelog.tip()
1543 rev = self.changelog.rev(node)
1544 elif changeid == b'.': 1546 elif changeid == b'.':
1545 # this is a hack to delay/avoid loading obsmarkers 1547 # this is a hack to delay/avoid loading obsmarkers
1546 # when we know that '.' won't be hidden 1548 # when we know that '.' won't be hidden
1547 node = self.dirstate.p1() 1549 node = self.dirstate.p1()
1548 rev = self.unfiltered().changelog.rev(node) 1550 rev = self.unfiltered().changelog.rev(node)