/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/branchbuilder.py

  • Committer: Martin
  • Date: 2018-11-16 19:09:31 UTC
  • mfrom: (7175 work)
  • mto: This revision was merged to the branch mainline in revision 7177.
  • Revision ID: gzlist@googlemail.com-20181116190931-rmh7pk2an1zuecby
Merge trunk to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
            else:
110
110
                base_id = parent_ids[0]
111
111
            if base_id != self._branch.last_revision():
112
 
                self._move_branch_pointer(base_id,
113
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
 
112
                self._move_branch_pointer(
 
113
                    base_id, allow_leftmost_as_ghost=allow_leftmost_as_ghost)
114
114
        tree = self._branch.create_memorytree()
115
115
        with tree.lock_write():
116
116
            if parent_ids is not None:
117
 
                tree.set_parent_ids(parent_ids,
 
117
                tree.set_parent_ids(
 
118
                    parent_ids,
118
119
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
119
120
            tree.add('')
120
121
            return self._do_commit(tree, **commit_kwargs)
124
125
        if message is None and message_callback is None:
125
126
            message = u'commit %d' % (self._branch.revno() + 1,)
126
127
        return tree.commit(message, message_callback=message_callback,
127
 
            reporter=reporter,
128
 
            **kwargs)
 
128
                           reporter=reporter, **kwargs)
129
129
 
130
130
    def _move_branch_pointer(self, new_revision_id,
131
 
        allow_leftmost_as_ghost=False):
 
131
                             allow_leftmost_as_ghost=False):
132
132
        """Point self._branch to a different revision id."""
133
133
        with self._branch.lock_write():
134
134
            # We don't seem to have a simple set_last_revision(), so we
136
136
            cur_revno, cur_revision_id = self._branch.last_revision_info()
137
137
            try:
138
138
                g = self._branch.repository.get_graph()
139
 
                new_revno = g.find_distance_to_null(new_revision_id,
140
 
                    [(cur_revision_id, cur_revno)])
 
139
                new_revno = g.find_distance_to_null(
 
140
                    new_revision_id, [(cur_revision_id, cur_revno)])
141
141
                self._branch.set_last_revision_info(new_revno, new_revision_id)
142
142
            except errors.GhostRevisionsHaveNoRevno:
143
143
                if not allow_leftmost_as_ghost:
174
174
        self._tree = None
175
175
 
176
176
    def build_snapshot(self, parent_ids, actions, message=None, timestamp=None,
177
 
            allow_leftmost_as_ghost=False, committer=None, timezone=None,
178
 
            message_callback=None, revision_id=None):
 
177
                       allow_leftmost_as_ghost=False, committer=None,
 
178
                       timezone=None, message_callback=None, revision_id=None):
179
179
        """Build a commit, shaped in a specific way.
180
180
 
181
181
        Most of the actions are self-explanatory.  'flush' is special action to
210
210
            else:
211
211
                base_id = parent_ids[0]
212
212
            if base_id != self._branch.last_revision():
213
 
                self._move_branch_pointer(base_id,
214
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
 
213
                self._move_branch_pointer(
 
214
                    base_id, allow_leftmost_as_ghost=allow_leftmost_as_ghost)
215
215
 
216
216
        if self._tree is not None:
217
217
            tree = self._tree
219
219
            tree = self._branch.create_memorytree()
220
220
        with tree.lock_write():
221
221
            if parent_ids is not None:
222
 
                tree.set_parent_ids(parent_ids,
 
222
                tree.set_parent_ids(
 
223
                    parent_ids,
223
224
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
224
225
            # Unfortunately, MemoryTree.add(directory) just creates an
225
226
            # inventory entry. And the only public function to create a
251
252
                else:
252
253
                    raise ValueError('Unknown build action: "%s"' % (action,))
253
254
            self._flush_pending(tree, pending)
254
 
            return self._do_commit(tree, message=message, rev_id=revision_id,
 
255
            return self._do_commit(
 
256
                tree, message=message, rev_id=revision_id,
255
257
                timestamp=timestamp, timezone=timezone, committer=committer,
256
258
                message_callback=message_callback)
257
259
 
258
260
    def _flush_pending(self, tree, pending):
259
 
        """Flush the pending actions in 'pending', i.e. apply them to 'tree'."""
 
261
        """Flush the pending actions in 'pending', i.e. apply them to tree."""
260
262
        for path, file_id in pending.to_add_directories:
261
263
            if path == '':
262
 
                if tree.has_filename(path) and path in pending.to_unversion_paths:
 
264
                if tree.has_filename(path) \
 
265
                        and path in pending.to_unversion_paths:
263
266
                    # We're overwriting this path, no need to unversion
264
267
                    pending.to_unversion_paths.discard(path)
265
268
                # Special case, because the path already exists
270
273
            tree.rename_one(from_relpath, to_relpath)
271
274
        if pending.to_unversion_paths:
272
275
            tree.unversion(pending.to_unversion_paths)
273
 
        tree.add(pending.to_add_files, pending.to_add_file_ids, pending.to_add_kinds)
 
276
        tree.add(pending.to_add_files, pending.to_add_file_ids,
 
277
                 pending.to_add_kinds)
274
278
        for path, content in viewitems(pending.new_contents):
275
279
            tree.put_file_bytes_non_atomic(path, content)
276
280
 
294
298
        self.new_contents = {}
295
299
        self.to_unversion_paths = set()
296
300
        self.to_rename = []
297