Mercurial > hg-allpaths
annotate allpaths.py @ 5:0c3ddf5c1a3f
One more README syntax tweak
author | Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl> |
---|---|
date | Sun, 08 Nov 2015 08:26:34 +0100 |
parents | f8703c9e2fb9 |
children | b1d440f1027a |
rev | line source |
---|---|
0 | 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: | |
1
f8703c9e2fb9
D'oh, actually push to the correct path.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
31 mercurial.commands.push(ui, repo, path[1], **push_opts) |
0 | 32 except Exception as e: |
33 if not opts.get('ignore_errors'): | |
34 raise | |
1
f8703c9e2fb9
D'oh, actually push to the correct path.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
35 ui.warn(_('error pushing to %s: %s') % (path[1], e)) |
0 | 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 } |