263 if len(parents) == 2: |
263 if len(parents) == 2: |
264 return parents[1] |
264 return parents[1] |
265 return self._repo[nullrev] |
265 return self._repo[nullrev] |
266 |
266 |
267 def _fileinfo(self, path): |
267 def _fileinfo(self, path): |
268 if r'_manifest' in self.__dict__: |
268 if '_manifest' in self.__dict__: |
269 try: |
269 try: |
270 return self._manifest[path], self._manifest.flags(path) |
270 return self._manifest[path], self._manifest.flags(path) |
271 except KeyError: |
271 except KeyError: |
272 raise error.ManifestLookupError( |
272 raise error.ManifestLookupError( |
273 self._node, path, _(b'not found in manifest') |
273 self._node, path, _(b'not found in manifest') |
274 ) |
274 ) |
275 if r'_manifestdelta' in self.__dict__ or path in self.files(): |
275 if '_manifestdelta' in self.__dict__ or path in self.files(): |
276 if path in self._manifestdelta: |
276 if path in self._manifestdelta: |
277 return ( |
277 return ( |
278 self._manifestdelta[path], |
278 self._manifestdelta[path], |
279 self._manifestdelta.flags(path), |
279 self._manifestdelta.flags(path), |
280 ) |
280 ) |
744 def _filelog(self): |
744 def _filelog(self): |
745 return self._repo.file(self._path) |
745 return self._repo.file(self._path) |
746 |
746 |
747 @propertycache |
747 @propertycache |
748 def _changeid(self): |
748 def _changeid(self): |
749 if r'_changectx' in self.__dict__: |
749 if '_changectx' in self.__dict__: |
750 return self._changectx.rev() |
750 return self._changectx.rev() |
751 elif r'_descendantrev' in self.__dict__: |
751 elif '_descendantrev' in self.__dict__: |
752 # this file context was created from a revision with a known |
752 # this file context was created from a revision with a known |
753 # descendant, we can (lazily) correct for linkrev aliases |
753 # descendant, we can (lazily) correct for linkrev aliases |
754 return self._adjustlinkrev(self._descendantrev) |
754 return self._adjustlinkrev(self._descendantrev) |
755 else: |
755 else: |
756 return self._filelog.linkrev(self._filerev) |
756 return self._filelog.linkrev(self._filerev) |
757 |
757 |
758 @propertycache |
758 @propertycache |
759 def _filenode(self): |
759 def _filenode(self): |
760 if r'_fileid' in self.__dict__: |
760 if '_fileid' in self.__dict__: |
761 return self._filelog.lookup(self._fileid) |
761 return self._filelog.lookup(self._fileid) |
762 else: |
762 else: |
763 return self._changectx.filenode(self._path) |
763 return self._changectx.filenode(self._path) |
764 |
764 |
765 @propertycache |
765 @propertycache |
1022 `stoprev` revision and "None" might be returned. This is useful to |
1022 `stoprev` revision and "None" might be returned. This is useful to |
1023 limit the iteration range. |
1023 limit the iteration range. |
1024 """ |
1024 """ |
1025 toprev = None |
1025 toprev = None |
1026 attrs = vars(self) |
1026 attrs = vars(self) |
1027 if r'_changeid' in attrs: |
1027 if '_changeid' in attrs: |
1028 # We have a cached value already |
1028 # We have a cached value already |
1029 toprev = self._changeid |
1029 toprev = self._changeid |
1030 elif r'_changectx' in attrs: |
1030 elif '_changectx' in attrs: |
1031 # We know which changelog entry we are coming from |
1031 # We know which changelog entry we are coming from |
1032 toprev = self._changectx.rev() |
1032 toprev = self._changectx.rev() |
1033 |
1033 |
1034 if toprev is not None: |
1034 if toprev is not None: |
1035 return self._adjustlinkrev(toprev, inclusive=True, stoprev=stoprev) |
1035 return self._adjustlinkrev(toprev, inclusive=True, stoprev=stoprev) |
1036 elif r'_descendantrev' in attrs: |
1036 elif '_descendantrev' in attrs: |
1037 introrev = self._adjustlinkrev(self._descendantrev, stoprev=stoprev) |
1037 introrev = self._adjustlinkrev(self._descendantrev, stoprev=stoprev) |
1038 # be nice and cache the result of the computation |
1038 # be nice and cache the result of the computation |
1039 if introrev is not None: |
1039 if introrev is not None: |
1040 self._changeid = introrev |
1040 self._changeid = introrev |
1041 return introrev |
1041 return introrev |
1051 return self.filectx(self.filenode(), changeid=introrev) |
1051 return self.filectx(self.filenode(), changeid=introrev) |
1052 |
1052 |
1053 def _parentfilectx(self, path, fileid, filelog): |
1053 def _parentfilectx(self, path, fileid, filelog): |
1054 """create parent filectx keeping ancestry info for _adjustlinkrev()""" |
1054 """create parent filectx keeping ancestry info for _adjustlinkrev()""" |
1055 fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) |
1055 fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) |
1056 if r'_changeid' in vars(self) or r'_changectx' in vars(self): |
1056 if '_changeid' in vars(self) or '_changectx' in vars(self): |
1057 # If self is associated with a changeset (probably explicitly |
1057 # If self is associated with a changeset (probably explicitly |
1058 # fed), ensure the created filectx is associated with a |
1058 # fed), ensure the created filectx is associated with a |
1059 # changeset that is an ancestor of self.changectx. |
1059 # changeset that is an ancestor of self.changectx. |
1060 # This lets us later use _adjustlinkrev to get a correct link. |
1060 # This lets us later use _adjustlinkrev to get a correct link. |
1061 fctx._descendantrev = self.rev() |
1061 fctx._descendantrev = self.rev() |
1062 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
1062 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
1063 elif r'_descendantrev' in vars(self): |
1063 elif '_descendantrev' in vars(self): |
1064 # Otherwise propagate _descendantrev if we have one associated. |
1064 # Otherwise propagate _descendantrev if we have one associated. |
1065 fctx._descendantrev = self._descendantrev |
1065 fctx._descendantrev = self._descendantrev |
1066 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
1066 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
1067 return fctx |
1067 return fctx |
1068 |
1068 |
1118 pl = [p for p in pl if p.path() == f.path()] |
1118 pl = [p for p in pl if p.path() == f.path()] |
1119 |
1119 |
1120 # renamed filectx won't have a filelog yet, so set it |
1120 # renamed filectx won't have a filelog yet, so set it |
1121 # from the cache to save time |
1121 # from the cache to save time |
1122 for p in pl: |
1122 for p in pl: |
1123 if not r'_filelog' in p.__dict__: |
1123 if not '_filelog' in p.__dict__: |
1124 p._filelog = getlog(p.path()) |
1124 p._filelog = getlog(p.path()) |
1125 |
1125 |
1126 return pl |
1126 return pl |
1127 |
1127 |
1128 # use linkrev to find the first changeset where self appeared |
1128 # use linkrev to find the first changeset where self appeared |
1532 @propertycache |
1532 @propertycache |
1533 def _flagfunc(self): |
1533 def _flagfunc(self): |
1534 return self._repo.dirstate.flagfunc(self._buildflagfunc) |
1534 return self._repo.dirstate.flagfunc(self._buildflagfunc) |
1535 |
1535 |
1536 def flags(self, path): |
1536 def flags(self, path): |
1537 if r'_manifest' in self.__dict__: |
1537 if '_manifest' in self.__dict__: |
1538 try: |
1538 try: |
1539 return self._manifest.flags(path) |
1539 return self._manifest.flags(path) |
1540 except KeyError: |
1540 except KeyError: |
1541 return b'' |
1541 return b'' |
1542 |
1542 |