67
72
def describe(self):
68
73
return "%s is locked" % self.lockable_thing
76
class _AncestryMismatch(Mismatch):
77
"""Ancestry matching mismatch."""
79
def __init__(self, tip_revision, got, expected):
80
self.tip_revision = tip_revision
82
self.expected = expected
85
return "mismatched ancestry for revision %r was %r, expected %r" % (
86
self.tip_revision, self.got, self.expected)
89
class MatchesAncestry(Matcher):
90
"""A matcher that checks the ancestry of a particular revision.
92
:ivar graph: Graph in which to check the ancestry
93
:ivar revision_id: Revision id of the revision
96
def __init__(self, repository, revision_id):
97
Matcher.__init__(self)
98
self.repository = repository
99
self.revision_id = revision_id
102
return ('MatchesAncestry(repository=%r, revision_id=%r)' % (
103
self.repository, self.revision_id))
105
def match(self, expected):
106
self.repository.lock_read()
108
graph = self.repository.get_graph()
109
got = [r for r, p in graph.iter_ancestry([self.revision_id])]
110
if _mod_revision.NULL_REVISION in got:
111
got.remove(_mod_revision.NULL_REVISION)
113
self.repository.unlock()
114
if sorted(got) != sorted(expected):
115
return _AncestryMismatch(self.revision_id, sorted(got), sorted(expected))