Improve use of dictionaries
- iteritems() where we do iter over dicts' items
- store commithooks in dictionary
(safe, as hook.hook() sorts before execution)
--- 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)