# HG changeset patch # User Marcin Kasperski # Date 1446967754 -3600 # Node ID b1d440f1027a0fef4d5c6202abfc905f787dbeec # Parent 0c3ddf5c1a3f9c6792a285e68b8d79904ad6272a (internal) Changed the way in which extension options are separated: pop own flags and pass-on the rest. This way in case push options change, fix must be made in one place only. Also, dropped *args as no non-named arguments can be given. (internal) Make pylint happier diff -r 0c3ddf5c1a3f -r b1d440f1027a .hgignore --- a/.hgignore Sun Nov 08 08:26:34 2015 +0100 +++ b/.hgignore Sun Nov 08 08:29:14 2015 +0100 @@ -6,5 +6,5 @@ *.err build dist -.egg-info +*.egg-info README.html diff -r 0c3ddf5c1a3f -r b1d440f1027a allpaths.py --- a/allpaths.py Sun Nov 08 08:26:34 2015 +0100 +++ b/allpaths.py Sun Nov 08 08:29:14 2015 +0100 @@ -9,18 +9,16 @@ import mercurial.commands from mercurial.i18n import _ -push_flags = ['force', 'rev', 'bookmark', 'branch', 'new-branch'] +#pylint:disable=invalid-name,broad-except,line-too-long -def pushall(ui, repo, *args, **opts): + +def pushall(ui, repo, **opts): """execute a push command on multiple paths""" - # Filter options that should be passed on to `push`. - push_opts = {} - for key in opts: - if key in push_flags: - push_opts[key] = opts[key] + # Extract our options and filter them out + group = opts.pop('group', None) + ignore_errors = opts.pop('ignore_errors', None) # Get the paths to push to. - group = opts.get('group') paths = ui.configitems(group) if not paths: raise mercurial.util.Abort(_('No paths defined in section %s') % group) @@ -28,25 +26,24 @@ # Push! for path in paths: try: - mercurial.commands.push(ui, repo, path[1], **push_opts) + mercurial.commands.push(ui, repo, path[1], **opts) except Exception as e: - if not opts.get('ignore_errors'): + if not ignore_errors: raise ui.warn(_('error pushing to %s: %s') % (path[1], e)) cmdtable = { - "pushall": - ( - pushall, - [ - ('g', 'group', 'paths', _('use a named group of paths')), - ('', 'ignore-errors', None, _('continue execution despite errors')), - ('f', 'force', None, _('force push')), - ('r', 'rev', [], _('a changeset intended to be included in the destination'), _('REV')), - ('B', 'bookmark', [], _('bookmark to push'), _('BOOKMARK')), - ('b', 'branch', [], _('a specific branch you would like to push'), _('BRANCH')), - ('', 'new-branch', False, _('allow pushing a new branch')) - ], - _('[-g GROUP] [--ignore-errors] ')) - } + "pushall": ( + pushall, + [ + ('g', 'group', 'paths', _('use a named group of paths')), + ('', 'ignore-errors', None, _('continue execution despite errors')), + ('f', 'force', None, _('force push')), + ('r', 'rev', [], _('a changeset intended to be included in the destination'), _('REV')), + ('B', 'bookmark', [], _('bookmark to push'), _('BOOKMARK')), + ('b', 'branch', [], _('a specific branch you would like to push'), _('BRANCH')), + ('', 'new-branch', False, _('allow pushing a new branch')) + ], + _('[-g GROUP] [--ignore-errors] ')) +}