Mercurial > hg-allpaths
annotate mercurial_all_paths.py @ 78:02b85549369b default tip
Update for Mercurial 4.8.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 03 Nov 2018 23:40:04 -0700 |
parents | 772d75b1a030 |
children |
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 | |
77
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
10 import os |
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
11 import sys |
0 | 12 import mercurial.util |
13 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
|
14 import mercurial.cmdutil |
78
02b85549369b
Update for Mercurial 4.8.
Ludovic Chabant <ludovic@chabant.com>
parents:
77
diff
changeset
|
15 import mercurial.registrar |
0 | 16 from mercurial.i18n import _ |
17 | |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
18 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
19 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
|
20 """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
|
21 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
|
22 try: |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 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
|
27 # 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
|
28 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
|
29 # 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
|
30 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
|
31 # 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
|
32 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
|
33 ]) |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
34 try: |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
35 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
|
36 except ImportError: |
77
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
37 return None |
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() |
77
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
46 if meu: |
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
47 command_decorator = meu.command |
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
48 else: |
78
02b85549369b
Update for Mercurial 4.8.
Ludovic Chabant <ludovic@chabant.com>
parents:
77
diff
changeset
|
49 command_decorator = mercurial.registrar.command |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
50 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
51 |
34
7500a4ecb935
Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
31
diff
changeset
|
52 # pylint:disable=invalid-name,broad-except,line-too-long |
0 | 53 |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
54 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
|
55 """ |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
56 Finds all paths defined for repo |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
57 :return: list of pairs (alias, path) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
58 """ |
48
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
59 paths = ui.configitems("paths") |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
60 if not paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
61 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
|
62 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
63 if skip_ignored: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
64 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
|
65 if ignored: |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
66 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
|
67 if not paths: |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
68 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
|
69 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
70 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
|
71 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
|
72 if prior: |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
73 prior_val = {} |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
74 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
|
75 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
|
76 higher = len(prior) |
00995da9c204
Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
47
diff
changeset
|
77 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
|
78 |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
79 return paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
80 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
81 def _find_paths(ui, group=None): |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
82 """ |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
83 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
|
84 (sans config) if group is not specified. |
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 :param ui: repository ui |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
87 :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
|
88 :return: list of pairs (alias, path) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
89 """ |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
90 if not group: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
91 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
|
92 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
93 # „Modern” syntax |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
94 grp_def = ui.configlist("all_paths", "group." + group) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
95 if grp_def: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
96 all_paths = dict(_find_all_paths(ui)) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
97 paths = [] |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
98 for item in grp_def: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
99 if item in all_paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
100 paths.append((item, all_paths[item])) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
101 if not paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
102 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
|
103 |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
104 return paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
105 |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
106 # „Legacy” syntax, used also for all paths |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
107 paths = ui.configitems(group) |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
108 if not paths: |
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
109 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
|
110 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
|
111 |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
112 |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
113 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
|
114 """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
|
115 # Extract our options and filter them out |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
116 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
|
117 ignore_errors = opts.pop('ignore_errors', None) |
0 | 118 |
119 # Get the paths to push to. | |
47
916b05f73b53
preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
45
diff
changeset
|
120 paths = _find_paths(ui, group) |
0 | 121 |
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 # 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
|
123 handled = {} |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
124 # 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
|
125 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
|
126 |
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
|
127 # 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
|
128 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
|
129 if path in handled: |
45
237dd8c4fe78
Finalized separators
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
44
diff
changeset
|
130 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
|
131 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
|
132 else: |
44
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
133 ui.status(sep) |
2d6c7e0c1b2f
Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
41
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 raise |
31
9d595bda6f2f
Fixed buggy information printed on errors:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
13
diff
changeset
|
141 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
|
142 sep = '\n' |
8
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
143 |
eced61373a74
Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
7
diff
changeset
|
144 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
145 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
|
146 ('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
|
147 ('', '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
|
148 ] |
9
dac7580bfff2
Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
8
diff
changeset
|
149 |
dac7580bfff2
Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
8
diff
changeset
|
150 |
7
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
151 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
|
152 """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
|
153 _, 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
|
154 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
|
155 |
1ea915867337
Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
6
diff
changeset
|
156 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
157 cmdtable = {} |
77
772d75b1a030
Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
Ludovic Chabant <ludovic@chabant.com>
parents:
76
diff
changeset
|
158 command = command_decorator(cmdtable) |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
159 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
160 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
161 @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
|
162 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
|
163 _('[-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
|
164 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
|
165 """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
|
166 _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
|
167 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
168 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
169 @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
|
170 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
|
171 _('[-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
|
172 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
|
173 """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
|
174 _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
|
175 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
176 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
177 @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
|
178 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
|
179 _('[--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
|
180 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
|
181 """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
|
182 _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
|
183 |
34
7500a4ecb935
Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
31
diff
changeset
|
184 |
73
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
185 @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
|
186 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
|
187 _('[--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
|
188 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
|
189 """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
|
190 _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
|
191 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
192 |
d262139732f7
Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents:
57
diff
changeset
|
193 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
|
194 buglink = 'https://bitbucket.org/Mekk/mercurial-all_paths/issues' |