comparison mercurial_all_paths.py @ 44:2d6c7e0c1b2f

Added newline between successive items output
author Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
date Sun, 25 Sep 2016 08:38:27 +0200
parents b8a7342fbf23
children 237dd8c4fe78
comparison
equal deleted inserted replaced
43:a1fb32ff4532 44:2d6c7e0c1b2f
11 from mercurial.i18n import _ 11 from mercurial.i18n import _
12 12
13 # pylint:disable=invalid-name,broad-except,line-too-long 13 # pylint:disable=invalid-name,broad-except,line-too-long
14 14
15 15
16 def _iter_over_paths(command, ui, repo, **opts): 16 def _iter_over_paths(command, ui, repo, add_sep, **opts):
17 """execute given command on multiple paths""" 17 """execute given command on multiple paths"""
18 # Extract our options and filter them out 18 # Extract our options and filter them out
19 group = opts.pop('group', None) or 'paths' 19 group = opts.pop('group', None) or 'paths'
20 ignore_errors = opts.pop('ignore_errors', None) 20 ignore_errors = opts.pop('ignore_errors', None)
21 21
24 if not paths: 24 if not paths:
25 raise mercurial.util.Abort(_('No paths defined in section %s') % group) 25 raise mercurial.util.Abort(_('No paths defined in section %s') % group)
26 26
27 # Used to avoid handling duplicate paths twice 27 # Used to avoid handling duplicate paths twice
28 handled = {} 28 handled = {}
29 # Used to add extra newline between items
30 sep = ''
29 31
30 # Act! 32 # Act!
31 for alias, path in paths: 33 for alias, path in paths:
32 if path in handled: 34 if path in handled:
33 ui.note(_("Skipping %s as path %s was already handled %s\n") % (alias, handled[path])) 35 ui.status(sep + _("Skipping %s as path %s was already handled %s\n") % (alias, handled[path]))
36 sep = '\n' if add_sep else ''
34 else: 37 else:
38 ui.status(sep)
39 sep = '\n' if add_sep else ''
35 handled[path] = alias 40 handled[path] = alias
36 try: 41 try:
37 command(ui, repo, path, **opts) 42 command(ui, repo, path, **opts)
38 except Exception as e: 43 except Exception as e:
39 if not ignore_errors: 44 if not ignore_errors:
40 raise 45 raise
41 ui.warn(_('error handling %s: %s\n') % (alias, e)) 46 ui.warn(_('error handling %s: %s\n') % (alias, e))
42 47 sep = '\n'
43 48
44 def pushall(ui, repo, **opts): 49 def pushall(ui, repo, **opts):
45 """execute push on multiple paths""" 50 """execute push on multiple paths"""
46 _iter_over_paths(mercurial.commands.push, ui, repo, **opts) 51 _iter_over_paths(mercurial.commands.push, ui, repo, True, **opts)
47 52
48 53
49 def pullall(ui, repo, **opts): 54 def pullall(ui, repo, **opts):
50 """execute pull on multiple paths""" 55 """execute pull on multiple paths"""
51 _iter_over_paths(mercurial.commands.pull, ui, repo, **opts) 56 _iter_over_paths(mercurial.commands.pull, ui, repo, True, **opts)
52 57
53 58
54 def incomingall(ui, repo, **opts): 59 def incomingall(ui, repo, **opts):
55 """execute incoming on multiple paths""" 60 """execute incoming on multiple paths"""
56 _iter_over_paths(mercurial.commands.incoming, ui, repo, **opts) 61 _iter_over_paths(mercurial.commands.incoming, ui, repo, False, **opts)
57 62
58 63
59 def outgoingall(ui, repo, **opts): 64 def outgoingall(ui, repo, **opts):
60 """execute outgoing on multiple paths""" 65 """execute outgoing on multiple paths"""
61 _iter_over_paths(mercurial.commands.outgoing, ui, repo, **opts) 66 _iter_over_paths(mercurial.commands.outgoing, ui, repo, False, **opts)
62 67
63 68
64 def _original_options(cmdname): 69 def _original_options(cmdname):
65 """Gets list of given command options as specified in Mercurial core""" 70 """Gets list of given command options as specified in Mercurial core"""
66 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) 71 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table)