##// END OF EJS Templates
context: reduce dependence of changectx constructor...
Martin von Zweigbergk -
r39993:e1e3d1b4 default
parent child Browse files
Show More
@@ -242,7 +242,7 b' class basectx(object):'
242 parents = self._parents
242 parents = self._parents
243 if len(parents) == 2:
243 if len(parents) == 2:
244 return parents[1]
244 return parents[1]
245 return changectx(self._repo, nullrev)
245 return self._repo[nullrev]
246
246
247 def _fileinfo(self, path):
247 def _fileinfo(self, path):
248 if r'_manifest' in self.__dict__:
248 if r'_manifest' in self.__dict__:
@@ -482,8 +482,8 b' class changectx(basectx):'
482 repo = self._repo
482 repo = self._repo
483 p1, p2 = repo.changelog.parentrevs(self._rev)
483 p1, p2 = repo.changelog.parentrevs(self._rev)
484 if p2 == nullrev:
484 if p2 == nullrev:
485 return [changectx(repo, p1)]
485 return [repo[p1]]
486 return [changectx(repo, p1), changectx(repo, p2)]
486 return [repo[p1], repo[p2]]
487
487
488 def changeset(self):
488 def changeset(self):
489 c = self._changeset
489 c = self._changeset
@@ -534,11 +534,11 b' class changectx(basectx):'
534 recursively walk children.
534 recursively walk children.
535 """
535 """
536 c = self._repo.changelog.children(self._node)
536 c = self._repo.changelog.children(self._node)
537 return [changectx(self._repo, x) for x in c]
537 return [self._repo[x] for x in c]
538
538
539 def ancestors(self):
539 def ancestors(self):
540 for a in self._repo.changelog.ancestors([self._rev]):
540 for a in self._repo.changelog.ancestors([self._rev]):
541 yield changectx(self._repo, a)
541 yield self._repo[a]
542
542
543 def descendants(self):
543 def descendants(self):
544 """Recursively yield all children of the changeset.
544 """Recursively yield all children of the changeset.
@@ -546,7 +546,7 b' class changectx(basectx):'
546 For just the immediate children, use children()
546 For just the immediate children, use children()
547 """
547 """
548 for d in self._repo.changelog.descendants([self._rev]):
548 for d in self._repo.changelog.descendants([self._rev]):
549 yield changectx(self._repo, d)
549 yield self._repo[d]
550
550
551 def filectx(self, path, fileid=None, filelog=None):
551 def filectx(self, path, fileid=None, filelog=None):
552 """get a file context from this changeset"""
552 """get a file context from this changeset"""
@@ -589,7 +589,7 b' class changectx(basectx):'
589 ''.join(_(" alternatively, use --config "
589 ''.join(_(" alternatively, use --config "
590 "merge.preferancestor=%s\n") %
590 "merge.preferancestor=%s\n") %
591 short(n) for n in sorted(cahs) if n != anc))
591 short(n) for n in sorted(cahs) if n != anc))
592 return changectx(self._repo, anc)
592 return self._repo[anc]
593
593
594 def isancestorof(self, other):
594 def isancestorof(self, other):
595 """True if this changeset is an ancestor of other"""
595 """True if this changeset is an ancestor of other"""
@@ -992,7 +992,7 b' class filectx(basefilectx):'
992 @propertycache
992 @propertycache
993 def _changectx(self):
993 def _changectx(self):
994 try:
994 try:
995 return changectx(self._repo, self._changeid)
995 return self._repo[self._changeid]
996 except error.FilteredRepoLookupError:
996 except error.FilteredRepoLookupError:
997 # Linkrev may point to any revision in the repository. When the
997 # Linkrev may point to any revision in the repository. When the
998 # repository is filtered this may lead to `filectx` trying to build
998 # repository is filtered this may lead to `filectx` trying to build
@@ -1010,7 +1010,7 b' class filectx(basefilectx):'
1010 # Linkrevs have several serious troubles with filtering that are
1010 # Linkrevs have several serious troubles with filtering that are
1011 # complicated to solve. Proper handling of the issue here should be
1011 # complicated to solve. Proper handling of the issue here should be
1012 # considered when solving linkrev issue are on the table.
1012 # considered when solving linkrev issue are on the table.
1013 return changectx(self._repo.unfiltered(), self._changeid)
1013 return self._repo.unfiltered()[self._changeid]
1014
1014
1015 def filectx(self, fileid, changeid=None):
1015 def filectx(self, fileid, changeid=None):
1016 '''opens an arbitrary revision of the file without
1016 '''opens an arbitrary revision of the file without
@@ -1244,7 +1244,7 b' class committablectx(basectx):'
1244 yield p
1244 yield p
1245 for a in self._repo.changelog.ancestors(
1245 for a in self._repo.changelog.ancestors(
1246 [p.rev() for p in self._parents]):
1246 [p.rev() for p in self._parents]):
1247 yield changectx(self._repo, a)
1247 yield self._repo[a]
1248
1248
1249 def markcommitted(self, node):
1249 def markcommitted(self, node):
1250 """Perform post-commit cleanup necessary after committing this ctx
1250 """Perform post-commit cleanup necessary after committing this ctx
@@ -1301,7 +1301,7 b' class workingctx(committablectx):'
1301 p = self._repo.dirstate.parents()
1301 p = self._repo.dirstate.parents()
1302 if p[1] == nullid:
1302 if p[1] == nullid:
1303 p = p[:-1]
1303 p = p[:-1]
1304 return [changectx(self._repo, x) for x in p]
1304 return [self._repo[x] for x in p]
1305
1305
1306 def _fileinfo(self, path):
1306 def _fileinfo(self, path):
1307 # populate __dict__['_manifest'] as workingctx has no _manifestdelta
1307 # populate __dict__['_manifest'] as workingctx has no _manifestdelta
@@ -1210,7 +1210,7 b' class localrepository(object):'
1210 return changeid
1210 return changeid
1211 if isinstance(changeid, slice):
1211 if isinstance(changeid, slice):
1212 # wdirrev isn't contiguous so the slice shouldn't include it
1212 # wdirrev isn't contiguous so the slice shouldn't include it
1213 return [context.changectx(self, i)
1213 return [self[i]
1214 for i in pycompat.xrange(*changeid.indices(len(self)))
1214 for i in pycompat.xrange(*changeid.indices(len(self)))
1215 if i not in self.changelog.filteredrevs]
1215 if i not in self.changelog.filteredrevs]
1216 try:
1216 try:
General Comments 0
You need to be logged in to leave comments. Login now