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