~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

(gz) Never raise KnownFailure in tests,
 use knownFailure method instead (Martin [gz])

Show diffs side-by-side

added added

removed removed

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