/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/matchers.py

Use new context stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
            self.repository, self.revision_id))
117
117
 
118
118
    def match(self, expected):
119
 
        self.repository.lock_read()
120
 
        try:
 
119
        with self.repository.lock_read():
121
120
            graph = self.repository.get_graph()
122
121
            got = [r for r, p in graph.iter_ancestry([self.revision_id])]
123
122
            if _mod_revision.NULL_REVISION in got:
124
123
                got.remove(_mod_revision.NULL_REVISION)
125
 
        finally:
126
 
            self.repository.unlock()
127
124
        if sorted(got) != sorted(expected):
128
125
            return _AncestryMismatch(self.revision_id, sorted(got),
129
126
                sorted(expected))
141
138
 
142
139
    def get_tree_layout(self, tree):
143
140
        """Get the (path, file_id) pairs for the current tree."""
144
 
        tree.lock_read()
145
 
        try:
 
141
        with tree.lock_read():
146
142
            for path, ie in tree.iter_entries_by_dir():
147
143
                if ie.parent_id is None:
148
144
                    yield (u"", ie.file_id)
149
145
                else:
150
146
                    yield (path+ie.kind_character(), ie.file_id)
151
 
        finally:
152
 
            tree.unlock()
153
147
 
154
148
    @staticmethod
155
149
    def _strip_unreferenced_directories(entries):
202
196
        return 'RevisionHistoryMatches(%r)' % self.expected
203
197
 
204
198
    def match(self, branch):
205
 
        branch.lock_read()
206
 
        try:
 
199
        with branch.lock_read():
207
200
            graph = branch.repository.get_graph()
208
201
            history = list(graph.iter_lefthand_ancestry(
209
202
                branch.last_revision(), [_mod_revision.NULL_REVISION]))
210
203
            history.reverse()
211
 
        finally:
212
 
            branch.unlock()
213
204
        return Equals(self.expected).match(history)
214
205
 
215
206