Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmutil.py @ 21111:9d28fd795215
match: improve documentation - docstrings and more descriptive variable naming
No real changes.
pattern: 'kind:pat' as specified on the command line
patterns, pats: list of patterns
kind: 'path', 'glob' or 're' or ...
pat: string in the corresponding 'kind' format
kindpats: list of (kind, pat) tuples
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 03 Oct 2013 18:01:21 +0200 |
parents | 6fb4c94ae300 |
children | 764b691b8bda |
line wrap: on
line diff
--- a/mercurial/scmutil.py Wed Mar 05 15:55:09 2014 -0800 +++ b/mercurial/scmutil.py Thu Oct 03 18:01:21 2013 +0200 @@ -564,23 +564,27 @@ return l def expandpats(pats): + '''Expand bare globs when running on windows. + On posix we assume it already has already been done by sh.''' if not util.expandglobs: return list(pats) ret = [] - for p in pats: - kind, name = matchmod._patsplit(p, None) + for kindpat in pats: + kind, pat = matchmod._patsplit(kindpat, None) if kind is None: try: - globbed = glob.glob(name) + globbed = glob.glob(pat) except re.error: - globbed = [name] + globbed = [pat] if globbed: ret.extend(globbed) continue - ret.append(p) + ret.append(kindpat) return ret def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'): + '''Return a matcher and the patterns that were used. + The matcher will warn about bad matches.''' if pats == ("",): pats = [] if not globbed and default == 'relpath': @@ -594,12 +598,15 @@ return m, pats def match(ctx, pats=[], opts={}, globbed=False, default='relpath'): + '''Return a matcher that will warn about bad matches.''' return matchandpats(ctx, pats, opts, globbed, default)[0] def matchall(repo): + '''Return a matcher that will efficiently match everything.''' return matchmod.always(repo.root, repo.getcwd()) def matchfiles(repo, files): + '''Return a matcher that will efficiently match exactly these files.''' return matchmod.exact(repo.root, repo.getcwd(), files) def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):