annotate mercurial_all_paths.py @ 74:879d1f392fa7 1.1.0

Version number set to 1.1.0
author Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
date Thu, 18 May 2017 17:36:23 +0200
parents d262139732f7
children 03cc0603800e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 # allpaths.py - execute commands on multiple paths
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 #
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 # the GNU General Public License version 2 or any later version.
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 '''execute commands on multiple paths'''
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 import mercurial.util
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
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
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 from mercurial.i18n import _
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
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:
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
34 raise util.Abort(_("""Can not 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
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)."""))
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
38 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
39
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
40 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
41
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
42
34
7500a4ecb935 Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 31
diff changeset
43 # pylint:disable=invalid-name,broad-except,line-too-long
0
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
44
47
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
45 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
46 """
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
47 Finds all paths defined for repo
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
48 :return: list of pairs (alias, path)
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
49 """
48
00995da9c204 Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 47
diff changeset
50 paths = ui.configitems("paths")
47
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
51 if not paths:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
52 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
53
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
54 if skip_ignored:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
55 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
56 if ignored:
00995da9c204 Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 47
diff changeset
57 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
58 if not paths:
00995da9c204 Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 47
diff changeset
59 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
60
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
61 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
62 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
63 if prior:
00995da9c204 Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 47
diff changeset
64 prior_val = {}
00995da9c204 Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 47
diff changeset
65 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
66 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
67 higher = len(prior)
00995da9c204 Implemented priorities, fixed bugs in ignoring, both should work.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 47
diff changeset
68 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
69
47
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
70 return paths
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
71
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
72 def _find_paths(ui, group=None):
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
73 """
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
74 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
75 (sans config) if group is not specified.
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 :param ui: repository ui
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
78 :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
79 :return: list of pairs (alias, path)
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 if not group:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
82 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
83
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
84 # „Modern” syntax
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
85 grp_def = ui.configlist("all_paths", "group." + group)
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
86 if grp_def:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
87 all_paths = dict(_find_all_paths(ui))
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
88 paths = []
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
89 for item in grp_def:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
90 if item in all_paths:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
91 paths.append((item, all_paths[item]))
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
92 if not paths:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
93 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
94
47
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
95 return paths
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
96
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
97 # „Legacy” syntax, used also for all paths
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
98 paths = ui.configitems(group)
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
99 if not paths:
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
100 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
101 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
102
8
eced61373a74 Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 7
diff changeset
103
44
2d6c7e0c1b2f Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 41
diff changeset
104 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
105 """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
106 # Extract our options and filter them out
47
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
107 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
108 ignore_errors = opts.pop('ignore_errors', None)
0
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
109
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
110 # Get the paths to push to.
47
916b05f73b53 preliminary impl of groups
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 45
diff changeset
111 paths = _find_paths(ui, group)
0
6f92e4c814d1 Initial commit.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
112
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
113 # 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
114 handled = {}
44
2d6c7e0c1b2f Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 41
diff changeset
115 # 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
116 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
117
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 # 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
119 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
120 if path in handled:
45
237dd8c4fe78 Finalized separators
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 44
diff changeset
121 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
122 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
123 else:
44
2d6c7e0c1b2f Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 41
diff changeset
124 ui.status(sep)
2d6c7e0c1b2f Added newline between successive items output
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 41
diff changeset
125 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
126 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
127 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
128 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
129 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
130 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
131 raise
31
9d595bda6f2f Fixed buggy information printed on errors:
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 13
diff changeset
132 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
133 sep = '\n'
8
eced61373a74 Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 7
diff changeset
134
eced61373a74 Added pullall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 7
diff changeset
135
73
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
136 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
137 ('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
138 ('', '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
139 ]
9
dac7580bfff2 Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 8
diff changeset
140
dac7580bfff2 Added incomingall and outgoingall
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 8
diff changeset
141
7
1ea915867337 Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 6
diff changeset
142 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
143 """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
144 _, 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
145 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
146
1ea915867337 Standard push options are imported from mercurial, not copied here.
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 6
diff changeset
147
73
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
148 cmdtable = {}
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
149 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
150
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
151
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
152 @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
153 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
154 _('[-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
155 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
156 """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
157 _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
158
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 @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
161 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
162 _('[-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
163 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
164 """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
165 _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
166
73
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 @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
169 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
170 _('[--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
171 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
172 """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
173 _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
174
34
7500a4ecb935 Preliminary steps towards tests (tox.ini, would-be testedwith decl)
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 31
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 @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
177 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
178 _('[--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
179 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
180 """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
181 _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
182
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
183
d262139732f7 Fixed to work against mercurial >= 4.1 (which requires using @command
Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
parents: 57
diff changeset
184 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
185 buglink = 'https://bitbucket.org/Mekk/mercurial-all_paths/issues'