hgext/githelp.py
author Augie Fackler <augie@google.com>
Sun, 06 Oct 2019 09:45:02 -0400
changeset 43076 2372284d9457
parent 42416 7752cd3a2f83
child 43077 687b865b95ad
permissions -rw-r--r--
formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# githelp.py - Try to map Git commands to Mercurial equivalents.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# Copyright 2013 Facebook, Inc.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
#
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
"""try mapping git commands to Mercurial commands
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
Tries to map a given git command to a Mercurial command:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
  $ hg githelp -- git checkout master
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
  hg update master
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
If an unknown command or parameter combination is detected, an error is
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
produced.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
"""
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
from __future__ import absolute_import
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
import getopt
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
import re
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
from mercurial.i18n import _
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
from mercurial import (
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
    25
    encoding,
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
    error,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
    fancyopts,
41436
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41387
diff changeset
    28
    pycompat,
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
    registrar,
37388
764ada920db5 githelp: use revsymbol() for looking up symbol
Martin von Zweigbergk <martinvonz@google.com>
parents: 37123
diff changeset
    30
    scmutil,
37123
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 36268
diff changeset
    31
)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    32
from mercurial.utils import procutil
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
# be specifying the version(s) of Mercurial they are tested with, or
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
# leave the attribute unspecified.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
testedwith = 'ships-with-hg-core'
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
cmdtable = {}
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
command = registrar.command(cmdtable)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    42
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    43
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
def convert(s):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
    if s.startswith("origin/"):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
        return s[7:]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
    if 'HEAD' in s:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
        s = s.replace('HEAD', '.')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
    # HEAD~ in git is .~1 in mercurial
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
    s = re.sub('~$', '~1', s)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
    return s
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    53
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    54
@command(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    55
    'githelp|git',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    56
    [],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    57
    _('hg githelp'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    58
    helpcategory=command.CATEGORY_HELP,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    59
    helpbasic=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    60
)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
def githelp(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
    '''suggests the Mercurial equivalent of the given git command
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    64
    Usage: hg githelp -- <git command>
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
    '''
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    67
    if len(args) == 0 or (len(args) == 1 and args[0] == 'git'):
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    68
        raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    69
            _('missing git command - ' 'usage: hg githelp -- <git command>')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    70
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
    if args[0] == 'git':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
        args = args[1:]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
    cmd = args[0]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
    if not cmd in gitcommands:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    77
        raise error.Abort(_("error: unknown git command %s") % cmd)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
    ui.pager('githelp')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
    args = args[1:]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
    return gitcommands[cmd](ui, repo, *args, **kwargs)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
    83
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
def parseoptions(ui, cmdoptions, args):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
    cmdoptions = list(cmdoptions)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
    opts = {}
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
    args = list(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
    while True:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    89
        try:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
            args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
            break
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
        except getopt.GetoptError as ex:
41436
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41387
diff changeset
    93
            if r"requires argument" in ex.msg:
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
                raise
41436
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41387
diff changeset
    95
            if (r'--' + ex.opt) in ex.msg:
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41387
diff changeset
    96
                flag = '--' + pycompat.bytestr(ex.opt)
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41387
diff changeset
    97
            elif (r'-' + ex.opt) in ex.msg:
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41387
diff changeset
    98
                flag = '-' + pycompat.bytestr(ex.opt)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
            else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   100
                raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   101
                    _("unknown option %s") % pycompat.bytestr(ex.opt)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   102
                )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   103
            try:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   104
                args.remove(flag)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   105
            except Exception:
38176
c3960c7e66fa py3: replace str.format(x) with `str % x` in githelp
Matt Harbison <matt_harbison@yahoo.com>
parents: 38175
diff changeset
   106
                msg = _("unknown option '%s' packed with other options")
c3960c7e66fa py3: replace str.format(x) with `str % x` in githelp
Matt Harbison <matt_harbison@yahoo.com>
parents: 38175
diff changeset
   107
                hint = _("please try passing the option as its own flag: -%s")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   108
                raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   109
                    msg % pycompat.bytestr(ex.opt),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   110
                    hint=hint % pycompat.bytestr(ex.opt),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   111
                )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   113
            ui.warn(_("ignoring unknown option %s\n") % flag)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   114
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   115
    args = list([convert(x) for x in args])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   116
    opts = dict(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   117
        [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   118
            (k, convert(v)) if isinstance(v, str) else (k, v)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   119
            for k, v in opts.iteritems()
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   120
        ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   121
    )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   122
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   123
    return args, opts
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   124
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   125
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   126
class Command(object):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   127
    def __init__(self, name):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   128
        self.name = name
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   129
        self.args = []
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   130
        self.opts = {}
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   131
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   132
    def __bytes__(self):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   133
        cmd = "hg " + self.name
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
        if self.opts:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   135
            for k, values in sorted(self.opts.iteritems()):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   136
                for v in values:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   137
                    if v:
41437
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41436
diff changeset
   138
                        if isinstance(v, int):
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41436
diff changeset
   139
                            fmt = ' %s %d'
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41436
diff changeset
   140
                        else:
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41436
diff changeset
   141
                            fmt = ' %s %s'
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41436
diff changeset
   142
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41436
diff changeset
   143
                        cmd += fmt % (k, v)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   144
                    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   145
                        cmd += " %s" % (k,)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   146
        if self.args:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   147
            cmd += " "
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   148
            cmd += " ".join(self.args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   149
        return cmd
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   150
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   151
    __str__ = encoding.strmethod(__bytes__)
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   152
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   153
    def append(self, value):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   154
        self.args.append(value)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   155
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   156
    def extend(self, values):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   157
        self.args.extend(values)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   158
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   159
    def __setitem__(self, key, value):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   160
        values = self.opts.setdefault(key, [])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   161
        values.append(value)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   162
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   163
    def __and__(self, other):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   164
        return AndCommand(self, other)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   165
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   166
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   167
class AndCommand(object):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   168
    def __init__(self, left, right):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   169
        self.left = left
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   170
        self.right = right
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   171
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   172
    def __str__(self):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   173
        return "%s && %s" % (self.left, self.right)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   174
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   175
    def __and__(self, other):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   176
        return AndCommand(self, other)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   178
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   179
def add(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   180
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   181
        ('A', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   182
        ('p', 'patch', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   183
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   184
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   185
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   186
    if opts.get('patch'):
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   187
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   188
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   189
                "note: Mercurial will commit when complete, "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   190
                "as there is no staging area in Mercurial\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   191
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   192
        )
35715
8dbd000f7de9 githelp: improve help for `git add`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35714
diff changeset
   193
        cmd = Command('commit --interactive')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   194
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   195
        cmd = Command("add")
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   196
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   197
        if not opts.get('all'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   198
            cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   199
        else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   200
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   201
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   202
                    "note: use hg addremove to remove files that have "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   203
                    "been deleted\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   204
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   205
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   206
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   207
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   208
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   209
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   210
def am(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   211
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   212
    args, opts = parseoptions(ui, cmdoptions, args)
35716
05b8adf38c55 githelp: recommend `hg import` for `git am`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35715
diff changeset
   213
    cmd = Command('import')
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   214
    ui.status(bytes(cmd), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   215
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   216
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   217
def apply(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   218
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   219
        ('p', 'p', int, ''),
42414
eddff539f5be githelp: translate --directory of git apply to --prefix
Anton Shestakov <av6@dwimlabs.net>
parents: 41437
diff changeset
   220
        ('', 'directory', '', ''),
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   221
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   222
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   223
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   224
    cmd = Command('import --no-commit')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   225
    if opts.get('p'):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   226
        cmd['-p'] = opts.get('p')
42414
eddff539f5be githelp: translate --directory of git apply to --prefix
Anton Shestakov <av6@dwimlabs.net>
parents: 41437
diff changeset
   227
    if opts.get('directory'):
eddff539f5be githelp: translate --directory of git apply to --prefix
Anton Shestakov <av6@dwimlabs.net>
parents: 41437
diff changeset
   228
        cmd['--prefix'] = opts.get('directory')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   229
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   230
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   231
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   232
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   233
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   234
def bisect(ui, repo, *args, **kwargs):
38175
cfa93fbbe9b4 githelp: drop the trailing period from single sentence output for consistency
Matt Harbison <matt_harbison@yahoo.com>
parents: 38163
diff changeset
   235
    ui.status(_("see 'hg help bisect' for how to use bisect\n\n"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   236
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   237
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   238
def blame(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   239
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   240
    args, opts = parseoptions(ui, cmdoptions, args)
35717
5edfead8cc95 githelp: remove reference to tweakdefaults
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35716
diff changeset
   241
    cmd = Command('annotate -udl')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   242
    cmd.extend([convert(v) for v in args])
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   243
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   244
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   245
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   246
def branch(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   247
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   248
        ('', 'set-upstream', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   249
        ('', 'set-upstream-to', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   250
        ('d', 'delete', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   251
        ('D', 'delete', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   252
        ('m', 'move', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   253
        ('M', 'move', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   254
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   255
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   256
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   257
    cmd = Command("bookmark")
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   258
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   259
    if opts.get('set_upstream') or opts.get('set_upstream_to'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   260
        ui.status(_("Mercurial has no concept of upstream branches\n"))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   261
        return
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   262
    elif opts.get('delete'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   263
        cmd = Command("strip")
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   264
        for branch in args:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   265
            cmd['-B'] = branch
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   266
        else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   267
            cmd['-B'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   268
    elif opts.get('move'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   269
        if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   270
            if len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   271
                old = args.pop(0)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   272
            else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   273
                # shell command to output the active bookmark for the active
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   274
                # revision
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   275
                old = '`hg log -T"{activebookmark}" -r .`'
38151
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
   276
        else:
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
   277
            raise error.Abort(_('missing newbranch argument'))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   278
        new = args[0]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   279
        cmd['-m'] = old
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   280
        cmd.append(new)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   281
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   282
        if len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   283
            cmd['-r'] = args[1]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   284
            cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   285
        elif len(args) == 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   286
            cmd.append(args[0])
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   287
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   288
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   289
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   290
def ispath(repo, string):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   291
    """
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   292
    The first argument to git checkout can either be a revision or a path. Let's
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   293
    generally assume it's a revision, unless it's obviously a path. There are
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   294
    too many ways to spell revisions in git for us to reasonably catch all of
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   295
    them, so let's be conservative.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   296
    """
37388
764ada920db5 githelp: use revsymbol() for looking up symbol
Martin von Zweigbergk <martinvonz@google.com>
parents: 37123
diff changeset
   297
    if scmutil.isrevsymbol(repo, string):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   298
        # if it's definitely a revision let's not even check if a file of the
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   299
        # same name exists.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   300
        return False
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   301
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   302
    cwd = repo.getcwd()
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   303
    if cwd == '':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   304
        repopath = string
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   305
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   306
        repopath = cwd + '/' + string
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   307
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   308
    exists = repo.wvfs.exists(repopath)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   309
    if exists:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   310
        return True
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   311
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   312
    manifest = repo['.'].manifest()
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   313
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   314
    didexist = (repopath in manifest) or manifest.hasdir(repopath)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   315
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   316
    return didexist
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   317
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   318
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   319
def checkout(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   320
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   321
        ('b', 'branch', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   322
        ('B', 'branch', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   323
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   324
        ('p', 'patch', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   325
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   326
    paths = []
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   327
    if '--' in args:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   328
        sepindex = args.index('--')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   329
        paths.extend(args[sepindex + 1 :])
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   330
        args = args[:sepindex]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   331
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   332
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   333
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   334
    rev = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   335
    if args and ispath(repo, args[0]):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   336
        paths = args + paths
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   337
    elif args:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   338
        rev = args[0]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   339
        paths = args[1:] + paths
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   340
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   341
    cmd = Command('update')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   342
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   343
    if opts.get('force'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   344
        if paths or rev:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   345
            cmd['-C'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   346
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   347
    if opts.get('patch'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   348
        cmd = Command('revert')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   349
        cmd['-i'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   350
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   351
    if opts.get('branch'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   352
        if len(args) == 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   353
            cmd = Command('bookmark')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   354
            cmd.append(opts.get('branch'))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   355
        else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   356
            cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   357
            bookcmd = Command('bookmark')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   358
            bookcmd.append(opts.get('branch'))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   359
            cmd = cmd & bookcmd
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   360
    # if there is any path argument supplied, use revert instead of update
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   361
    elif len(paths) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   362
        ui.status(_("note: use --no-backup to avoid creating .orig files\n\n"))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   363
        cmd = Command('revert')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   364
        if opts.get('patch'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   365
            cmd['-i'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   366
        if rev:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   367
            cmd['-r'] = rev
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   368
        cmd.extend(paths)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   369
    elif rev:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   370
        if opts.get('patch'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   371
            cmd['-r'] = rev
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   372
        else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   373
            cmd.append(rev)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   374
    elif opts.get('force'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   375
        cmd = Command('revert')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   376
        cmd['--all'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   377
    else:
38153
16463278e7f4 githelp: make several strings localizable
Matt Harbison <matt_harbison@yahoo.com>
parents: 38152
diff changeset
   378
        raise error.Abort(_("a commit must be specified"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   379
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   380
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   381
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   382
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   383
def cherrypick(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   384
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   385
        ('', 'continue', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   386
        ('', 'abort', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   387
        ('e', 'edit', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   388
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   389
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   390
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   391
    cmd = Command('graft')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   392
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   393
    if opts.get('edit'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   394
        cmd['--edit'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   395
    if opts.get('continue'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   396
        cmd['--continue'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   397
    elif opts.get('abort'):
38175
cfa93fbbe9b4 githelp: drop the trailing period from single sentence output for consistency
Matt Harbison <matt_harbison@yahoo.com>
parents: 38163
diff changeset
   398
        ui.status(_("note: hg graft does not have --abort\n\n"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   399
        return
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   400
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   401
        cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   402
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   403
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   404
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   405
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   406
def clean(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   407
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   408
        ('d', 'd', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   409
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   410
        ('x', 'x', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   411
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   412
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   413
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   414
    cmd = Command('purge')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   415
    if opts.get('x'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   416
        cmd['--all'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   417
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   418
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   419
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   420
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   421
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   422
def clone(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   423
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   424
        ('', 'bare', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   425
        ('n', 'no-checkout', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   426
        ('b', 'branch', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   427
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   428
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   429
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   430
    if len(args) == 0:
38153
16463278e7f4 githelp: make several strings localizable
Matt Harbison <matt_harbison@yahoo.com>
parents: 38152
diff changeset
   431
        raise error.Abort(_("a repository to clone must be specified"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   432
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   433
    cmd = Command('clone')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   434
    cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   435
    if len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   436
        cmd.append(args[1])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   437
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   438
    if opts.get('bare'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   439
        cmd['-U'] = None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   440
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   441
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   442
                "note: Mercurial does not have bare clones. "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   443
                "-U will clone the repo without checking out a commit\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   444
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   445
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   446
    elif opts.get('no_checkout'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   447
        cmd['-U'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   448
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   449
    if opts.get('branch'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   450
        cocmd = Command("update")
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   451
        cocmd.append(opts.get('branch'))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   452
        cmd = cmd & cocmd
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   453
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   454
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   455
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   456
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   457
def commit(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   458
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   459
        ('a', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   460
        ('m', 'message', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   461
        ('p', 'patch', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   462
        ('C', 'reuse-message', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   463
        ('F', 'file', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   464
        ('', 'author', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   465
        ('', 'date', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   466
        ('', 'amend', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   467
        ('', 'no-edit', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   468
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   469
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   470
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   471
    cmd = Command('commit')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   472
    if opts.get('patch'):
35718
a10a0d5561a9 githelp: replace suggestion of `hg record`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35717
diff changeset
   473
        cmd = Command('commit --interactive')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   474
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   475
    if opts.get('amend'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   476
        if opts.get('no_edit'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   477
            cmd = Command('amend')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   478
        else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   479
            cmd['--amend'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   480
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   481
    if opts.get('reuse_message'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   482
        cmd['-M'] = opts.get('reuse_message')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   483
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   484
    if opts.get('message'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   485
        cmd['-m'] = "'%s'" % (opts.get('message'),)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   486
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   487
    if opts.get('all'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   488
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   489
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   490
                "note: Mercurial doesn't have a staging area, "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   491
                "so there is no --all. -A will add and remove files "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   492
                "for you though.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   493
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   494
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   495
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   496
    if opts.get('file'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   497
        cmd['-l'] = opts.get('file')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   498
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   499
    if opts.get('author'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   500
        cmd['-u'] = opts.get('author')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   501
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   502
    if opts.get('date'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   503
        cmd['-d'] = opts.get('date')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   504
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   505
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   506
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   507
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   508
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   509
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   510
def deprecated(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   511
    ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   512
        _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   513
            'this command has been deprecated in the git project, '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   514
            'thus isn\'t supported by this tool\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   515
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   516
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   517
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   518
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   519
def diff(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   520
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   521
        ('a', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   522
        ('', 'cached', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   523
        ('R', 'reverse', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   524
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   525
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   526
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   527
    cmd = Command('diff')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   528
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   529
    if opts.get('cached'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   530
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   531
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   532
                'note: Mercurial has no concept of a staging area, '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   533
                'so --cached does nothing\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   534
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   535
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   536
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   537
    if opts.get('reverse'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   538
        cmd['--reverse'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   539
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   540
    for a in list(args):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   541
        args.remove(a)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   542
        try:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   543
            repo.revs(a)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   544
            cmd['-r'] = a
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   545
        except Exception:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   546
            cmd.append(a)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   547
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   548
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   549
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   550
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   551
def difftool(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   552
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   553
        _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   554
            'Mercurial does not enable external difftool by default. You '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   555
            'need to enable the extdiff extension in your .hgrc file by adding\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   556
            'extdiff =\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   557
            'to the [extensions] section and then running\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   558
            'hg extdiff -p <program>\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   559
            'See \'hg help extdiff\' and \'hg help -e extdiff\' for more '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   560
            'information.\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   561
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   562
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   563
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   564
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   565
def fetch(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   566
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   567
        ('', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   568
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   569
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   570
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   571
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   572
    cmd = Command('pull')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   573
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   574
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   575
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   576
        if len(args) > 1:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   577
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   578
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   579
                    "note: Mercurial doesn't have refspecs. "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   580
                    "-r can be used to specify which commits you want to "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   581
                    "pull. -B can be used to specify which bookmark you "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   582
                    "want to pull.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   583
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   584
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   585
            for v in args[1:]:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   586
                if v in repo._bookmarks:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   587
                    cmd['-B'] = v
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   588
                else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   589
                    cmd['-r'] = v
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   590
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   591
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   592
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   593
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   594
def grep(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   595
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   596
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   597
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   598
    cmd = Command('grep')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   599
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   600
    # For basic usage, git grep and hg grep are the same. They both have the
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   601
    # pattern first, followed by paths.
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   602
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   603
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   604
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   605
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   606
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   607
def init(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   608
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   609
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   610
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   611
    cmd = Command('init')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   612
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   613
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   614
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   615
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   616
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   617
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   618
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   619
def log(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   620
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   621
        ('', 'follow', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   622
        ('', 'decorate', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   623
        ('n', 'number', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   624
        ('1', '1', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   625
        ('', 'pretty', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   626
        ('', 'format', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   627
        ('', 'oneline', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   628
        ('', 'stat', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   629
        ('', 'graph', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   630
        ('p', 'patch', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   631
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   632
    args, opts = parseoptions(ui, cmdoptions, args)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   633
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   634
        _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   635
            'note: -v prints the entire commit message like Git does. To '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   636
            'print just the first line, drop the -v.\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   637
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   638
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   639
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   640
        _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   641
            "note: see hg help revset for information on how to filter "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   642
            "log output\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   643
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   644
    )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   645
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   646
    cmd = Command('log')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   647
    cmd['-v'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   648
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   649
    if opts.get('number'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   650
        cmd['-l'] = opts.get('number')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   651
    if opts.get('1'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   652
        cmd['-l'] = '1'
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   653
    if opts.get('stat'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   654
        cmd['--stat'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   655
    if opts.get('graph'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   656
        cmd['-G'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   657
    if opts.get('patch'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   658
        cmd['-p'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   659
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   660
    if opts.get('pretty') or opts.get('format') or opts.get('oneline'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   661
        format = opts.get('format', '')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   662
        if 'format:' in format:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   663
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   664
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   665
                    "note: --format format:??? equates to Mercurial's "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   666
                    "--template. See hg help templates for more info.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   667
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   668
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   669
            cmd['--template'] = '???'
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   670
        else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   671
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   672
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   673
                    "note: --pretty/format/oneline equate to Mercurial's "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   674
                    "--style or --template. See hg help templates for "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   675
                    "more info.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   676
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   677
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   678
            cmd['--style'] = '???'
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   679
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   680
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   681
        if '..' in args[0]:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   682
            since, until = args[0].split('..')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   683
            cmd['-r'] = "'%s::%s'" % (since, until)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   684
            del args[0]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   685
        cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   686
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   687
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   688
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   689
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   690
def lsfiles(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   691
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   692
        ('c', 'cached', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   693
        ('d', 'deleted', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   694
        ('m', 'modified', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   695
        ('o', 'others', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   696
        ('i', 'ignored', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   697
        ('s', 'stage', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   698
        ('z', '_zero', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   699
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   700
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   701
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   702
    if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   703
        opts.get('modified')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   704
        or opts.get('deleted')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   705
        or opts.get('others')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   706
        or opts.get('ignored')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   707
    ):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   708
        cmd = Command('status')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   709
        if opts.get('deleted'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   710
            cmd['-d'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   711
        if opts.get('modified'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   712
            cmd['-m'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   713
        if opts.get('others'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   714
            cmd['-o'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   715
        if opts.get('ignored'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   716
            cmd['-i'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   717
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   718
        cmd = Command('files')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   719
    if opts.get('stage'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   720
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   721
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   722
                "note: Mercurial doesn't have a staging area, ignoring "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   723
                "--stage\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   724
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   725
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   726
    if opts.get('_zero'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   727
        cmd['-0'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   728
    cmd.append('.')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   729
    for include in args:
37123
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 36268
diff changeset
   730
        cmd['-I'] = procutil.shellquote(include)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   731
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   732
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   733
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   734
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   735
def merge(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   736
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   737
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   738
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   739
    cmd = Command('merge')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   740
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   741
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   742
        cmd.append(args[len(args) - 1])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   743
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   744
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   745
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   746
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   747
def mergebase(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   748
    cmdoptions = []
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   749
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   750
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   751
    if len(args) != 2:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   752
        args = ['A', 'B']
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   753
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   754
    cmd = Command(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   755
        "log -T '{node}\\n' -r 'ancestor(%s,%s)'" % (args[0], args[1])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   756
    )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   757
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   758
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   759
        _('note: ancestors() is part of the revset language\n'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   760
        _("(learn more about revsets with 'hg help revsets')\n\n"),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   761
    )
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   762
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   763
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   764
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   765
def mergetool(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   766
    cmdoptions = []
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   767
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   768
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   769
    cmd = Command("resolve")
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   770
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   771
    if len(args) == 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   772
        cmd['--all'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   773
    cmd.extend(args)
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   774
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   775
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   776
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   777
def mv(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   778
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   779
        ('f', 'force', None, ''),
42415
37ff80505dfd githelp: add --dry-run for mv
Anton Shestakov <av6@dwimlabs.net>
parents: 42414
diff changeset
   780
        ('n', 'dry-run', None, ''),
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   781
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   782
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   783
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   784
    cmd = Command('mv')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   785
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   786
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   787
    if opts.get('force'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   788
        cmd['-f'] = None
42415
37ff80505dfd githelp: add --dry-run for mv
Anton Shestakov <av6@dwimlabs.net>
parents: 42414
diff changeset
   789
    if opts.get('dry_run'):
37ff80505dfd githelp: add --dry-run for mv
Anton Shestakov <av6@dwimlabs.net>
parents: 42414
diff changeset
   790
        cmd['-n'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   791
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   792
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   793
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   794
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   795
def pull(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   796
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   797
        ('', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   798
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   799
        ('r', 'rebase', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   800
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   801
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   802
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   803
    cmd = Command('pull')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   804
    cmd['--rebase'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   805
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   806
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   807
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   808
        if len(args) > 1:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   809
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   810
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   811
                    "note: Mercurial doesn't have refspecs. "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   812
                    "-r can be used to specify which commits you want to "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   813
                    "pull. -B can be used to specify which bookmark you "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   814
                    "want to pull.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   815
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   816
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   817
            for v in args[1:]:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   818
                if v in repo._bookmarks:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   819
                    cmd['-B'] = v
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   820
                else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   821
                    cmd['-r'] = v
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   822
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   823
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   824
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   825
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   826
def push(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   827
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   828
        ('', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   829
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   830
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   831
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   832
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   833
    cmd = Command('push')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   834
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   835
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   836
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   837
        if len(args) > 1:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   838
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   839
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   840
                    "note: Mercurial doesn't have refspecs. "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   841
                    "-r can be used to specify which commits you want "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   842
                    "to push. -B can be used to specify which bookmark "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   843
                    "you want to push.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   844
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   845
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   846
            for v in args[1:]:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   847
                if v in repo._bookmarks:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   848
                    cmd['-B'] = v
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   849
                else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   850
                    cmd['-r'] = v
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   851
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   852
    if opts.get('force'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   853
        cmd['-f'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   854
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   855
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   856
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   857
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   858
def rebase(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   859
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   860
        ('', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   861
        ('i', 'interactive', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   862
        ('', 'onto', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   863
        ('', 'abort', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   864
        ('', 'continue', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   865
        ('', 'skip', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   866
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   867
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   868
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   869
    if opts.get('interactive'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   870
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   871
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   872
                "note: hg histedit does not perform a rebase. "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   873
                "It just edits history.\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   874
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   875
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   876
        cmd = Command('histedit')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   877
        if len(args) > 0:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   878
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   879
                _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   880
                    "also note: 'hg histedit' will automatically detect"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   881
                    " your stack, so no second argument is necessary\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   882
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   883
            )
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   884
        ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   885
        return
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   886
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   887
    if opts.get('skip'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   888
        cmd = Command('revert --all -r .')
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   889
        ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   890
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   891
    cmd = Command('rebase')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   892
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   893
    if opts.get('continue') or opts.get('skip'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   894
        cmd['--continue'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   895
    if opts.get('abort'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   896
        cmd['--abort'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   897
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   898
    if opts.get('onto'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   899
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   900
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   901
                "note: if you're trying to lift a commit off one branch, "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   902
                "try hg rebase -d <destination commit> -s <commit to be "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   903
                "lifted>\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   904
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   905
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   906
        cmd['-d'] = convert(opts.get('onto'))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   907
        if len(args) < 2:
38155
26b73fad45d9 githelp: lowercase the start of output messages for consistency
Matt Harbison <matt_harbison@yahoo.com>
parents: 38154
diff changeset
   908
            raise error.Abort(_("expected format: git rebase --onto X Y Z"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   909
        cmd['-s'] = "'::%s - ::%s'" % (convert(args[1]), convert(args[0]))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   910
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   911
        if len(args) == 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   912
            cmd['-d'] = convert(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   913
        elif len(args) == 2:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   914
            cmd['-d'] = convert(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   915
            cmd['-b'] = convert(args[1])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   916
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   917
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   918
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   919
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   920
def reflog(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   921
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   922
        ('', 'all', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   923
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   924
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   925
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   926
    cmd = Command('journal')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   927
    if opts.get('all'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   928
        cmd['--all'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   929
    if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   930
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   931
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   932
    ui.status(bytes(cmd), "\n\n")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   933
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   934
        _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   935
            "note: in hg commits can be deleted from repo but we always"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   936
            " have backups\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   937
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   938
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   939
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   940
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   941
def reset(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   942
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   943
        ('', 'soft', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   944
        ('', 'hard', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   945
        ('', 'mixed', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   946
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   947
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   948
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   949
    commit = convert(args[0] if len(args) > 0 else '.')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   950
    hard = opts.get('hard')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   951
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   952
    if opts.get('mixed'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   953
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   954
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   955
                'note: --mixed has no meaning since Mercurial has no '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   956
                'staging area\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   957
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   958
        )
35720
b3cf58487731 githelp: improve help for "reset"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35719
diff changeset
   959
    if opts.get('soft'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   960
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   961
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   962
                'note: --soft has no meaning since Mercurial has no '
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   963
                'staging area\n\n'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   964
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   965
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   966
35720
b3cf58487731 githelp: improve help for "reset"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35719
diff changeset
   967
    cmd = Command('update')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   968
    if hard:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   969
        cmd.append('--clean')
35720
b3cf58487731 githelp: improve help for "reset"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35719
diff changeset
   970
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   971
    cmd.append(commit)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   972
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   973
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   974
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   975
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   976
def revert(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   977
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   978
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   979
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   980
    if len(args) > 1:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   981
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   982
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   983
                "note: hg backout doesn't support multiple commits at "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   984
                "once\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   985
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   986
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   987
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   988
    cmd = Command('backout')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   989
    if args:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   990
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   991
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   992
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   993
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
   994
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   995
def revparse(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   996
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   997
        ('', 'show-cdup', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   998
        ('', 'show-toplevel', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   999
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1000
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1001
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1002
    if opts.get('show_cdup') or opts.get('show_toplevel'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1003
        cmd = Command('root')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1004
        if opts.get('show_cdup'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1005
            ui.status(_("note: hg root prints the root of the repository\n\n"))
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1006
        ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1007
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1008
        ui.status(_("note: see hg help revset for how to refer to commits\n"))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1009
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1010
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1011
def rm(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1012
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1013
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1014
        ('n', 'dry-run', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1015
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1016
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1017
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1018
    cmd = Command('rm')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1019
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1020
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1021
    if opts.get('force'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1022
        cmd['-f'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1023
    if opts.get('dry_run'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1024
        cmd['-n'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1025
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1026
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1027
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1028
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1029
def show(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1030
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1031
        ('', 'name-status', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1032
        ('', 'pretty', '', ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1033
        ('U', 'unified', int, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1034
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1035
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1036
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1037
    if opts.get('name_status'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1038
        if opts.get('pretty') == 'format:':
35721
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1039
            cmd = Command('status')
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1040
            cmd['--change'] = '.'
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1041
        else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1042
            cmd = Command('log')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1043
            cmd.append('--style status')
35721
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1044
            cmd.append('-r .')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1045
    elif len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1046
        if ispath(repo, args[0]):
35721
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1047
            cmd = Command('cat')
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1048
        else:
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1049
            cmd = Command('export')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1050
        cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1051
        if opts.get('unified'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1052
            cmd.append('--config diff.unified=%d' % (opts['unified'],))
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1053
    elif opts.get('unified'):
35721
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1054
        cmd = Command('export')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1055
        cmd.append('--config diff.unified=%d' % (opts['unified'],))
35721
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1056
    else:
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1057
        cmd = Command('export')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1058
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1059
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1060
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1061
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1062
def stash(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1063
    cmdoptions = [
42416
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1064
        ('p', 'patch', None, ''),
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1065
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1066
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1067
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1068
    cmd = Command('shelve')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1069
    action = args[0] if len(args) > 0 else None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1070
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1071
    if action == 'list':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1072
        cmd['-l'] = None
42416
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1073
        if opts.get('patch'):
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1074
            cmd['-p'] = None
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1075
    elif action == 'show':
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1076
        if opts.get('patch'):
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1077
            cmd['-p'] = None
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1078
        else:
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1079
            cmd['--stat'] = None
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1080
        if len(args) > 1:
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1081
            cmd.append(args[1])
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1082
    elif action == 'clear':
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1083
        cmd['--cleanup'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1084
    elif action == 'drop':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1085
        cmd['-d'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1086
        if len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1087
            cmd.append(args[1])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1088
        else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1089
            cmd.append('<shelve name>')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1090
    elif action == 'pop' or action == 'apply':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1091
        cmd = Command('unshelve')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1092
        if len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1093
            cmd.append(args[1])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1094
        if action == 'apply':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1095
            cmd['--keep'] = None
42416
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42415
diff changeset
  1096
    elif action == 'branch' or action == 'create':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1097
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1098
            _(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1099
                "note: Mercurial doesn't have equivalents to the "
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1100
                "git stash branch or create actions\n\n"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1101
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1102
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1103
        return
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1104
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1105
        if len(args) > 0:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1106
            if args[0] != 'save':
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1107
                cmd['--name'] = args[0]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1108
            elif len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1109
                cmd['--name'] = args[1]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1110
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1111
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1112
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1113
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1114
def status(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1115
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1116
        ('', 'ignored', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1117
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1118
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1119
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1120
    cmd = Command('status')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1121
    cmd.extend(args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1122
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1123
    if opts.get('ignored'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1124
        cmd['-i'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1125
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1126
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1127
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1128
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1129
def svn(ui, repo, *args, **kwargs):
38151
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1130
    if not args:
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1131
        raise error.Abort(_('missing svn command'))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1132
    svncmd = args[0]
38154
10befe8e8b59 githelp: rewrite a Yoda conditional
Matt Harbison <matt_harbison@yahoo.com>
parents: 38153
diff changeset
  1133
    if svncmd not in gitsvncommands:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1134
        raise error.Abort(_('unknown git svn command "%s"') % svncmd)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1135
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1136
    args = args[1:]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1137
    return gitsvncommands[svncmd](ui, repo, *args, **kwargs)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1138
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1139
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1140
def svndcommit(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1141
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1142
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1143
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1144
    cmd = Command('push')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1145
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1146
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1147
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1148
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1149
def svnfetch(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1150
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1151
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1152
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1153
    cmd = Command('pull')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1154
    cmd.append('default-push')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1155
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1156
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1157
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1158
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1159
def svnfindrev(ui, repo, *args, **kwargs):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1160
    cmdoptions = []
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1161
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1162
38151
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1163
    if not args:
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1164
        raise error.Abort(_('missing find-rev argument'))
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1165
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1166
    cmd = Command('log')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1167
    cmd['-r'] = args[0]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1168
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1169
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1170
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1171
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1172
def svnrebase(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1173
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1174
        ('l', 'local', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1175
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1176
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1177
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1178
    pullcmd = Command('pull')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1179
    pullcmd.append('default-push')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1180
    rebasecmd = Command('rebase')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1181
    rebasecmd.append('tip')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1182
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1183
    cmd = pullcmd & rebasecmd
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1184
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1185
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1186
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1187
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1188
def tag(ui, repo, *args, **kwargs):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1189
    cmdoptions = [
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1190
        ('f', 'force', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1191
        ('l', 'list', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1192
        ('d', 'delete', None, ''),
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1193
    ]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1194
    args, opts = parseoptions(ui, cmdoptions, args)
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1195
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1196
    if opts.get('list'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1197
        cmd = Command('tags')
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1198
    else:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1199
        cmd = Command('tag')
38151
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1200
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1201
        if not args:
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1202
            raise error.Abort(_('missing tag argument'))
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1203
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1204
        cmd.append(args[0])
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1205
        if len(args) > 1:
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1206
            cmd['-r'] = args[1]
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1207
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1208
        if opts.get('delete'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1209
            cmd['--remove'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1210
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1211
        if opts.get('force'):
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1212
            cmd['-f'] = None
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1213
36268
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
  1214
    ui.status((bytes(cmd)), "\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1215
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42416
diff changeset
  1216
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1217
gitcommands = {
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1218
    'add': add,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1219
    'am': am,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1220
    'apply': apply,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1221
    'bisect': bisect,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1222
    'blame': blame,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1223
    'branch': branch,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1224
    'checkout': checkout,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1225
    'cherry-pick': cherrypick,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1226
    'clean': clean,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1227
    'clone': clone,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1228
    'commit': commit,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1229
    'diff': diff,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1230
    'difftool': difftool,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1231
    'fetch': fetch,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1232
    'grep': grep,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1233
    'init': init,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1234
    'log': log,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1235
    'ls-files': lsfiles,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1236
    'merge': merge,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1237
    'merge-base': mergebase,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1238
    'mergetool': mergetool,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1239
    'mv': mv,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1240
    'pull': pull,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1241
    'push': push,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1242
    'rebase': rebase,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1243
    'reflog': reflog,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1244
    'reset': reset,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1245
    'revert': revert,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1246
    'rev-parse': revparse,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1247
    'rm': rm,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1248
    'show': show,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1249
    'stash': stash,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1250
    'status': status,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1251
    'svn': svn,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1252
    'tag': tag,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1253
    'whatchanged': deprecated,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1254
}
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1255
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1256
gitsvncommands = {
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1257
    'dcommit': svndcommit,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1258
    'fetch': svnfetch,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1259
    'find-rev': svnfindrev,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1260
    'rebase': svnrebase,
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1261
}