hgext/githelp.py
author Augie Fackler <augie@google.com>
Wed, 30 Oct 2019 16:29:45 -0400
branchstable
changeset 43352 14e3be17e5f5
parent 43117 8ff1ecfadcd1
child 43503 313e3a279828
child 43745 24d0189238f1
permissions -rw-r--r--
hghave: verify we have a black that is new enough for our format We require what is currently the absolute latest black, so let's be paranoid.
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 (
36230
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,
41414
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41365
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: 37120
diff changeset
    30
    scmutil,
37120
a8a902d7176e procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents: 36230
diff changeset
    31
)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    38
testedwith = b'ships-with-hg-core'
35714
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: 42397
diff changeset
    43
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
def convert(s):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    45
    if s.startswith(b"origin/"):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
        return s[7:]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    47
    if b'HEAD' in s:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    48
        s = s.replace(b'HEAD', b'.')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
    # HEAD~ in git is .~1 in mercurial
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    50
    s = re.sub(b'~$', b'~1', s)
35714
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: 42397
diff changeset
    53
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
    54
@command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    55
    b'githelp|git',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
    56
    [],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    57
    _(b'hg githelp'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
    58
    helpcategory=command.CATEGORY_HELP,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
    59
    helpbasic=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    67
    if len(args) == 0 or (len(args) == 1 and args[0] == b'git'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
    68
        raise error.Abort(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43105
diff changeset
    69
            _(b'missing git command - usage: hg githelp -- <git command>')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
    70
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    72
    if args[0] == b'git':
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    77
        raise error.Abort(_(b"error: unknown git command %s") % cmd)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    79
    ui.pager(b'githelp')
35714
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: 42397
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:
41414
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41365
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
41414
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41365
diff changeset
    95
            if (r'--' + ex.opt) in ex.msg:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    96
                flag = b'--' + pycompat.bytestr(ex.opt)
41414
031d91623fdc githelp: make argument parsing more compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41365
diff changeset
    97
            elif (r'-' + ex.opt) in ex.msg:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
    98
                flag = b'-' + 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: 42397
diff changeset
   100
                raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   101
                    _(b"unknown option %s") % pycompat.bytestr(ex.opt)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   106
                msg = _(b"unknown option '%s' packed with other options")
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   107
                hint = _(b"please try passing the option as its own flag: -%s")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   108
                raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   109
                    msg % pycompat.bytestr(ex.opt),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   110
                    hint=hint % pycompat.bytestr(ex.opt),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   111
                )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   113
            ui.warn(_(b"ignoring unknown option %s\n") % flag)
35714
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: 42397
diff changeset
   116
    opts = dict(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   117
        [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   118
            (k, convert(v)) if isinstance(v, str) else (k, v)
43105
649d3ac37a12 py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
   119
            for k, v in pycompat.iteritems(opts)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   120
        ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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: 42397
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
36230
257f3651ada9 githelp: cast commands to bytes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35721
diff changeset
   132
    def __bytes__(self):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   133
        cmd = b"hg " + self.name
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
        if self.opts:
43105
649d3ac37a12 py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
   135
            for k, values in sorted(pycompat.iteritems(self.opts)):
35714
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:
41415
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41414
diff changeset
   138
                        if isinstance(v, int):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   139
                            fmt = b' %s %d'
41415
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41414
diff changeset
   140
                        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   141
                            fmt = b' %s %s'
41415
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41414
diff changeset
   142
873a28d7e962 githelp: format with %d if an integer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41414
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   145
                        cmd += b" %s" % (k,)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   146
        if self.args:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   147
            cmd += b" "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   148
            cmd += b" ".join(self.args)
35714
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
36230
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: 42397
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):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   173
        return b"%s && %s" % (self.left, self.right)
35714
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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   181
        (b'A', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   182
        (b'p', b'patch', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   186
    if opts.get(b'patch'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   187
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   188
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   189
                b"note: Mercurial will commit when complete, "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   190
                b"as there is no staging area in Mercurial\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   191
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   192
        )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   193
        cmd = Command(b'commit --interactive')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   194
    else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   195
        cmd = Command(b"add")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   196
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   197
        if not opts.get(b'all'):
35714
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: 42397
diff changeset
   200
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   201
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   202
                    b"note: use hg addremove to remove files that have "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   203
                    b"been deleted\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   204
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   205
            )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   206
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   207
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   213
    cmd = Command(b'import')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   214
    ui.status(bytes(cmd), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   219
        (b'p', b'p', int, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   220
        (b'', b'directory', b'', b''),
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   224
    cmd = Command(b'import --no-commit')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   225
    if opts.get(b'p'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   226
        cmd[b'-p'] = opts.get(b'p')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   227
    if opts.get(b'directory'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   228
        cmd[b'--prefix'] = opts.get(b'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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   231
    ui.status((bytes(cmd)), b"\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: 42397
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):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   235
    ui.status(_(b"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: 42397
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: 42397
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)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   241
    cmd = Command(b'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])
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   243
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   248
        (b'', b'set-upstream', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   249
        (b'', b'set-upstream-to', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   250
        (b'd', b'delete', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   251
        (b'D', b'delete', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   252
        (b'm', b'move', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   253
        (b'M', b'move', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   257
    cmd = Command(b"bookmark")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   258
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   259
    if opts.get(b'set_upstream') or opts.get(b'set_upstream_to'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   260
        ui.status(_(b"Mercurial has no concept of upstream branches\n"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   261
        return
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   262
    elif opts.get(b'delete'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   263
        cmd = Command(b"strip")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   264
        for branch in args:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   265
            cmd[b'-B'] = branch
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   266
        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   267
            cmd[b'-B'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   268
    elif opts.get(b'move'):
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   275
                old = b'`hg log -T"{activebookmark}" -r .`'
38118
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
   276
        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   277
            raise error.Abort(_(b'missing newbranch argument'))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   278
        new = args[0]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   279
        cmd[b'-m'] = old
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   283
            cmd[b'-r'] = args[1]
35714
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])
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   287
    ui.status((bytes(cmd)), b"\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: 42397
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: 37120
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()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   303
    if cwd == b'':
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   306
        repopath = cwd + b'/' + string
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   312
    manifest = repo[b'.'].manifest()
35714
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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   321
        (b'b', b'branch', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   322
        (b'B', b'branch', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   323
        (b'f', b'force', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   324
        (b'p', b'patch', None, b''),
35714
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 = []
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   327
    if b'--' in args:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   328
        sepindex = args.index(b'--')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   341
    cmd = Command(b'update')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   342
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   343
    if opts.get(b'force'):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   344
        if paths or rev:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   345
            cmd[b'-C'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   346
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   347
    if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   348
        cmd = Command(b'revert')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   349
        cmd[b'-i'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   350
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   351
    if opts.get(b'branch'):
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   352
        if len(args) == 0:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   353
            cmd = Command(b'bookmark')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   354
            cmd.append(opts.get(b'branch'))
35714
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])
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   357
            bookcmd = Command(b'bookmark')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   358
            bookcmd.append(opts.get(b'branch'))
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   362
        ui.status(_(b"note: use --no-backup to avoid creating .orig files\n\n"))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   363
        cmd = Command(b'revert')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   364
        if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   365
            cmd[b'-i'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   366
        if rev:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   367
            cmd[b'-r'] = rev
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   370
        if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   371
            cmd[b'-r'] = rev
35714
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)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   374
    elif opts.get(b'force'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   375
        cmd = Command(b'revert')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   376
        cmd[b'--all'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   377
    else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   378
        raise error.Abort(_(b"a commit must be specified"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   379
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   380
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   385
        (b'', b'continue', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   386
        (b'', b'abort', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   387
        (b'e', b'edit', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   391
    cmd = Command(b'graft')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   392
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   393
    if opts.get(b'edit'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   394
        cmd[b'--edit'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   395
    if opts.get(b'continue'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   396
        cmd[b'--continue'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   397
    elif opts.get(b'abort'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   398
        ui.status(_(b"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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   403
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   408
        (b'd', b'd', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   409
        (b'f', b'force', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   410
        (b'x', b'x', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   414
    cmd = Command(b'purge')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   415
    if opts.get(b'x'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   416
        cmd[b'--all'] = None
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   419
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   424
        (b'', b'bare', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   425
        (b'n', b'no-checkout', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   426
        (b'b', b'branch', b'', b''),
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   431
        raise error.Abort(_(b"a repository to clone must be specified"))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   432
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   433
    cmd = Command(b'clone')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   438
    if opts.get(b'bare'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   439
        cmd[b'-U'] = None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   440
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   441
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   442
                b"note: Mercurial does not have bare clones. "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   443
                b"-U will clone the repo without checking out a commit\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   444
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   445
        )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   446
    elif opts.get(b'no_checkout'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   447
        cmd[b'-U'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   448
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   449
    if opts.get(b'branch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   450
        cocmd = Command(b"update")
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   451
        cocmd.append(opts.get(b'branch'))
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   454
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   459
        (b'a', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   460
        (b'm', b'message', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   461
        (b'p', b'patch', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   462
        (b'C', b'reuse-message', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   463
        (b'F', b'file', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   464
        (b'', b'author', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   465
        (b'', b'date', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   466
        (b'', b'amend', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   467
        (b'', b'no-edit', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   471
    cmd = Command(b'commit')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   472
    if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   473
        cmd = Command(b'commit --interactive')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   474
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   475
    if opts.get(b'amend'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   476
        if opts.get(b'no_edit'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   477
            cmd = Command(b'amend')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   478
        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   479
            cmd[b'--amend'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   480
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   481
    if opts.get(b'reuse_message'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   482
        cmd[b'-M'] = opts.get(b'reuse_message')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   483
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   484
    if opts.get(b'message'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   485
        cmd[b'-m'] = b"'%s'" % (opts.get(b'message'),)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   486
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   487
    if opts.get(b'all'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   488
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   489
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   490
                b"note: Mercurial doesn't have a staging area, "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   491
                b"so there is no --all. -A will add and remove files "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   492
                b"for you though.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   493
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   494
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   495
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   496
    if opts.get(b'file'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   497
        cmd[b'-l'] = opts.get(b'file')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   498
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   499
    if opts.get(b'author'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   500
        cmd[b'-u'] = opts.get(b'author')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   501
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   502
    if opts.get(b'date'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   503
        cmd[b'-d'] = opts.get(b'date')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   507
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
diff changeset
   511
    ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   512
        _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   513
            b'this command has been deprecated in the git project, '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   514
            b'thus isn\'t supported by this tool\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   515
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   516
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   521
        (b'a', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   522
        (b'', b'cached', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   523
        (b'R', b'reverse', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   527
    cmd = Command(b'diff')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   528
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   529
    if opts.get(b'cached'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   530
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   531
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   532
                b'note: Mercurial has no concept of a staging area, '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   533
                b'so --cached does nothing\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   534
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   535
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   536
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   537
    if opts.get(b'reverse'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   538
        cmd[b'--reverse'] = None
35714
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)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   544
            cmd[b'-r'] = a
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   548
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
diff changeset
   552
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   553
        _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   554
            b'Mercurial does not enable external difftool by default. You '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   555
            b'need to enable the extdiff extension in your .hgrc file by adding\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   556
            b'extdiff =\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   557
            b'to the [extensions] section and then running\n\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   558
            b'hg extdiff -p <program>\n\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   559
            b'See \'hg help extdiff\' and \'hg help -e extdiff\' for more '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   560
            b'information.\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   561
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   562
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   567
        (b'', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   568
        (b'f', b'force', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   572
    cmd = Command(b'pull')
35714
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: 42397
diff changeset
   577
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   578
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   579
                    b"note: Mercurial doesn't have refspecs. "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   580
                    b"-r can be used to specify which commits you want to "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   581
                    b"pull. -B can be used to specify which bookmark you "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   582
                    b"want to pull.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   583
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   587
                    cmd[b'-B'] = v
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   588
                else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   589
                    cmd[b'-r'] = v
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   590
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   591
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   598
    cmd = Command(b'grep')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   604
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   611
    cmd = Command(b'init')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   616
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   621
        (b'', b'follow', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   622
        (b'', b'decorate', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   623
        (b'n', b'number', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   624
        (b'1', b'1', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   625
        (b'', b'pretty', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   626
        (b'', b'format', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   627
        (b'', b'oneline', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   628
        (b'', b'stat', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   629
        (b'', b'graph', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   630
        (b'p', b'patch', None, b''),
35714
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: 42397
diff changeset
   633
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   634
        _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   635
            b'note: -v prints the entire commit message like Git does. To '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   636
            b'print just the first line, drop the -v.\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   637
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   638
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   639
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   640
        _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   641
            b"note: see hg help revset for information on how to filter "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   642
            b"log output\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   643
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   644
    )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   645
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   646
    cmd = Command(b'log')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   647
    cmd[b'-v'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   648
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   649
    if opts.get(b'number'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   650
        cmd[b'-l'] = opts.get(b'number')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   651
    if opts.get(b'1'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   652
        cmd[b'-l'] = b'1'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   653
    if opts.get(b'stat'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   654
        cmd[b'--stat'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   655
    if opts.get(b'graph'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   656
        cmd[b'-G'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   657
    if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   658
        cmd[b'-p'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   659
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   660
    if opts.get(b'pretty') or opts.get(b'format') or opts.get(b'oneline'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   661
        format = opts.get(b'format', b'')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   662
        if b'format:' in format:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   663
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   664
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   665
                    b"note: --format format:??? equates to Mercurial's "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   666
                    b"--template. See hg help templates for more info.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   667
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   668
            )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   669
            cmd[b'--template'] = b'???'
35714
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: 42397
diff changeset
   671
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   672
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   673
                    b"note: --pretty/format/oneline equate to Mercurial's "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   674
                    b"--style or --template. See hg help templates for "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   675
                    b"more info.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   676
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   677
            )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   678
            cmd[b'--style'] = b'???'
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   681
        if b'..' in args[0]:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   682
            since, until = args[0].split(b'..')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   683
            cmd[b'-r'] = b"'%s::%s'" % (since, until)
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   687
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   692
        (b'c', b'cached', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   693
        (b'd', b'deleted', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   694
        (b'm', b'modified', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   695
        (b'o', b'others', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   696
        (b'i', b'ignored', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   697
        (b's', b'stage', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   698
        (b'z', b'_zero', None, b''),
35714
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: 42397
diff changeset
   702
    if (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   703
        opts.get(b'modified')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   704
        or opts.get(b'deleted')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   705
        or opts.get(b'others')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   706
        or opts.get(b'ignored')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   707
    ):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   708
        cmd = Command(b'status')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   709
        if opts.get(b'deleted'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   710
            cmd[b'-d'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   711
        if opts.get(b'modified'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   712
            cmd[b'-m'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   713
        if opts.get(b'others'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   714
            cmd[b'-o'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   715
        if opts.get(b'ignored'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   716
            cmd[b'-i'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   717
    else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   718
        cmd = Command(b'files')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   719
    if opts.get(b'stage'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   720
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   721
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   722
                b"note: Mercurial doesn't have a staging area, ignoring "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   723
                b"--stage\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   724
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   725
        )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   726
    if opts.get(b'_zero'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   727
        cmd[b'-0'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   728
    cmd.append(b'.')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   729
    for include in args:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   730
        cmd[b'-I'] = procutil.shellquote(include)
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   731
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   732
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   739
    cmd = Command(b'merge')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   744
    ui.status((bytes(cmd)), b"\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: 42397
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   752
        args = [b'A', b'B']
35714
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: 42397
diff changeset
   754
    cmd = Command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   755
        b"log -T '{node}\\n' -r 'ancestor(%s,%s)'" % (args[0], args[1])
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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: 42397
diff changeset
   758
    ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   759
        _(b'note: ancestors() is part of the revset language\n'),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   760
        _(b"(learn more about revsets with 'hg help revsets')\n\n"),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   761
    )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   762
    ui.status((bytes(cmd)), b"\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: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   769
    cmd = Command(b"resolve")
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   772
        cmd[b'--all'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   773
    cmd.extend(args)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   774
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   779
        (b'f', b'force', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   780
        (b'n', b'dry-run', None, b''),
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   784
    cmd = Command(b'mv')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   787
    if opts.get(b'force'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   788
        cmd[b'-f'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   789
    if opts.get(b'dry_run'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   790
        cmd[b'-n'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   791
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   792
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   797
        (b'', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   798
        (b'f', b'force', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   799
        (b'r', b'rebase', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   803
    cmd = Command(b'pull')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   804
    cmd[b'--rebase'] = None
35714
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: 42397
diff changeset
   809
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   810
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   811
                    b"note: Mercurial doesn't have refspecs. "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   812
                    b"-r can be used to specify which commits you want to "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   813
                    b"pull. -B can be used to specify which bookmark you "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   814
                    b"want to pull.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   815
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   819
                    cmd[b'-B'] = v
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   820
                else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   821
                    cmd[b'-r'] = v
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   822
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   823
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   828
        (b'', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   829
        (b'f', b'force', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   833
    cmd = Command(b'push')
35714
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: 42397
diff changeset
   838
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   839
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   840
                    b"note: Mercurial doesn't have refspecs. "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   841
                    b"-r can be used to specify which commits you want "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   842
                    b"to push. -B can be used to specify which bookmark "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   843
                    b"you want to push.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   844
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   848
                    cmd[b'-B'] = v
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   849
                else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   850
                    cmd[b'-r'] = v
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   851
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   852
    if opts.get(b'force'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   853
        cmd[b'-f'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   854
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   855
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   860
        (b'', b'all', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   861
        (b'i', b'interactive', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   862
        (b'', b'onto', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   863
        (b'', b'abort', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   864
        (b'', b'continue', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   865
        (b'', b'skip', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   869
    if opts.get(b'interactive'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   870
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   871
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   872
                b"note: hg histedit does not perform a rebase. "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   873
                b"It just edits history.\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   874
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   875
        )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   876
        cmd = Command(b'histedit')
35714
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: 42397
diff changeset
   878
            ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   879
                _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   880
                    b"also note: 'hg histedit' will automatically detect"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   881
                    b" your stack, so no second argument is necessary\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   882
                )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   883
            )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   884
        ui.status((bytes(cmd)), b"\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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   887
    if opts.get(b'skip'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   888
        cmd = Command(b'revert --all -r .')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   889
        ui.status((bytes(cmd)), b"\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   890
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   891
    cmd = Command(b'rebase')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   892
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   893
    if opts.get(b'continue') or opts.get(b'skip'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   894
        cmd[b'--continue'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   895
    if opts.get(b'abort'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   896
        cmd[b'--abort'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   897
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   898
    if opts.get(b'onto'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   899
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   900
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   901
                b"note: if you're trying to lift a commit off one branch, "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   902
                b"try hg rebase -d <destination commit> -s <commit to be "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   903
                b"lifted>\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   904
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   905
        )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   906
        cmd[b'-d'] = convert(opts.get(b'onto'))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   907
        if len(args) < 2:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   908
            raise error.Abort(_(b"expected format: git rebase --onto X Y Z"))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   909
        cmd[b'-s'] = b"'::%s - ::%s'" % (convert(args[1]), convert(args[0]))
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   912
            cmd[b'-d'] = convert(args[0])
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   913
        elif len(args) == 2:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   914
            cmd[b'-d'] = convert(args[0])
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   915
            cmd[b'-b'] = convert(args[1])
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   916
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   917
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   922
        (b'', b'all', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   926
    cmd = Command(b'journal')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   927
    if opts.get(b'all'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   928
        cmd[b'--all'] = None
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   932
    ui.status(bytes(cmd), b"\n\n")
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   933
    ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   934
        _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   935
            b"note: in hg commits can be deleted from repo but we always"
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   936
            b" have backups\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   937
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   938
    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   943
        (b'', b'soft', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   944
        (b'', b'hard', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   945
        (b'', b'mixed', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   949
    commit = convert(args[0] if len(args) > 0 else b'.')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   950
    hard = opts.get(b'hard')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   951
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   952
    if opts.get(b'mixed'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   953
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   954
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   955
                b'note: --mixed has no meaning since Mercurial has no '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   956
                b'staging area\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   957
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   958
        )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   959
    if opts.get(b'soft'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   960
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   961
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   962
                b'note: --soft has no meaning since Mercurial has no '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   963
                b'staging area\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   964
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   965
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   966
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   967
    cmd = Command(b'update')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   968
    if hard:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   969
        cmd.append(b'--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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   973
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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: 42397
diff changeset
   981
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   982
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   983
                b"note: hg backout doesn't support multiple commits at "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   984
                b"once\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   985
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
   986
        )
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   987
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   988
    cmd = Command(b'backout')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   992
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   997
        (b'', b'show-cdup', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   998
        (b'', b'show-toplevel', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1002
    if opts.get(b'show_cdup') or opts.get(b'show_toplevel'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1003
        cmd = Command(b'root')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1004
        if opts.get(b'show_cdup'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1005
            ui.status(_(b"note: hg root prints the root of the repository\n\n"))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1006
        ui.status((bytes(cmd)), b"\n")
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1007
    else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1008
        ui.status(_(b"note: see hg help revset for how to refer to commits\n"))
35714
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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1013
        (b'f', b'force', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1014
        (b'n', b'dry-run', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1018
    cmd = Command(b'rm')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1021
    if opts.get(b'force'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1022
        cmd[b'-f'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1023
    if opts.get(b'dry_run'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1024
        cmd[b'-n'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1025
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1026
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1031
        (b'', b'name-status', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1032
        (b'', b'pretty', b'', b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1033
        (b'U', b'unified', int, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1037
    if opts.get(b'name_status'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1038
        if opts.get(b'pretty') == b'format:':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1039
            cmd = Command(b'status')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1040
            cmd[b'--change'] = b'.'
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1041
        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1042
            cmd = Command(b'log')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1043
            cmd.append(b'--style status')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1044
            cmd.append(b'-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]):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1047
            cmd = Command(b'cat')
35721
f50067fbeead githelp: don't reference 3rd party commands for `git show`
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35720
diff changeset
  1048
        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1049
            cmd = Command(b'export')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1050
        cmd.extend(args)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1051
        if opts.get(b'unified'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1052
            cmd.append(b'--config diff.unified=%d' % (opts[b'unified'],))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1053
    elif opts.get(b'unified'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1054
        cmd = Command(b'export')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1055
        cmd.append(b'--config diff.unified=%d' % (opts[b'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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1057
        cmd = Command(b'export')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1058
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1059
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1064
        (b'p', b'patch', None, b''),
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1068
    cmd = Command(b'shelve')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1071
    if action == b'list':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1072
        cmd[b'-l'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1073
        if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1074
            cmd[b'-p'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1075
    elif action == b'show':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1076
        if opts.get(b'patch'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1077
            cmd[b'-p'] = None
42397
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42396
diff changeset
  1078
        else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1079
            cmd[b'--stat'] = None
42397
7752cd3a2f83 githelp: translate git stash show and clear actions and --patch flag
Anton Shestakov <av6@dwimlabs.net>
parents: 42396
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: 42396
diff changeset
  1081
            cmd.append(args[1])
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1082
    elif action == b'clear':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1083
        cmd[b'--cleanup'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1084
    elif action == b'drop':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1085
        cmd[b'-d'] = None
35714
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1089
            cmd.append(b'<shelve name>')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1090
    elif action == b'pop' or action == b'apply':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1091
        cmd = Command(b'unshelve')
35714
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])
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1094
        if action == b'apply':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1095
            cmd[b'--keep'] = None
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1096
    elif action == b'branch' or action == b'create':
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
  1097
        ui.status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
  1098
            _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1099
                b"note: Mercurial doesn't have equivalents to the "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1100
                b"git stash branch or create actions\n\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
diff changeset
  1101
            )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42397
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1106
            if args[0] != b'save':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1107
                cmd[b'--name'] = args[0]
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1108
            elif len(args) > 1:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1109
                cmd[b'--name'] = args[1]
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1110
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1111
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1116
        (b'', b'ignored', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1120
    cmd = Command(b'status')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1123
    if opts.get(b'ignored'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1124
        cmd[b'-i'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1125
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1126
    ui.status((bytes(cmd)), b"\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: 42397
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):
38118
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1131
        raise error.Abort(_(b'missing svn command'))
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1132
    svncmd = args[0]
38121
10befe8e8b59 githelp: rewrite a Yoda conditional
Matt Harbison <matt_harbison@yahoo.com>
parents: 38120
diff changeset
  1133
    if svncmd not in gitsvncommands:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1134
        raise error.Abort(_(b'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: 42397
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: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1144
    cmd = Command(b'push')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1145
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1146
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1153
    cmd = Command(b'pull')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1154
    cmd.append(b'default-push')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1155
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1156
    ui.status((bytes(cmd)), b"\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: 42397
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: 42397
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
38118
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1164
        raise error.Abort(_(b'missing find-rev argument'))
38118
d8bd6a9c64a5 githelp: fail gracefully in a couple cases where arguments are missing
Matt Harbison <matt_harbison@yahoo.com>
parents: 37388
diff changeset
  1165
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1166
    cmd = Command(b'log')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1167
    cmd[b'-r'] = args[0]
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1168
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1169
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1174
        (b'l', b'local', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1178
    pullcmd = Command(b'pull')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1179
    pullcmd.append(b'default-push')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1180
    rebasecmd = Command(b'rebase')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1181
    rebasecmd.append(b'tip')
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1185
    ui.status((bytes(cmd)), b"\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: 42397
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 = [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1190
        (b'f', b'force', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1191
        (b'l', b'list', None, b''),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1192
        (b'd', b'delete', None, b''),
35714
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
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1196
    if opts.get(b'list'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1197
        cmd = Command(b'tags')
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1198
    else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1199
        cmd = Command(b'tag')
38118
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1202
            raise error.Abort(_(b'missing tag argument'))
38118
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:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1206
            cmd[b'-r'] = args[1]
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1207
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1208
        if opts.get(b'delete'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1209
            cmd[b'--remove'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1210
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1211
        if opts.get(b'force'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1212
            cmd[b'-f'] = None
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1213
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1214
    ui.status((bytes(cmd)), b"\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: 42397
diff changeset
  1216
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1217
gitcommands = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1218
    b'add': add,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1219
    b'am': am,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1220
    b'apply': apply,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1221
    b'bisect': bisect,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1222
    b'blame': blame,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1223
    b'branch': branch,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1224
    b'checkout': checkout,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1225
    b'cherry-pick': cherrypick,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1226
    b'clean': clean,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1227
    b'clone': clone,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1228
    b'commit': commit,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1229
    b'diff': diff,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1230
    b'difftool': difftool,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1231
    b'fetch': fetch,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1232
    b'grep': grep,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1233
    b'init': init,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1234
    b'log': log,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1235
    b'ls-files': lsfiles,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1236
    b'merge': merge,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1237
    b'merge-base': mergebase,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1238
    b'mergetool': mergetool,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1239
    b'mv': mv,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1240
    b'pull': pull,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1241
    b'push': push,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1242
    b'rebase': rebase,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1243
    b'reflog': reflog,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1244
    b'reset': reset,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1245
    b'revert': revert,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1246
    b'rev-parse': revparse,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1247
    b'rm': rm,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1248
    b'show': show,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1249
    b'stash': stash,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1250
    b'status': status,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1251
    b'svn': svn,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1252
    b'tag': tag,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1253
    b'whatchanged': deprecated,
35714
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 = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1257
    b'dcommit': svndcommit,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1258
    b'fetch': svnfetch,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1259
    b'find-rev': svnfindrev,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
  1260
    b'rebase': svnrebase,
35714
113281667205 githelp: vendor Facebook authored extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
  1261
}