240
238
"""Store the inventory for the new revision."""
241
239
inv_text = serializer_v5.write_inventory_to_string(self.new_inv)
242
240
self.inv_sha1 = sha_string(inv_text)
243
s = self.branch.control_weaves
241
s = self.branch.control_weaves
244
242
s.add_text('inventory', self.rev_id,
245
split_lines(inv_text), self.parents)
243
split_lines(inv_text), self.parents)
247
def _escape_commit_message(self):
248
"""Replace xml-incompatible control characters."""
249
# Python strings can include characters that can't be
250
# represented in well-formed XML; escape characters that
251
# aren't listed in the XML specification
252
# (http://www.w3.org/TR/REC-xml/#NT-Char).
253
if isinstance(self.message, unicode):
254
char_pattern = u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]'
256
# Use a regular 'str' as pattern to avoid having re.subn
257
# return 'unicode' results.
258
char_pattern = '[^x09\x0A\x0D\x20-\xFF]'
259
self.message, escape_count = re.subn(
261
lambda match: match.group(0).encode('unicode_escape'),
264
note("replaced %d control characters in message", escape_count)
266
246
def _record_ancestry(self):
267
247
"""Append merged revision ancestry to the ancestry file.
269
249
This should be the merged ancestry of all parents, plus the
270
250
new revision id."""
271
s = self.branch.control_weaves
251
s = self.branch.control_weaves
272
252
w = s.get_weave_or_empty('ancestry')
273
253
lines = self._make_ancestry(w)
274
254
w.add(self.rev_id, self.parents, lines)
317
297
rev_tmp = StringIO()
318
298
serializer_v5.write_revision(self.rev, rev_tmp)
320
self.branch.revision_store.add(rev_tmp, self.rev_id, compressed=True)
300
self.branch.revision_store.add(rev_tmp, self.rev_id, compressed=False)
321
301
mutter('new revision_id is {%s}', self.rev_id)