~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-22 20:40:34 UTC
  • mto: (3514.4.8 merge_lca_multi)
  • mto: This revision was merged to the branch mainline in revision 3590.
  • Revision ID: john@arbash-meinel.com-20080722204034-x54day968ipfmr1y
Add the ability to define a series of commits, which allows us to hold open the locks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
            format = bzrdir.format_registry.make_bzrdir(format)
52
52
        self._branch = bzrdir.BzrDir.create_branch_convenience(transport.base,
53
53
            format=format, force_new_tree=False)
 
54
        self._tree = None
54
55
 
55
56
    def build_commit(self):
56
57
        """Build a commit on the branch."""
75
76
            self._branch.set_last_revision_info(new_revno, new_revision_id)
76
77
        finally:
77
78
            self._branch.unlock()
 
79
        if self._tree is not None:
 
80
            # We are currently processing a series, but when switching branch
 
81
            # pointers, it is easiest to just create a new memory tree.
 
82
            # That way we are sure to have the right files-on-disk
 
83
            # We are cheating a little bit here, and locking the new tree
 
84
            # before the old tree is unlocked. But that way the branch stays
 
85
            # locked throughout.
 
86
            new_tree = memorytree.MemoryTree.create_on_branch(self._branch)
 
87
            new_tree.lock_write()
 
88
            self._tree.unlock()
 
89
            self._tree = new_tree
 
90
 
 
91
    def start_series(self):
 
92
        """We will be creating a series of commits.
 
93
 
 
94
        This allows us to hold open the locks while we are processing.
 
95
 
 
96
        Make sure to call 'finish_series' when you are done.
 
97
        """
 
98
        self._tree = memorytree.MemoryTree.create_on_branch(self._branch)
 
99
        self._tree.lock_write()
 
100
 
 
101
    def finish_series(self):
 
102
        """Call this after start_series to unlock the various objects."""
 
103
        self._tree.unlock()
 
104
        self._tree = None
78
105
 
79
106
    def build_snapshot(self, revision_id, parent_ids, actions,
80
107
                       message=None):
97
124
            if base_id != self._branch.last_revision():
98
125
                self._move_branch_pointer(base_id)
99
126
 
100
 
        tree = memorytree.MemoryTree.create_on_branch(self._branch)
 
127
        if self._tree is not None:
 
128
            tree = self._tree
 
129
        else:
 
130
            tree = memorytree.MemoryTree.create_on_branch(self._branch)
101
131
        tree.lock_write()
102
132
        try:
103
133
            if parent_ids is not None: