/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/bundle_data.py

  • Committer: Marius Kruger
  • Date: 2007-08-12 08:15:15 UTC
  • mfrom: (2695 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2979.
  • Revision ID: amanic@gmail.com-20070812081515-vgekipfhohcuj6rn
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from bzrlib import (
25
25
    osutils,
 
26
    timestamp,
26
27
    )
27
28
import bzrlib.errors
28
29
from bzrlib.bundle import apply_bundle
76
77
        if self.properties:
77
78
            for property in self.properties:
78
79
                key_end = property.find(': ')
79
 
                assert key_end is not None
80
 
                key = property[:key_end].encode('utf-8')
81
 
                value = property[key_end+2:].encode('utf-8')
 
80
                if key_end == -1:
 
81
                    assert property.endswith(':')
 
82
                    key = str(property[:-1])
 
83
                    value = ''
 
84
                else:
 
85
                    key = str(property[:key_end])
 
86
                    value = property[key_end+2:]
82
87
                rev.properties[key] = value
83
88
 
84
89
        return rev
85
90
 
 
91
    @staticmethod
 
92
    def from_revision(revision):
 
93
        revision_info = RevisionInfo(revision.revision_id)
 
94
        date = timestamp.format_highres_date(revision.timestamp,
 
95
                                             revision.timezone)
 
96
        revision_info.date = date
 
97
        revision_info.timezone = revision.timezone
 
98
        revision_info.timestamp = revision.timestamp
 
99
        revision_info.message = revision.message.split('\n')
 
100
        revision_info.properties = [': '.join(p) for p in
 
101
                                    revision.properties.iteritems()]
 
102
        return revision_info
 
103
 
86
104
 
87
105
class BundleInfo(object):
88
106
    """This contains the meta information. Stuff that allows you to
89
107
    recreate the revision or inventory XML.
90
108
    """
91
 
    def __init__(self):
 
109
    def __init__(self, bundle_format=None):
 
110
        self.bundle_format = None
92
111
        self.committer = None
93
112
        self.date = None
94
113
        self.message = None
105
124
        self.timestamp = None
106
125
        self.timezone = None
107
126
 
 
127
        # Have we checked the repository yet?
 
128
        self._validated_revisions_against_repo = False
 
129
 
108
130
    def __str__(self):
109
131
        return pprint.pformat(self.__dict__)
110
132
 
176
198
        revision = self.get_revision(revision_id)
177
199
        base = self.get_base(revision)
178
200
        assert base != revision_id
179
 
        self._validate_references_from_repository(repository)
 
201
        if not self._validated_revisions_against_repo:
 
202
            self._validate_references_from_repository(repository)
180
203
        revision_info = self.get_revision_info(revision_id)
181
204
        inventory_revision_id = revision_id
182
205
        bundle_tree = BundleTree(repository.revision_tree(base), 
258
281
            warning('Not all revision hashes could be validated.'
259
282
                    ' Unable validate %d hashes' % len(missing))
260
283
        mutter('Verified %d sha hashes for the bundle.' % count)
 
284
        self._validated_revisions_against_repo = True
261
285
 
262
286
    def _validate_inventory(self, inv, revision_id):
263
287
        """At this point we should have generated the BundleTree,
438
462
        apply_bundle.install_bundle(target_repo, self)
439
463
        return self.target
440
464
 
 
465
    def get_merge_request(self, target_repo):
 
466
        """Provide data for performing a merge
 
467
 
 
468
        Returns suggested base, suggested target, and patch verification status
 
469
        """
 
470
        return None, self.target, 'inapplicable'
 
471
 
441
472
 
442
473
class BundleTree(Tree):
443
474
    def __init__(self, base_tree, revision_id):