/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 __future__ import absolute_import
21
 
 
22
 
from .lazy_import import lazy_import
23
 
lazy_import(globals(), """
24
 
from breezy.i18n import gettext
25
 
""")
26
 
 
27
20
from . import (
28
21
    errors,
29
22
    lock,
32
25
    trace,
33
26
    )
34
27
from .inter import InterObject
35
 
from .sixish import (
36
 
    text_type,
37
 
    viewvalues,
38
 
    )
39
28
 
40
29
 
41
30
class FileTimestampUnavailable(errors.BzrError):
128
117
class TreeChange(object):
129
118
    """Describes the changes between the same item in two different trees."""
130
119
 
131
 
    __slots__ = ['file_id', 'path', 'changed_content', 'versioned', 'parent_id',
 
120
    __slots__ = ['path', 'changed_content', 'versioned',
132
121
                 'name', 'kind', 'executable', 'copied']
133
122
 
134
 
    def __init__(self, file_id, path, changed_content, versioned, parent_id,
 
123
    def __init__(self, path, changed_content, versioned,
135
124
                 name, kind, executable, copied=False):
136
 
        self.file_id = file_id
137
125
        self.path = path
138
126
        self.changed_content = changed_content
139
127
        self.versioned = versioned
140
 
        self.parent_id = parent_id
141
128
        self.name = name
142
129
        self.kind = kind
143
130
        self.executable = executable
146
133
    def __repr__(self):
147
134
        return "%s%r" % (self.__class__.__name__, self._as_tuple())
148
135
 
149
 
    def __len__(self):
150
 
        return len(self.__slots__)
151
 
 
152
136
    def _as_tuple(self):
153
 
        return (self.file_id, self.path, self.changed_content, self.versioned,
154
 
                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)
155
139
 
156
140
    def __eq__(self, other):
157
141
        if isinstance(other, TreeChange):
169
153
        return False
170
154
 
171
155
    def is_reparented(self):
172
 
        return self.parent_id[0] != self.parent_id[1]
 
156
        return os.path.dirname(self.path[0]) != os.path.dirname(self.path[1])
173
157
 
174
158
    def discard_new(self):
175
159
        return self.__class__(
176
 
            self.file_id, (self.path[0], None), self.changed_content,
177
 
            (self.versioned[0], None), (self.parent_id[0], None),
 
160
            (self.path[0], None), self.changed_content,
 
161
            (self.versioned[0], None),
178
162
            (self.name[0], None), (self.kind[0], None),
179
163
            (self.executable[0], None),
180
164
            copied=False)
643
627
        list to exclude some directories, they are then not descended into.
644
628
 
645
629
        The data yielded is of the form:
646
 
        ((directory-relpath, directory-path-from-root, directory-fileid),
647
 
        [(relpath, basename, kind, lstat, path_from_tree_root, file_id,
 
630
        (directory-relpath,
 
631
        [(relpath, basename, kind, lstat, path_from_tree_root,
648
632
          versioned_kind), ...]),
649
 
         - directory-relpath is the containing dirs relpath from prefix
650
633
         - directory-path-from-root is the containing dirs path from /
651
 
         - directory-fileid is the id of the directory if it is versioned.
652
634
         - relpath is the relative path within the subtree being walked.
653
635
         - basename is the basename
654
636
         - kind is the kind of the file now. If unknonwn then the file is not
656
638
           versioned_kind.
657
639
         - lstat is the stat data *if* the file was statted.
658
640
         - path_from_tree_root is the path from the root of the tree.
659
 
         - file_id is the file_id if the entry is versioned.
660
641
         - versioned_kind is the kind of the file as last recorded in the
661
642
           versioning system. If 'unknown' the file is not versioned.
662
643
        One of 'kind' and 'versioned_kind' must not be 'unknown'.
689
670
        prefs = next(self.iter_search_rules([path], filter_pref_names))
690
671
        stk = filters._get_filter_stack_for(prefs)
691
672
        if 'filters' in debug.debug_flags:
692
 
            trace.note(
693
 
                gettext("*** {0} content-filter: {1} => {2!r}").format(path, prefs, stk))
 
673
            trace.note("*** {0} content-filter: {1} => {2!r}").format(path, prefs, stk)
694
674
        return stk
695
675
 
696
676
    def _content_filter_stack_provider(self):