changeset 481:65e38d33acae

python/hgrc.py
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 10 Aug 2013 20:42:04 -0700
parents 529fd4e1087e
children 6c0aac8799da
files python/hgrc.py
diffstat 1 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/python/hgrc.py	Sat Aug 10 20:35:50 2013 -0700
+++ b/python/hgrc.py	Sat Aug 10 20:42:04 2013 -0700
@@ -90,15 +90,16 @@
 
     # if not specified, set a default action
     default_action = 'default_push_ssh'
-    available_actions = ('default_push',
-                        'default_push_ssh',
-                        'list_hgrc',
+    available_actions = ('default',
+                         'default_push',
+                         'default_push_ssh',
+                         'list_hgrc',
                         )
-    actions = dict([(name, getattr(options, name))
-                    for name in available_actions
-                    if getattr(options, name)])
+    actions = [(name, getattr(options, name))
+               for name in available_actions
+               if getattr(options, name)])
     if not actions:
-        actions = {'default_push_ssh': True}
+        actions = [('default_push_ssh', True)]
 
     # find all hgrc files
     hgrc = []
@@ -148,9 +149,12 @@
                 config[path].read(path)
 
     # print the chosen hgrc paths
-    if actions.pop('list_hgrc', None):
+    if options.list_hgrc:
         print '\n'.join(hgrc)
 
+        # TODO -> OrderedDict
+        actions.pop('list_hgrc', None):
+
     # map of actions -> functions;
     # XXX this is pretty improv; to be improved
     action_map = {'default_push_ssh': set_default_push_to_ssh,
@@ -158,18 +162,17 @@
                   }
 
     # alter .hgrc files
-    action_names = actions.keys()
-    while actions:
+    for action_name, parameter in actions:
 
         # XXX crappy
-        action_name = action_names.pop()
-        parameter = actions.pop(action_name)
         method = action_map[action_name]
         if action_name == 'default_push_ssh':
             parameter = None
 
         # apply to all files
         for path, ini in config.items():
+
+            # call method with parser
             if parameter is not None:
                 method(ini, parameter)
             else: