~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/v08.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-22 14:45:05 UTC
  • mfrom: (2294.1.11 utf8_file_ids)
  • Revision ID: pqm@pqm.ubuntu.com-20070222144505-5f7551602cad9332
(John Arbash Meinel, r=robert) Update apis to expect UTF-8 file ids instead of Unicode

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        else:
55
55
            self.properties = properties
56
56
 
 
57
    def add_utf8_property(self, name, value):
 
58
        """Add a property whose value is currently utf8 to the action."""
 
59
        self.properties.append((name, value.decode('utf8')))
 
60
 
57
61
    def add_property(self, name, value):
58
62
        """Add a property to the action"""
59
63
        self.properties.append((name, value))
138
142
        f.write(key.encode('utf-8'))
139
143
        if not value:
140
144
            f.write(':\n')
141
 
        elif isinstance(value, basestring):
 
145
        elif isinstance(value, str):
 
146
            f.write(': ')
 
147
            f.write(value)
 
148
            f.write('\n')
 
149
        elif isinstance(value, unicode):
142
150
            f.write(': ')
143
151
            f.write(value.encode('utf-8'))
144
152
            f.write('\n')
146
154
            f.write(':\n')
147
155
            for entry in value:
148
156
                f.write('#' + (' ' * (indent+2)))
149
 
                f.write(entry.encode('utf-8'))
 
157
                if isinstance(entry, str):
 
158
                    f.write(entry)
 
159
                else:
 
160
                    f.write(entry.encode('utf-8'))
150
161
                f.write('\n')
151
162
 
152
163
    def _write_revisions(self, pb):
156
167
        last_rev_id = None
157
168
        last_rev_tree = None
158
169
 
159
 
        i_max = len(self.revision_ids) 
 
170
        i_max = len(self.revision_ids)
160
171
        for i, rev_id in enumerate(self.revision_ids):
161
172
            pb.update("Generating revsion data", i, i_max)
162
173
            rev = self.source.get_revision(rev_id)
265
276
                          old_path, new_path):
266
277
            entry = new_tree.inventory[file_id]
267
278
            if entry.revision != default_revision_id:
268
 
                action.add_property('last-changed', entry.revision)
 
279
                action.add_utf8_property('last-changed', entry.revision)
269
280
            if meta_modified:
270
281
                action.add_bool_property('executable', entry.executable)
271
282
            if text_modified and kind == "symlink":
308
319
            if new_rev != old_rev:
309
320
                action = Action('modified', [ie.kind, 
310
321
                                             new_tree.id2path(ie.file_id)])
311
 
                action.add_property('last-changed', ie.revision)
 
322
                action.add_utf8_property('last-changed', ie.revision)
312
323
                action.write(self.to_file)
313
324
 
314
325
 
425
436
        revision_info = self.info.revisions[-1]
426
437
        if key in revision_info.__dict__:
427
438
            if getattr(revision_info, key) is None:
 
439
                if key in ('file_id', 'revision_id', 'base_id'):
 
440
                    value = value.encode('utf8')
 
441
                elif key in ('parent_ids'):
 
442
                    value = [v.encode('utf8') for v in value]
428
443
                setattr(revision_info, key, value)
429
444
            else:
430
445
                raise errors.MalformedHeader('Duplicated Key: %s' % key)