# HG changeset patch # User Christian Ebert # Date 1201078420 -3600 # Node ID 2c2b49def9d8e3b8ddd4670dec6f2bbc111fc353 # Parent af2da5e499f27469bee342009b5d517d22fd53e0 Improve use of dictionaries - iteritems() where we do iter over dicts' items - store commithooks in dictionary (safe, as hook.hook() sorts before execution) diff -r af2da5e499f2 -r 2c2b49def9d8 hgkw/keyword.py --- a/hgkw/keyword.py Wed Jan 23 10:02:57 2008 +0100 +++ b/hgkw/keyword.py Wed Jan 23 09:53:40 2008 +0100 @@ -312,7 +312,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 @@ -331,7 +331,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]) @@ -466,10 +466,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 @@ -490,7 +490,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)