~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

  • Committer: Robert Collins
  • Date: 2007-04-27 03:02:05 UTC
  • mto: (2495.3.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2498.
  • Revision ID: robertc@robertcollins.net-20070427030205-ll4s3d57mf0dcaqk
Add BranchBuilder.build_commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Utility for create branches with particular contents."""
18
18
 
19
 
from bzrlib import bzrdir, errors
 
19
from bzrlib import bzrdir, errors, memorytree
20
20
 
21
21
 
22
22
class BranchBuilder(object):
34
34
        self._branch = bzrdir.BzrDir.create_branch_convenience(transport.base,
35
35
            format=bzrdir.format_registry.make_bzrdir('default'))
36
36
 
 
37
    def build_commit(self):
 
38
        """Build a commit on the branch."""
 
39
        tree = memorytree.MemoryTree.create_on_branch(self._branch)
 
40
        tree.lock_write()
 
41
        tree.add('')
 
42
        tree.commit('commit %d' % (self._branch.revno() + 1))
 
43
        tree.unlock()
 
44
 
37
45
    def get_branch(self):
38
46
        """Return the branch created by the builder."""
39
47
        return self._branch