Commit dc85ddd9 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

graph: fix revision comparison when nodes == {wctx} (fixes #5542, #5531, #5507)

branch : stable
parent 0251dab9d547
......@@ -983,14 +983,26 @@ class Graph(object):
def isfilled(self):
return self.grapher is None
def _bottom_rev(self):
"""Returns the known lowest revision number
If nodes == {} or {wctx}, the lowest revision is not yet known, so
returns None.
if not self.nodes:
return None
return self.nodes[-1].rev
def index(self, rev):
if len(self) == 0:
brev = self._bottom_rev()
if brev is None:
# graph is empty, let's build some nodes. nodes for unapplied
# patches are built at once because they don't have comparable
# revision numbers, which makes build_nodes() go wrong.
self.build_nodes(10, len(self.repo) - 1)
if isinstance(rev, int) and len(self) > 0 and rev < self.nodes[-1].rev:
self.build_nodes(self.nodes[-1].rev - rev)
brev = self._bottom_rev()
if isinstance(rev, int) and brev is not None and rev < brev:
self.build_nodes(brev - rev)
return self.nodes.index(self.nodesdict[rev])
except KeyError:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment