/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/bundle/serializer/v08.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import errors
23
23
from bzrlib.bundle.serializer import (BundleSerializer,
24
24
                                      BUNDLE_HEADER,
25
 
                                      format_highres_date,
26
 
                                      unpack_highres_date,
27
25
                                     )
28
26
from bzrlib.bundle.serializer import binary_diff
29
27
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
31
29
from bzrlib.osutils import pathjoin
32
30
from bzrlib.progress import DummyProgress
33
31
from bzrlib.revision import NULL_REVISION
34
 
from bzrlib.rio import RioWriter, read_stanzas
35
32
import bzrlib.ui
36
33
from bzrlib.testament import StrictTestament
 
34
from bzrlib.timestamp import (
 
35
    format_highres_date,
 
36
    unpack_highres_date,
 
37
)
37
38
from bzrlib.textfile import text_file
38
39
from bzrlib.trace import mutter
39
40
 
54
55
        else:
55
56
            self.properties = properties
56
57
 
 
58
    def add_utf8_property(self, name, value):
 
59
        """Add a property whose value is currently utf8 to the action."""
 
60
        self.properties.append((name, value.decode('utf8')))
 
61
 
57
62
    def add_property(self, name, value):
58
63
        """Add a property to the action"""
59
64
        self.properties.append((name, value))
138
143
        f.write(key.encode('utf-8'))
139
144
        if not value:
140
145
            f.write(':\n')
141
 
        elif isinstance(value, basestring):
 
146
        elif isinstance(value, str):
 
147
            f.write(': ')
 
148
            f.write(value)
 
149
            f.write('\n')
 
150
        elif isinstance(value, unicode):
142
151
            f.write(': ')
143
152
            f.write(value.encode('utf-8'))
144
153
            f.write('\n')
146
155
            f.write(':\n')
147
156
            for entry in value:
148
157
                f.write('#' + (' ' * (indent+2)))
149
 
                f.write(entry.encode('utf-8'))
 
158
                if isinstance(entry, str):
 
159
                    f.write(entry)
 
160
                else:
 
161
                    f.write(entry.encode('utf-8'))
150
162
                f.write('\n')
151
163
 
152
164
    def _write_revisions(self, pb):
156
168
        last_rev_id = None
157
169
        last_rev_tree = None
158
170
 
159
 
        i_max = len(self.revision_ids) 
 
171
        i_max = len(self.revision_ids)
160
172
        for i, rev_id in enumerate(self.revision_ids):
161
173
            pb.update("Generating revsion data", i, i_max)
162
174
            rev = self.source.get_revision(rev_id)
265
277
                          old_path, new_path):
266
278
            entry = new_tree.inventory[file_id]
267
279
            if entry.revision != default_revision_id:
268
 
                action.add_property('last-changed', entry.revision)
 
280
                action.add_utf8_property('last-changed', entry.revision)
269
281
            if meta_modified:
270
282
                action.add_bool_property('executable', entry.executable)
271
283
            if text_modified and kind == "symlink":
308
320
            if new_rev != old_rev:
309
321
                action = Action('modified', [ie.kind, 
310
322
                                             new_tree.id2path(ie.file_id)])
311
 
                action.add_property('last-changed', ie.revision)
 
323
                action.add_utf8_property('last-changed', ie.revision)
312
324
                action.write(self.to_file)
313
325
 
314
326
 
425
437
        revision_info = self.info.revisions[-1]
426
438
        if key in revision_info.__dict__:
427
439
            if getattr(revision_info, key) is None:
 
440
                if key in ('file_id', 'revision_id', 'base_id'):
 
441
                    value = value.encode('utf8')
 
442
                elif key in ('parent_ids'):
 
443
                    value = [v.encode('utf8') for v in value]
428
444
                setattr(revision_info, key, value)
429
445
            else:
430
446
                raise errors.MalformedHeader('Duplicated Key: %s' % key)
512
528
                self._next().next()
513
529
                break
514
530
 
515
 
 
516
531
class BundleInfo08(BundleInfo):
517
532
 
518
533
    def _update_tree(self, bundle_tree, revision_id):