69
67
from .i18n import gettext
70
68
from . import mutabletree
71
69
from .mutabletree import needs_tree_write_lock
72
73
from .trace import mutter, note
1010
1007
if pat is not None:
1011
1008
yield subp, pat
1013
def get_ignore_list(self):
1014
"""Return list of ignore patterns.
1016
Cached in the Tree object after the first call.
1018
ignoreset = getattr(self, '_ignoreset', None)
1019
if ignoreset is not None:
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)
1028
ignore_globs.update(ignores.parse_ignore_file(f))
1031
self._ignoreset = ignore_globs
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
1039
1010
def is_ignored(self, filename):
1040
1011
r"""Check whether the filename matches an ignore pattern.
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.
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)
1013
raise NotImplementedError(self.is_ignored)
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.
1160
if isinstance(files, basestring):
1121
if isinstance(files, (str, text_type)):
1161
1122
files = [files]