Mercurial > hg-allpaths
comparison allpaths.py @ 8:eced61373a74
Added pullall
author | Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl> |
---|---|
date | Sun, 08 Nov 2015 08:50:25 +0100 |
parents | 1ea915867337 |
children | dac7580bfff2 |
comparison
equal
deleted
inserted
replaced
7:1ea915867337 | 8:eced61373a74 |
---|---|
10 import mercurial.cmdutil | 10 import mercurial.cmdutil |
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 def pushall(ui, repo, **opts): | 15 |
16 """execute a push command on multiple paths""" | 16 def _iter_over_paths(command, ui, repo, **opts): |
17 """execute given command on multiple paths""" | |
17 # Extract our options and filter them out | 18 # Extract our options and filter them out |
18 group = opts.pop('group', None) | 19 group = opts.pop('group', None) |
19 ignore_errors = opts.pop('ignore_errors', None) | 20 ignore_errors = opts.pop('ignore_errors', None) |
20 | 21 |
21 # Get the paths to push to. | 22 # Get the paths to push to. |
24 raise mercurial.util.Abort(_('No paths defined in section %s') % group) | 25 raise mercurial.util.Abort(_('No paths defined in section %s') % group) |
25 | 26 |
26 # Push! | 27 # Push! |
27 for path in paths: | 28 for path in paths: |
28 try: | 29 try: |
29 mercurial.commands.push(ui, repo, path[1], **opts) | 30 command(ui, repo, path[1], **opts) |
30 except Exception as e: | 31 except Exception as e: |
31 if not ignore_errors: | 32 if not ignore_errors: |
32 raise | 33 raise |
33 ui.warn(_('error pushing to %s: %s') % (path[1], e)) | 34 ui.warn(_('error handling %s: %s') % (path[1], e)) |
35 | |
36 | |
37 def pushall(ui, repo, **opts): | |
38 """execute pull on multiple paths""" | |
39 _iter_over_paths(mercurial.commands.push, ui, repo, **opts) | |
40 | |
41 | |
42 def pullall(ui, repo, **opts): | |
43 """execute push on multiple paths""" | |
44 _iter_over_paths(mercurial.commands.pull, ui, repo, **opts) | |
34 | 45 |
35 | 46 |
36 def _original_options(cmdname): | 47 def _original_options(cmdname): |
37 """Gets list of given command options as specified in Mercurial core""" | 48 """Gets list of given command options as specified in Mercurial core""" |
38 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) | 49 _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) |
45 [ | 56 [ |
46 ('g', 'group', 'paths', _('use a named group of paths')), | 57 ('g', 'group', 'paths', _('use a named group of paths')), |
47 ('', 'ignore-errors', None, _('continue execution despite errors')), | 58 ('', 'ignore-errors', None, _('continue execution despite errors')), |
48 ] + _original_options('push'), | 59 ] + _original_options('push'), |
49 _('[-g GROUP] [--ignore-errors] <push options>')), | 60 _('[-g GROUP] [--ignore-errors] <push options>')), |
61 "pullall": ( | |
62 pullall, | |
63 [ | |
64 ('g', 'group', 'paths', _('use a named group of paths')), | |
65 ('', 'ignore-errors', None, _('continue execution despite errors')), | |
66 ] + _original_options('pull'), | |
67 _('[-g GROUP] [--ignore-errors] <pull options>')), | |
50 } | 68 } |