~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-21 00:30:34 UTC
  • mto: This revision was merged to the branch mainline in revision 6154.
  • Revision ID: jelmer@samba.org-20110921003034-gmyos0opg0orl4bw
Fix typo.

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 __future__ import absolute_import
20
 
 
21
19
from bzrlib import (
22
 
    controldir,
 
20
    bzrdir,
23
21
    commit,
24
22
    errors,
25
23
    memorytree,
66
64
            If the path of the transport does not exist but its parent does
67
65
            it will be created.
68
66
        :param format: Either a BzrDirFormat, or the name of a format in the
69
 
            controldir format registry for the branch to be built.
 
67
            bzrdir format registry for the branch to be built.
70
68
        :param branch: An already constructed branch to use.  This param is
71
69
            mutually exclusive with the transport and format params.
72
70
        """
84
82
            if format is None:
85
83
                format = 'default'
86
84
            if isinstance(format, str):
87
 
                format = controldir.format_registry.make_bzrdir(format)
88
 
            self._branch = controldir.ControlDir.create_branch_convenience(
 
85
                format = bzrdir.format_registry.make_bzrdir(format)
 
86
            self._branch = bzrdir.BzrDir.create_branch_convenience(
89
87
                transport.base, format=format, force_new_tree=False)
90
88
        self._tree = None
91
89
 
92
 
    def build_commit(self, parent_ids=None, allow_leftmost_as_ghost=False,
93
 
                     **commit_kwargs):
 
90
    def build_commit(self, **commit_kwargs):
94
91
        """Build a commit on the branch.
95
92
 
96
93
        This makes a commit with no real file content for when you only want
99
96
        :param commit_kwargs: Arguments to pass through to commit, such as
100
97
             timestamp.
101
98
        """
102
 
        if parent_ids is not None:
103
 
            if len(parent_ids) == 0:
104
 
                base_id = revision.NULL_REVISION
105
 
            else:
106
 
                base_id = parent_ids[0]
107
 
            if base_id != self._branch.last_revision():
108
 
                self._move_branch_pointer(base_id,
109
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
110
99
        tree = memorytree.MemoryTree.create_on_branch(self._branch)
111
100
        tree.lock_write()
112
101
        try:
113
 
            if parent_ids is not None:
114
 
                tree.set_parent_ids(parent_ids,
115
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
116
102
            tree.add('')
117
103
            return self._do_commit(tree, **commit_kwargs)
118
104
        finally: