# HG changeset patch # User Gregory Szorc # Date 1534535332 0 # Node ID 8de52699584449d9a2da4adf481ef40afb55d635 # Parent 1c3184d7e882676e6fe07cdf63887e6fde19f0bc dagutil: use revlog.parentrevs() for resolving parent revisions And remove parents() since it is no longer used. revlog.parentrevs() is almost the same as parents(). The main difference is that parentrevs() can return nullrev. dagop.headrevs() already handles nullrev. We add an inline check for nullrev in the other call site to account for the difference. .. api:: parents() removed from dagutil classes Use parentrevs() on the storage object instead. Differential Revision: https://phab.mercurial-scm.org/D4328 diff -r 1c3184d7e882 -r 8de526995844 mercurial/dagutil.py --- a/mercurial/dagutil.py Fri Aug 17 19:45:13 2018 +0000 +++ b/mercurial/dagutil.py Fri Aug 17 19:48:52 2018 +0000 @@ -20,21 +20,6 @@ def __init__(self, revlog): self._revlog = revlog - def parents(self, ix): - rlog = self._revlog - idx = rlog.index - revdata = idx[ix] - prev = revdata[5] - if prev != nullrev: - prev2 = revdata[6] - if prev2 == nullrev: - return [prev] - return [prev, prev2] - prev2 = revdata[6] - if prev2 != nullrev: - return [prev2] - return [] - def linearize(self, ixs): '''linearize and topologically sort a list of revisions @@ -45,7 +30,7 @@ parent, then adding the rev itself to the output list. ''' sorted = [] - visit = list(dagop.headrevs(ixs, self.parents)) + visit = list(dagop.headrevs(ixs, self._revlog.parentrevs)) visit.sort(reverse=True) finished = set() @@ -58,7 +43,7 @@ finished.add(cur) else: visit.append(-cur - 1) - visit += [p for p in self.parents(cur) - if p in ixs and p not in finished] + visit += [p for p in self._revlog.parentrevs(cur) + if p != nullrev and p in ixs and p not in finished] assert len(sorted) == len(ixs) return sorted