comparison allpaths.py @ 6:b1d440f1027a

(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
author Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
date Sun, 08 Nov 2015 08:29:14 +0100
parents f8703c9e2fb9
children 1ea915867337
comparison
equal deleted inserted replaced
5:0c3ddf5c1a3f 6:b1d440f1027a
7 7
8 import mercurial.util 8 import mercurial.util
9 import mercurial.commands 9 import mercurial.commands
10 from mercurial.i18n import _ 10 from mercurial.i18n import _
11 11
12 push_flags = ['force', 'rev', 'bookmark', 'branch', 'new-branch'] 12 #pylint:disable=invalid-name,broad-except,line-too-long
13 13
14 def pushall(ui, repo, *args, **opts): 14
15 def pushall(ui, repo, **opts):
15 """execute a push command on multiple paths""" 16 """execute a push command on multiple paths"""
16 # Filter options that should be passed on to `push`. 17 # Extract our options and filter them out
17 push_opts = {} 18 group = opts.pop('group', None)
18 for key in opts: 19 ignore_errors = opts.pop('ignore_errors', None)
19 if key in push_flags:
20 push_opts[key] = opts[key]
21 20
22 # Get the paths to push to. 21 # Get the paths to push to.
23 group = opts.get('group')
24 paths = ui.configitems(group) 22 paths = ui.configitems(group)
25 if not paths: 23 if not paths:
26 raise mercurial.util.Abort(_('No paths defined in section %s') % group) 24 raise mercurial.util.Abort(_('No paths defined in section %s') % group)
27 25
28 # Push! 26 # Push!
29 for path in paths: 27 for path in paths:
30 try: 28 try:
31 mercurial.commands.push(ui, repo, path[1], **push_opts) 29 mercurial.commands.push(ui, repo, path[1], **opts)
32 except Exception as e: 30 except Exception as e:
33 if not opts.get('ignore_errors'): 31 if not ignore_errors:
34 raise 32 raise
35 ui.warn(_('error pushing to %s: %s') % (path[1], e)) 33 ui.warn(_('error pushing to %s: %s') % (path[1], e))
36 34
37 35
38 cmdtable = { 36 cmdtable = {
39 "pushall": 37 "pushall": (
40 ( 38 pushall,
41 pushall, 39 [
42 [ 40 ('g', 'group', 'paths', _('use a named group of paths')),
43 ('g', 'group', 'paths', _('use a named group of paths')), 41 ('', 'ignore-errors', None, _('continue execution despite errors')),
44 ('', 'ignore-errors', None, _('continue execution despite errors')), 42 ('f', 'force', None, _('force push')),
45 ('f', 'force', None, _('force push')), 43 ('r', 'rev', [], _('a changeset intended to be included in the destination'), _('REV')),
46 ('r', 'rev', [], _('a changeset intended to be included in the destination'), _('REV')), 44 ('B', 'bookmark', [], _('bookmark to push'), _('BOOKMARK')),
47 ('B', 'bookmark', [], _('bookmark to push'), _('BOOKMARK')), 45 ('b', 'branch', [], _('a specific branch you would like to push'), _('BRANCH')),
48 ('b', 'branch', [], _('a specific branch you would like to push'), _('BRANCH')), 46 ('', 'new-branch', False, _('allow pushing a new branch'))
49 ('', 'new-branch', False, _('allow pushing a new branch')) 47 ],
50 ], 48 _('[-g GROUP] [--ignore-errors] <push options>'))
51 _('[-g GROUP] [--ignore-errors] <push options>')) 49 }
52 }