234
234
self.branch.unlock()
238
236
def _record_inventory(self):
239
237
"""Store the inventory for the new revision."""
240
238
inv_text = serializer_v5.write_inventory_to_string(self.new_inv)
241
239
self.inv_sha1 = sha_string(inv_text)
242
240
s = self.branch.control_weaves
243
241
s.add_text('inventory', self.rev_id,
244
split_lines(inv_text), self.parents)
242
split_lines(inv_text), self.present_parents)
246
244
def _escape_commit_message(self):
247
245
"""Replace xml-incompatible control characters."""
270
268
s = self.branch.control_weaves
271
269
w = s.get_weave_or_empty('ancestry')
272
270
lines = self._make_ancestry(w)
273
w.add(self.rev_id, self.parents, lines)
271
w.add(self.rev_id, self.present_parents, lines)
274
272
s.put_weave('ancestry', w)
277
274
def _make_ancestry(self, ancestry_weave):
278
275
"""Return merged ancestry lines.
280
277
The lines are revision-ids followed by newlines."""
281
parent_ancestries = [ancestry_weave.get(p) for p in self.parents]
278
parent_ancestries = [ancestry_weave.get(p) for p in self.present_parents]
282
279
new_lines = merge_ancestry_lines(self.rev_id, parent_ancestries)
283
280
mutter('merged ancestry of {%s}:\n%s', self.rev_id, ''.join(new_lines))
287
283
def _gather_parents(self):
284
"""Record the parents of a merge for merge detection."""
288
285
pending_merges = self.branch.pending_merges()
289
286
self.parents = []
290
287
self.parent_trees = []
288
self.present_parents = []
291
289
precursor_id = self.branch.last_revision()
293
291
self.parents.append(precursor_id)
294
self.parent_trees.append(self.basis_tree)
295
292
self.parents += pending_merges
296
self.parent_trees.extend(map(self.branch.revision_tree, pending_merges))
293
for revision in self.parents:
294
if self.branch.has_revision(revision):
295
self.parent_trees.append(self.branch.revision_tree(revision))
296
self.present_parents.append(revision)
299
298
def _check_parents_present(self):
300
299
for parent_id in self.parents:
301
300
mutter('commit parent revision {%s}', parent_id)
302
301
if not self.branch.has_revision(parent_id):
303
warning("can't commit a merge from an absent parent")
304
raise HistoryMissing(self.branch, 'revision', parent_id)
302
if parent_id == self.branch.last_revision():
303
warning("parent is pissing %r", parent_id)
304
raise HistoryMissing(self.branch, 'revision', parent_id)
306
mutter("commit will ghost revision %r", parent_id)
307
308
def _make_revision(self):
308
309
"""Record a new revision object for this commit."""