/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 bzrlib/commit.py

[merge] up-to-date against bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
from binascii import hexlify
73
73
from cStringIO import StringIO
74
74
 
 
75
from bzrlib.atomicfile import AtomicFile
75
76
from bzrlib.osutils import (local_time_offset,
76
77
                            rand_bytes, compact_date,
77
78
                            kind_marker, is_inside_any, quotefn,
78
79
                            sha_string, sha_strings, sha_file, isdir, isfile,
79
80
                            split_lines)
80
 
from bzrlib.branch import gen_file_id
81
81
import bzrlib.config
82
82
from bzrlib.errors import (BzrError, PointlessCommit,
83
83
                           HistoryMissing,
92
92
from bzrlib.inventory import Inventory, ROOT_ID
93
93
from bzrlib.weave import Weave
94
94
from bzrlib.weavefile import read_weave, write_weave_v5
95
 
from bzrlib.atomicfile import AtomicFile
 
95
from bzrlib.workingtree import WorkingTree
96
96
 
97
97
 
98
98
def commit(*args, **kwargs):
124
124
    def missing(self, path):
125
125
        pass
126
126
 
 
127
 
127
128
class ReportCommitToLog(NullCommitReporter):
128
129
 
129
130
    def snapshot_change(self, change, path):
141
142
    def missing(self, path):
142
143
        note('missing %s', path)
143
144
 
 
145
 
144
146
class Commit(object):
145
147
    """Task of committing a new revision.
146
148
 
207
209
        self.revprops = {'branch-nick': branch.nick}
208
210
        if revprops:
209
211
            self.revprops.update(revprops)
 
212
        self.work_tree = WorkingTree(branch.base, branch)
210
213
 
211
214
        if strict:
212
215
            # raise an exception as soon as we find a single unknown.
213
 
            for unknown in branch.unknowns():
 
216
            for unknown in self.work_tree.unknowns():
214
217
                raise StrictCommitFailed()
215
218
 
216
219
        if timestamp is None:
237
240
        else:
238
241
            self.timezone = int(timezone)
239
242
 
240
 
        assert isinstance(message, basestring), type(message)
 
243
        if isinstance(message, str):
 
244
            message = message.decode(bzrlib.user_encoding)
 
245
        assert isinstance(message, unicode), type(message)
241
246
        self.message = message
242
247
        self._escape_commit_message()
243
248
 
244
249
        self.branch.lock_write()
245
250
        try:
246
 
            self.work_tree = self.branch.working_tree()
247
251
            self.work_inv = self.work_tree.inventory
248
252
            self.basis_tree = self.branch.basis_tree()
249
253
            self.basis_inv = self.basis_tree.inventory
297
301
        # represented in well-formed XML; escape characters that
298
302
        # aren't listed in the XML specification
299
303
        # (http://www.w3.org/TR/REC-xml/#NT-Char).
300
 
        if isinstance(self.message, unicode):
301
 
            char_pattern = u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]'
302
 
        else:
303
 
            # Use a regular 'str' as pattern to avoid having re.subn
304
 
            # return 'unicode' results.
305
 
            char_pattern = '[^x09\x0A\x0D\x20-\xFF]'
306
304
        self.message, escape_count = re.subn(
307
 
            char_pattern,
 
305
            u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
308
306
            lambda match: match.group(0).encode('unicode_escape'),
309
307
            self.message)
310
308
        if escape_count: