Mercurial > hg
changeset 5946:ee0dc0f3804b
keyword: improve use of dicts
- actually use iteritems() when we iter over items of a dictionary
- store commit hooks in dictionary
(safe, as hook.hook() sorts before execution)
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Tue, 22 Jan 2008 13:12:43 +0100 |
parents | 7f593d7fccce |
children | 597d8402087d |
files | hgext/keyword.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/keyword.py Wed Jan 23 10:39:19 2008 +0100 +++ b/hgext/keyword.py Tue Jan 22 13:12:43 2008 +0100 @@ -310,7 +310,7 @@ kwmaps = kwtemplater.templates if ui.configitems('keywordmaps'): # override maps from optional rcfile - for k, v in kwmaps.items(): + for k, v in kwmaps.iteritems(): ui.setconfig('keywordmaps', k, v) elif args: # simulate hgrc parsing @@ -329,7 +329,7 @@ demostatus('config using %s keyword template maps' % kwstatus) ui.write('[extensions]\n%s\n' % extension) demoitems('keyword', ui.configitems('keyword')) - demoitems('keywordmaps', kwmaps.items()) + demoitems('keywordmaps', kwmaps.iteritems()) keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n' repo.wopener(fn, 'w').write(keywords) repo.add([fn]) @@ -464,10 +464,10 @@ wlock = self.wlock() lock = self.lock() # store and postpone commit hooks - commithooks = [] + commithooks = {} for name, cmd in ui.configitems('hooks'): if name.split('.', 1)[0] == 'commit': - commithooks.append((name, cmd)) + commithooks[name] = cmd ui.setconfig('hooks', name, None) if commithooks: # store parents for commit hook environment @@ -488,7 +488,7 @@ p1=p1, p2=p2, extra=extra) # restore commit hooks - for name, cmd in commithooks: + for name, cmd in commithooks.iteritems(): ui.setconfig('hooks', name, cmd) if node is not None: _overwrite(ui, self, node=node)