/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: Jelmer Vernooij
  • Date: 2020-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

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):
163
153
        return False
164
154
 
165
155
    def is_reparented(self):
166
 
        return self.parent_id[0] != self.parent_id[1]
 
156
        return os.path.dirname(self.path[0]) != os.path.dirname(self.path[1])
167
157
 
168
158
    def discard_new(self):
169
159
        return self.__class__(
170
 
            self.file_id, (self.path[0], None), self.changed_content,
171
 
            (self.versioned[0], None), (self.parent_id[0], None),
 
160
            (self.path[0], None), self.changed_content,
 
161
            (self.versioned[0], None),
172
162
            (self.name[0], None), (self.kind[0], None),
173
163
            (self.executable[0], None),
174
164
            copied=False)
637
627
        list to exclude some directories, they are then not descended into.
638
628
 
639
629
        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,
 
630
        (directory-relpath,
 
631
        [(relpath, basename, kind, lstat, path_from_tree_root,
642
632
          versioned_kind), ...]),
643
 
         - directory-relpath is the containing dirs relpath from prefix
644
633
         - directory-path-from-root is the containing dirs path from /
645
 
         - directory-fileid is the id of the directory if it is versioned.
646
634
         - relpath is the relative path within the subtree being walked.
647
635
         - basename is the basename
648
636
         - kind is the kind of the file now. If unknonwn then the file is not
650
638
           versioned_kind.
651
639
         - lstat is the stat data *if* the file was statted.
652
640
         - 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
641
         - versioned_kind is the kind of the file as last recorded in the
655
642
           versioning system. If 'unknown' the file is not versioned.
656
643
        One of 'kind' and 'versioned_kind' must not be 'unknown'.
683
670
        prefs = next(self.iter_search_rules([path], filter_pref_names))
684
671
        stk = filters._get_filter_stack_for(prefs)
685
672
        if 'filters' in debug.debug_flags:
686
 
            trace.note(
687
 
                gettext("*** {0} content-filter: {1} => {2!r}").format(path, prefs, stk))
 
673
            trace.note("*** {0} content-filter: {1} => {2!r}").format(path, prefs, stk)
688
674
        return stk
689
675
 
690
676
    def _content_filter_stack_provider(self):