310 if opts.get('default'): |
310 if opts.get('default'): |
311 kwstatus = 'default' |
311 kwstatus = 'default' |
312 kwmaps = kwtemplater.templates |
312 kwmaps = kwtemplater.templates |
313 if ui.configitems('keywordmaps'): |
313 if ui.configitems('keywordmaps'): |
314 # override maps from optional rcfile |
314 # override maps from optional rcfile |
315 for k, v in kwmaps.items(): |
315 for k, v in kwmaps.iteritems(): |
316 ui.setconfig('keywordmaps', k, v) |
316 ui.setconfig('keywordmaps', k, v) |
317 elif args: |
317 elif args: |
318 # simulate hgrc parsing |
318 # simulate hgrc parsing |
319 rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args] |
319 rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args] |
320 fp = repo.opener('hgrc', 'w') |
320 fp = repo.opener('hgrc', 'w') |
329 extension = '%s = %s' % (k, v) |
329 extension = '%s = %s' % (k, v) |
330 break |
330 break |
331 demostatus('config using %s keyword template maps' % kwstatus) |
331 demostatus('config using %s keyword template maps' % kwstatus) |
332 ui.write('[extensions]\n%s\n' % extension) |
332 ui.write('[extensions]\n%s\n' % extension) |
333 demoitems('keyword', ui.configitems('keyword')) |
333 demoitems('keyword', ui.configitems('keyword')) |
334 demoitems('keywordmaps', kwmaps.items()) |
334 demoitems('keywordmaps', kwmaps.iteritems()) |
335 keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n' |
335 keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n' |
336 repo.wopener(fn, 'w').write(keywords) |
336 repo.wopener(fn, 'w').write(keywords) |
337 repo.add([fn]) |
337 repo.add([fn]) |
338 path = repo.wjoin(fn) |
338 path = repo.wjoin(fn) |
339 ui.note(_('\n%s keywords written to %s:\n') % (kwstatus, path)) |
339 ui.note(_('\n%s keywords written to %s:\n') % (kwstatus, path)) |
464 _p1 = _p2 = None |
464 _p1 = _p2 = None |
465 try: |
465 try: |
466 wlock = self.wlock() |
466 wlock = self.wlock() |
467 lock = self.lock() |
467 lock = self.lock() |
468 # store and postpone commit hooks |
468 # store and postpone commit hooks |
469 commithooks = [] |
469 commithooks = {} |
470 for name, cmd in ui.configitems('hooks'): |
470 for name, cmd in ui.configitems('hooks'): |
471 if name.split('.', 1)[0] == 'commit': |
471 if name.split('.', 1)[0] == 'commit': |
472 commithooks.append((name, cmd)) |
472 commithooks[name] = cmd |
473 ui.setconfig('hooks', name, None) |
473 ui.setconfig('hooks', name, None) |
474 if commithooks: |
474 if commithooks: |
475 # store parents for commit hook environment |
475 # store parents for commit hook environment |
476 if p1 is None: |
476 if p1 is None: |
477 _p1, _p2 = repo.dirstate.parents() |
477 _p1, _p2 = repo.dirstate.parents() |
488 date=date, match=match, force=force, |
488 date=date, match=match, force=force, |
489 force_editor=force_editor, |
489 force_editor=force_editor, |
490 p1=p1, p2=p2, extra=extra) |
490 p1=p1, p2=p2, extra=extra) |
491 |
491 |
492 # restore commit hooks |
492 # restore commit hooks |
493 for name, cmd in commithooks: |
493 for name, cmd in commithooks.iteritems(): |
494 ui.setconfig('hooks', name, cmd) |
494 ui.setconfig('hooks', name, cmd) |
495 if node is not None: |
495 if node is not None: |
496 _overwrite(ui, self, node=node) |
496 _overwrite(ui, self, node=node) |
497 repo.hook('commit', node=node, parent1=_p1, parent2=_p2) |
497 repo.hook('commit', node=node, parent1=_p1, parent2=_p2) |
498 return node |
498 return node |