~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-08-14 16:16:53 UTC
  • mto: (1946.2.6 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1919.
  • Revision ID: john@arbash-meinel.com-20060814161653-54cdcdadcd4e9003
Remove bogus entry from BRANCH.TODO

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# (C) 2005 Canonical Development Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
94
94
        """
95
95
        return BundleReader(f).info
96
96
 
97
 
    def check_compatible(self):
98
 
        if self.source.supports_rich_root():
99
 
            raise errors.IncompatibleFormat('0.8', repr(self.source))
100
 
 
101
97
    def write(self, source, revision_ids, forced_bases, f):
102
98
        """Write the bundless to the supplied files.
103
99
 
110
106
        self.revision_ids = revision_ids
111
107
        self.forced_bases = forced_bases
112
108
        self.to_file = f
113
 
        self.check_compatible()
114
109
        source.lock_read()
115
110
        try:
116
111
            self._write_main_header()
163
158
            if rev_id == last_rev_id:
164
159
                rev_tree = last_rev_tree
165
160
            else:
166
 
                rev_tree = self.source.revision_tree(rev_id)
 
161
                base_tree = self.source.revision_tree(rev_id)
 
162
            rev_tree = self.source.revision_tree(rev_id)
167
163
            if rev_id in self.forced_bases:
168
164
                explicit_base = True
169
165
                base_id = self.forced_bases[rev_id]
187
183
            last_rev_id = base_id
188
184
            last_rev_tree = base_tree
189
185
 
190
 
    def _testament_sha1(self, revision_id):
191
 
        return StrictTestament.from_revision(self.source, 
192
 
                                             revision_id).as_sha1()
193
 
 
194
186
    def _write_revision(self, rev, rev_tree, base_rev, base_tree, 
195
187
                        explicit_base, force_binary):
196
188
        """Write out the information for a revision."""
205
197
        self._write_delta(rev_tree, base_tree, rev.revision_id, force_binary)
206
198
 
207
199
        w('revision id', rev.revision_id)
208
 
        w('sha1', self._testament_sha1(rev.revision_id))
 
200
        w('sha1', StrictTestament.from_revision(self.source, 
 
201
                                                rev.revision_id).as_sha1())
209
202
        w('inventory sha1', rev.inventory_sha1)
210
203
        if rev.parent_ids:
211
204
            w('parent ids', rev.parent_ids)
275
268
            else:
276
269
                action.write(self.to_file)
277
270
 
278
 
        delta = new_tree.changes_from(old_tree, want_unchanged=True,
279
 
                                      include_root=True)
 
271
        delta = new_tree.changes_from(old_tree, want_unchanged=True)
280
272
        for path, file_id, kind in delta.removed:
281
273
            action = Action('removed', [kind, path]).write(self.to_file)
282
274
 
325
317
        self.from_file = iter(from_file)
326
318
        self._next_line = None
327
319
        
328
 
        self.info = self._get_info()
 
320
        self.info = BundleInfo()
329
321
        # We put the actual inventory ids in the footer, so that the patch
330
322
        # is easier to read for humans.
331
323
        # Unfortunately, that means we need to read everything before we
333
325
        self._read()
334
326
        self._validate()
335
327
 
336
 
    def _get_info(self):
337
 
        return BundleInfo08()
338
 
 
339
328
    def _read(self):
340
329
        self._next().next()
341
330
        while self._next_line is not None:
423
412
            return
424
413
 
425
414
        revision_info = self.info.revisions[-1]
426
 
        if key in revision_info.__dict__:
 
415
        if hasattr(revision_info, key):
427
416
            if getattr(revision_info, key) is None:
428
417
                setattr(revision_info, key, value)
429
418
            else:
511
500
                # Consume the trailing \n and stop processing
512
501
                self._next().next()
513
502
                break
514
 
 
515
 
 
516
 
class BundleInfo08(BundleInfo):
517
 
 
518
 
    def _update_tree(self, bundle_tree, revision_id):
519
 
        bundle_tree.note_last_changed('', revision_id)
520
 
        BundleInfo._update_tree(self, bundle_tree, revision_id)
521
 
 
522
 
    def _testament_sha1_from_revision(self, repository, revision_id):
523
 
        testament = StrictTestament.from_revision(repository, revision_id)
524
 
        return testament.as_sha1()
525
 
 
526
 
    def _testament_sha1(self, revision, inventory):
527
 
        return StrictTestament(revision, inventory).as_sha1()