~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: John Arbash Meinel
  • Date: 2006-11-10 15:38:16 UTC
  • mto: This revision was merged to the branch mainline in revision 2129.
  • Revision ID: john@arbash-meinel.com-20061110153816-46acf76fc86a512b
use try/finally to clean up a nested progress bar during weave fetching

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
 
    )
27
24
import bzrlib.errors
28
 
from bzrlib.bundle import apply_bundle
29
25
from bzrlib.errors import (TestamentMismatch, BzrError, 
30
26
                           MalformedHeader, MalformedPatches, NotABundle)
31
27
from bzrlib.inventory import (Inventory, InventoryEntry,
76
72
        if self.properties:
77
73
            for property in self.properties:
78
74
                key_end = property.find(': ')
79
 
                if key_end == -1:
80
 
                    assert property.endswith(':')
81
 
                    key = str(property[:-1])
82
 
                    value = ''
83
 
                else:
84
 
                    key = str(property[:key_end])
85
 
                    value = property[key_end+2:]
 
75
                assert key_end is not None
 
76
                key = property[:key_end].encode('utf-8')
 
77
                value = property[key_end+2:].encode('utf-8')
86
78
                rev.properties[key] = value
87
79
 
88
80
        return rev
109
101
        self.timestamp = None
110
102
        self.timezone = None
111
103
 
112
 
        # Have we checked the repository yet?
113
 
        self._validated_revisions_against_repo = False
114
 
 
115
104
    def __str__(self):
116
105
        return pprint.pformat(self.__dict__)
117
106
 
120
109
        split up, based on the assumptions that can be made
121
110
        when information is missing.
122
111
        """
123
 
        from bzrlib.timestamp import unpack_highres_date
 
112
        from bzrlib.bundle.serializer import unpack_highres_date
124
113
        # Put in all of the guessable information.
125
114
        if not self.timestamp and self.date:
126
115
            self.timestamp, self.timezone = unpack_highres_date(self.date)
179
168
        raise KeyError(revision_id)
180
169
 
181
170
    def revision_tree(self, repository, revision_id, base=None):
182
 
        revision_id = osutils.safe_revision_id(revision_id)
183
171
        revision = self.get_revision(revision_id)
184
172
        base = self.get_base(revision)
185
173
        assert base != revision_id
186
 
        if not self._validated_revisions_against_repo:
187
 
            self._validate_references_from_repository(repository)
 
174
        self._validate_references_from_repository(repository)
188
175
        revision_info = self.get_revision_info(revision_id)
189
176
        inventory_revision_id = revision_id
190
177
        bundle_tree = BundleTree(repository.revision_tree(base), 
266
253
            warning('Not all revision hashes could be validated.'
267
254
                    ' Unable validate %d hashes' % len(missing))
268
255
        mutter('Verified %d sha hashes for the bundle.' % count)
269
 
        self._validated_revisions_against_repo = True
270
256
 
271
257
    def _validate_inventory(self, inv, revision_id):
272
258
        """At this point we should have generated the BundleTree,
313
299
 
314
300
        def get_rev_id(last_changed, path, kind):
315
301
            if last_changed is not None:
316
 
                # last_changed will be a Unicode string because of how it was
317
 
                # read. Convert it back to utf8.
318
 
                changed_revision_id = osutils.safe_revision_id(last_changed,
319
 
                                                               warn=False)
 
302
                changed_revision_id = last_changed.decode('utf-8')
320
303
            else:
321
304
                changed_revision_id = revision_id
322
305
            bundle_tree.note_last_changed(path, changed_revision_id)
389
372
            if not info[1].startswith('file-id:'):
390
373
                raise BzrError('The file-id should follow the path for an add'
391
374
                        ': %r' % extra)
392
 
            # This will be Unicode because of how the stream is read. Turn it
393
 
            # back into a utf8 file_id
394
 
            file_id = osutils.safe_file_id(info[1][8:], warn=False)
 
375
            file_id = info[1][8:]
395
376
 
396
377
            bundle_tree.note_id(file_id, path, kind)
397
378
            # this will be overridden in extra_info if executable is specified.
442
423
                        ' (unrecognized action): %r' % action_line)
443
424
            valid_actions[action](kind, extra, lines)
444
425
 
445
 
    def install_revisions(self, target_repo):
446
 
        """Install revisions and return the target revision"""
447
 
        apply_bundle.install_bundle(target_repo, self)
448
 
        return self.target
449
 
 
450
426
 
451
427
class BundleTree(Tree):
452
428
    def __init__(self, base_tree, revision_id):