Mercurial > hg-stable
comparison mercurial/cmdutil.py @ 6578:f242d3684f83
walk: begin refactoring badmatch handling
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 12 May 2008 11:37:07 -0500 |
parents | 569761919450 |
children | 0159b7a36184 |
comparison
equal
deleted
inserted
replaced
6577:569761919450 | 6578:f242d3684f83 |
---|---|
226 def matchpats(repo, pats=[], opts={}, globbed=False, default='relpath'): | 226 def matchpats(repo, pats=[], opts={}, globbed=False, default='relpath'): |
227 if not globbed and default == 'relpath': | 227 if not globbed and default == 'relpath': |
228 pats = util.expand_glob(pats or []) | 228 pats = util.expand_glob(pats or []) |
229 m = match.match(repo.root, repo.getcwd(), pats, opts.get('include'), | 229 m = match.match(repo.root, repo.getcwd(), pats, opts.get('include'), |
230 opts.get('exclude'), default) | 230 opts.get('exclude'), default) |
231 def badfn(f, msg): | |
232 repo.ui.warn("%s: %s\n" % (m.rel(f), msg)) | |
233 return False | |
234 m.bad = badfn | |
231 return m.files(), m, m.anypats() | 235 return m.files(), m, m.anypats() |
232 | 236 |
233 def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, | 237 def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False, |
234 default='relpath'): | 238 default='relpath'): |
235 dummy, m, dummy = matchpats(repo, pats, opts, globbed, default) | 239 dummy, m, dummy = matchpats(repo, pats, opts, globbed, default) |
236 for src, fn in repo.walk(node, m, badmatch): | 240 if badmatch: |
241 m.bad = badmatch | |
242 for src, fn in repo.walk(node, m): | |
237 yield src, fn, m.rel(fn), m.exact(fn) | 243 yield src, fn, m.rel(fn), m.exact(fn) |
238 | 244 |
239 def findrenames(repo, added=None, removed=None, threshold=0.5): | 245 def findrenames(repo, added=None, removed=None, threshold=0.5): |
240 '''find renamed files -- yields (before, after, score) tuples''' | 246 '''find renamed files -- yields (before, after, score) tuples''' |
241 if added is None or removed is None: | 247 if added is None or removed is None: |