/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: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from __future__ import absolute_import
21
21
 
22
 
from .... import (
 
22
from breezy import (
23
23
    errors,
24
24
    ui,
25
25
    )
26
 
from . import (
 
26
from breezy.bundle.serializer import (
27
27
    BundleSerializer,
28
28
    _get_bundle_header,
29
 
    binary_diff,
30
29
    )
31
 
from ..bundle_data import (
 
30
from breezy.bundle.serializer import binary_diff
 
31
from breezy.bundle.bundle_data import (
32
32
    RevisionInfo,
33
33
    BundleInfo,
34
34
    )
35
 
from ....diff import internal_diff
36
 
from ....revision import NULL_REVISION
37
 
from ....sixish import text_type
38
 
from ...testament import StrictTestament
39
 
from ....timestamp import (
 
35
from breezy.diff import internal_diff
 
36
from breezy.revision import NULL_REVISION
 
37
from breezy.sixish import text_type
 
38
from breezy.bzr.testament import StrictTestament
 
39
from breezy.timestamp import (
40
40
    format_highres_date,
41
41
    )
42
 
from ....textfile import text_file
43
 
from ....trace import mutter
 
42
from breezy.textfile import text_file
 
43
from breezy.trace import mutter
44
44
 
45
45
bool_text = {True: 'yes', False: 'no'}
46
46
 
269
269
 
270
270
        def do_diff(file_id, old_path, new_path, action, force_binary):
271
271
            def tree_lines(tree, path, require_text=False):
272
 
                try:
 
272
                if tree.has_id(file_id):
273
273
                    tree_file = tree.get_file(path)
274
 
                except errors.NoSuchFile:
275
 
                    return []
276
 
                else:
277
274
                    if require_text is True:
278
275
                        tree_file = text_file(tree_file)
279
276
                    return tree_file.readlines()
 
277
                else:
 
278
                    return []
280
279
 
281
280
            try:
282
281
                if force_binary:
310
309
 
311
310
        delta = new_tree.changes_from(old_tree, want_unchanged=True,
312
311
                                      include_root=True)
313
 
        for change in delta.removed:
314
 
            action = Action('removed', [change.kind[0], change.path[0]]).write(self.to_file)
 
312
        for path, file_id, kind in delta.removed:
 
313
            action = Action('removed', [kind, path]).write(self.to_file)
315
314
 
316
 
        # TODO(jelmer): Treat copied specially here?
317
 
        for change in delta.added + delta.copied:
 
315
        for path, file_id, kind in delta.added:
318
316
            action = Action(
319
 
                'added', [change.kind[1], change.path[1]],
320
 
                [('file-id', change.file_id.decode('utf-8'))])
321
 
            meta_modified = (change.kind[1] == 'file' and
322
 
                             change.executable[1])
323
 
            finish_action(action, change.file_id, change.kind[1], meta_modified, change.changed_content,
324
 
                          DEVNULL, change.path[1])
325
 
 
326
 
        for change in delta.renamed:
327
 
            action = Action('renamed', [change.kind[1], change.path[0]], [(change.path[1],)])
328
 
            finish_action(action, change.file_id, change.kind[1], change.meta_modified(), change.changed_content,
329
 
                          change.path[0], change.path[1])
330
 
 
331
 
        for change in delta.modified:
332
 
            action = Action('modified', [change.kind[1], change.path[1]])
333
 
            finish_action(action, change.file_id, change.kind[1], change.meta_modified(), change.changed_content,
334
 
                          change.path[0], change.path[1])
335
 
 
336
 
        for change in delta.unchanged:
337
 
            new_rev = new_tree.get_file_revision(change.path[1])
 
317
                'added', [kind, path], [('file-id', file_id.decode('utf-8'))])
 
318
            meta_modified = (kind == 'file' and
 
319
                             new_tree.is_executable(path))
 
320
            finish_action(action, file_id, kind, meta_modified, True,
 
321
                          DEVNULL, path)
 
322
 
 
323
        for (old_path, new_path, file_id, kind,
 
324
             text_modified, meta_modified) in delta.renamed:
 
325
            action = Action('renamed', [kind, old_path], [(new_path,)])
 
326
            finish_action(action, file_id, kind, meta_modified, text_modified,
 
327
                          old_path, new_path)
 
328
 
 
329
        for (path, file_id, kind,
 
330
             text_modified, meta_modified) in delta.modified:
 
331
            action = Action('modified', [kind, path])
 
332
            finish_action(action, file_id, kind, meta_modified, text_modified,
 
333
                          path, path)
 
334
 
 
335
        for path, file_id, kind in delta.unchanged:
 
336
            new_rev = new_tree.get_file_revision(path)
338
337
            if new_rev is None:
339
338
                continue
340
 
            old_rev = old_tree.get_file_revision(change.path[0])
 
339
            old_rev = old_tree.get_file_revision(old_tree.id2path(file_id))
341
340
            if new_rev != old_rev:
342
 
                action = Action('modified', [change.kind[1], change.path[1]])
 
341
                action = Action('modified', [new_tree.kind(path), path])
343
342
                action.add_utf8_property('last-changed', new_rev)
344
343
                action.write(self.to_file)
345
344
 
563
562
        testament = StrictTestament.from_revision(repository, revision_id)
564
563
        return testament.as_sha1()
565
564
 
566
 
    def _testament(self, revision, tree):
567
 
        return StrictTestament(revision, tree)
 
565
    def _testament_sha1(self, revision, tree):
 
566
        return StrictTestament(revision, tree).as_sha1()