equal
deleted
inserted
replaced
103 raise commands.ParseError(None, inst) |
103 raise commands.ParseError(None, inst) |
104 if args: |
104 if args: |
105 cmd = args[0] |
105 cmd = args[0] |
106 aliases, i = findcmd(ui, cmd) |
106 aliases, i = findcmd(ui, cmd) |
107 return aliases[0] |
107 return aliases[0] |
|
108 |
|
109 def keywordmatcher(ui, repo): |
|
110 '''Collects include/exclude filename patterns for expansion |
|
111 candidates of current configuration. Returns filename matching |
|
112 function if include patterns exist, None otherwise.''' |
|
113 inc, exc = [], ['.hg*'] |
|
114 for pat, opt in ui.configitems('keyword'): |
|
115 if opt != 'ignore': |
|
116 inc.append(pat) |
|
117 else: |
|
118 exc.append(pat) |
|
119 if not inc: |
|
120 return None |
|
121 return util.matcher(repo.root, inc=inc, exc=exc)[1] |
108 |
122 |
109 class kwtemplater(object): |
123 class kwtemplater(object): |
110 ''' |
124 ''' |
111 Sets up keyword templates, corresponding keyword regex, and |
125 Sets up keyword templates, corresponding keyword regex, and |
112 provides keyword substitution functions. |
126 provides keyword substitution functions. |
239 ui.status(_('\n%s keywords expanded:\n') % kwstatus) |
253 ui.status(_('\n%s keywords expanded:\n') % kwstatus) |
240 ui.write(_repo.wread(fn)) |
254 ui.write(_repo.wread(fn)) |
241 ui.debug(_('\nremoving temporary repo\n')) |
255 ui.debug(_('\nremoving temporary repo\n')) |
242 shutil.rmtree(tmpdir) |
256 shutil.rmtree(tmpdir) |
243 |
257 |
|
258 |
244 def reposetup(ui, repo): |
259 def reposetup(ui, repo): |
245 '''Sets up repo as kwrepo for keyword substitution. |
260 '''Sets up repo as kwrepo for keyword substitution. |
246 Overrides file method to return kwfilelog instead of filelog |
261 Overrides file method to return kwfilelog instead of filelog |
247 if file matches user configuration. |
262 if file matches user configuration. |
248 Wraps commit to overwrite configured files with updated |
263 Wraps commit to overwrite configured files with updated |
251 files configured at all for keyword substitution.''' |
266 files configured at all for keyword substitution.''' |
252 |
267 |
253 if not repo.local() or getcmd(repo.ui) in nokwcommands: |
268 if not repo.local() or getcmd(repo.ui) in nokwcommands: |
254 return |
269 return |
255 |
270 |
256 inc, exc = [], ['.hg*'] |
271 kwfmatcher = keywordmatcher(ui, repo) |
257 for pat, opt in repo.ui.configitems('keyword'): |
272 if kwfmatcher is None: |
258 if opt != 'ignore': |
|
259 inc.append(pat) |
|
260 else: |
|
261 exc.append(pat) |
|
262 if not inc: |
|
263 return |
273 return |
264 |
274 |
265 kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
|
266 ui = repo.ui |
275 ui = repo.ui |
267 |
276 |
268 class kwrepo(repo.__class__): |
277 class kwrepo(repo.__class__): |
269 def file(self, f): |
278 def file(self, f): |
270 if f[0] == '/': |
279 if f[0] == '/': |
300 and f not in removed |
309 and f not in removed |
301 and not os.path.islink(self.wjoin(f))] |
310 and not os.path.islink(self.wjoin(f))] |
302 if candidates: |
311 if candidates: |
303 kwt = kwtemplater(ui, self, node=node) |
312 kwt = kwtemplater(ui, self, node=node) |
304 kwt.overwrite(candidates, cl[0]) |
313 kwt.overwrite(candidates, cl[0]) |
305 |
|
306 return node |
314 return node |
307 finally: |
315 finally: |
308 if wrelease: |
316 if wrelease: |
309 wlock.release() |
317 wlock.release() |
310 |
318 |