##// END OF EJS Templates
workingfilectx: always use the same filelog, even for renames...
Benoit Boissinot -
r8528:4ddffb79 default
parent child Browse files
Show More
@@ -638,49 +638,36 b' class workingfilectx(filectx):'
638 def _changectx(self):
638 def _changectx(self):
639 return workingctx(self._repo)
639 return workingctx(self._repo)
640
640
641 @propertycache
642 def _repopath(self):
643 return self._repo.dirstate.copied(self._path) or self._path
644
645 @propertycache
646 def _filelog(self):
647 return self._repo.file(self._repopath)
648
649 def __nonzero__(self):
641 def __nonzero__(self):
650 return True
642 return True
651
643
652 def __str__(self):
644 def __str__(self):
653 return "%s@%s" % (self.path(), self._changectx)
645 return "%s@%s" % (self.path(), self._changectx)
654
646
655 def filectx(self, fileid):
656 '''opens an arbitrary revision of the file without
657 opening a new filelog'''
658 return filectx(self._repo, self._repopath, fileid=fileid,
659 filelog=self._filelog)
660
661 def rev(self):
662 if '_changectx' in self.__dict__:
663 return self._changectx.rev()
664 return self._filelog.linkrev(self._filerev)
665
666 def data(self): return self._repo.wread(self._path)
647 def data(self): return self._repo.wread(self._path)
667 def renamed(self):
648 def renamed(self):
668 rp = self._repopath
649 rp = self._repo.dirstate.copied(self._path)
669 if rp == self._path:
650 if not rp:
670 return None
651 return None
671 return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
652 return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
672
653
673 def parents(self):
654 def parents(self):
674 '''return parent filectxs, following copies if necessary'''
655 '''return parent filectxs, following copies if necessary'''
675 p = self._path
656 def filenode(ctx, path):
676 rp = self._repopath
657 return ctx._manifest.get(path, nullid)
677 pcl = self._changectx._parents
658
659 path = self._path
678 fl = self._filelog
660 fl = self._filelog
679 pl = [(rp, pcl[0]._manifest.get(rp, nullid), fl)]
661 pcl = self._changectx._parents
680 if len(pcl) > 1:
662 renamed = self.renamed()
681 if rp != p:
663
682 fl = None
664 if renamed:
683 pl.append((p, pcl[1]._manifest.get(p, nullid), fl))
665 pl = [renamed + (None,)]
666 else:
667 pl = [(path, filenode(pcl[0], path), fl)]
668
669 for pc in pcl[1:]:
670 pl.append((path, filenode(pc, path), fl))
684
671
685 return [filectx(self._repo, p, fileid=n, filelog=l)
672 return [filectx(self._repo, p, fileid=n, filelog=l)
686 for p,n,l in pl if n != nullid]
673 for p,n,l in pl if n != nullid]
General Comments 0
You need to be logged in to leave comments. Login now