~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/matchers.py

Merge bzr.dev and tree-file-ids-as-tuples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    'MatchesAncestry',
32
32
    'ContainsNoVfsCalls',
33
33
    'ReturnsUnlockable',
 
34
    'RevisionHistoryMatches',
34
35
    ]
35
36
 
36
37
from bzrlib import (
184
185
        return Equals(entries).match(actual)
185
186
 
186
187
 
 
188
class RevisionHistoryMatches(Matcher):
 
189
    """A matcher that checks if a branch has a specific revision history.
 
190
 
 
191
    :ivar history: Revision history, as list of revisions. Oldest first.
 
192
    """
 
193
 
 
194
    def __init__(self, history):
 
195
        Matcher.__init__(self)
 
196
        self.expected = history
 
197
 
 
198
    def __str__(self):
 
199
        return 'RevisionHistoryMatches(%r)' % self.expected
 
200
 
 
201
    def match(self, branch):
 
202
        branch.lock_read()
 
203
        try:
 
204
            graph = branch.repository.get_graph()
 
205
            history = list(graph.iter_lefthand_ancestry(
 
206
                branch.last_revision(), [_mod_revision.NULL_REVISION]))
 
207
            history.reverse()
 
208
        finally:
 
209
            branch.unlock()
 
210
        return Equals(self.expected).match(history)
 
211
 
 
212
 
187
213
class _NoVfsCallsMismatch(Mismatch):
188
214
    """Mismatch describing a list of HPSS calls which includes VFS requests."""
189
215