/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 breezy/bundle/serializer/v08.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 01:35:53 UTC
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610013553-560y7mn3su4pp763
Fix remaining tests.

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
 
from bzrlib import (
 
22
from breezy import (
23
23
    errors,
24
24
    ui,
25
25
    )
26
 
from bzrlib.bundle.serializer import (BundleSerializer,
 
26
from breezy.bundle.serializer import (BundleSerializer,
27
27
                                      _get_bundle_header,
28
28
                                     )
29
 
from bzrlib.bundle.serializer import binary_diff
30
 
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
31
 
from bzrlib.diff import internal_diff
32
 
from bzrlib.osutils import pathjoin
33
 
from bzrlib.revision import NULL_REVISION
34
 
from bzrlib.testament import StrictTestament
35
 
from bzrlib.timestamp import (
 
29
from breezy.bundle.serializer import binary_diff
 
30
from breezy.bundle.bundle_data import (RevisionInfo, BundleInfo)
 
31
from breezy.diff import internal_diff
 
32
from breezy.revision import NULL_REVISION
 
33
from breezy.testament import StrictTestament
 
34
from breezy.timestamp import (
36
35
    format_highres_date,
37
 
    unpack_highres_date,
38
 
)
39
 
from bzrlib.textfile import text_file
40
 
from bzrlib.trace import mutter
 
36
    )
 
37
from breezy.textfile import text_file
 
38
from breezy.trace import mutter
41
39
 
42
40
bool_text = {True: 'yes', False: 'no'}
43
41
 
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]
 
290
            entry = new_tree.root_inventory[file_id]
293
291
            if entry.revision != default_revision_id:
294
292
                action.add_utf8_property('last-changed', entry.revision)
295
293
            if meta_modified:
326
324
                          path, path)
327
325
 
328
326
        for path, file_id, kind in delta.unchanged:
329
 
            ie = new_tree.inventory[file_id]
330
 
            new_rev = getattr(ie, 'revision', None)
 
327
            new_rev = new_tree.get_file_revision(file_id)
331
328
            if new_rev is None:
332
329
                continue
333
 
            old_rev = getattr(old_tree.inventory[ie.file_id], 'revision', None)
 
330
            old_rev = old_tree.get_file_revision(file_id)
334
331
            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)
 
332
                action = Action('modified', [new_tree.kind(file_id),
 
333
                                             new_tree.id2path(file_id)])
 
334
                action.add_utf8_property('last-changed', new_rev)
338
335
                action.write(self.to_file)
339
336
 
340
337
 
363
360
        return BundleInfo08()
364
361
 
365
362
    def _read(self):
366
 
        self._next().next()
 
363
        next(self._next())
367
364
        while self._next_line is not None:
368
365
            if not self._read_revision_header():
369
366
                break
540
537
                break
541
538
            if not self._next_line.startswith('#'):
542
539
                # Consume the trailing \n and stop processing
543
 
                self._next().next()
 
540
                next(self._next())
544
541
                break
545
542
 
546
543
class BundleInfo08(BundleInfo):
553
550
        testament = StrictTestament.from_revision(repository, revision_id)
554
551
        return testament.as_sha1()
555
552
 
556
 
    def _testament_sha1(self, revision, inventory):
557
 
        return StrictTestament(revision, inventory).as_sha1()
 
553
    def _testament_sha1(self, revision, tree):
 
554
        return StrictTestament(revision, tree).as_sha1()