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

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
See MutableTree for more details.
20
20
"""
21
21
 
 
22
from __future__ import absolute_import
 
23
 
22
24
from . import (
23
25
    errors,
24
26
    hooks,
27
29
    tree,
28
30
    )
29
31
 
 
32
from .sixish import (
 
33
    text_type,
 
34
    )
30
35
 
31
36
 
32
37
class BadReferenceTarget(errors.InternalBzrError):
96
101
 
97
102
        TODO: Perhaps callback with the ids and paths as they're added.
98
103
        """
99
 
        if isinstance(files, str):
 
104
        if isinstance(files, (str, text_type)):
100
105
            # XXX: Passing a single string is inconsistent and should be
101
106
            # deprecated.
102
107
            if not (ids is None or isinstance(ids, bytes)):
103
108
                raise AssertionError()
104
 
            if not (kinds is None or isinstance(kinds, str)):
 
109
            if not (kinds is None or isinstance(kinds, (str, text_type))):
105
110
                raise AssertionError()
106
111
            files = [files]
107
112
            if ids is not None:
185
190
 
186
191
        :return: True if a change is found. False otherwise
187
192
        """
188
 
        raise NotImplementedError(self.has_changes)
 
193
        with self.lock_read():
 
194
            # Check pending merges
 
195
            if len(self.get_parent_ids()) > 1:
 
196
                return True
 
197
            if _from_tree is None:
 
198
                _from_tree = self.basis_tree()
 
199
            changes = self.iter_changes(_from_tree)
 
200
            if self.supports_symlinks():
 
201
                # Fast path for has_changes.
 
202
                try:
 
203
                    change = next(changes)
 
204
                    # Exclude root (talk about black magic... --vila 20090629)
 
205
                    if change.parent_id == (None, None):
 
206
                        change = next(changes)
 
207
                    return True
 
208
                except StopIteration:
 
209
                    # No changes
 
210
                    return False
 
211
            else:
 
212
                # Slow path for has_changes.
 
213
                # Handle platforms that do not support symlinks in the
 
214
                # conditional below. This is slower than the try/except
 
215
                # approach below that but we don't have a choice as we
 
216
                # need to be sure that all symlinks are removed from the
 
217
                # entire changeset. This is because in platforms that
 
218
                # do not support symlinks, they show up as None in the
 
219
                # working copy as compared to the repository.
 
220
                # Also, exclude root as mention in the above fast path.
 
221
                changes = filter(
 
222
                    lambda c: c[6][0] != 'symlink' and c[4] != (None, None),
 
223
                    changes)
 
224
                try:
 
225
                    next(iter(changes))
 
226
                except StopIteration:
 
227
                    return False
 
228
                return True
189
229
 
190
230
    def check_changed_or_out_of_date(self, strict, opt_name,
191
231
                                     more_error, more_warning):
208
248
                strict = self.branch.get_config_stack().get(opt_name)
209
249
            if strict is not False:
210
250
                err_class = None
211
 
                if self.has_changes():
 
251
                if (self.has_changes()):
212
252
                    err_class = errors.UncommittedChanges
213
253
                elif self.last_revision() != self.branch.last_revision():
214
254
                    # The tree has lost sync with its branch, there is little