~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

[patch] 'bzr init DIR' (John)

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
        self.rev_id = rev_id
205
205
        self.specific_files = specific_files
206
206
        self.allow_pointless = allow_pointless
207
 
        self.revprops = {'branch-nick': branch.nick}
208
 
        if revprops:
209
 
            self.revprops.update(revprops)
 
207
        self.revprops = revprops
210
208
 
211
209
        if strict:
212
210
            # raise an exception as soon as we find a single unknown.
237
235
        else:
238
236
            self.timezone = int(timezone)
239
237
 
240
 
        if isinstance(message, str):
241
 
            message = message.decode(bzrlib.user_encoding)
242
 
        assert isinstance(message, unicode), type(message)
 
238
        assert isinstance(message, basestring), type(message)
243
239
        self.message = message
244
240
        self._escape_commit_message()
245
241
 
271
267
            self._record_inventory()
272
268
            self._make_revision()
273
269
            self.branch.append_revision(self.rev_id)
274
 
            self.work_tree.set_pending_merges([])
 
270
            self.branch.set_pending_merges([])
275
271
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
276
272
            if self.config.post_commit() is not None:
277
273
                hooks = self.config.post_commit().split(' ')
299
295
        # represented in well-formed XML; escape characters that
300
296
        # aren't listed in the XML specification
301
297
        # (http://www.w3.org/TR/REC-xml/#NT-Char).
 
298
        if isinstance(self.message, unicode):
 
299
            char_pattern = u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]'
 
300
        else:
 
301
            # Use a regular 'str' as pattern to avoid having re.subn
 
302
            # return 'unicode' results.
 
303
            char_pattern = '[^x09\x0A\x0D\x20-\xFF]'
302
304
        self.message, escape_count = re.subn(
303
 
            u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
 
305
            char_pattern,
304
306
            lambda match: match.group(0).encode('unicode_escape'),
305
307
            self.message)
306
308
        if escape_count:
308
310
 
309
311
    def _gather_parents(self):
310
312
        """Record the parents of a merge for merge detection."""
311
 
        pending_merges = self.work_tree.pending_merges()
 
313
        pending_merges = self.branch.pending_merges()
312
314
        self.parents = []
313
315
        self.parent_invs = []
314
316
        self.present_parents = []
374
376
            deleted_ids.sort(reverse=True)
375
377
            for path, file_id in deleted_ids:
376
378
                del self.work_inv[file_id]
377
 
            self.work_tree._write_inventory(self.work_inv)
 
379
            self.branch._write_inventory(self.work_inv)
378
380
 
379
381
    def _store_snapshot(self):
380
382
        """Pass over inventory and record a snapshot.