D5289: context: remove seemingly impossible code branch
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Tue Nov 20 07:09:10 UTC 2018
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
I'm not a Python expert, but I can't think of a way that the following
branch can ever be hit:
def _changeid(self):
if r'_changeid' in self.__dict__:
return self._changeid
It seems to me that if that condition is true, then this function
would not have been called. The only exception I can think of is if a
reference to the function had been stored beforehand, something like this:
c = fctx.__dict__['_changeid']
fctx._changeid
c()
But that seems like very unlikely code to exist.
The condition was added in https://phab.mercurial-scm.org/rHG921b64e1f7b900cc58ffcc9b3fae4457bcb4d72b (filecontext: use 'is not
None' to check for filelog existence, 2013-05-01) as a "bonus" change
(in addition to what the patch was actually about)
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5289
AFFECTED FILES
mercurial/context.py
CHANGE DETAILS
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -562,9 +562,7 @@
@propertycache
def _changeid(self):
- if r'_changeid' in self.__dict__:
- return self._changeid
- elif r'_changectx' in self.__dict__:
+ if r'_changectx' in self.__dict__:
return self._changectx.rev()
elif r'_descendantrev' in self.__dict__:
# this file context was created from a revision with a known
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list