/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 bzrlib/tests/test_graph.py

  • Committer: Alexander Belchenko
  • Date: 2007-11-23 17:55:37 UTC
  • mfrom: (3018 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3020.
  • Revision ID: bialix@ukr.net-20071123175537-wke5mt9hxkh92xc2
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
        return self._real_parents_provider.get_parents(nodes)
146
146
 
147
147
 
148
 
class DictParentsProvider(object):
149
 
 
150
 
    def __init__(self, ancestry):
151
 
        self.ancestry = ancestry
152
 
 
153
 
    def __repr__(self):
154
 
        return 'DictParentsProvider(%r)' % self.ancestry
155
 
 
156
 
    def get_parents(self, revisions):
157
 
        return [self.ancestry.get(r, None) for r in revisions]
158
 
 
159
 
 
160
148
class TestGraph(TestCaseWithMemoryTransport):
161
149
 
162
150
    def make_graph(self, ancestors):
163
151
        tree = self.prepare_memory_tree('.')
164
152
        self.build_ancestry(tree, ancestors)
165
 
        tree.unlock()
 
153
        self.addCleanup(tree.unlock)
166
154
        return tree.branch.repository.get_graph()
167
155
 
168
156
    def prepare_memory_tree(self, location):
271
259
        """Ensure we do unique_lca using data from two repos"""
272
260
        mainline_tree = self.prepare_memory_tree('mainline')
273
261
        self.build_ancestry(mainline_tree, mainline)
274
 
        mainline_tree.unlock()
 
262
        self.addCleanup(mainline_tree.unlock)
275
263
 
276
264
        # This is cheating, because the revisions in the graph are actually
277
265
        # different revisions, despite having the same revision-id.
278
266
        feature_tree = self.prepare_memory_tree('feature')
279
267
        self.build_ancestry(feature_tree, feature_branch)
280
 
        feature_tree.unlock()
 
268
        self.addCleanup(feature_tree.unlock)
 
269
 
281
270
        graph = mainline_tree.branch.repository.get_graph(
282
271
            feature_tree.branch.repository)
283
272
        self.assertEqual('rev2b', graph.find_unique_lca('rev2a', 'rev3b'))
303
292
 
304
293
    def test_stacked_parents_provider(self):
305
294
 
306
 
        parents1 = DictParentsProvider({'rev2': ['rev3']})
307
 
        parents2 = DictParentsProvider({'rev1': ['rev4']})
 
295
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev3']})
 
296
        parents2 = _mod_graph.DictParentsProvider({'rev1': ['rev4']})
308
297
        stacked = _mod_graph._StackedParentsProvider([parents1, parents2])
309
298
        self.assertEqual([['rev4',], ['rev3']],
310
299
                         stacked.get_parents(['rev1', 'rev2']))