comparison allpaths.py @ 0:6f92e4c814d1

Initial commit.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 19 Feb 2013 17:29:34 -0800
parents
children f8703c9e2fb9
comparison
equal deleted inserted replaced
-1:000000000000 0:6f92e4c814d1
1 # allpaths.py - execute commands on multiple paths
2 #
3 # This software may be used and distributed according to the terms of
4 # the GNU General Public License version 2 or any later version.
5
6 '''execute commands on multiple paths'''
7
8 import mercurial.util
9 import mercurial.commands
10 from mercurial.i18n import _
11
12 push_flags = ['force', 'rev', 'bookmark', 'branch', 'new-branch']
13
14 def pushall(ui, repo, *args, **opts):
15 """execute a push command on multiple paths"""
16 # Filter options that should be passed on to `push`.
17 push_opts = {}
18 for key in opts:
19 if key in push_flags:
20 push_opts[key] = opts[key]
21
22 # Get the paths to push to.
23 group = opts.get('group')
24 paths = ui.configitems(group)
25 if not paths:
26 raise mercurial.util.Abort(_('No paths defined in section %s') % group)
27
28 # Push!
29 for path in paths:
30 try:
31 mercurial.commands.push(ui, repo, **push_opts)
32 except Exception as e:
33 if not opts.get('ignore_errors'):
34 raise
35 ui.warn(_('error pushing to %s: %s') % (path, e))
36
37
38 cmdtable = {
39 "pushall":
40 (
41 pushall,
42 [
43 ('g', 'group', 'paths', _('use a named group of paths')),
44 ('', 'ignore-errors', None, _('continue execution despite errors')),
45 ('f', 'force', None, _('force push')),
46 ('r', 'rev', [], _('a changeset intended to be included in the destination'), _('REV')),
47 ('B', 'bookmark', [], _('bookmark to push'), _('BOOKMARK')),
48 ('b', 'branch', [], _('a specific branch you would like to push'), _('BRANCH')),
49 ('', 'new-branch', False, _('allow pushing a new branch'))
50 ],
51 _('[-g GROUP] [--ignore-errors] <push options>'))
52 }