On 11/02/2016 12:51 AM, Jun Wu wrote:
Excerpts from Pierre-Yves David's message of 2016-11-02 00:37:30 +0100:

On 11/01/2016 09:51 AM, Jun Wu wrote:
# HG changeset patch
# User Jun Wu <qu...@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

I believe the method was outside the filecontext object so it does not have
"self".

I would like something a bit more tangible than "I believe" for example the changeset that made it a method without cleaning the argument. It might contains data about why it did not cleaned them up.

Cheers,



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):
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


--
Pierre-Yves David
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to