hg
author Anton Shestakov <av6@dwimlabs.net>
Tue, 04 Oct 2016 20:49:59 +0800
changeset 30080 33e8a5a00007
parent 29235 1f5052d35b30
child 32424 b4810bf95c03
permissions -rwxr-xr-x
zsh_completion: update some option usage flags ('+', '=' and ':') Here are the relevant symbol descriptions from [0] optspec:... The colon indicates handling for one or more arguments to the option; if it is not present, the option is assumed to take no arguments. -optname+ The first argument may appear immediately after optname in the same word, or may appear as a separate word after the option. For example, ‘-foo+:...’ specifies that the completed option and argument will look like either ‘-fooarg’ or ‘-foo arg’. -optname= The argument may appear as the next word, or in same word as the option name provided that it is separated from it by an equals sign, for example ‘-foo=arg’ or ‘-foo arg’. There are 3 types of changes in this patch: - addition of '=': means that '--repository ~/foo' can now also be spelled as '--reporitory=~/foo' - addition of '+': means '-r 0' can now also be spelled as '-r0' - removal of '+', '=' and ':': means that '-u|--untrusted' doesn't take any arguments, so '-uq' is definitely '-u -q' and not '--untrusted=q' Occasionally, ':' had to be added together with '=' and '+'. This patch is mostly just making zsh_completion file look more like zsh's own hg completion file so that we can more easily take improvements from them or send patches to them. Some context for this patch from zsh project: [2] [3]. [0]: http://zsh.sourceforge.net/Doc/Release/Completion-System.html [1]: https://sourceforge.net/p/zsh/code/ci/master/tree/Completion/Unix/Command/_hg [2]: https://sourceforge.net/p/zsh/code/ci/92584634d3d39e9ca64475ae5af8010e2ccebe24/ [3]: http://www.zsh.org/mla/workers/2015/msg02551.html

#!/usr/bin/env python
#
# mercurial - scalable distributed SCM
#
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

import os
import sys

if os.environ.get('HGUNICODEPEDANTRY', False):
    try:
        reload(sys)
        sys.setdefaultencoding("undefined")
    except NameError:
        pass

libdir = '@LIBDIR@'

if libdir != '@' 'LIBDIR' '@':
    if not os.path.isabs(libdir):
        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              libdir)
        libdir = os.path.abspath(libdir)
    sys.path.insert(0, libdir)

# enable importing on demand to reduce startup time
try:
    if sys.version_info[0] < 3:
        from mercurial import demandimport; demandimport.enable()
except ImportError:
    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
                     ' '.join(sys.path))
    sys.stderr.write("(check your install and PYTHONPATH)\n")
    sys.exit(-1)

import mercurial.util
import mercurial.dispatch

for fp in (sys.stdin, sys.stdout, sys.stderr):
    mercurial.util.setbinary(fp)

mercurial.dispatch.run()