Mercurial > hg-allpaths
annotate allpaths.py @ 8:eced61373a74
Added pullall
author | Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl> |
---|---|
date | Sun, 08 Nov 2015 08:50:25 +0100 |
parents | 1ea915867337 |
children | dac7580bfff2 |
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 | |
7
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
10 import mercurial.cmdutil |
0 | 11 from mercurial.i18n import _ |
12 | |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
13 #pylint:disable=invalid-name,broad-except,line-too-long |
0 | 14 |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
15 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
16 def _iter_over_paths(command, ui, repo, **opts): |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
17 """execute given 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
|
18 # 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
|
19 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
|
20 ignore_errors = opts.pop('ignore_errors', None) |
0 | 21 |
22 # Get the paths to push to. | |
23 paths = ui.configitems(group) | |
24 if not paths: | |
25 raise mercurial.util.Abort(_('No paths defined in section %s') % group) | |
26 | |
27 # Push! | |
28 for path in paths: | |
29 try: | |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
30 command(ui, repo, path[1], **opts) |
0 | 31 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
|
32 if not ignore_errors: |
0 | 33 raise |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
34 ui.warn(_('error handling %s: %s') % (path[1], e)) |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
35 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
36 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
37 def pushall(ui, repo, **opts): |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
38 """execute pull on multiple paths""" |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
39 _iter_over_paths(mercurial.commands.push, ui, repo, **opts) |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
40 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
41 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
42 def pullall(ui, repo, **opts): |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
43 """execute push on multiple paths""" |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
44 _iter_over_paths(mercurial.commands.pull, ui, repo, **opts) |
0 | 45 |
46 | |
7
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
47 def _original_options(cmdname): |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
48 """Gets list of given command options as specified in Mercurial core""" |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
49 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
50 return spec[1] |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
51 |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
52 |
0 | 53 cmdtable = { |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
54 "pushall": ( |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
55 pushall, |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
56 [ |
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
57 ('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
|
58 ('', 'ignore-errors', None, _('continue execution despite errors')), |
7
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
59 ] + _original_options('push'), |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
60 _('[-g GROUP] [--ignore-errors] <push options>')), |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
61 "pullall": ( |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
62 pullall, |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
63 [ |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
64 ('g', 'group', 'paths', _('use a named group of paths')), |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
65 ('', 'ignore-errors', None, _('continue execution despite errors')), |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
66 ] + _original_options('pull'), |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
67 _('[-g GROUP] [--ignore-errors] <pull options>')), |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
68 } |