~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2005-09-22 13:32:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050922133202-347cfd35d2941dd5
- simple weave-based annotate code (not complete)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
 
64
64
 
65
65
import os
66
 
import re
67
66
import sys
68
67
import time
69
68
import pdb
199
198
 
200
199
        assert isinstance(message, basestring), type(message)
201
200
        self.message = message
202
 
        self._escape_commit_message()
203
201
 
204
202
        self.branch.lock_write()
205
203
        try:
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)
246
244
 
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]'
255
 
        else:
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(
260
 
            char_pattern,
261
 
            lambda match: match.group(0).encode('unicode_escape'),
262
 
            self.message)
263
 
        if escape_count:
264
 
            note("replaced %d control characters in message", escape_count)
265
245
 
266
246
    def _record_ancestry(self):
267
247
        """Append merged revision ancestry to the ancestry file.
268
248
 
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)
319
299
        rev_tmp.seek(0)
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)
322
302
 
323
303
 
532
512
    assert r not in seen
533
513
    ancs.append(r)
534
514
    return ancs
 
515