##// END OF EJS Templates
py3: manually import pycompat.setattr where it is needed...
py3: manually import pycompat.setattr where it is needed Continuing to eliminate the implicit import of symbols in the Python 3 source transformer so we can eliminate it. Differential Revision: https://phab.mercurial-scm.org/D7007

File last commit:

r43347:687b865b default
r43357:66f2cc21 default
Show More
githelp.py
1261 lines | 32.2 KiB | text/x-python | PythonLexer
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 # githelp.py - Try to map Git commands to Mercurial equivalents.
#
# Copyright 2013 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""try mapping git commands to Mercurial commands
Tries to map a given git command to a Mercurial command:
$ hg githelp -- git checkout master
hg update master
If an unknown command or parameter combination is detected, an error is
produced.
"""
from __future__ import absolute_import
import getopt
import re
from mercurial.i18n import _
from mercurial import (
Gregory Szorc
githelp: cast commands to bytes...
r36248 encoding,
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 error,
fancyopts,
Gregory Szorc
githelp: make argument parsing more compatible with Python 3...
r41459 pycompat,
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 registrar,
Martin von Zweigbergk
githelp: use revsymbol() for looking up symbol...
r37406 scmutil,
Yuya Nishihara
procutil: bulk-replace function calls to point to new module
r37138 )
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial.utils import procutil
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 testedwith = b'ships-with-hg-core'
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
cmdtable = {}
command = registrar.command(cmdtable)
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def convert(s):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if s.startswith(b"origin/"):
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return s[7:]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'HEAD' in s:
s = s.replace(b'HEAD', b'.')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 # HEAD~ in git is .~1 in mercurial
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 s = re.sub(b'~$', b'~1', s)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return s
Augie Fackler
formatting: blacken the codebase...
r43346
@command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'githelp|git',
Augie Fackler
formatting: blacken the codebase...
r43346 [],
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'hg githelp'),
Augie Fackler
formatting: blacken the codebase...
r43346 helpcategory=command.CATEGORY_HELP,
helpbasic=True,
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def githelp(ui, repo, *args, **kwargs):
'''suggests the Mercurial equivalent of the given git command
Usage: hg githelp -- <git command>
'''
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if len(args) == 0 or (len(args) == 1 and args[0] == b'git'):
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'missing git command - ' b'usage: hg githelp -- <git command>')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if args[0] == b'git':
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args = args[1:]
cmd = args[0]
if not cmd in gitcommands:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"error: unknown git command %s") % cmd)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.pager(b'githelp')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args = args[1:]
return gitcommands[cmd](ui, repo, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def parseoptions(ui, cmdoptions, args):
cmdoptions = list(cmdoptions)
opts = {}
args = list(args)
while True:
try:
args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
break
except getopt.GetoptError as ex:
Gregory Szorc
githelp: make argument parsing more compatible with Python 3...
r41459 if r"requires argument" in ex.msg:
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 raise
Gregory Szorc
githelp: make argument parsing more compatible with Python 3...
r41459 if (r'--' + ex.opt) in ex.msg:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 flag = b'--' + pycompat.bytestr(ex.opt)
Gregory Szorc
githelp: make argument parsing more compatible with Python 3...
r41459 elif (r'-' + ex.opt) in ex.msg:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 flag = b'-' + pycompat.bytestr(ex.opt)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"unknown option %s") % pycompat.bytestr(ex.opt)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 try:
args.remove(flag)
except Exception:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b"unknown option '%s' packed with other options")
hint = _(b"please try passing the option as its own flag: -%s")
Augie Fackler
formatting: blacken the codebase...
r43346 raise error.Abort(
msg % pycompat.bytestr(ex.opt),
hint=hint % pycompat.bytestr(ex.opt),
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.warn(_(b"ignoring unknown option %s\n") % flag)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
args = list([convert(x) for x in args])
Augie Fackler
formatting: blacken the codebase...
r43346 opts = dict(
[
(k, convert(v)) if isinstance(v, str) else (k, v)
for k, v in opts.iteritems()
]
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
return args, opts
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 class Command(object):
def __init__(self, name):
self.name = name
self.args = []
self.opts = {}
Gregory Szorc
githelp: cast commands to bytes...
r36248 def __bytes__(self):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = b"hg " + self.name
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if self.opts:
for k, values in sorted(self.opts.iteritems()):
for v in values:
if v:
Gregory Szorc
githelp: format with %d if an integer...
r41460 if isinstance(v, int):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fmt = b' %s %d'
Gregory Szorc
githelp: format with %d if an integer...
r41460 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 fmt = b' %s %s'
Gregory Szorc
githelp: format with %d if an integer...
r41460
cmd += fmt % (k, v)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd += b" %s" % (k,)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if self.args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd += b" "
cmd += b" ".join(self.args)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return cmd
Gregory Szorc
githelp: cast commands to bytes...
r36248 __str__ = encoding.strmethod(__bytes__)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def append(self, value):
self.args.append(value)
def extend(self, values):
self.args.extend(values)
def __setitem__(self, key, value):
values = self.opts.setdefault(key, [])
values.append(value)
def __and__(self, other):
return AndCommand(self, other)
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 class AndCommand(object):
def __init__(self, left, right):
self.left = left
self.right = right
def __str__(self):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b"%s && %s" % (self.left, self.right)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
def __and__(self, other):
return AndCommand(self, other)
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def add(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'A', b'all', None, b''),
(b'p', b'patch', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'patch'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial will commit when complete, "
b"as there is no staging area in Mercurial\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'commit --interactive')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b"add")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not opts.get(b'all'):
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
else:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: use hg addremove to remove files that have "
b"been deleted\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def am(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'import')
ui.status(bytes(cmd), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def apply(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'p', b'p', int, b''),
(b'', b'directory', b'', b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'import --no-commit')
if opts.get(b'p'):
cmd[b'-p'] = opts.get(b'p')
if opts.get(b'directory'):
cmd[b'--prefix'] = opts.get(b'directory')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def bisect(ui, repo, *args, **kwargs):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b"see 'hg help bisect' for how to use bisect\n\n"))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def blame(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'annotate -udl')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend([convert(v) for v in args])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def branch(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'set-upstream', None, b''),
(b'', b'set-upstream-to', b'', b''),
(b'd', b'delete', None, b''),
(b'D', b'delete', None, b''),
(b'm', b'move', None, b''),
(b'M', b'move', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b"bookmark")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'set_upstream') or opts.get(b'set_upstream_to'):
ui.status(_(b"Mercurial has no concept of upstream branches\n"))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'delete'):
cmd = Command(b"strip")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 for branch in args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-B'] = branch
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-B'] = None
elif opts.get(b'move'):
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) > 0:
if len(args) > 1:
old = args.pop(0)
else:
# shell command to output the active bookmark for the active
# revision
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 old = b'`hg log -T"{activebookmark}" -r .`'
Matt Harbison
githelp: fail gracefully in a couple cases where arguments are missing...
r38130 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'missing newbranch argument'))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 new = args[0]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-m'] = old
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.append(new)
else:
if len(args) > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = args[1]
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.append(args[0])
elif len(args) == 1:
cmd.append(args[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def ispath(repo, string):
"""
The first argument to git checkout can either be a revision or a path. Let's
generally assume it's a revision, unless it's obviously a path. There are
too many ways to spell revisions in git for us to reasonably catch all of
them, so let's be conservative.
"""
Martin von Zweigbergk
githelp: use revsymbol() for looking up symbol...
r37406 if scmutil.isrevsymbol(repo, string):
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 # if it's definitely a revision let's not even check if a file of the
# same name exists.
return False
cwd = repo.getcwd()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if cwd == b'':
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 repopath = string
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repopath = cwd + b'/' + string
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
exists = repo.wvfs.exists(repopath)
if exists:
return True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 manifest = repo[b'.'].manifest()
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
didexist = (repopath in manifest) or manifest.hasdir(repopath)
return didexist
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def checkout(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'b', b'branch', b'', b''),
(b'B', b'branch', b'', b''),
(b'f', b'force', None, b''),
(b'p', b'patch', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
paths = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'--' in args:
sepindex = args.index(b'--')
Augie Fackler
formatting: blacken the codebase...
r43346 paths.extend(args[sepindex + 1 :])
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args = args[:sepindex]
args, opts = parseoptions(ui, cmdoptions, args)
rev = None
if args and ispath(repo, args[0]):
paths = args + paths
elif args:
rev = args[0]
paths = args[1:] + paths
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'update')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'force'):
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if paths or rev:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-C'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'patch'):
cmd = Command(b'revert')
cmd[b'-i'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'branch'):
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) == 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'bookmark')
cmd.append(opts.get(b'branch'))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
cmd.append(args[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 bookcmd = Command(b'bookmark')
bookcmd.append(opts.get(b'branch'))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd = cmd & bookcmd
# if there is any path argument supplied, use revert instead of update
elif len(paths) > 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b"note: use --no-backup to avoid creating .orig files\n\n"))
cmd = Command(b'revert')
if opts.get(b'patch'):
cmd[b'-i'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if rev:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = rev
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(paths)
elif rev:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'patch'):
cmd[b'-r'] = rev
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
cmd.append(rev)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'force'):
cmd = Command(b'revert')
cmd[b'--all'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"a commit must be specified"))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def cherrypick(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'continue', None, b''),
(b'', b'abort', None, b''),
(b'e', b'edit', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'graft')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'edit'):
cmd[b'--edit'] = None
if opts.get(b'continue'):
cmd[b'--continue'] = None
elif opts.get(b'abort'):
ui.status(_(b"note: hg graft does not have --abort\n\n"))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return
else:
cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def clean(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'd', b'd', None, b''),
(b'f', b'force', None, b''),
(b'x', b'x', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'purge')
if opts.get(b'x'):
cmd[b'--all'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def clone(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'bare', None, b''),
(b'n', b'no-checkout', None, b''),
(b'b', b'branch', b'', b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
if len(args) == 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"a repository to clone must be specified"))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'clone')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.append(args[0])
if len(args) > 1:
cmd.append(args[1])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'bare'):
cmd[b'-U'] = None
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial does not have bare clones. "
b"-U will clone the repo without checking out a commit\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif opts.get(b'no_checkout'):
cmd[b'-U'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'branch'):
cocmd = Command(b"update")
cocmd.append(opts.get(b'branch'))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd = cmd & cocmd
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def commit(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'a', b'all', None, b''),
(b'm', b'message', b'', b''),
(b'p', b'patch', None, b''),
(b'C', b'reuse-message', b'', b''),
(b'F', b'file', b'', b''),
(b'', b'author', b'', b''),
(b'', b'date', b'', b''),
(b'', b'amend', None, b''),
(b'', b'no-edit', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'commit')
if opts.get(b'patch'):
cmd = Command(b'commit --interactive')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'amend'):
if opts.get(b'no_edit'):
cmd = Command(b'amend')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'--amend'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'reuse_message'):
cmd[b'-M'] = opts.get(b'reuse_message')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'message'):
cmd[b'-m'] = b"'%s'" % (opts.get(b'message'),)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'all'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial doesn't have a staging area, "
b"so there is no --all. -A will add and remove files "
b"for you though.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'file'):
cmd[b'-l'] = opts.get(b'file')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'author'):
cmd[b'-u'] = opts.get(b'author')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'date'):
cmd[b'-d'] = opts.get(b'date')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def deprecated(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.warn(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'this command has been deprecated in the git project, '
b'thus isn\'t supported by this tool\n\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
def diff(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'a', b'all', None, b''),
(b'', b'cached', None, b''),
(b'R', b'reverse', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'diff')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'cached'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'note: Mercurial has no concept of a staging area, '
b'so --cached does nothing\n\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'reverse'):
cmd[b'--reverse'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
for a in list(args):
args.remove(a)
try:
repo.revs(a)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = a
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 except Exception:
cmd.append(a)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def difftool(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'Mercurial does not enable external difftool by default. You '
b'need to enable the extdiff extension in your .hgrc file by adding\n'
b'extdiff =\n'
b'to the [extensions] section and then running\n\n'
b'hg extdiff -p <program>\n\n'
b'See \'hg help extdiff\' and \'hg help -e extdiff\' for more '
b'information.\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
def fetch(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'all', None, b''),
(b'f', b'force', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'pull')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) > 0:
cmd.append(args[0])
if len(args) > 1:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial doesn't have refspecs. "
b"-r can be used to specify which commits you want to "
b"pull. -B can be used to specify which bookmark you "
b"want to pull.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 for v in args[1:]:
if v in repo._bookmarks:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-B'] = v
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = v
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def grep(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'grep')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
# For basic usage, git grep and hg grep are the same. They both have the
# pattern first, followed by paths.
cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def init(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'init')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) > 0:
cmd.append(args[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def log(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'follow', None, b''),
(b'', b'decorate', None, b''),
(b'n', b'number', b'', b''),
(b'1', b'1', None, b''),
(b'', b'pretty', b'', b''),
(b'', b'format', b'', b''),
(b'', b'oneline', None, b''),
(b'', b'stat', None, b''),
(b'', b'graph', None, b''),
(b'p', b'patch', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'note: -v prints the entire commit message like Git does. To '
b'print just the first line, drop the -v.\n\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: see hg help revset for information on how to filter "
b"log output\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'log')
cmd[b'-v'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'number'):
cmd[b'-l'] = opts.get(b'number')
if opts.get(b'1'):
cmd[b'-l'] = b'1'
if opts.get(b'stat'):
cmd[b'--stat'] = None
if opts.get(b'graph'):
cmd[b'-G'] = None
if opts.get(b'patch'):
cmd[b'-p'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'pretty') or opts.get(b'format') or opts.get(b'oneline'):
format = opts.get(b'format', b'')
if b'format:' in format:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: --format format:??? equates to Mercurial's "
b"--template. See hg help templates for more info.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'--template'] = b'???'
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: --pretty/format/oneline equate to Mercurial's "
b"--style or --template. See hg help templates for "
b"more info.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'--style'] = b'???'
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) > 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'..' in args[0]:
since, until = args[0].split(b'..')
cmd[b'-r'] = b"'%s::%s'" % (since, until)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 del args[0]
cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def lsfiles(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'c', b'cached', None, b''),
(b'd', b'deleted', None, b''),
(b'm', b'modified', None, b''),
(b'o', b'others', None, b''),
(b'i', b'ignored', None, b''),
(b's', b'stage', None, b''),
(b'z', b'_zero', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: blacken the codebase...
r43346 if (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 opts.get(b'modified')
or opts.get(b'deleted')
or opts.get(b'others')
or opts.get(b'ignored')
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'status')
if opts.get(b'deleted'):
cmd[b'-d'] = None
if opts.get(b'modified'):
cmd[b'-m'] = None
if opts.get(b'others'):
cmd[b'-o'] = None
if opts.get(b'ignored'):
cmd[b'-i'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'files')
if opts.get(b'stage'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial doesn't have a staging area, ignoring "
b"--stage\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'_zero'):
cmd[b'-0'] = None
cmd.append(b'.')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 for include in args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-I'] = procutil.shellquote(include)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def merge(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'merge')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) > 0:
cmd.append(args[len(args) - 1])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def mergebase(ui, repo, *args, **kwargs):
cmdoptions = []
args, opts = parseoptions(ui, cmdoptions, args)
if len(args) != 2:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 args = [b'A', b'B']
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346 cmd = Command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"log -T '{node}\\n' -r 'ancestor(%s,%s)'" % (args[0], args[1])
Augie Fackler
formatting: blacken the codebase...
r43346 )
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'note: ancestors() is part of the revset language\n'),
_(b"(learn more about revsets with 'hg help revsets')\n\n"),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def mergetool(ui, repo, *args, **kwargs):
cmdoptions = []
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b"resolve")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) == 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'--all'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def mv(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'f', b'force', None, b''),
(b'n', b'dry-run', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'mv')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'force'):
cmd[b'-f'] = None
if opts.get(b'dry_run'):
cmd[b'-n'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def pull(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'all', None, b''),
(b'f', b'force', None, b''),
(b'r', b'rebase', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'pull')
cmd[b'--rebase'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) > 0:
cmd.append(args[0])
if len(args) > 1:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial doesn't have refspecs. "
b"-r can be used to specify which commits you want to "
b"pull. -B can be used to specify which bookmark you "
b"want to pull.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 for v in args[1:]:
if v in repo._bookmarks:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-B'] = v
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = v
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def push(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'all', None, b''),
(b'f', b'force', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'push')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
if len(args) > 0:
cmd.append(args[0])
if len(args) > 1:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial doesn't have refspecs. "
b"-r can be used to specify which commits you want "
b"to push. -B can be used to specify which bookmark "
b"you want to push.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 for v in args[1:]:
if v in repo._bookmarks:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-B'] = v
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = v
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'force'):
cmd[b'-f'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def rebase(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'all', None, b''),
(b'i', b'interactive', None, b''),
(b'', b'onto', b'', b''),
(b'', b'abort', None, b''),
(b'', b'continue', None, b''),
(b'', b'skip', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'interactive'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: hg histedit does not perform a rebase. "
b"It just edits history.\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'histedit')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) > 0:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"also note: 'hg histedit' will automatically detect"
b" your stack, so no second argument is necessary\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'skip'):
cmd = Command(b'revert --all -r .')
ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'rebase')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'continue') or opts.get(b'skip'):
cmd[b'--continue'] = None
if opts.get(b'abort'):
cmd[b'--abort'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'onto'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: if you're trying to lift a commit off one branch, "
b"try hg rebase -d <destination commit> -s <commit to be "
b"lifted>\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-d'] = convert(opts.get(b'onto'))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) < 2:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"expected format: git rebase --onto X Y Z"))
cmd[b'-s'] = b"'::%s - ::%s'" % (convert(args[1]), convert(args[0]))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
if len(args) == 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-d'] = convert(args[0])
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 elif len(args) == 2:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-d'] = convert(args[0])
cmd[b'-b'] = convert(args[1])
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def reflog(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'all', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'journal')
if opts.get(b'all'):
cmd[b'--all'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) > 0:
cmd.append(args[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(bytes(cmd), b"\n\n")
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: in hg commits can be deleted from repo but we always"
b" have backups\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
def reset(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'soft', None, b''),
(b'', b'hard', None, b''),
(b'', b'mixed', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 commit = convert(args[0] if len(args) > 0 else b'.')
hard = opts.get(b'hard')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'mixed'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'note: --mixed has no meaning since Mercurial has no '
b'staging area\n\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'soft'):
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'note: --soft has no meaning since Mercurial has no '
b'staging area\n\n'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'update')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if hard:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd.append(b'--clean')
Gregory Szorc
githelp: improve help for "reset"...
r35738
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.append(commit)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def revert(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
if len(args) > 1:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: hg backout doesn't support multiple commits at "
b"once\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'backout')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if args:
cmd.append(args[0])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def revparse(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'show-cdup', None, b''),
(b'', b'show-toplevel', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'show_cdup') or opts.get(b'show_toplevel'):
cmd = Command(b'root')
if opts.get(b'show_cdup'):
ui.status(_(b"note: hg root prints the root of the repository\n\n"))
ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status(_(b"note: see hg help revset for how to refer to commits\n"))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def rm(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'f', b'force', None, b''),
(b'n', b'dry-run', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'rm')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'force'):
cmd[b'-f'] = None
if opts.get(b'dry_run'):
cmd[b'-n'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def show(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'name-status', None, b''),
(b'', b'pretty', b'', b''),
(b'U', b'unified', int, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'name_status'):
if opts.get(b'pretty') == b'format:':
cmd = Command(b'status')
cmd[b'--change'] = b'.'
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'log')
cmd.append(b'--style status')
cmd.append(b'-r .')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 elif len(args) > 0:
if ispath(repo, args[0]):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'cat')
Gregory Szorc
githelp: don't reference 3rd party commands for `git show`...
r35739 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'export')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'unified'):
cmd.append(b'--config diff.unified=%d' % (opts[b'unified'],))
elif opts.get(b'unified'):
cmd = Command(b'export')
cmd.append(b'--config diff.unified=%d' % (opts[b'unified'],))
Gregory Szorc
githelp: don't reference 3rd party commands for `git show`...
r35739 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'export')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def stash(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'p', b'patch', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'shelve')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 action = args[0] if len(args) > 0 else None
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if action == b'list':
cmd[b'-l'] = None
if opts.get(b'patch'):
cmd[b'-p'] = None
elif action == b'show':
if opts.get(b'patch'):
cmd[b'-p'] = None
av6
githelp: translate git stash show and clear actions and --patch flag...
r42589 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'--stat'] = None
av6
githelp: translate git stash show and clear actions and --patch flag...
r42589 if len(args) > 1:
cmd.append(args[1])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif action == b'clear':
cmd[b'--cleanup'] = None
elif action == b'drop':
cmd[b'-d'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) > 1:
cmd.append(args[1])
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd.append(b'<shelve name>')
elif action == b'pop' or action == b'apply':
cmd = Command(b'unshelve')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 if len(args) > 1:
cmd.append(args[1])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if action == b'apply':
cmd[b'--keep'] = None
elif action == b'branch' or action == b'create':
Augie Fackler
formatting: blacken the codebase...
r43346 ui.status(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"note: Mercurial doesn't have equivalents to the "
b"git stash branch or create actions\n\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 return
else:
if len(args) > 0:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if args[0] != b'save':
cmd[b'--name'] = args[0]
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 elif len(args) > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'--name'] = args[1]
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def status(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'', b'ignored', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'status')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.extend(args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'ignored'):
cmd[b'-i'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def svn(ui, repo, *args, **kwargs):
Matt Harbison
githelp: fail gracefully in a couple cases where arguments are missing...
r38130 if not args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'missing svn command'))
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 svncmd = args[0]
Matt Harbison
githelp: rewrite a Yoda conditional
r38133 if svncmd not in gitsvncommands:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'unknown git svn command "%s"') % svncmd)
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
args = args[1:]
return gitsvncommands[svncmd](ui, repo, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def svndcommit(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'push')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def svnfetch(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'pull')
cmd.append(b'default-push')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def svnfindrev(ui, repo, *args, **kwargs):
Augie Fackler
formatting: blacken the codebase...
r43346 cmdoptions = []
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 args, opts = parseoptions(ui, cmdoptions, args)
Matt Harbison
githelp: fail gracefully in a couple cases where arguments are missing...
r38130 if not args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'missing find-rev argument'))
Matt Harbison
githelp: fail gracefully in a couple cases where arguments are missing...
r38130
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'log')
cmd[b'-r'] = args[0]
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def svnrebase(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'l', b'local', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 pullcmd = Command(b'pull')
pullcmd.append(b'default-push')
rebasecmd = Command(b'rebase')
rebasecmd.append(b'tip')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
cmd = pullcmd & rebasecmd
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 def tag(ui, repo, *args, **kwargs):
cmdoptions = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'f', b'force', None, b''),
(b'l', b'list', None, b''),
(b'd', b'delete', None, b''),
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 ]
args, opts = parseoptions(ui, cmdoptions, args)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'list'):
cmd = Command(b'tags')
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd = Command(b'tag')
Matt Harbison
githelp: fail gracefully in a couple cases where arguments are missing...
r38130
if not args:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'missing tag argument'))
Matt Harbison
githelp: fail gracefully in a couple cases where arguments are missing...
r38130
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 cmd.append(args[0])
if len(args) > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmd[b'-r'] = args[1]
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'delete'):
cmd[b'--remove'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'force'):
cmd[b'-f'] = None
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.status((bytes(cmd)), b"\n")
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 gitcommands = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'add': add,
b'am': am,
b'apply': apply,
b'bisect': bisect,
b'blame': blame,
b'branch': branch,
b'checkout': checkout,
b'cherry-pick': cherrypick,
b'clean': clean,
b'clone': clone,
b'commit': commit,
b'diff': diff,
b'difftool': difftool,
b'fetch': fetch,
b'grep': grep,
b'init': init,
b'log': log,
b'ls-files': lsfiles,
b'merge': merge,
b'merge-base': mergebase,
b'mergetool': mergetool,
b'mv': mv,
b'pull': pull,
b'push': push,
b'rebase': rebase,
b'reflog': reflog,
b'reset': reset,
b'revert': revert,
b'rev-parse': revparse,
b'rm': rm,
b'show': show,
b'stash': stash,
b'status': status,
b'svn': svn,
b'tag': tag,
b'whatchanged': deprecated,
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 }
gitsvncommands = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'dcommit': svndcommit,
b'fetch': svnfetch,
b'find-rev': svnfindrev,
b'rebase': svnrebase,
Gregory Szorc
githelp: vendor Facebook authored extension...
r35732 }