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