Mercurial > hg
changeset 8528:4ddffb793d18
workingfilectx: always use the same filelog, even for renames
workingfilectx() was using the "src" filelog in case the file was renamed in
the working copy.
For consistency, stop special-casing it. This allows us to remove some
duplication between filectx and workingfilectx.
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 20 May 2009 02:08:53 +0200 |
parents | f9a80054dd3c |
children | a767998f0a78 |
files | mercurial/context.py |
diffstat | 1 files changed, 16 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Wed May 20 00:52:46 2009 +0200 +++ b/mercurial/context.py Wed May 20 02:08:53 2009 +0200 @@ -638,49 +638,36 @@ def _changectx(self): return workingctx(self._repo) - @propertycache - def _repopath(self): - return self._repo.dirstate.copied(self._path) or self._path - - @propertycache - def _filelog(self): - return self._repo.file(self._repopath) - def __nonzero__(self): return True def __str__(self): return "%s@%s" % (self.path(), self._changectx) - def filectx(self, fileid): - '''opens an arbitrary revision of the file without - opening a new filelog''' - return filectx(self._repo, self._repopath, fileid=fileid, - filelog=self._filelog) - - def rev(self): - if '_changectx' in self.__dict__: - return self._changectx.rev() - return self._filelog.linkrev(self._filerev) - def data(self): return self._repo.wread(self._path) def renamed(self): - rp = self._repopath - if rp == self._path: + rp = self._repo.dirstate.copied(self._path) + if not rp: return None return rp, self._changectx._parents[0]._manifest.get(rp, nullid) def parents(self): '''return parent filectxs, following copies if necessary''' - p = self._path - rp = self._repopath - pcl = self._changectx._parents + def filenode(ctx, path): + return ctx._manifest.get(path, nullid) + + path = self._path fl = self._filelog - pl = [(rp, pcl[0]._manifest.get(rp, nullid), fl)] - if len(pcl) > 1: - if rp != p: - fl = None - pl.append((p, pcl[1]._manifest.get(p, nullid), fl)) + pcl = self._changectx._parents + renamed = self.renamed() + + if renamed: + pl = [renamed + (None,)] + else: + pl = [(path, filenode(pcl[0], path), fl)] + + for pc in pcl[1:]: + pl.append((path, filenode(pc, path), fl)) return [filectx(self._repo, p, fileid=n, filelog=l) for p,n,l in pl if n != nullid]