Keys in self.dict and vars() are always str. So we need to use
raw strings to ensure lookups work on Python 3.
- skip-blame just r'' prefixes
pulkit |
hg-reviewers |
Keys in self.dict and vars() are always str. So we need to use
raw strings to ensure lookups work on Python 3.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/remotefilelog/remotefilectx.py (8 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Feb 13 2019, 7:31 PM |
fileid, filelog, changectx) | fileid, filelog, changectx) | ||||
self._ancestormap = ancestormap | self._ancestormap = ancestormap | ||||
def size(self): | def size(self): | ||||
return self._filelog.size(self._filenode) | return self._filelog.size(self._filenode) | ||||
@propertycache | @propertycache | ||||
def _changeid(self): | def _changeid(self): | ||||
if '_changeid' in self.__dict__: | if r'_changeid' in self.__dict__: | ||||
return self._changeid | return self._changeid | ||||
elif '_changectx' in self.__dict__: | elif r'_changectx' in self.__dict__: | ||||
return self._changectx.rev() | return self._changectx.rev() | ||||
elif '_descendantrev' in self.__dict__: | elif r'_descendantrev' in self.__dict__: | ||||
# this file context was created from a revision with a known | # this file context was created from a revision with a known | ||||
# descendant, we can (lazily) correct for linkrev aliases | # descendant, we can (lazily) correct for linkrev aliases | ||||
linknode = self._adjustlinknode(self._path, self._filelog, | linknode = self._adjustlinknode(self._path, self._filelog, | ||||
self._filenode, self._descendantrev) | self._filenode, self._descendantrev) | ||||
return self._repo.unfiltered().changelog.rev(linknode) | return self._repo.unfiltered().changelog.rev(linknode) | ||||
else: | else: | ||||
return self.linkrev() | return self.linkrev() | ||||
This method is different from linkrev because it take into account the | This method is different from linkrev because it take into account the | ||||
changeset the filectx was created from. It ensures the returned | changeset the filectx was created from. It ensures the returned | ||||
revision is one of its ancestors. This prevents bugs from | revision is one of its ancestors. This prevents bugs from | ||||
'linkrev-shadowing' when a file revision is used by multiple | 'linkrev-shadowing' when a file revision is used by multiple | ||||
changesets. | changesets. | ||||
""" | """ | ||||
lkr = self.linkrev() | lkr = self.linkrev() | ||||
attrs = vars(self) | attrs = vars(self) | ||||
noctx = not ('_changeid' in attrs or '_changectx' in attrs) | noctx = not (r'_changeid' in attrs or r'_changectx' in attrs) | ||||
if noctx or self.rev() == lkr: | if noctx or self.rev() == lkr: | ||||
return lkr | return lkr | ||||
linknode = self._adjustlinknode(self._path, self._filelog, | linknode = self._adjustlinknode(self._path, self._filelog, | ||||
self._filenode, self.rev(), | self._filenode, self.rev(), | ||||
inclusive=True) | inclusive=True) | ||||
return self._repo.changelog.rev(linknode) | return self._repo.changelog.rev(linknode) | ||||
def renamed(self): | def renamed(self): |