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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-08-23 01:15:41 UTC
  • mfrom: (7520.1.4 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200823011541-nv0oh7nzaganx2qy
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/389690

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tree classes, representing directory at point in time.
18
18
"""
19
19
 
20
 
from .lazy_import import lazy_import
21
 
lazy_import(globals(), """
22
 
from breezy.i18n import gettext
23
 
""")
24
 
 
25
20
from . import (
26
21
    errors,
27
22
    lock,
122
117
class TreeChange(object):
123
118
    """Describes the changes between the same item in two different trees."""
124
119
 
125
 
    __slots__ = ['file_id', 'path', 'changed_content', 'versioned', 'parent_id',
 
120
    __slots__ = ['path', 'changed_content', 'versioned',
126
121
                 'name', 'kind', 'executable', 'copied']
127
122
 
128
 
    def __init__(self, file_id, path, changed_content, versioned, parent_id,
 
123
    def __init__(self, path, changed_content, versioned,
129
124
                 name, kind, executable, copied=False):
130
 
        self.file_id = file_id
131
125
        self.path = path
132
126
        self.changed_content = changed_content
133
127
        self.versioned = versioned
134
 
        self.parent_id = parent_id
135
128
        self.name = name
136
129
        self.kind = kind
137
130
        self.executable = executable
140
133
    def __repr__(self):
141
134
        return "%s%r" % (self.__class__.__name__, self._as_tuple())
142
135
 
143
 
    def __len__(self):
144
 
        return len(self.__slots__)
145
 
 
146
136
    def _as_tuple(self):
147
 
        return (self.file_id, self.path, self.changed_content, self.versioned,
148
 
                self.parent_id, self.name, self.kind, self.executable, self.copied)
 
137
        return (self.path, self.changed_content, self.versioned,
 
138
                self.name, self.kind, self.executable, self.copied)
149
139
 
150
140
    def __eq__(self, other):
151
141
        if isinstance(other, TreeChange):
162
152
            return (self.executable[0] != self.executable[1])
163
153
        return False
164
154
 
 
155
    @property
 
156
    def renamed(self):
 
157
        return (
 
158
            not self.copied and
 
159
            None not in self.name and
 
160
            self.path[0] != self.path[1])
 
161
 
165
162
    def is_reparented(self):
166
 
        return self.parent_id[0] != self.parent_id[1]
 
163
        return os.path.dirname(self.path[0]) != os.path.dirname(self.path[1])
167
164
 
168
165
    def discard_new(self):
169
166
        return self.__class__(
170
 
            self.file_id, (self.path[0], None), self.changed_content,
171
 
            (self.versioned[0], None), (self.parent_id[0], None),
 
167
            (self.path[0], None), self.changed_content,
 
168
            (self.versioned[0], None),
172
169
            (self.name[0], None), (self.kind[0], None),
173
170
            (self.executable[0], None),
174
171
            copied=False)
637
634
        list to exclude some directories, they are then not descended into.
638
635
 
639
636
        The data yielded is of the form:
640
 
        ((directory-relpath, directory-path-from-root, directory-fileid),
641
 
        [(relpath, basename, kind, lstat, path_from_tree_root, file_id,
 
637
        (directory-relpath,
 
638
        [(relpath, basename, kind, lstat, path_from_tree_root,
642
639
          versioned_kind), ...]),
643
 
         - directory-relpath is the containing dirs relpath from prefix
644
640
         - directory-path-from-root is the containing dirs path from /
645
 
         - directory-fileid is the id of the directory if it is versioned.
646
641
         - relpath is the relative path within the subtree being walked.
647
642
         - basename is the basename
648
643
         - kind is the kind of the file now. If unknonwn then the file is not
650
645
           versioned_kind.
651
646
         - lstat is the stat data *if* the file was statted.
652
647
         - path_from_tree_root is the path from the root of the tree.
653
 
         - file_id is the file_id if the entry is versioned.
654
648
         - versioned_kind is the kind of the file as last recorded in the
655
649
           versioning system. If 'unknown' the file is not versioned.
656
650
        One of 'kind' and 'versioned_kind' must not be 'unknown'.
683
677
        prefs = next(self.iter_search_rules([path], filter_pref_names))
684
678
        stk = filters._get_filter_stack_for(prefs)
685
679
        if 'filters' in debug.debug_flags:
686
 
            trace.note(
687
 
                gettext("*** {0} content-filter: {1} => {2!r}").format(path, prefs, stk))
 
680
            trace.note("*** {0} content-filter: {1} => {2!r}").format(path, prefs, stk)
688
681
        return stk
689
682
 
690
683
    def _content_filter_stack_provider(self):