~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branchbuilder.py

  • Committer: Robert Collins
  • Date: 2009-04-27 03:27:46 UTC
  • mto: This revision was merged to the branch mainline in revision 4304.
  • Revision ID: robertc@robertcollins.net-20090427032746-vqmcsfbsbvbm04sk
Fixup tests broken by cleaning up the layering.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
            reporter=reporter,
112
112
            **kwargs)
113
113
 
114
 
    def _move_branch_pointer(self, new_revision_id,
115
 
        allow_leftmost_as_ghost=False):
 
114
    def _move_branch_pointer(self, new_revision_id):
116
115
        """Point self._branch to a different revision id."""
117
116
        self._branch.lock_write()
118
117
        try:
119
118
            # We don't seem to have a simple set_last_revision(), so we
120
119
            # implement it here.
121
120
            cur_revno, cur_revision_id = self._branch.last_revision_info()
122
 
            try:
123
 
                g = self._branch.repository.get_graph()
124
 
                new_revno = g.find_distance_to_null(new_revision_id,
125
 
                    [(cur_revision_id, cur_revno)])
126
 
                self._branch.set_last_revision_info(new_revno, new_revision_id)
127
 
            except errors.GhostRevisionsHaveNoRevno:
128
 
                if not allow_leftmost_as_ghost:
129
 
                    raise
130
 
                new_revno = 1
 
121
            g = self._branch.repository.get_graph()
 
122
            new_revno = g.find_distance_to_null(new_revision_id,
 
123
                                                [(cur_revision_id, cur_revno)])
 
124
            self._branch.set_last_revision_info(new_revno, new_revision_id)
131
125
        finally:
132
126
            self._branch.unlock()
133
127
        if self._tree is not None:
161
155
        self._tree = None
162
156
 
163
157
    def build_snapshot(self, revision_id, parent_ids, actions,
164
 
        message=None, timestamp=None, allow_leftmost_as_ghost=False,
165
 
        committer=None, timezone=None):
 
158
                       message=None, timestamp=None):
166
159
        """Build a commit, shaped in a specific way.
167
160
 
168
161
        :param revision_id: The handle for the new commit, can be None
177
170
            commit message will be written.
178
171
        :param timestamp: If non-None, set the timestamp of the commit to this
179
172
            value.
180
 
        :param timezone: An optional timezone for timestamp.
181
 
        :param committer: An optional username to use for commit
182
 
        :param allow_leftmost_as_ghost: True if the leftmost parent should be
183
 
            permitted to be a ghost.
184
173
        :return: The revision_id of the new commit
185
174
        """
186
175
        if parent_ids is not None:
187
176
            base_id = parent_ids[0]
188
177
            if base_id != self._branch.last_revision():
189
 
                self._move_branch_pointer(base_id,
190
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
 
178
                self._move_branch_pointer(base_id)
191
179
 
192
180
        if self._tree is not None:
193
181
            tree = self._tree
196
184
        tree.lock_write()
197
185
        try:
198
186
            if parent_ids is not None:
199
 
                tree.set_parent_ids(parent_ids,
200
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
 
187
                tree.set_parent_ids(parent_ids)
201
188
            # Unfortunately, MemoryTree.add(directory) just creates an
202
189
            # inventory entry. And the only public function to create a
203
190
            # directory is MemoryTree.mkdir() which creates the directory, but
244
231
            for file_id, content in new_contents.iteritems():
245
232
                tree.put_file_bytes_non_atomic(file_id, content)
246
233
            return self._do_commit(tree, message=message, rev_id=revision_id,
247
 
                timestamp=timestamp, timezone=timezone, committer=committer)
 
234
                timestamp=timestamp)
248
235
        finally:
249
236
            tree.unlock()
250
237