comparison mercurial/dirstate.py @ 27594:0921caca7703

dirstate: extract logic to compute the list of ignorefiles We are going to reuse this logic to improve debugignore in the next patches of the series.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 23 Dec 2015 11:52:54 -0800
parents bc97b9af4e62
children 4374f039d269
comparison
equal deleted inserted replaced
27593:bc97b9af4e62 27594:0921caca7703
201 def dirs(self): 201 def dirs(self):
202 return self._dirs 202 return self._dirs
203 203
204 @rootcache('.hgignore') 204 @rootcache('.hgignore')
205 def _ignore(self): 205 def _ignore(self):
206 files = [] 206 files = self._ignorefiles()
207 if os.path.exists(self._join('.hgignore')):
208 files.append(self._join('.hgignore'))
209 for name, path in self._ui.configitems("ui"):
210 if name == 'ignore' or name.startswith('ignore.'):
211 # we need to use os.path.join here rather than self._join
212 # because path is arbitrary and user-specified
213 files.append(os.path.join(self._rootdir, util.expandpath(path)))
214
215 if not files: 207 if not files:
216 return util.never 208 return util.never
217 209
218 pats = ['include:%s' % f for f in files] 210 pats = ['include:%s' % f for f in files]
219 return matchmod.match(self._root, '', [], pats, warn=self._ui.warn) 211 return matchmod.match(self._root, '', [], pats, warn=self._ui.warn)
771 return True 763 return True
772 for p in util.finddirs(f): 764 for p in util.finddirs(f):
773 if self._ignore(p): 765 if self._ignore(p):
774 return True 766 return True
775 return False 767 return False
768
769 def _ignorefiles(self):
770 files = []
771 if os.path.exists(self._join('.hgignore')):
772 files.append(self._join('.hgignore'))
773 for name, path in self._ui.configitems("ui"):
774 if name == 'ignore' or name.startswith('ignore.'):
775 # we need to use os.path.join here rather than self._join
776 # because path is arbitrary and user-specified
777 files.append(os.path.join(self._rootdir, util.expandpath(path)))
778 return files
776 779
777 def _walkexplicit(self, match, subrepos): 780 def _walkexplicit(self, match, subrepos):
778 '''Get stat data about the files explicitly specified by match. 781 '''Get stat data about the files explicitly specified by match.
779 782
780 Return a triple (results, dirsfound, dirsnotfound). 783 Return a triple (results, dirsfound, dirsnotfound).