Submitter | Paul Morelle |
---|---|
Date | July 1, 2018, 6:38 a.m. |
Message ID | <494f5f95311e3b36a01c.1530427120@belenos.localdomain> |
Download | mbox | patch |
Permalink | /patch/32538/ |
State | Accepted |
Headers | show |
Comments
On Sun, 01 Jul 2018 08:38:40 +0200, Paul Morelle wrote: > # HG changeset patch > # User Boris Feld <boris.feld@octobus.net> > # Date 1529621811 -3600 > # Thu Jun 21 23:56:51 2018 +0100 > # Node ID 494f5f95311e3b36a01cca745e52f536c3977a5c > # Parent c6a8430582d584770c873a3b6234750482b9b65e > # EXP-Topic descendant > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 494f5f95311e > revlog: refactor out the rev-oriented part of commonancestorheads > > We plan to use this in a function taking revs as argument. Round trips to nodes > seem silly. > > diff -r c6a8430582d5 -r 494f5f95311e mercurial/revlog.py > --- a/mercurial/revlog.py Thu Jun 21 23:53:43 2018 +0100 > +++ b/mercurial/revlog.py Thu Jun 21 23:56:51 2018 +0100 > @@ -1390,11 +1390,16 @@ > def commonancestorsheads(self, a, b): > """calculate all the heads of the common ancestors of nodes a and b""" > a, b = self.rev(a), self.rev(b) > + ancs = self._commonancestorsheads(a, b) > + return pycompat.maplist(self.node, ancs) > + > + def _commonancestorsheads(self, *revs): > + """calculate all the heads of the common ancestors of revs""" > try: > - ancs = self.index.commonancestorsheads(a, b) > + ancs = self.index.commonancestorsheads(*revs) > except (AttributeError, OverflowError): # C implementation failed > - ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) > - return pycompat.maplist(self.node, ancs) > + ancs = ancestor.commonancestorsheads(self.parentrevs, *revs) > + return ancs Sean, maybe we can use this function to implement _commonancestorsheads() revset.
On Mon, Jul 2, 2018, 05:05 Yuya Nishihara <yuya@tcha.org> wrote: > On Sun, 01 Jul 2018 08:38:40 +0200, Paul Morelle wrote: > > # HG changeset patch > > # User Boris Feld <boris.feld@octobus.net> > > # Date 1529621811 -3600 > > # Thu Jun 21 23:56:51 2018 +0100 > > # Node ID 494f5f95311e3b36a01cca745e52f536c3977a5c > > # Parent c6a8430582d584770c873a3b6234750482b9b65e > > # EXP-Topic descendant > > # Available At https://bitbucket.org/octobus/mercurial-devel/ > > # hg pull https://bitbucket.org/octobus/mercurial-devel/ > -r 494f5f95311e > > revlog: refactor out the rev-oriented part of commonancestorheads > > > > We plan to use this in a function taking revs as argument. Round trips > to nodes > > seem silly. > > > > diff -r c6a8430582d5 -r 494f5f95311e mercurial/revlog.py > > --- a/mercurial/revlog.py Thu Jun 21 23:53:43 2018 +0100 > > +++ b/mercurial/revlog.py Thu Jun 21 23:56:51 2018 +0100 > > @@ -1390,11 +1390,16 @@ > > def commonancestorsheads(self, a, b): > > """calculate all the heads of the common ancestors of nodes a > and b""" > > a, b = self.rev(a), self.rev(b) > > + ancs = self._commonancestorsheads(a, b) > > + return pycompat.maplist(self.node, ancs) > > + > > + def _commonancestorsheads(self, *revs): > > + """calculate all the heads of the common ancestors of revs""" > > try: > > - ancs = self.index.commonancestorsheads(a, b) > > + ancs = self.index.commonancestorsheads(*revs) > > except (AttributeError, OverflowError): # C implementation > failed > > - ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) > > - return pycompat.maplist(self.node, ancs) > > + ancs = ancestor.commonancestorsheads(self.parentrevs, *revs) > > + return ancs > > Sean, maybe we can use this function to implement _commonancestorsheads() > revset. > I think rebase also wants to use this method, so it might get two external callers then.
Yuya Nishihara <yuya@tcha.org> writes: > On Sun, 01 Jul 2018 08:38:40 +0200, Paul Morelle wrote: >> # HG changeset patch >> # User Boris Feld <boris.feld@octobus.net> >> # Date 1529621811 -3600 >> # Thu Jun 21 23:56:51 2018 +0100 >> # Node ID 494f5f95311e3b36a01cca745e52f536c3977a5c >> # Parent c6a8430582d584770c873a3b6234750482b9b65e >> # EXP-Topic descendant >> # Available At https://bitbucket.org/octobus/mercurial-devel/ >> # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 494f5f95311e >> revlog: refactor out the rev-oriented part of commonancestorheads >> >> We plan to use this in a function taking revs as argument. Round trips to nodes >> seem silly. >> >> diff -r c6a8430582d5 -r 494f5f95311e mercurial/revlog.py >> --- a/mercurial/revlog.py Thu Jun 21 23:53:43 2018 +0100 >> +++ b/mercurial/revlog.py Thu Jun 21 23:56:51 2018 +0100 >> @@ -1390,11 +1390,16 @@ >> def commonancestorsheads(self, a, b): >> """calculate all the heads of the common ancestors of nodes a and b""" >> a, b = self.rev(a), self.rev(b) >> + ancs = self._commonancestorsheads(a, b) >> + return pycompat.maplist(self.node, ancs) >> + >> + def _commonancestorsheads(self, *revs): >> + """calculate all the heads of the common ancestors of revs""" >> try: >> - ancs = self.index.commonancestorsheads(a, b) >> + ancs = self.index.commonancestorsheads(*revs) >> except (AttributeError, OverflowError): # C implementation failed >> - ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) >> - return pycompat.maplist(self.node, ancs) >> + ancs = ancestor.commonancestorsheads(self.parentrevs, *revs) >> + return ancs > > Sean, maybe we can use this function to implement _commonancestorsheads() > revset. Ah, yes, that's possible now; great!
Patch
diff -r c6a8430582d5 -r 494f5f95311e mercurial/revlog.py --- a/mercurial/revlog.py Thu Jun 21 23:53:43 2018 +0100 +++ b/mercurial/revlog.py Thu Jun 21 23:56:51 2018 +0100 @@ -1390,11 +1390,16 @@ def commonancestorsheads(self, a, b): """calculate all the heads of the common ancestors of nodes a and b""" a, b = self.rev(a), self.rev(b) + ancs = self._commonancestorsheads(a, b) + return pycompat.maplist(self.node, ancs) + + def _commonancestorsheads(self, *revs): + """calculate all the heads of the common ancestors of revs""" try: - ancs = self.index.commonancestorsheads(a, b) + ancs = self.index.commonancestorsheads(*revs) except (AttributeError, OverflowError): # C implementation failed - ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) - return pycompat.maplist(self.node, ancs) + ancs = ancestor.commonancestorsheads(self.parentrevs, *revs) + return ancs def isancestor(self, a, b): """return True if node a is an ancestor of node b