From patchwork Thu Jul 12 13:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D3931: revlog: introduce a isancestorrev() and use it in rebase From: phabricator X-Patchwork-Id: 32811 Message-Id: <021a6240ed0a2f2c1aebacb3d4da980e@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Thu, 12 Jul 2018 13:12:12 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHGa06b2b032557: revlog: introduce a isancestorrev() and use it in rebase (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3931?vs=9561&id=9567 REVISION DETAIL https://phab.mercurial-scm.org/D3931 AFFECTED FILES hgext/rebase.py mercurial/revlog.py CHANGE DETAILS To: martinvonz, indygreg, #hg-reviewers Cc: lothiraldan, mercurial-devel diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1679,6 +1679,12 @@ A revision is considered an ancestor of itself.""" a, b = self.rev(a), self.rev(b) + return self.isancestorrev(a, b) + + def isancestorrev(self, a, b): + """return True if revision a is an ancestor of revision b + + A revision is considered an ancestor of itself.""" return self.isdescendantrev(b, a) def ancestor(self, a, b): diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -1291,13 +1291,7 @@ # use unfiltered changelog since successorrevs may return filtered nodes assert repo.filtername is None cl = repo.changelog - def isancestor(a, b): - # take revision numbers instead of nodes - if a == b: - return True - elif a > b: - return False - return cl.isancestor(cl.node(a), cl.node(b)) + isancestor = cl.isancestorrev dest = destmap[rev] oldps = repo.changelog.parentrevs(rev) # old parents