~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: 2010-08-24 23:20:14 UTC
  • mfrom: (5365.5.29 2.3-btree-chk-leaf)
  • Revision ID: pqm@pqm.ubuntu.com-20100824232014-nu9owzel2zym2jk2
(jam) Use a custom C type for CHK index entries, saves memory

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Serializer factory for reading and writing bundles.
18
18
"""
19
19
 
20
 
from __future__ import absolute_import
 
20
import os
21
21
 
22
22
from bzrlib import (
23
23
    errors,
27
27
                                      _get_bundle_header,
28
28
                                     )
29
29
from bzrlib.bundle.serializer import binary_diff
30
 
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo)
 
30
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
31
31
from bzrlib.diff import internal_diff
 
32
from bzrlib.osutils import pathjoin
32
33
from bzrlib.revision import NULL_REVISION
33
34
from bzrlib.testament import StrictTestament
34
35
from bzrlib.timestamp import (
35
36
    format_highres_date,
36
 
    )
 
37
    unpack_highres_date,
 
38
)
37
39
from bzrlib.textfile import text_file
38
40
from bzrlib.trace import mutter
39
41
 
261
263
 
262
264
        def do_diff(file_id, old_path, new_path, action, force_binary):
263
265
            def tree_lines(tree, require_text=False):
264
 
                if tree.has_id(file_id):
 
266
                if file_id in tree:
265
267
                    tree_file = tree.get_file(file_id)
266
268
                    if require_text is True:
267
269
                        tree_file = text_file(tree_file)
287
289
 
288
290
        def finish_action(action, file_id, kind, meta_modified, text_modified,
289
291
                          old_path, new_path):
290
 
            entry = new_tree.root_inventory[file_id]
 
292
            entry = new_tree.inventory[file_id]
291
293
            if entry.revision != default_revision_id:
292
294
                action.add_utf8_property('last-changed', entry.revision)
293
295
            if meta_modified:
324
326
                          path, path)
325
327
 
326
328
        for path, file_id, kind in delta.unchanged:
327
 
            new_rev = new_tree.get_file_revision(file_id)
 
329
            ie = new_tree.inventory[file_id]
 
330
            new_rev = getattr(ie, 'revision', None)
328
331
            if new_rev is None:
329
332
                continue
330
 
            old_rev = old_tree.get_file_revision(file_id)
 
333
            old_rev = getattr(old_tree.inventory[ie.file_id], 'revision', None)
331
334
            if new_rev != old_rev:
332
 
                action = Action('modified', [new_tree.kind(file_id),
333
 
                                             new_tree.id2path(file_id)])
334
 
                action.add_utf8_property('last-changed', new_rev)
 
335
                action = Action('modified', [ie.kind,
 
336
                                             new_tree.id2path(ie.file_id)])
 
337
                action.add_utf8_property('last-changed', ie.revision)
335
338
                action.write(self.to_file)
336
339
 
337
340
 
550
553
        testament = StrictTestament.from_revision(repository, revision_id)
551
554
        return testament.as_sha1()
552
555
 
553
 
    def _testament_sha1(self, revision, tree):
554
 
        return StrictTestament(revision, tree).as_sha1()
 
556
    def _testament_sha1(self, revision, inventory):
 
557
        return StrictTestament(revision, inventory).as_sha1()