~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-18 15:28:32 UTC
  • mto: This revision was merged to the branch mainline in revision 6226.
  • Revision ID: jelmer@samba.org-20111018152832-tbakonkap90w9al5
Add parent_ids argument to BranchBuilder.build_commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
                transport.base, format=format, force_new_tree=False)
88
88
        self._tree = None
89
89
 
90
 
    def build_commit(self, **commit_kwargs):
 
90
    def build_commit(self, parent_ids=None, allow_leftmost_as_ghost=False,
 
91
                     **commit_kwargs):
91
92
        """Build a commit on the branch.
92
93
 
93
94
        This makes a commit with no real file content for when you only want
96
97
        :param commit_kwargs: Arguments to pass through to commit, such as
97
98
             timestamp.
98
99
        """
 
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)
99
108
        tree = memorytree.MemoryTree.create_on_branch(self._branch)
100
109
        tree.lock_write()
101
110
        try:
 
111
            if parent_ids is not None:
 
112
                tree.set_parent_ids(parent_ids,
 
113
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
102
114
            tree.add('')
103
115
            return self._do_commit(tree, **commit_kwargs)
104
116
        finally: