/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/transform.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-03-24 00:16:27 UTC
  • mfrom: (6883.5.22 supports-rename-tracking)
  • Revision ID: breezy.the.bot@gmail.com-20180324001627-zc0yqcvhpsgeyq92
Add a flag for Trees to indicate whether they support rename tracking.

Merged from https://code.launchpad.net/~jelmer/brz/supports-rename-tracking/+merge/341565

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    viewitems,
70
70
    viewvalues,
71
71
    )
 
72
from .tree import (
 
73
    find_previous_path,
 
74
    )
72
75
 
73
76
 
74
77
ROOT_PARENT = "root-parent"
2243
2246
        trans_id = self._transform.trans_id_file_id(file_id)
2244
2247
        return self._stat_limbo_file(trans_id).st_mtime
2245
2248
 
2246
 
    def _file_size(self, entry, stat_value):
2247
 
        path = self.id2path(entry.file_id)
2248
 
        return self.get_file_size(path, entry.file_id)
2249
 
 
2250
2249
    def get_file_size(self, path, file_id=None):
2251
2250
        """See Tree.get_file_size"""
2252
2251
        if file_id is None:
2610
2609
                        else:
2611
2610
                            divert.add(file_id)
2612
2611
                    if (file_id not in divert and
2613
 
                        _content_match(tree, entry, file_id, kind,
 
2612
                        _content_match(tree, entry, tree_path, file_id, kind,
2614
2613
                        target_path)):
2615
2614
                        tt.delete_contents(tt.trans_id_tree_path(tree_path))
2616
2615
                        if kind == 'directory':
2722
2721
    return by_parent[old_parent]
2723
2722
 
2724
2723
 
2725
 
def _content_match(tree, entry, file_id, kind, target_path):
 
2724
def _content_match(tree, entry, tree_path, file_id, kind, target_path):
2726
2725
    if entry.kind != kind:
2727
2726
        return False
2728
2727
    if entry.kind == "directory":
2729
2728
        return True
2730
 
    path = tree.id2path(file_id)
2731
2729
    if entry.kind == "file":
2732
2730
        f = file(target_path, 'rb')
2733
2731
        try:
2734
 
            if tree.get_file_text(path, file_id) == f.read():
 
2732
            if tree.get_file_text(tree_path, file_id) == f.read():
2735
2733
                return True
2736
2734
        finally:
2737
2735
            f.close()
2738
2736
    elif entry.kind == "symlink":
2739
 
        if tree.get_symlink_target(path, file_id) == os.readlink(target_path):
 
2737
        if tree.get_symlink_target(tree_path, file_id) == os.readlink(target_path):
2740
2738
            return True
2741
2739
    return False
2742
2740
 
2910
2908
                        if basis_tree is None:
2911
2909
                            basis_tree = working_tree.basis_tree()
2912
2910
                            basis_tree.lock_read()
2913
 
                        try:
2914
 
                            basis_path = basis_tree.id2path(file_id)
2915
 
                        except errors.NoSuchId:
 
2911
                        basis_path = find_previous_path(working_tree, basis_tree, wt_path)
 
2912
                        if basis_path is None:
2916
2913
                            if target_kind is None and not target_versioned:
2917
2914
                                keep_content = True
2918
2915
                        else:
2949
2946
                        basis_tree = working_tree.basis_tree()
2950
2947
                        basis_tree.lock_read()
2951
2948
                    new_sha1 = target_tree.get_file_sha1(target_path, file_id)
2952
 
                    try:
2953
 
                        basis_path = basis_tree.id2path(file_id)
2954
 
                    except errors.NoSuchId:
2955
 
                        basis_path = None
 
2949
                    basis_path = find_previous_path(target_tree, basis_tree, target_path)
2956
2950
                    if (basis_path is not None and
2957
2951
                        new_sha1 == basis_tree.get_file_sha1(basis_path, file_id)):
2958
2952
                        if file_id in merge_modified: