comparison mercurial/context.py @ 40695:9fa0d6dd1617

context: split `introrev` logic in a sub function We want to add a mechanism to stop iteration early associated to intro rev early in some case. However, it does not make sense to expose it in the public `filectx` API. So we split the code into an internal method instead.
author Boris Feld <boris.feld@octobus.net>
date Wed, 10 Oct 2018 00:50:36 +0200
parents 8a0136f69027
children 69206452a2ac
comparison
equal deleted inserted replaced
40694:8a0136f69027 40695:9fa0d6dd1617
762 762
763 def isintroducedafter(self, changelogrev): 763 def isintroducedafter(self, changelogrev):
764 """True if a filectx has been introduced after a given floor revision 764 """True if a filectx has been introduced after a given floor revision
765 """ 765 """
766 return (self.linkrev() >= changelogrev 766 return (self.linkrev() >= changelogrev
767 or self.introrev() >= changelogrev) 767 or self._introrev() >= changelogrev)
768 768
769 def introrev(self): 769 def introrev(self):
770 """return the rev of the changeset which introduced this file revision 770 """return the rev of the changeset which introduced this file revision
771 771
772 This method is different from linkrev because it take into account the 772 This method is different from linkrev because it take into account the
773 changeset the filectx was created from. It ensures the returned 773 changeset the filectx was created from. It ensures the returned
774 revision is one of its ancestors. This prevents bugs from 774 revision is one of its ancestors. This prevents bugs from
775 'linkrev-shadowing' when a file revision is used by multiple 775 'linkrev-shadowing' when a file revision is used by multiple
776 changesets. 776 changesets.
777 """ 777 """
778 return self._introrev()
779
780 def _introrev(self):
778 toprev = None 781 toprev = None
779 attrs = vars(self) 782 attrs = vars(self)
780 if r'_changeid' in attrs: 783 if r'_changeid' in attrs:
781 # We have a cached value already 784 # We have a cached value already
782 toprev = self._changeid 785 toprev = self._changeid