Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG9adfa48792a7: match: some minimal pycompat fixes guided by test-hgignore.t
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/match.py (5 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Abandoned | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Abandoned | durin42 |
import os | import os | ||||
import re | import re | ||||
from .i18n import _ | from .i18n import _ | ||||
from . import ( | from . import ( | ||||
encoding, | encoding, | ||||
error, | error, | ||||
pathutil, | pathutil, | ||||
pycompat, | |||||
util, | util, | ||||
) | ) | ||||
allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', | allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', | ||||
'listfile', 'listfile0', 'set', 'include', 'subinclude', | 'listfile', 'listfile0', 'set', 'include', 'subinclude', | ||||
'rootfilesin') | 'rootfilesin') | ||||
cwdrelativepatternkinds = ('relpath', 'glob') | cwdrelativepatternkinds = ('relpath', 'glob') | ||||
for k, p, source in _donormalize(includepats, default, | for k, p, source in _donormalize(includepats, default, | ||||
root, cwd, auditor, warn): | root, cwd, auditor, warn): | ||||
kindpats.append((k, p, source or pat)) | kindpats.append((k, p, source or pat)) | ||||
except error.Abort as inst: | except error.Abort as inst: | ||||
raise error.Abort('%s: %s' % (pat, inst[0])) | raise error.Abort('%s: %s' % (pat, inst[0])) | ||||
except IOError as inst: | except IOError as inst: | ||||
if warn: | if warn: | ||||
warn(_("skipping unreadable pattern file '%s': %s\n") % | warn(_("skipping unreadable pattern file '%s': %s\n") % | ||||
(pat, inst.strerror)) | (pat, util.forcebytestr(inst.strerror))) | ||||
continue | continue | ||||
# else: re or relre - which cannot be normalized | # else: re or relre - which cannot be normalized | ||||
kindpats.append((kind, pat, '')) | kindpats.append((kind, pat, '')) | ||||
return kindpats | return kindpats | ||||
class basematcher(object): | class basematcher(object): | ||||
def __init__(self, root, cwd, badfn=None, relativeuipath=True): | def __init__(self, root, cwd, badfn=None, relativeuipath=True): | ||||
return ('.' in self._roots or | return ('.' in self._roots or | ||||
dir in self._roots or | dir in self._roots or | ||||
dir in self._dirs or | dir in self._dirs or | ||||
any(parentdir in self._roots | any(parentdir in self._roots | ||||
for parentdir in util.finddirs(dir))) | for parentdir in util.finddirs(dir))) | ||||
@encoding.strmethod | @encoding.strmethod | ||||
def __repr__(self): | def __repr__(self): | ||||
return ('<includematcher includes=%r>' % self._pats) | return ('<includematcher includes=%r>' % pycompat.bytestr(self._pats)) | ||||
class exactmatcher(basematcher): | class exactmatcher(basematcher): | ||||
'''Matches the input files exactly. They are interpreted as paths, not | '''Matches the input files exactly. They are interpreted as paths, not | ||||
patterns (so no kind-prefixes). | patterns (so no kind-prefixes). | ||||
''' | ''' | ||||
def __init__(self, root, cwd, files, badfn=None): | def __init__(self, root, cwd, files, badfn=None): | ||||
super(exactmatcher, self).__init__(root, cwd, badfn) | super(exactmatcher, self).__init__(root, cwd, badfn) |