[PATCH 5 of 5] adjustlinkrev: remove unnecessary parameters
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Nov 1 19:37:30 EDT 2016
On 11/01/2016 09:51 AM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1477988570 0
> # Tue Nov 01 08:22:50 2016 +0000
> # Node ID a14256ded0abbba1c85209f94826dddd96bf8d58
> # Parent f6c6598addaa1854f8556bacb732347256964e3e
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r a14256ded0ab
> adjustlinkrev: remove unnecessary parameters
>
> Since adjustlinkrev has "self", and is a method of a filectx object, it does
> not need path, filelog, filenode. They can be fetched from the "self"
> easily.
Yep, this signature is a bit strange. can you make some minimal
archeology to find out why we ended up with this?
Thanks
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -681,6 +681,5 @@ class basefilectx(object):
> # this file context was created from a revision with a known
> # descendant, we can (lazily) correct for linkrev aliases
> - return self._adjustlinkrev(self._path, self._filelog,
> - self._filenode, self._descendantrev)
> + return self._adjustlinkrev(self._descendantrev)
> else:
> return self._filelog.linkrev(self._filerev)
> @@ -809,6 +808,6 @@ class basefilectx(object):
> return True
>
> - def _adjustlinkrev(self, path, filelog, fnode, srcrev):
> - """return the first ancestor of <srcrev> introducing <fnode>
> + def _adjustlinkrev(self, srcrev):
> + """return the first ancestor of <srcrev> introducing this file node
>
> If the linkrev of the file revision does not point to an ancestor of
> @@ -816,8 +815,4 @@ class basefilectx(object):
> this file revision.
>
> - :repo: a localrepository object (used to access changelog and manifest)
> - :path: the file path
> - :fnode: the nodeid of the file revision
> - :filelog: the filelog of this path
> :srcrev: the changeset revision we search ancestors from
> """
> @@ -826,6 +821,5 @@ class basefilectx(object):
> mfl = repo.manifestlog
> # fetch the linkrev
> - fr = filelog.rev(fnode)
> - lkr = filelog.linkrev(fr)
> + lkr = self.linkrev()
> # hack to reuse ancestor computation when searching for renames
> memberanc = getattr(self, '_ancestrycontext', None)
> @@ -844,4 +838,6 @@ class basefilectx(object):
> return lkr
> # fallback to walk through the changelog
> + fnode = self._filenode
> + path = self._path
> iteranc = cl.ancestors(revs, lkr, inclusive=True)
> for a in iteranc:
> @@ -872,6 +868,5 @@ class basefilectx(object):
> if noctx or self.rev() == lkr:
> return self.linkrev()
> - return self._adjustlinkrev(self._path, self._filelog, self._filenode,
> - self.rev())
> + return self._adjustlinkrev(self.rev())
>
> def _parentfilectx(self, path, fileid, filelog):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list