~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
import pprint
23
23
 
 
24
from bzrlib import (
 
25
    osutils,
 
26
    )
24
27
import bzrlib.errors
 
28
from bzrlib.bundle import apply_bundle
25
29
from bzrlib.errors import (TestamentMismatch, BzrError, 
26
30
                           MalformedHeader, MalformedPatches, NotABundle)
27
31
from bzrlib.inventory import (Inventory, InventoryEntry,
109
113
        split up, based on the assumptions that can be made
110
114
        when information is missing.
111
115
        """
112
 
        from bzrlib.bundle.serializer import unpack_highres_date
 
116
        from bzrlib.timestamp import unpack_highres_date
113
117
        # Put in all of the guessable information.
114
118
        if not self.timestamp and self.date:
115
119
            self.timestamp, self.timezone = unpack_highres_date(self.date)
168
172
        raise KeyError(revision_id)
169
173
 
170
174
    def revision_tree(self, repository, revision_id, base=None):
 
175
        revision_id = osutils.safe_revision_id(revision_id)
171
176
        revision = self.get_revision(revision_id)
172
177
        base = self.get_base(revision)
173
178
        assert base != revision_id
299
304
 
300
305
        def get_rev_id(last_changed, path, kind):
301
306
            if last_changed is not None:
302
 
                changed_revision_id = last_changed.decode('utf-8')
 
307
                # last_changed will be a Unicode string because of how it was
 
308
                # read. Convert it back to utf8.
 
309
                changed_revision_id = osutils.safe_revision_id(last_changed,
 
310
                                                               warn=False)
303
311
            else:
304
312
                changed_revision_id = revision_id
305
313
            bundle_tree.note_last_changed(path, changed_revision_id)
372
380
            if not info[1].startswith('file-id:'):
373
381
                raise BzrError('The file-id should follow the path for an add'
374
382
                        ': %r' % extra)
375
 
            file_id = info[1][8:]
 
383
            # This will be Unicode because of how the stream is read. Turn it
 
384
            # back into a utf8 file_id
 
385
            file_id = osutils.safe_file_id(info[1][8:], warn=False)
376
386
 
377
387
            bundle_tree.note_id(file_id, path, kind)
378
388
            # this will be overridden in extra_info if executable is specified.
423
433
                        ' (unrecognized action): %r' % action_line)
424
434
            valid_actions[action](kind, extra, lines)
425
435
 
 
436
    def install_revisions(self, target_repo):
 
437
        """Install revisions and return the target revision"""
 
438
        apply_bundle.install_bundle(target_repo, self)
 
439
        return self.target
 
440
 
426
441
 
427
442
class BundleTree(Tree):
428
443
    def __init__(self, base_tree, revision_id):