Mercurial > hg-allpaths
annotate 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 |
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 | |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
12 #pylint:disable=invalid-name,broad-except,line-too-long |
0 | 13 |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
14 |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
15 def pushall(ui, repo, **opts): |
0 | 16 """execute a push command on multiple paths""" |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
17 # Extract our options and filter them out |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
18 group = opts.pop('group', None) |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
19 ignore_errors = opts.pop('ignore_errors', None) |
0 | 20 |
21 # Get the paths to push to. | |
22 paths = ui.configitems(group) | |
23 if not paths: | |
24 raise mercurial.util.Abort(_('No paths defined in section %s') % group) | |
25 | |
26 # Push! | |
27 for path in paths: | |
28 try: | |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
29 mercurial.commands.push(ui, repo, path[1], **opts) |
0 | 30 except Exception as e: |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
31 if not ignore_errors: |
0 | 32 raise |
1
f8703c9e2fb9
D'oh, actually push to the correct path.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
33 ui.warn(_('error pushing to %s: %s') % (path[1], e)) |
0 | 34 |
35 | |
36 cmdtable = { | |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
37 "pushall": ( |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
38 pushall, |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
39 [ |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
40 ('g', 'group', 'paths', _('use a named group of paths')), |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
41 ('', 'ignore-errors', None, _('continue execution despite errors')), |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
42 ('f', 'force', None, _('force push')), |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
43 ('r', 'rev', [], _('a changeset intended to be included in the destination'), _('REV')), |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
44 ('B', 'bookmark', [], _('bookmark to push'), _('BOOKMARK')), |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
45 ('b', 'branch', [], _('a specific branch you would like to push'), _('BRANCH')), |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
46 ('', 'new-branch', False, _('allow pushing a new branch')) |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
47 ], |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
48 _('[-g GROUP] [--ignore-errors] <push options>')) |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
49 } |