Mercurial > hg-allpaths
changeset 13:8cca585b11cc
Module renamed to mercurial_all_paths for possible pypi installation.
Extended README.
author | Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl> |
---|---|
date | Sun, 15 Nov 2015 10:16:21 +0100 |
parents | bed42905e871 |
children | 3b599fcd63f9 |
files | README.txt allpaths.py mercurial_all_paths.py setup.py |
diffstat | 4 files changed, 191 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/README.txt Sun Nov 08 09:08:58 2015 +0100 +++ b/README.txt Sun Nov 15 10:16:21 2015 +0100 @@ -1,27 +1,37 @@ .. -*- mode: rst; compile-command: "rst2html README.txt README.html" -*- ================================================ -allpaths extension +Mercurial All Paths extension ================================================ -Push or pull to many (or all) paths at once:: +Push or pull to many (or all) paths at once. + +.. contents:: + :local: + :depth: 2 + +.. sectnum:: + +Usage +================================================ + +Simple:: hg pushall -(pushes to all paths defined in the ``[paths]`` config section):: +pushes to all paths defined for the repository (all paths +returned by ``hg paths`` - usually defined in ``.hg/hgrc``, +but `Path Pattern`_ paths are also handled). + +There is also corresponding:: hg pullall -(pulls from all those paths):: - - hg incomingall - hg outgoingall - -You can also provide the name of a different section:: +Instead of using standard paths, you can define and use *groups*:: hg pushall -g publish -This will push to all paths specified in the ``[publish]`` config +pushes to all paths specified in the ``[publish]`` config section, which should look like this:: [publish] @@ -30,7 +40,7 @@ other = ssh://my@own/server local = /some/other/place -You can also provide standard options:: +All standard ``push`` and ``pull`` options can be used:: hg pushall -b branch @@ -40,3 +50,77 @@ etc. +Finally, there are:: + + hg incomingall + +and + + hg outgoingall + +which simply iterate over all paths. + +Installation +======================================================= + +From PyPi +-------------------- + +If you have working ``pip`` or ``easy_install``:: + + pip install --user mercurial_all_paths + +or maybe:: + + sudo pip install mercurial_all_paths + +Then activate by:: + + [extensions] + mercurial_all_paths = + +To upgrade, repeat the same command with ``--upgrade`` option, for +example:: + + pip install --user --upgrade mercurial_all_paths + +From source +------------------------------------------------------- + +Clone this repository:: + + cd ~/sources + hg clone https://bitbucket.org/Mekk/mercurial-all_paths/ + +either:: + + pip install --user -e mercurial-all_paths + +and activate as above, or just activate by full path:: + + [extensions] + mercurial_path_pattern = ~/sources/mercurial-path_pattern/mercurial_path_pattern.py + +To upgrade, pull and update. + +Development, bug reports, enhancement suggestions +======================================================= + +At the moment this extension is forked. Version by +Marcin Kasperski is maintained at + + http://bitbucket.org/Mekk/mercurial-all_paths/ + +while original version by Ludovic Chabant is available at + + https://bitbucket.org/ludovicchabant/allpaths + +Additional notes +======================================================= + +Information about this extension is also available +on Mercurial Wiki: http://mercurial.selenic.com/wiki/AllPathsExtension + + + +.. Path Pattern: https://bitbucket.org/Mekk/mercurial-path_pattern/
--- a/allpaths.py Sun Nov 08 09:08:58 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -# allpaths.py - execute commands on multiple paths -# -# This software may be used and distributed according to the terms of -# the GNU General Public License version 2 or any later version. - -'''execute commands on multiple paths''' - -import mercurial.util -import mercurial.commands -import mercurial.cmdutil -from mercurial.i18n import _ - -#pylint:disable=invalid-name,broad-except,line-too-long - - -def _iter_over_paths(command, ui, repo, **opts): - """execute given command on multiple paths""" - # Extract our options and filter them out - group = opts.pop('group', None) or 'paths' - ignore_errors = opts.pop('ignore_errors', None) - - # Get the paths to push to. - paths = ui.configitems(group) - if not paths: - raise mercurial.util.Abort(_('No paths defined in section %s') % group) - - # Used to avoid handling duplicate paths twice - handled = {} - - # Act! - for alias, path in paths: - if path in handled: - ui.note(_("Skipping %s as it aliases already handled %s\n") % (alias, handled[path])) - else: - handled[path] = alias - try: - command(ui, repo, path, **opts) - except Exception as e: - if not ignore_errors: - raise - ui.warn(_('error handling %s: %s') % (path[1], e)) - - -def pushall(ui, repo, **opts): - """execute pull on multiple paths""" - _iter_over_paths(mercurial.commands.push, ui, repo, **opts) - - -def pullall(ui, repo, **opts): - """execute push on multiple paths""" - _iter_over_paths(mercurial.commands.pull, ui, repo, **opts) - - -def incomingall(ui, repo, **opts): - """execute incoming on multiple paths""" - _iter_over_paths(mercurial.commands.incoming, ui, repo, **opts) - - -def outgoingall(ui, repo, **opts): - """execute outgoing on multiple paths""" - _iter_over_paths(mercurial.commands.outgoing, ui, repo, **opts) - - -def _original_options(cmdname): - """Gets list of given command options as specified in Mercurial core""" - _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) - return spec[1] - - -EXT_OPTS = [ - ('g', 'group', 'paths', _('use a named group of paths')), - ('', 'ignore-errors', None, _('continue execution despite errors')), -] - -cmdtable = { - "pushall": ( - pushall, - EXT_OPTS + _original_options('push'), - _('[-g GROUP] [--ignore-errors] <push options>')), - "pullall": ( - pullall, - EXT_OPTS + _original_options('pull'), - _('[-g GROUP] [--ignore-errors] <pull options>')), - "incomingall": ( - incomingall, - EXT_OPTS + _original_options('incoming'), - _('[-g GROUP] [--ignore-errors] <incoming options>')), - "outgoingall": ( - outgoingall, - EXT_OPTS + _original_options('outgoing'), - _('[-g GROUP] [--ignore-errors] <outgoing options>')), -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial_all_paths.py Sun Nov 15 10:16:21 2015 +0100 @@ -0,0 +1,92 @@ +# allpaths.py - execute commands on multiple paths +# +# This software may be used and distributed according to the terms of +# the GNU General Public License version 2 or any later version. + +'''execute commands on multiple paths''' + +import mercurial.util +import mercurial.commands +import mercurial.cmdutil +from mercurial.i18n import _ + +#pylint:disable=invalid-name,broad-except,line-too-long + + +def _iter_over_paths(command, ui, repo, **opts): + """execute given command on multiple paths""" + # Extract our options and filter them out + group = opts.pop('group', None) or 'paths' + ignore_errors = opts.pop('ignore_errors', None) + + # Get the paths to push to. + paths = ui.configitems(group) + if not paths: + raise mercurial.util.Abort(_('No paths defined in section %s') % group) + + # Used to avoid handling duplicate paths twice + handled = {} + + # Act! + for alias, path in paths: + if path in handled: + ui.note(_("Skipping %s as it aliases already handled %s\n") % (alias, handled[path])) + else: + handled[path] = alias + try: + command(ui, repo, path, **opts) + except Exception as e: + if not ignore_errors: + raise + ui.warn(_('error handling %s: %s') % (path[1], e)) + + +def pushall(ui, repo, **opts): + """execute pull on multiple paths""" + _iter_over_paths(mercurial.commands.push, ui, repo, **opts) + + +def pullall(ui, repo, **opts): + """execute push on multiple paths""" + _iter_over_paths(mercurial.commands.pull, ui, repo, **opts) + + +def incomingall(ui, repo, **opts): + """execute incoming on multiple paths""" + _iter_over_paths(mercurial.commands.incoming, ui, repo, **opts) + + +def outgoingall(ui, repo, **opts): + """execute outgoing on multiple paths""" + _iter_over_paths(mercurial.commands.outgoing, ui, repo, **opts) + + +def _original_options(cmdname): + """Gets list of given command options as specified in Mercurial core""" + _, spec = mercurial.cmdutil.findcmd(cmdname, mercurial.commands.table) + return spec[1] + + +EXT_OPTS = [ + ('g', 'group', 'paths', _('use a named group of paths')), + ('', 'ignore-errors', None, _('continue execution despite errors')), +] + +cmdtable = { + "pushall": ( + pushall, + EXT_OPTS + _original_options('push'), + _('[-g GROUP] [--ignore-errors] <push options>')), + "pullall": ( + pullall, + EXT_OPTS + _original_options('pull'), + _('[-g GROUP] [--ignore-errors] <pull options>')), + "incomingall": ( + incomingall, + EXT_OPTS + _original_options('incoming'), + _('[-g GROUP] [--ignore-errors] <incoming options>')), + "outgoingall": ( + outgoingall, + EXT_OPTS + _original_options('outgoing'), + _('[-g GROUP] [--ignore-errors] <outgoing options>')), +}
--- a/setup.py Sun Nov 08 09:08:58 2015 +0100 +++ b/setup.py Sun Nov 15 10:16:21 2015 +0100 @@ -15,13 +15,12 @@ setup( name="mercurial_all_paths", version=VERSION, - author='Ludovic Chabant', - # url='http://bitbucket.org/Mekk/mercurial-all_paths', - url='http://bitbucket.org/ludovicchabant/allpaths', + author='Marcin Kasperski', + url='http://bitbucket.org/Mekk/mercurial-all_paths', description='Mercurial allpaths extension', long_description=LONG_DESCRIPTION, - license='BSD', - py_modules=['allpaths'], + license='GNU', + py_modules=['mercurial_all_paths'], keywords="mercurial paths multi extension", classifiers=[ 'Development Status :: 4 - Beta',