comparison mercurial/context.py @ 40671:1423ff45c322

context: remove seemingly impossible code branch 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 921b64e1f7b9 (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) Differential Revision: https://phab.mercurial-scm.org/D5289
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 19 Nov 2018 23:08:09 -0800
parents af2306bf7d5d
children f3f4d8537b11
comparison
equal deleted inserted replaced
40669:d6a13f6db69c 40671:1423ff45c322
560 def _filelog(self): 560 def _filelog(self):
561 return self._repo.file(self._path) 561 return self._repo.file(self._path)
562 562
563 @propertycache 563 @propertycache
564 def _changeid(self): 564 def _changeid(self):
565 if r'_changeid' in self.__dict__: 565 if r'_changectx' in self.__dict__:
566 return self._changeid
567 elif r'_changectx' in self.__dict__:
568 return self._changectx.rev() 566 return self._changectx.rev()
569 elif r'_descendantrev' in self.__dict__: 567 elif r'_descendantrev' in self.__dict__:
570 # this file context was created from a revision with a known 568 # this file context was created from a revision with a known
571 # descendant, we can (lazily) correct for linkrev aliases 569 # descendant, we can (lazily) correct for linkrev aliases
572 return self._adjustlinkrev(self._descendantrev) 570 return self._adjustlinkrev(self._descendantrev)