123 return pat |
123 return pat |
124 return open(make_filename(repo, pat, node, total, seqno, revwidth, |
124 return open(make_filename(repo, pat, node, total, seqno, revwidth, |
125 pathname), |
125 pathname), |
126 mode) |
126 mode) |
127 |
127 |
128 def matchpats(repo, pats=[], opts={}, head=''): |
128 def matchpats(repo, pats=[], opts={}, head='', globbed=False): |
129 cwd = repo.getcwd() |
129 cwd = repo.getcwd() |
130 if not pats and cwd: |
130 if not pats and cwd: |
131 opts['include'] = [os.path.join(cwd, i) |
131 opts['include'] = [os.path.join(cwd, i) |
132 for i in opts.get('include', [])] |
132 for i in opts.get('include', [])] |
133 opts['exclude'] = [os.path.join(cwd, x) |
133 opts['exclude'] = [os.path.join(cwd, x) |
134 for x in opts.get('exclude', [])] |
134 for x in opts.get('exclude', [])] |
135 cwd = '' |
135 cwd = '' |
136 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
136 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
137 opts.get('exclude'), head) |
137 opts.get('exclude'), head, globbed=globbed) |
138 |
138 |
139 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None): |
139 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None, |
140 files, matchfn, anypats = matchpats(repo, pats, opts, head) |
140 globbed=False): |
|
141 files, matchfn, anypats = matchpats(repo, pats, opts, head, |
|
142 globbed=globbed) |
141 exact = dict.fromkeys(files) |
143 exact = dict.fromkeys(files) |
142 for src, fn in repo.walk(node=node, files=files, match=matchfn, |
144 for src, fn in repo.walk(node=node, files=files, match=matchfn, |
143 badmatch=badmatch): |
145 badmatch=badmatch): |
144 yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact |
146 yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact |
145 |
147 |