Mercurial > hg-allpaths
annotate mercurial_all_paths.py @ 76:03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 22 Jul 2017 15:48:58 -0700 |
parents | d262139732f7 |
children | 772d75b1a030 |
rev | line source |
---|---|
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
1 # -*- coding: utf-8 -*- |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
2 # |
0 | 3 # allpaths.py - execute commands on multiple paths |
4 # | |
5 # This software may be used and distributed according to the terms of | |
6 # the GNU General Public License version 2 or any later version. | |
7 | |
8 '''execute commands on multiple paths''' | |
9 | |
10 import mercurial.util | |
11 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
|
12 import mercurial.cmdutil |
0 | 13 from mercurial.i18n import _ |
14 | |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
15 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
16 def import_meu(): |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
17 """Importing mercurial_extension_utils so it can be found also outside |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
18 Python PATH (support for TortoiseHG/Win and similar setups)""" |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
19 try: |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
20 import mercurial_extension_utils |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
21 except ImportError: |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
22 my_dir = os.path.dirname(__file__) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
23 sys.path.extend([ |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
24 # In the same dir (manual or site-packages after pip) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
25 my_dir, |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
26 # Developer clone |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
27 os.path.join(os.path.dirname(my_dir), "extension_utils"), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
28 # Side clone |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
29 os.path.join(os.path.dirname(my_dir), "mercurial-extension_utils"), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
30 ]) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
31 try: |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
32 import mercurial_extension_utils |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
33 except ImportError: |
76
03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
Ludovic Chabant <ludovic@chabant.com>
parents:
73
diff
changeset
|
34 raise mercurial.util.Abort(_("""Can not import mercurial_extension_utils. |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
35 Please install this module in Python path. |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
36 See Installation chapter in https://bitbucket.org/Mekk/mercurial-dynamic_username/ for details |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
37 (and for info about TortoiseHG on Windows, or other bundled Python).""")) |
76
03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
Ludovic Chabant <ludovic@chabant.com>
parents:
73
diff
changeset
|
38 |
03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
Ludovic Chabant <ludovic@chabant.com>
parents:
73
diff
changeset
|
39 if not hasattr(mercurial_extension_utils, 'command'): |
03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
Ludovic Chabant <ludovic@chabant.com>
parents:
73
diff
changeset
|
40 raise mercurial.util.Abort(_("""Your mercurial_extension_utils is outdated. |
03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
Ludovic Chabant <ludovic@chabant.com>
parents:
73
diff
changeset
|
41 See Installation chapter in https://bitbucket.org/Mekk/mercurial-dynamic_username/ for details.""")) |
03cc0603800e
Fix incorrect call for `Abort`, and add error message when MEU is outdated.
Ludovic Chabant <ludovic@chabant.com>
parents:
73
diff
changeset
|
42 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
43 return mercurial_extension_utils |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
44 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
45 meu = import_meu() |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
46 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
47 |
34
7500a4ecb935
Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
31
diff
changeset
|
48 # pylint:disable=invalid-name,broad-except,line-too-long |
0 | 49 |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
50 def _find_all_paths(ui, skip_ignored=False, sort_by_priority=False): |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
51 """ |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
52 Finds all paths defined for repo |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
53 :return: list of pairs (alias, path) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
54 """ |
48
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
55 paths = ui.configitems("paths") |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
56 if not paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
57 raise mercurial.util.Abort(_('No paths defined for repository')) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
58 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
59 if skip_ignored: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
60 ignored = ui.configlist("all_paths", "ignore") |
48
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
61 if ignored: |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
62 paths = [(alias, path) for alias, path in paths if alias not in ignored] |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
63 if not paths: |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
64 raise mercurial.util.Abort(_('All paths defined for this repository are ignored')) |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
65 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
66 if sort_by_priority: |
48
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
67 prior = ui.configlist("all_paths", "prioritize") |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
68 if prior: |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
69 prior_val = {} |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
70 for idx, item in enumerate(prior): |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
71 prior_val[item] = idx |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
72 higher = len(prior) |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
73 paths.sort(key = lambda it: prior_val.get(it[0], higher)) |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
74 |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
75 return paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
76 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
77 def _find_paths(ui, group=None): |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
78 """ |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
79 Finds and returns all paths defined in given group, or all paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
80 (sans config) if group is not specified. |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
81 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
82 :param ui: repository ui |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
83 :param group: group name or None for all paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
84 :return: list of pairs (alias, path) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
85 """ |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
86 if not group: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
87 return _find_all_paths(ui, skip_ignored=True, sort_by_priority=True) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
88 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
89 # „Modern” syntax |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
90 grp_def = ui.configlist("all_paths", "group." + group) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
91 if grp_def: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
92 all_paths = dict(_find_all_paths(ui)) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
93 paths = [] |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
94 for item in grp_def: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
95 if item in all_paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
96 paths.append((item, all_paths[item])) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
97 if not paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
98 raise mercurial.util.Abort(_('None of the paths from group %s is defined in this repository') % group) |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
99 |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
100 return paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
101 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
102 # „Legacy” syntax, used also for all paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
103 paths = ui.configitems(group) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
104 if not paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
105 raise mercurial.util.Abort(_('No paths defined in section %s') % group) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
106 return paths |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
107 |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
108 |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
109 def _iter_over_paths(command, ui, repo, add_sep, **opts): |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
110 """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
|
111 # Extract our options and filter them out |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
112 group = opts.pop('group', None) |
6
b1d440f1027a
(internal) Changed the way in which extension options are separated:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
1
diff
changeset
|
113 ignore_errors = opts.pop('ignore_errors', None) |
0 | 114 |
115 # Get the paths to push to. | |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
116 paths = _find_paths(ui, group) |
0 | 117 |
12
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
118 # Used to avoid handling duplicate paths twice |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
119 handled = {} |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
120 # Used to add extra newline between items |
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
121 sep = '' |
12
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
122 |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
123 # Act! |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
124 for alias, path in paths: |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
125 if path in handled: |
45
237dd8c4fe78
Finalized separators
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
44
diff
changeset
|
126 ui.status(sep + _("Skipping %s as path %s was already handled\n") % (alias, handled[path])) |
237dd8c4fe78
Finalized separators
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
44
diff
changeset
|
127 sep = '\n' |
12
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
128 else: |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
129 ui.status(sep) |
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
130 sep = '\n' if add_sep else '' |
12
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
131 handled[path] = alias |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
132 try: |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
133 command(ui, repo, path, **opts) |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
134 except Exception as e: |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
135 if not ignore_errors: |
bed42905e871
Avoiding doing pull or push twice in case some path has more than one
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
11
diff
changeset
|
136 raise |
31
9d595bda6f2f
Fixed buggy information printed on errors:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
13
diff
changeset
|
137 ui.warn(_('error handling %s: %s\n') % (alias, e)) |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
138 sep = '\n' |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
139 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
140 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
141 EXT_OPTS = [ |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
142 ('g', 'group', '', _('use a named group instead of all paths')), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
143 ('', 'ignore-errors', None, _('continue execution despite errors')), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
144 ] |
9
dac7580bfff2
Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
8
diff
changeset
|
145 |
dac7580bfff2
Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
8
diff
changeset
|
146 |
7
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
147 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
|
148 """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
|
149 _, 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
|
150 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
|
151 |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
152 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
153 cmdtable = {} |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
154 command = meu.command(cmdtable) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
155 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
156 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
157 @command("pushall", |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
158 EXT_OPTS + _original_options('push'), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
159 _('[-g GROUP] [--ignore-errors] <push options>')) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
160 def pushall(ui, repo, **opts): |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
161 """execute push on multiple paths""" |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
162 _iter_over_paths(mercurial.commands.push, ui, repo, True, **opts) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
163 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
164 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
165 @command("pullall", |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
166 EXT_OPTS + _original_options('pull'), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
167 _('[-g GROUP] [--ignore-errors] <pull options>')) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
168 def pullall(ui, repo, **opts): |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
169 """execute pull on multiple paths""" |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
170 _iter_over_paths(mercurial.commands.pull, ui, repo, True, **opts) |
9
dac7580bfff2
Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
8
diff
changeset
|
171 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
172 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
173 @command("incomingall", |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
174 EXT_OPTS + _original_options('incoming'), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
175 _('[--group GROUP] [--ignore-errors] <incoming options>')) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
176 def incomingall(ui, repo, **opts): |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
177 """execute incoming on multiple paths""" |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
178 _iter_over_paths(mercurial.commands.incoming, ui, repo, False, **opts) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
179 |
34
7500a4ecb935
Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
31
diff
changeset
|
180 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
181 @command("outgoingall", |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
182 EXT_OPTS + _original_options('outgoing'), |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
183 _('[--group GROUP] [--ignore-errors] <outgoing options>')) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
184 def outgoingall(ui, repo, **opts): |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
185 """execute outgoing on multiple paths""" |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
186 _iter_over_paths(mercurial.commands.outgoing, ui, repo, False, **opts) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
187 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
188 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
189 testedwith = '2.7 2.9 3.0 3.3 3.6 3.7 3.8 4.0 4.1 4.2' |
34
7500a4ecb935
Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
31
diff
changeset
|
190 buglink = 'https://bitbucket.org/Mekk/mercurial-all_paths/issues' |