Mercurial > hg
changeset 24816:8eec040cb65e stable
filectx: extract function to create parent fctx keeping ancestry info
committablefilectx.parents() should use this to take advantage of the linkrev
adjustment.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 18 Apr 2015 14:03:41 +0900 |
parents | 023f97267784 |
children | 0bb98eee531d |
files | mercurial/context.py |
diffstat | 1 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Sat Apr 18 13:46:24 2015 +0900 +++ b/mercurial/context.py Sat Apr 18 14:03:41 2015 +0900 @@ -806,6 +806,22 @@ return self._adjustlinkrev(self._path, self._filelog, self._filenode, self.rev(), inclusive=True) + def _parentfilectx(self, path, fileid, filelog): + """create parent filectx keeping ancestry info for _adjustlinkrev()""" + fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) + if '_changeid' in vars(self) or '_changectx' in vars(self): + # If self is associated with a changeset (probably explicitly + # fed), ensure the created filectx is associated with a + # changeset that is an ancestor of self.changectx. + # This lets us later use _adjustlinkrev to get a correct link. + fctx._descendantrev = self.rev() + fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) + elif '_descendantrev' in vars(self): + # Otherwise propagate _descendantrev if we have one associated. + fctx._descendantrev = self._descendantrev + fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) + return fctx + def parents(self): _path = self._path fl = self._filelog @@ -824,22 +840,7 @@ # first nullid parent with rename information. pl.insert(0, (r[0], r[1], self._repo.file(r[0]))) - ret = [] - for path, fnode, l in pl: - fctx = filectx(self._repo, path, fileid=fnode, filelog=l) - if '_changeid' in vars(self) or '_changectx' in vars(self): - # If self is associated with a changeset (probably explicitly - # fed), ensure the created filectx is associated with a - # changeset that is an ancestor of self.changectx. - # This lets us later use _adjustlinkrev to get a correct link. - fctx._descendantrev = self.rev() - fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) - elif '_descendantrev' in vars(self): - # Otherwise propagate _descendantrev if we have one associated. - fctx._descendantrev = self._descendantrev - fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) - ret.append(fctx) - return ret + return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl] def p1(self): return self.parents()[0]