/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/benchmarks/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-07 21:59:49 UTC
  • mto: (1908.4.6 commit-perf)
  • mto: This revision was merged to the branch mainline in revision 1923.
  • Revision ID: john@arbash-meinel.com-20060807215949-9dd9639b34e79417
Allow the many_merged and many_commit trees to be cached

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
                         link_working=hardlink_working)
228
228
        return workingtree.WorkingTree.open(root)
229
229
 
230
 
    def make_many_commit_tree(self, directory_name='.'):
231
 
        """Create a tree with many commits.
232
 
        
233
 
        No files change are included.
234
 
        """
235
 
        tree = bzrdir.BzrDir.create_standalone_workingtree(directory_name)
 
230
    def _cache_many_commit_tree(self):
 
231
        cache_dir, is_cached = self.get_cache_dir('many_commit_tree')
 
232
        if is_cached:
 
233
            return cache_dir
 
234
 
 
235
        tree = bzrdir.BzrDir.create_standalone_workingtree(cache_dir)
236
236
        tree.lock_write()
237
237
        tree.branch.lock_write()
238
238
        tree.branch.repository.lock_write()
247
247
                    tree.branch.unlock()
248
248
            finally:
249
249
                tree.unlock()
250
 
        return tree
251
 
 
252
 
    def make_heavily_merged_tree(self, directory_name='.'):
253
 
        """Create a tree in which almost every commit is a merge.
254
 
       
255
 
        No files change are included.  This produces two trees, 
256
 
        one of which is returned.  Except for the first commit, every
257
 
        commit in its revision-history is a merge another commit in the other
258
 
        tree.
 
250
 
 
251
        return cache_dir
 
252
 
 
253
    def make_many_commit_tree(self, directory_name='.',
 
254
                              hardlink=False):
 
255
        """Create a tree with many commits.
 
256
        
 
257
        No file changes are included. Not hardlinking the working tree, 
 
258
        because there are no working tree files.
259
259
        """
260
 
        tree = bzrdir.BzrDir.create_standalone_workingtree(directory_name)
 
260
        cache_dir = self._cache_many_commit_tree()
 
261
        self._clone_tree(cache_dir, directory_name,
 
262
                         link_bzr=hardlink)
 
263
        return workingtree.WorkingTree.open(directory_name)
 
264
 
 
265
    def _cache_heavily_merged_tree(self):
 
266
        cache_dir, is_cached = self.get_cache_dir('heavily_merged_tree')
 
267
        if is_cached:
 
268
            return cache_dir
 
269
 
 
270
        os.mkdir(cache_dir)
 
271
        tree = bzrdir.BzrDir.create_standalone_workingtree(
 
272
                cache_dir + '/tree1')
261
273
        tree.lock_write()
262
274
        try:
263
 
            tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
 
275
            tree2 = tree.bzrdir.sprout(cache_dir + '/tree2').open_workingtree()
264
276
            tree2.lock_write()
265
277
            try:
266
278
                for i in xrange(250):
272
284
                    tree.set_pending_merges([revision_id])
273
285
                tree.set_pending_merges([])
274
286
            finally:
275
 
                tree.unlock()
 
287
                tree2.unlock()
276
288
        finally:
277
 
            tree2.unlock()
278
 
        return tree
 
289
            tree.unlock()
 
290
        return cache_dir
 
291
 
 
292
    def make_heavily_merged_tree(self, directory_name='.',
 
293
                                 hardlink=False):
 
294
        """Create a tree in which almost every commit is a merge.
 
295
       
 
296
        No file changes are included.  This produces two trees, 
 
297
        one of which is returned.  Except for the first commit, every
 
298
        commit in its revision-history is a merge another commit in the other
 
299
        tree.  Not hardlinking the working tree, because there are no working 
 
300
        tree files.
 
301
        """
 
302
        cache_dir = self._cache_heavily_merged_tree()
 
303
        tree_dir = cache_dir + '/tree1'
 
304
        self._clone_tree(tree_dir, directory_name,
 
305
                         link_bzr=hardlink)
 
306
        return workingtree.WorkingTree.open(directory_name)
279
307
 
280
308
 
281
309
def test_suite():