~jelmer/brz/fix-c-extensions

« back to all changes in this revision

Viewing changes to breezy/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    errors,
51
51
    filters as _mod_filters,
52
52
    generate_ids,
53
 
    globbing,
54
 
    ignores,
55
53
    merge,
56
54
    revision as _mod_revision,
57
55
    shelf,
69
67
from .i18n import gettext
70
68
from . import mutabletree
71
69
from .mutabletree import needs_tree_write_lock
 
70
from .sixish import (
 
71
    text_type,
 
72
    )
72
73
from .trace import mutter, note
73
74
 
74
75
 
396
397
            return self.branch.repository.revision_tree(
397
398
                       _mod_revision.NULL_REVISION)
398
399
 
399
 
    def _cleanup(self):
400
 
        self._flush_ignore_list_cache()
401
 
 
402
400
    def relpath(self, path):
403
401
        """Return the local path portion from a given path.
404
402
 
952
950
                                new_basis_tree,
953
951
                                basis_tree,
954
952
                                this_tree=self,
955
 
                                pb=None,
956
953
                                change_reporter=change_reporter,
957
954
                                show_base=show_base)
958
955
                    basis_root_id = basis_tree.get_root_id()
1010
1007
            if pat is not None:
1011
1008
                yield subp, pat
1012
1009
 
1013
 
    def get_ignore_list(self):
1014
 
        """Return list of ignore patterns.
1015
 
 
1016
 
        Cached in the Tree object after the first call.
1017
 
        """
1018
 
        ignoreset = getattr(self, '_ignoreset', None)
1019
 
        if ignoreset is not None:
1020
 
            return ignoreset
1021
 
 
1022
 
        ignore_globs = set()
1023
 
        ignore_globs.update(ignores.get_runtime_ignores())
1024
 
        ignore_globs.update(ignores.get_user_ignores())
1025
 
        if self.has_filename(breezy.IGNORE_FILENAME):
1026
 
            f = self.get_file_byname(breezy.IGNORE_FILENAME)
1027
 
            try:
1028
 
                ignore_globs.update(ignores.parse_ignore_file(f))
1029
 
            finally:
1030
 
                f.close()
1031
 
        self._ignoreset = ignore_globs
1032
 
        return ignore_globs
1033
 
 
1034
 
    def _flush_ignore_list_cache(self):
1035
 
        """Resets the cached ignore list to force a cache rebuild."""
1036
 
        self._ignoreset = None
1037
 
        self._ignoreglobster = None
1038
 
 
1039
1010
    def is_ignored(self, filename):
1040
1011
        r"""Check whether the filename matches an ignore pattern.
1041
 
 
1042
 
        Patterns containing '/' or '\' need to match the whole path;
1043
 
        others match against only the last component.  Patterns starting
1044
 
        with '!' are ignore exceptions.  Exceptions take precedence
1045
 
        over regular patterns and cause the filename to not be ignored.
1046
 
 
1047
 
        If the file is ignored, returns the pattern which caused it to
1048
 
        be ignored, otherwise None.  So this can simply be used as a
1049
 
        boolean if desired."""
1050
 
        if getattr(self, '_ignoreglobster', None) is None:
1051
 
            self._ignoreglobster = globbing.ExceptionGlobster(self.get_ignore_list())
1052
 
        return self._ignoreglobster.match(filename)
 
1012
        """
 
1013
        raise NotImplementedError(self.is_ignored)
1053
1014
 
1054
1015
    def kind(self, file_id):
1055
1016
        return osutils.file_kind(self.id2abspath(file_id))
1157
1118
        :force: Delete files and directories, even if they are changed and
1158
1119
            even if the directories are not empty.
1159
1120
        """
1160
 
        if isinstance(files, basestring):
 
1121
        if isinstance(files, (str, text_type)):
1161
1122
            files = [files]
1162
1123
 
1163
1124
        inv_delta = []