# HG changeset patch # User Jeff Hammel # Date 1376192524 25200 # Node ID 65e38d33acaea76d84ab92ef3d0bda805a84e8ef # Parent 529fd4e1087eee44d37dfecf9e99cda470b46719 python/hgrc.py diff -r 529fd4e1087e -r 65e38d33acae python/hgrc.py --- 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: