~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-02-24 12:50:51 UTC
  • mfrom: (6437.23.15 2.5)
  • mto: This revision was merged to the branch mainline in revision 6475.
  • Revision ID: v.ladeuil+lp@free.fr-20120224125051-i7p1xmjxw56jhmj3
Merge 2.5 branch

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
 
import os
 
20
from __future__ import absolute_import
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, BundleTree)
 
30
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo)
31
31
from bzrlib.diff import internal_diff
32
 
from bzrlib.osutils import pathjoin
33
32
from bzrlib.revision import NULL_REVISION
34
33
from bzrlib.testament import StrictTestament
35
34
from bzrlib.timestamp import (
36
35
    format_highres_date,
37
 
    unpack_highres_date,
38
 
)
 
36
    )
39
37
from bzrlib.textfile import text_file
40
38
from bzrlib.trace import mutter
41
39
 
263
261
 
264
262
        def do_diff(file_id, old_path, new_path, action, force_binary):
265
263
            def tree_lines(tree, require_text=False):
266
 
                if file_id in tree:
 
264
                if tree.has_id(file_id):
267
265
                    tree_file = tree.get_file(file_id)
268
266
                    if require_text is True:
269
267
                        tree_file = text_file(tree_file)
289
287
 
290
288
        def finish_action(action, file_id, kind, meta_modified, text_modified,
291
289
                          old_path, new_path):
292
 
            entry = new_tree.inventory[file_id]
293
 
            if entry.revision != default_revision_id:
294
 
                action.add_utf8_property('last-changed', entry.revision)
 
290
            revision = new_tree.get_file_revision(file_id)
 
291
            if revision != default_revision_id:
 
292
                action.add_utf8_property('last-changed', revision)
295
293
            if meta_modified:
296
 
                action.add_bool_property('executable', entry.executable)
 
294
                action.add_bool_property('executable',
 
295
                    new_tree.is_executable(file_id))
297
296
            if text_modified and kind == "symlink":
298
 
                action.add_property('target', entry.symlink_target)
 
297
                action.add_property('target',
 
298
                    new_tree.get_symlink_target(file_id))
299
299
            if text_modified and kind == "file":
300
300
                do_diff(file_id, old_path, new_path, action, force_binary)
301
301
            else:
326
326
                          path, path)
327
327
 
328
328
        for path, file_id, kind in delta.unchanged:
329
 
            ie = new_tree.inventory[file_id]
330
 
            new_rev = getattr(ie, 'revision', None)
 
329
            new_rev = new_tree.get_file_revision(file_id)
331
330
            if new_rev is None:
332
331
                continue
333
 
            old_rev = getattr(old_tree.inventory[ie.file_id], 'revision', None)
 
332
            old_rev = old_tree.get_file_revision(file_id)
334
333
            if new_rev != old_rev:
335
 
                action = Action('modified', [ie.kind,
336
 
                                             new_tree.id2path(ie.file_id)])
337
 
                action.add_utf8_property('last-changed', ie.revision)
 
334
                action = Action('modified', [new_tree.kind(file_id),
 
335
                                             new_tree.id2path(file_id)])
 
336
                action.add_utf8_property('last-changed', new_rev)
338
337
                action.write(self.to_file)
339
338
 
340
339