2019-11-01 22:33:28 +03:00
|
|
|
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
# dispatch.py - command dispatching for mercurial
|
|
|
|
#
|
|
|
|
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
|
|
|
|
#
|
2009-04-26 03:08:54 +04:00
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2018-02-02 23:18:00 +03:00
|
|
|
from __future__ import absolute_import
|
2015-08-09 00:42:48 +03:00
|
|
|
|
2015-01-26 23:43:13 +03:00
|
|
|
import difflib
|
2015-08-09 00:42:48 +03:00
|
|
|
import errno
|
2016-12-06 03:57:58 +03:00
|
|
|
import getopt
|
2015-08-09 00:42:48 +03:00
|
|
|
import os
|
|
|
|
import pdb
|
|
|
|
import re
|
|
|
|
import signal
|
2019-04-11 20:02:28 +03:00
|
|
|
import socket
|
2015-08-09 00:42:48 +03:00
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import traceback
|
|
|
|
|
2019-09-21 03:43:59 +03:00
|
|
|
import bindings
|
2019-07-20 11:01:33 +03:00
|
|
|
|
2015-08-09 00:42:48 +03:00
|
|
|
from . import (
|
2019-06-26 20:59:13 +03:00
|
|
|
blackbox,
|
2015-08-09 00:42:48 +03:00
|
|
|
cmdutil,
|
2016-11-18 20:18:15 +03:00
|
|
|
color,
|
2015-08-09 00:42:48 +03:00
|
|
|
commands,
|
|
|
|
demandimport,
|
|
|
|
encoding,
|
|
|
|
error,
|
|
|
|
extensions,
|
2017-02-21 22:20:05 +03:00
|
|
|
help,
|
2015-08-09 00:42:48 +03:00
|
|
|
hg,
|
2018-04-07 10:36:43 +03:00
|
|
|
hintutil,
|
2015-08-09 00:42:48 +03:00
|
|
|
hook,
|
2018-05-09 02:58:44 +03:00
|
|
|
i18n,
|
2019-03-26 03:09:11 +03:00
|
|
|
perftrace,
|
2016-08-15 02:30:44 +03:00
|
|
|
profiling,
|
2016-11-21 13:05:22 +03:00
|
|
|
pycompat,
|
2017-09-20 02:17:43 +03:00
|
|
|
registrar,
|
2016-11-24 03:48:40 +03:00
|
|
|
scmutil,
|
2020-09-19 04:46:00 +03:00
|
|
|
sshpeer,
|
2020-07-11 03:47:41 +03:00
|
|
|
templatekw,
|
|
|
|
templater,
|
2015-08-09 00:42:48 +03:00
|
|
|
ui as uimod,
|
2020-05-06 04:15:26 +03:00
|
|
|
uiconfig,
|
2015-08-09 00:42:48 +03:00
|
|
|
util,
|
|
|
|
)
|
2020-05-07 19:05:16 +03:00
|
|
|
from .i18n import _, _x
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2019-07-20 11:01:33 +03:00
|
|
|
cliparser = bindings.cliparser
|
|
|
|
|
|
|
|
|
2017-09-20 02:17:43 +03:00
|
|
|
unrecoverablewrite = registrar.command.unrecoverablewrite
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-05-26 01:44:11 +04:00
|
|
|
class request(object):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
args,
|
|
|
|
ui=None,
|
|
|
|
repo=None,
|
|
|
|
fin=None,
|
|
|
|
fout=None,
|
|
|
|
ferr=None,
|
|
|
|
prereposetups=None,
|
|
|
|
):
|
2011-05-26 01:44:11 +04:00
|
|
|
self.args = args
|
2011-05-26 01:53:23 +04:00
|
|
|
self.ui = ui
|
2011-06-02 01:43:34 +04:00
|
|
|
self.repo = repo
|
2011-05-26 01:44:11 +04:00
|
|
|
|
2011-06-07 14:39:09 +04:00
|
|
|
# input/output/error streams
|
2020-04-16 04:18:53 +03:00
|
|
|
if fin and not isinstance(fin, util.refcell):
|
|
|
|
fin = util.refcell(fin)
|
|
|
|
if fout and not isinstance(fout, util.refcell):
|
|
|
|
fout = util.refcell(fout)
|
|
|
|
if ferr and not isinstance(ferr, util.refcell):
|
|
|
|
ferr = util.refcell(ferr)
|
|
|
|
|
2011-06-07 14:39:09 +04:00
|
|
|
self.fin = fin
|
|
|
|
self.fout = fout
|
|
|
|
self.ferr = ferr
|
|
|
|
|
2017-11-23 16:23:59 +03:00
|
|
|
# remember options pre-parsed by _earlyparseopts()
|
2017-11-11 08:02:41 +03:00
|
|
|
self.earlyoptions = {}
|
|
|
|
|
2017-04-30 07:39:47 +03:00
|
|
|
# reposetups which run before extensions, useful for chg to pre-fill
|
|
|
|
# low-level repo state (for example, changelog) before extensions.
|
|
|
|
self.prereposetups = prereposetups or []
|
|
|
|
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
def _runexithandlers(self):
|
2019-03-26 04:30:01 +03:00
|
|
|
# Silence potential EPIPE or SIGPIPE errors when writing to stdout or
|
|
|
|
# stderr.
|
2019-03-28 05:09:39 +03:00
|
|
|
if util.safehasattr(signal, "SIGPIPE"):
|
2020-09-18 23:24:31 +03:00
|
|
|
util.signal(signal.SIGPIPE, signal.SIG_IGN)
|
2019-03-26 04:30:01 +03:00
|
|
|
|
|
|
|
class ignoreerrorui(self.ui.__class__):
|
|
|
|
def _write(self, *args, **kwargs):
|
|
|
|
try:
|
|
|
|
return super(ignoreerrorui, self)._write(*args, **kwargs)
|
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def _write_err(self, *args, **kwargs):
|
|
|
|
try:
|
|
|
|
return super(ignoreerrorui, self)._write_err(*args, **kwargs)
|
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
|
|
|
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
exc = None
|
2019-03-26 04:30:01 +03:00
|
|
|
self.ui.__class__ = ignoreerrorui
|
|
|
|
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
handlers = self.ui._exithandlers
|
|
|
|
try:
|
|
|
|
while handlers:
|
|
|
|
func, args, kwargs = handlers.pop()
|
|
|
|
try:
|
|
|
|
func(*args, **kwargs)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
except: # re-raises below
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
if exc is None:
|
|
|
|
exc = sys.exc_info()[1]
|
2020-05-07 19:05:16 +03:00
|
|
|
self.ui.warn(_x("error in exit handlers:\n"))
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
self.ui.traceback(force=True)
|
|
|
|
finally:
|
|
|
|
if exc is not None:
|
|
|
|
raise exc
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2020-02-04 05:24:33 +03:00
|
|
|
def run(args=None, fin=None, fout=None, ferr=None):
|
2007-08-16 01:55:13 +04:00
|
|
|
"run the command in sys.argv"
|
2017-10-02 09:18:24 +03:00
|
|
|
_initstdio()
|
2019-08-29 05:22:46 +03:00
|
|
|
if args is None:
|
|
|
|
args = pycompat.sysargv
|
2020-02-04 05:24:33 +03:00
|
|
|
req = request(args[1:], fin=fin, fout=fout, ferr=ferr)
|
2017-04-12 00:54:12 +03:00
|
|
|
err = None
|
|
|
|
try:
|
|
|
|
status = (dispatch(req) or 0) & 255
|
2017-10-02 08:52:10 +03:00
|
|
|
except error.StdioError as e:
|
|
|
|
err = e
|
2017-04-12 00:54:12 +03:00
|
|
|
status = -1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if util.safehasattr(req.ui, "fout"):
|
2017-04-12 00:54:12 +03:00
|
|
|
try:
|
2017-04-22 18:31:29 +03:00
|
|
|
req.ui.fout.flush()
|
2017-10-02 08:52:10 +03:00
|
|
|
except IOError as e:
|
|
|
|
err = e
|
2017-04-12 00:54:12 +03:00
|
|
|
status = -1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if util.safehasattr(req.ui, "ferr"):
|
2017-04-12 00:54:12 +03:00
|
|
|
if err is not None and err.errno != errno.EPIPE:
|
2020-04-09 19:21:15 +03:00
|
|
|
errormsg = pycompat.encodeutf8(err.strerror)
|
|
|
|
req.ui.ferr.write(b"abort: %s\n" % errormsg)
|
2017-04-22 18:31:29 +03:00
|
|
|
req.ui.ferr.flush()
|
2017-04-12 00:54:12 +03:00
|
|
|
sys.exit(status & 255)
|
2007-08-16 01:55:13 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-05-09 02:58:42 +03:00
|
|
|
def _preimportmodules():
|
|
|
|
"""pre-import modules that are side-effect free (used by chg server)"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
coremods = [
|
|
|
|
"ancestor",
|
|
|
|
"archival",
|
|
|
|
"bookmarks",
|
|
|
|
"branchmap",
|
|
|
|
"bundle2",
|
|
|
|
"bundlerepo",
|
|
|
|
"byterange",
|
|
|
|
"changegroup",
|
|
|
|
"changelog",
|
|
|
|
"color",
|
|
|
|
"config",
|
|
|
|
"configitems",
|
|
|
|
"connectionpool",
|
|
|
|
"context",
|
|
|
|
"copies",
|
|
|
|
"crecord",
|
|
|
|
"dagop",
|
|
|
|
"dagparser",
|
|
|
|
"dagutil",
|
|
|
|
"destutil",
|
|
|
|
"dirstate",
|
|
|
|
"dirstateguard",
|
|
|
|
"discovery",
|
2019-12-13 22:47:27 +03:00
|
|
|
"eden_dirstate",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"exchange",
|
|
|
|
"filelog",
|
|
|
|
"filemerge",
|
|
|
|
"fileset",
|
|
|
|
"formatter",
|
|
|
|
"graphmod",
|
|
|
|
"hbisect",
|
|
|
|
"httpclient",
|
|
|
|
"httpconnection",
|
|
|
|
"httppeer",
|
|
|
|
"localrepo",
|
|
|
|
"lock",
|
|
|
|
"mail",
|
|
|
|
"manifest",
|
|
|
|
"match",
|
|
|
|
"mdiff",
|
|
|
|
"merge",
|
|
|
|
"mergeutil",
|
|
|
|
"minirst",
|
|
|
|
"namespaces",
|
|
|
|
"node",
|
|
|
|
"obsolete",
|
|
|
|
"obsutil",
|
|
|
|
"parser",
|
|
|
|
"patch",
|
|
|
|
"pathutil",
|
|
|
|
"peer",
|
|
|
|
"phases",
|
|
|
|
"progress",
|
|
|
|
"pushkey",
|
|
|
|
"rcutil",
|
|
|
|
"repository",
|
|
|
|
"revlog",
|
|
|
|
"revset",
|
|
|
|
"revsetlang",
|
|
|
|
"rewriteutil",
|
|
|
|
"scmposix",
|
|
|
|
"scmutil",
|
|
|
|
"server",
|
|
|
|
"setdiscovery",
|
|
|
|
"similar",
|
|
|
|
"simplemerge",
|
|
|
|
"smartset",
|
|
|
|
"sshpeer",
|
|
|
|
"sshserver",
|
|
|
|
"sslutil",
|
2019-12-13 22:47:27 +03:00
|
|
|
"statprof",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"store",
|
|
|
|
"streamclone",
|
|
|
|
"templatefilters",
|
|
|
|
"templatekw",
|
|
|
|
"templater",
|
|
|
|
"transaction",
|
|
|
|
"txnutil",
|
|
|
|
"url",
|
|
|
|
"urllibcompat",
|
|
|
|
"vfs",
|
|
|
|
"wireproto",
|
|
|
|
"worker",
|
|
|
|
"__version__",
|
|
|
|
]
|
|
|
|
extmods = [
|
|
|
|
"absorb",
|
2018-10-11 16:55:19 +03:00
|
|
|
"amend",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"arcdiff",
|
|
|
|
"automv",
|
|
|
|
"blackbox",
|
|
|
|
"checkmessagehook",
|
|
|
|
"chistedit",
|
|
|
|
"clienttelemetry",
|
|
|
|
"clindex",
|
2019-12-13 22:47:27 +03:00
|
|
|
"commitcloud",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"conflictinfo",
|
|
|
|
"convert",
|
|
|
|
"copytrace",
|
|
|
|
"crdump",
|
|
|
|
"debugcommitmessage",
|
|
|
|
"debugshell",
|
|
|
|
"dialect",
|
|
|
|
"dirsync",
|
|
|
|
"extlib",
|
|
|
|
"extorder",
|
|
|
|
"extutil",
|
|
|
|
"fastannotate",
|
|
|
|
"fastlog",
|
2019-12-13 14:20:28 +03:00
|
|
|
"fbscmquery",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"fbhistedit",
|
|
|
|
"fsmonitor",
|
|
|
|
"githelp",
|
|
|
|
"gitlookup",
|
|
|
|
"grpcheck",
|
|
|
|
"hgevents",
|
|
|
|
"histedit",
|
|
|
|
"infinitepush",
|
|
|
|
"journal",
|
|
|
|
"lfs",
|
|
|
|
"logginghelper",
|
|
|
|
"lz4revlog",
|
|
|
|
"mergedriver",
|
|
|
|
"morestatus",
|
2019-12-13 22:47:27 +03:00
|
|
|
"myparent",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"patchrmdir",
|
|
|
|
"phabdiff",
|
|
|
|
"phabstatus",
|
|
|
|
"phrevset",
|
|
|
|
"progressfile",
|
|
|
|
"pullcreatemarkers",
|
|
|
|
"pushrebase",
|
|
|
|
"rage",
|
|
|
|
"rebase",
|
|
|
|
"remotefilelog",
|
|
|
|
"remotenames",
|
|
|
|
"reset",
|
|
|
|
"sampling",
|
|
|
|
"schemes",
|
|
|
|
"share",
|
2018-10-12 16:22:04 +03:00
|
|
|
"shelve",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"sigtrace",
|
|
|
|
"simplecache",
|
|
|
|
"smartlog",
|
2018-10-17 00:19:23 +03:00
|
|
|
"sparse",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"sshaskpass",
|
2019-12-13 22:47:27 +03:00
|
|
|
"stablerev",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"stat",
|
|
|
|
"traceprof",
|
|
|
|
"treemanifest",
|
|
|
|
"tweakdefaults",
|
|
|
|
"undo",
|
|
|
|
]
|
2019-12-13 22:47:27 +03:00
|
|
|
modnames = ["edenscm.mercurial.%s" % name for name in coremods] + [
|
|
|
|
"edenscm.hgext.fastannotate.support"
|
|
|
|
]
|
|
|
|
for name in modnames:
|
|
|
|
__import__(name)
|
2018-05-09 02:58:42 +03:00
|
|
|
for extname in extmods:
|
|
|
|
extensions.preimport(extname)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
chg: use a separate entry point
Summary:
Motivated by recent D7784903 which kills chg because it holds blackbox.log
file descriptor, and that patch is causing race conditions running with chg
(chg's sock atomic rename might fail if the directory is deleted).
There are other ways to solve the direct issue. This diff takes a more
aggressive but much cleaner approach. Basically, the `hg serve` framework is
too late for chg's usecase - the repo was already loaded, extension
side-effects have been already done at that time - chg has to use
workarounds to be compatible with that. Even with a best effort, it is still
possible to have weird interactions with shared repo because how hg loads
extensions.
The new approach is to pre-import a list of bundled extensions but do not
run their `uisetup`s. This solves a couple of hard problems:
- Compatibility - `uisetup` runs per request. That behaves exactly as what
an extension author expects.
- Less memory usage - there is no `repo` object is loaded in memory.
- Reduced process count - since extension config change does not require a
new chg server, the count of server processes would decrease (ex.
`--config extensions.blackbox=!` won't require a new chg server)
- Not holding fd to edenfs, since neither blackbox nor repo is loaded. This
makes it possible to remove the hacky killing chg logic in D7784903.
The downside is performance, since extension loading, and `uisetup` will run
every time. Benchmark shows that's could be 50ms-ish. But we could move
forward by moving extension logic to core incrementally to get rid of that
cost too.
This is basically a simplified version of my previous stack starting
with [1]. The original commit message was:
This is the beginning of a series that does a re-architect to chg mentioned
in [1], to achieve better compatibility.
The compatibility issues are mainly around "uisetup"s and "reposetup"s:
- Developers are usually unaware that uisetup runs only once per chg
process. We cannot reliably devel-warn them. The result is, potential
broken code are written. For example, it's really hard for chg to deal
with "experimental.evolution" changed from unset to manually set in
config files because setconfig is used if that config option is not set.
- An unnecessary "reposetup" caused by "hg serve" may have unwanted
side effects. This can become troublesome if the repo requires things
like remotefilelog or lz4revlog, and the user sets HGRCPATH to run
tests.
The current chg implementation assumes that "loading" an extension is not
side effect free - if extension related config has changed, a restart is
needed. The new idea is, "loading" = "importing" + "run ui/extsetup", the
"importing" part can be side-effect free for some extensions. And benchmark
shows "import" takes most of the time consumed, while "uisetup" is usually
very fast. We can afford running "uisetup"s per request.
To be able to (pre-)"import" extensions without running any "uisetup"s, a
different entry point is needed. Otherwise as long as we go through the
normal dispatch / runcommand ("hg serve") flow, "uisetup"s cannot be
avoided.
Aside from better compatibility, we can also remove some hacks:
- chg client: no longer needs to extract sensitive argv
- chg server: confighash can be changed to only hash environment variables
(reduce the number of server processes)
- chg server: srcui.walkconfig hack is no longer necessary
This patch adds a new script "chgserve" as the new entry point. Currently,
it is just a minimal implementation that makes "CHGHG=chgserve chg ..."
work, without doing any pre-importing. The change could also be done in the
"hg" script. But since chg is still experimental, let's keep "hg" untouched
for now.
[1]: www.mercurial-scm.org/pipermail/mercurial-devel/2016-July/085965.html
[1]: https://bitbucket.org/quark-zju/hg-draft/commits/6f91a1a69fccf89ae6cbffc31da92889aa521f43
Reviewed By: singhsrb
Differential Revision: D7840237
fbshipit-source-id: e3d613b41fe4b721238b86c5bf84434d32cf0609
2018-05-09 02:58:40 +03:00
|
|
|
def runchgserver():
|
|
|
|
"""start the chg server, pre-import bundled extensions"""
|
|
|
|
# Clean server - do not load any config files or repos.
|
|
|
|
_initstdio()
|
|
|
|
ui = uimod.ui()
|
|
|
|
repo = None
|
|
|
|
args = sys.argv[1:]
|
2019-07-20 11:01:33 +03:00
|
|
|
cmd, func, args, globalopts, cmdopts, _foundaliases = _parse(ui, args)
|
2019-02-09 01:51:20 +03:00
|
|
|
if not (cmd == "serve" and cmdopts["cmdserver"] == "chgunix2"):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.ProgrammingError("runchgserver called without chg command")
|
|
|
|
from . import chgserver, server
|
|
|
|
|
2018-05-09 02:58:42 +03:00
|
|
|
_preimportmodules()
|
chg: use a separate entry point
Summary:
Motivated by recent D7784903 which kills chg because it holds blackbox.log
file descriptor, and that patch is causing race conditions running with chg
(chg's sock atomic rename might fail if the directory is deleted).
There are other ways to solve the direct issue. This diff takes a more
aggressive but much cleaner approach. Basically, the `hg serve` framework is
too late for chg's usecase - the repo was already loaded, extension
side-effects have been already done at that time - chg has to use
workarounds to be compatible with that. Even with a best effort, it is still
possible to have weird interactions with shared repo because how hg loads
extensions.
The new approach is to pre-import a list of bundled extensions but do not
run their `uisetup`s. This solves a couple of hard problems:
- Compatibility - `uisetup` runs per request. That behaves exactly as what
an extension author expects.
- Less memory usage - there is no `repo` object is loaded in memory.
- Reduced process count - since extension config change does not require a
new chg server, the count of server processes would decrease (ex.
`--config extensions.blackbox=!` won't require a new chg server)
- Not holding fd to edenfs, since neither blackbox nor repo is loaded. This
makes it possible to remove the hacky killing chg logic in D7784903.
The downside is performance, since extension loading, and `uisetup` will run
every time. Benchmark shows that's could be 50ms-ish. But we could move
forward by moving extension logic to core incrementally to get rid of that
cost too.
This is basically a simplified version of my previous stack starting
with [1]. The original commit message was:
This is the beginning of a series that does a re-architect to chg mentioned
in [1], to achieve better compatibility.
The compatibility issues are mainly around "uisetup"s and "reposetup"s:
- Developers are usually unaware that uisetup runs only once per chg
process. We cannot reliably devel-warn them. The result is, potential
broken code are written. For example, it's really hard for chg to deal
with "experimental.evolution" changed from unset to manually set in
config files because setconfig is used if that config option is not set.
- An unnecessary "reposetup" caused by "hg serve" may have unwanted
side effects. This can become troublesome if the repo requires things
like remotefilelog or lz4revlog, and the user sets HGRCPATH to run
tests.
The current chg implementation assumes that "loading" an extension is not
side effect free - if extension related config has changed, a restart is
needed. The new idea is, "loading" = "importing" + "run ui/extsetup", the
"importing" part can be side-effect free for some extensions. And benchmark
shows "import" takes most of the time consumed, while "uisetup" is usually
very fast. We can afford running "uisetup"s per request.
To be able to (pre-)"import" extensions without running any "uisetup"s, a
different entry point is needed. Otherwise as long as we go through the
normal dispatch / runcommand ("hg serve") flow, "uisetup"s cannot be
avoided.
Aside from better compatibility, we can also remove some hacks:
- chg client: no longer needs to extract sensitive argv
- chg server: confighash can be changed to only hash environment variables
(reduce the number of server processes)
- chg server: srcui.walkconfig hack is no longer necessary
This patch adds a new script "chgserve" as the new entry point. Currently,
it is just a minimal implementation that makes "CHGHG=chgserve chg ..."
work, without doing any pre-importing. The change could also be done in the
"hg" script. But since chg is still experimental, let's keep "hg" untouched
for now.
[1]: www.mercurial-scm.org/pipermail/mercurial-devel/2016-July/085965.html
[1]: https://bitbucket.org/quark-zju/hg-draft/commits/6f91a1a69fccf89ae6cbffc31da92889aa521f43
Reviewed By: singhsrb
Differential Revision: D7840237
fbshipit-source-id: e3d613b41fe4b721238b86c5bf84434d32cf0609
2018-05-09 02:58:40 +03:00
|
|
|
service = chgserver.chgunixservice(ui, repo, cmdopts)
|
|
|
|
server.runservice(cmdopts, initfn=service.init, runfn=service.run)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-10-02 09:18:24 +03:00
|
|
|
def _initstdio():
|
|
|
|
for fp in (sys.stdin, sys.stdout, sys.stderr):
|
|
|
|
util.setbinary(fp)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-01-26 23:43:13 +03:00
|
|
|
def _getsimilar(symbols, value):
|
|
|
|
sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio()
|
|
|
|
# The cutoff for similarity here is pretty arbitrary. It should
|
|
|
|
# probably be investigated and tweaked.
|
|
|
|
return [s for s in symbols if sim(s) > 0.6]
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-01-05 08:52:44 +03:00
|
|
|
def _reportsimilar(write, similar):
|
|
|
|
if len(similar) == 1:
|
|
|
|
write(_("(did you mean %s?)\n") % similar[0])
|
|
|
|
elif similar:
|
|
|
|
ss = ", ".join(sorted(similar))
|
|
|
|
write(_("(did you mean one of %s?)\n") % ss)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-01-26 22:50:36 +03:00
|
|
|
def _formatparse(write, inst):
|
2015-01-26 23:43:13 +03:00
|
|
|
similar = []
|
|
|
|
if isinstance(inst, error.UnknownIdentifier):
|
|
|
|
# make sure to check fileset first, as revset can invoke fileset
|
|
|
|
similar = _getsimilar(inst.symbols, inst.function)
|
2015-01-26 22:50:36 +03:00
|
|
|
if len(inst.args) > 1:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
write(_("hg: parse error at %s: %s\n") % (inst.args[1], inst.args[0]))
|
|
|
|
if inst.args[0][0] == " ":
|
2015-01-26 22:50:36 +03:00
|
|
|
write(_("unexpected leading whitespace\n"))
|
|
|
|
else:
|
|
|
|
write(_("hg: parse error: %s\n") % inst.args[0])
|
2016-01-05 08:52:44 +03:00
|
|
|
_reportsimilar(write, similar)
|
2016-03-14 15:32:09 +03:00
|
|
|
if inst.hint:
|
|
|
|
write(_("(%s)\n") % inst.hint)
|
2015-01-26 22:50:36 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-03-19 07:18:53 +03:00
|
|
|
def _formatargs(args):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return " ".join(util.shellquote(a) for a in args)
|
|
|
|
|
2017-03-19 07:18:53 +03:00
|
|
|
|
2011-05-26 01:44:11 +04:00
|
|
|
def dispatch(req):
|
|
|
|
"run the command specified in req.args"
|
2011-06-08 15:54:47 +04:00
|
|
|
if req.ferr:
|
|
|
|
ferr = req.ferr
|
|
|
|
elif req.ui:
|
|
|
|
ferr = req.ui.ferr
|
|
|
|
else:
|
2016-10-20 17:53:36 +03:00
|
|
|
ferr = util.stderr
|
2011-06-08 15:54:47 +04:00
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
try:
|
2011-05-26 01:53:23 +04:00
|
|
|
if not req.ui:
|
2016-10-22 08:35:10 +03:00
|
|
|
req.ui = uimod.ui.load()
|
2017-11-23 16:23:59 +03:00
|
|
|
req.earlyoptions.update(_earlyparseopts(req.ui, req.args))
|
2020-08-28 04:11:28 +03:00
|
|
|
if req.earlyoptions["traceback"] or req.earlyoptions["trace"]:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.ui.setconfig("ui", "traceback", "on", "--traceback")
|
2011-06-08 15:54:47 +04:00
|
|
|
|
|
|
|
# set ui streams from the request
|
|
|
|
if req.fin:
|
|
|
|
req.ui.fin = req.fin
|
|
|
|
if req.fout:
|
|
|
|
req.ui.fout = req.fout
|
|
|
|
if req.ferr:
|
|
|
|
req.ui.ferr = req.ferr
|
2015-10-08 22:55:45 +03:00
|
|
|
except error.Abort as inst:
|
2011-06-08 15:54:47 +04:00
|
|
|
ferr.write(_("abort: %s\n") % inst)
|
2010-07-15 16:41:22 +04:00
|
|
|
if inst.hint:
|
2011-06-08 15:54:47 +04:00
|
|
|
ferr.write(_("(%s)\n") % inst.hint)
|
2007-08-16 01:55:13 +04:00
|
|
|
return -1
|
2015-06-24 08:20:08 +03:00
|
|
|
except error.ParseError as inst:
|
2015-01-26 22:50:36 +03:00
|
|
|
_formatparse(ferr.write, inst)
|
2009-09-19 15:52:54 +04:00
|
|
|
return -1
|
2011-06-08 15:54:47 +04:00
|
|
|
|
2019-07-19 01:04:30 +03:00
|
|
|
cmdmsg = _formatargs(req.args)
|
2017-02-16 00:17:39 +03:00
|
|
|
starttime = util.timer()
|
2013-05-23 04:31:47 +04:00
|
|
|
ret = None
|
2018-06-14 02:00:31 +03:00
|
|
|
retmask = 255
|
|
|
|
|
2019-03-21 08:46:07 +03:00
|
|
|
def logatexit():
|
|
|
|
ui = req.ui
|
|
|
|
if ui.logmeasuredtimes:
|
2020-02-01 03:33:39 +03:00
|
|
|
ui.log("measuredtimes", **(ui._measuredtimes))
|
2020-09-10 03:32:44 +03:00
|
|
|
hgmetrics = bindings.hgmetrics.summarize()
|
|
|
|
if hgmetrics:
|
2019-03-21 08:46:07 +03:00
|
|
|
# Re-arrange metrics so "a_b_c", "a_b_d", "a_c" becomes
|
|
|
|
# {'a': {'b': {'c': ..., 'd': ...}, 'c': ...}
|
|
|
|
metrics = {}
|
2020-09-10 03:32:44 +03:00
|
|
|
splitre = re.compile("_|/")
|
2020-09-10 03:32:44 +03:00
|
|
|
for key, value in hgmetrics.items():
|
2019-03-21 08:46:07 +03:00
|
|
|
cur = metrics
|
2020-09-10 03:32:44 +03:00
|
|
|
names = splitre.split(key)
|
2019-03-21 08:46:07 +03:00
|
|
|
for name in names[:-1]:
|
|
|
|
cur = cur.setdefault(name, {})
|
|
|
|
cur[names[-1]] = value
|
|
|
|
# pprint.pformat stablizes the output
|
|
|
|
from pprint import pformat
|
|
|
|
|
|
|
|
# developer config: devel.print-metrics
|
|
|
|
if ui.configbool("devel", "print-metrics"):
|
|
|
|
# Print it out.
|
|
|
|
msg = "%s\n" % pformat({"metrics": metrics}).replace("'", " ")
|
|
|
|
ui.flush()
|
2020-09-10 03:32:44 +03:00
|
|
|
ui.write_err(msg, label="hgmetrics")
|
2019-03-21 08:46:07 +03:00
|
|
|
# Write to blackbox, and sampling
|
2020-09-10 03:32:44 +03:00
|
|
|
ui.log("metrics", pformat({"metrics": metrics}, width=1024), **hgmetrics)
|
2019-06-26 20:59:13 +03:00
|
|
|
blackbox.sync()
|
2018-02-07 03:49:55 +03:00
|
|
|
|
2020-04-08 00:23:11 +03:00
|
|
|
if util.isoldversion():
|
|
|
|
hintutil.trigger("old-version")
|
|
|
|
|
2019-03-21 08:46:07 +03:00
|
|
|
# by registering this exit handler here, we guarantee that it runs
|
|
|
|
# after other exithandlers, like the killpager one
|
|
|
|
req.ui.atexit(logatexit)
|
2018-02-07 03:49:55 +03:00
|
|
|
|
2019-03-21 08:46:07 +03:00
|
|
|
try:
|
2013-05-23 04:31:47 +04:00
|
|
|
ret = _runcatch(req)
|
2017-05-14 09:41:27 +03:00
|
|
|
except error.ProgrammingError as inst:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.ui.warn(_("** ProgrammingError: %s\n") % inst)
|
2017-05-14 09:41:27 +03:00
|
|
|
if inst.hint:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.ui.warn(_("** (%s)\n") % inst.hint)
|
2017-05-14 09:41:27 +03:00
|
|
|
raise
|
2017-04-23 01:00:17 +03:00
|
|
|
except KeyboardInterrupt as inst:
|
2015-12-27 07:38:46 +03:00
|
|
|
try:
|
2017-04-23 01:00:17 +03:00
|
|
|
if isinstance(inst, error.SignalInterrupt):
|
|
|
|
msg = _("killed!\n")
|
|
|
|
else:
|
|
|
|
msg = _("interrupted!\n")
|
|
|
|
req.ui.warn(msg)
|
dispatch: ignore further SIGPIPE while handling KeyboardInterrupt
I got the following error by running "hg log" and quitting the pager
immediately. Any output here may trigger another SIGPIPE, so only thing
we can do is to swallow the exception and exit with an error status.
Traceback (most recent call last):
File "./hg", line 45, in <module>
mercurial.dispatch.run()
File "mercurial/dispatch.py", line 83, in run
status = (dispatch(req) or 0) & 255
File "mercurial/dispatch.py", line 167, in dispatch
req.ui.warn(_("interrupted!\n"))
File "mercurial/ui.py", line 1224, in warn
self.write_err(*msg, **opts)
File "mercurial/ui.py", line 790, in write_err
self._write_err(*msgs, **opts)
File "mercurial/ui.py", line 798, in _write_err
self.ferr.write(a)
File "mercurial/ui.py", line 129, in _catchterm
raise error.SignalInterrupt
mercurial.error.SignalInterrupt
Perhaps this wasn't visible before ee4f321cd621 because the original stderr
handle was restored very late.
2017-04-17 17:53:19 +03:00
|
|
|
except error.SignalInterrupt:
|
|
|
|
# maybe pager would quit without consuming all the output, and
|
|
|
|
# SIGPIPE was raised. we cannot print anything in this case.
|
|
|
|
pass
|
2015-12-27 07:38:46 +03:00
|
|
|
except IOError as inst:
|
|
|
|
if inst.errno != errno.EPIPE:
|
|
|
|
raise
|
|
|
|
ret = -1
|
windows: handle the broken pipe case cleanly
Summary:
The scenario we are handling is as follows:
1. the user runs a long-running Mercurial command with a lot of output, like
`hg log`
2. Mercurial runs pager, which is a subprocess, like `less` and changes its
stdout/stderr to point to pager's stdin.
3. The user exits from the pager (by pressing `q`, for example)
4. The pipe connecting Mercurial stdout/stderr with pager's stdin is now dead.
5. Mercurial tries to write something into its stdout, a failure occurs
6. The finally section restores stdout/stderr to be a tty
7. A failure gets caught up in the stack and printed to stderr, now a tty
A failure is vague here. On Linux, it means a `SIGPIPE`, on Windows, just and
exception that is manifested in Python as `IOError` with `errno=EINVAL`.
This is how Linux deals with it:
1. registed a signal handler for `SIGPIPE`, make this handler raise a
Mercurial-defined `error.SingalInterrupt`, which is a child exception class to
`KerboardInterrupt`
2. catch `KeyboardInterrupt` in `dispatch.dispatch`, handle the broken pipe
case there
For Windows this does not work, since there's no `SIGPIPE`, so
`SignalInterrupt` never gets raised, so we never handle the `IOError`.
This diff just explicitly handles the `IOError` in `dispatch.dispatch` and
silently consumes the `errno.EINVAL` case.
Reviewed By: quark-zju
Differential Revision: D8610555
fbshipit-source-id: 6cadba6a9ec296f03b1b616b763e56ec55da3a70
2018-06-26 20:48:45 +03:00
|
|
|
except IOError as inst:
|
|
|
|
# Windows does not have SIGPIPE, so pager exit does not
|
|
|
|
# get raised as a SignalInterrupt. Let's handle the error
|
|
|
|
# explicitly here
|
|
|
|
if not pycompat.iswindows or inst.errno != errno.EINVAL:
|
|
|
|
raise
|
|
|
|
ret = -1
|
2013-05-23 04:31:47 +04:00
|
|
|
finally:
|
2017-02-16 00:17:39 +03:00
|
|
|
duration = util.timer() - starttime
|
2016-03-14 14:06:34 +03:00
|
|
|
req.ui.flush()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.ui.log(
|
2019-04-23 12:45:38 +03:00
|
|
|
"command_finish",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"%s exited %d after %0.2f seconds\n",
|
2019-07-19 01:04:30 +03:00
|
|
|
cmdmsg,
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ret or 0,
|
|
|
|
duration,
|
|
|
|
)
|
2019-03-26 03:09:11 +03:00
|
|
|
|
2020-01-10 03:00:30 +03:00
|
|
|
threshold = req.ui.configint("tracing", "threshold")
|
2019-11-08 01:19:52 +03:00
|
|
|
if duration >= threshold:
|
|
|
|
key = "flat/perftrace-%(host)s-%(pid)s-%(time)s" % {
|
|
|
|
"host": socket.gethostname(),
|
|
|
|
"pid": os.getpid(),
|
|
|
|
"time": time.time(),
|
|
|
|
}
|
|
|
|
# TODO: Move this into a background task that renders from
|
|
|
|
# blackbox instead.
|
|
|
|
# The "duration" is chosen dynamically for long commands.
|
|
|
|
# The ASCII implementation will fold repetitive calls so
|
|
|
|
# the length of the output is practically bounded.
|
|
|
|
output = bindings.tracing.singleton.ascii(
|
2020-01-10 03:00:30 +03:00
|
|
|
# Minimum resolution = 1% of max(duration, threshold)
|
|
|
|
# It's in microseconds (1e6) to divide it by 100 = 1e4
|
|
|
|
(max([duration, threshold]) * 1e4)
|
2019-11-08 01:19:52 +03:00
|
|
|
)
|
|
|
|
if req.ui.configbool("tracing", "stderr"):
|
|
|
|
req.ui.warn("%s\n" % output)
|
|
|
|
req.ui.log("perftrace", "Trace:\n%s\n", output, key=key, payload=output)
|
|
|
|
req.ui.log("perftracekey", "Trace key:%s\n", key, perftracekey=key)
|
2019-03-26 03:09:11 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.ui._measuredtimes["command_duration"] = duration * 1000
|
2018-06-14 02:00:31 +03:00
|
|
|
retmask = req.ui.configint("ui", "exitcodemask")
|
2018-02-07 03:49:55 +03:00
|
|
|
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
try:
|
|
|
|
req._runexithandlers()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
except: # exiting, so no re-raises
|
ui: add special-purpose atexit functionality
In spite of its longstanding use, Python's built-in atexit code is
not suitable for Mercurial's purposes, for several reasons:
* Handlers run after application code has finished.
* Because of this, the code that runs handlers swallows exceptions
(since there's no possible stacktrace to associate errors with).
If we're lucky, we'll get something spat out to stderr (if stderr
still works), which of course isn't any use in a big deployment
where it's important that exceptions get logged and aggregated.
* Mercurial's current atexit handlers make unfortunate assumptions
about process state (specifically stdio) that, coupled with the
above problems, make it impossible to deal with certain categories
of error (try "hg status > /dev/full" on a Linux box).
* In Python 3, the atexit implementation is completely hidden, so
we can't hijack the platform's atexit code to run handlers at a
time of our choosing.
As a result, here's a perfectly cromulent atexit-like implementation
over which we have control. This lets us decide exactly when the
handlers run (after each request has completed), and control what
the process state is when that occurs (and afterwards).
2017-04-12 00:54:12 +03:00
|
|
|
ret = ret or -1
|
2018-06-14 02:00:31 +03:00
|
|
|
if ret is None:
|
|
|
|
ret = 0
|
|
|
|
return ret & retmask
|
2007-08-16 01:55:13 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-05-26 01:53:23 +04:00
|
|
|
def _runcatch(req):
|
2007-08-16 01:55:13 +04:00
|
|
|
def catchterm(*args):
|
2009-01-12 20:48:05 +03:00
|
|
|
raise error.SignalInterrupt
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2011-05-26 01:53:23 +04:00
|
|
|
ui = req.ui
|
2010-04-07 04:41:22 +04:00
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for name in "SIGBREAK", "SIGHUP", "SIGTERM":
|
2010-04-07 04:41:22 +04:00
|
|
|
num = getattr(signal, name, None)
|
|
|
|
if num:
|
2020-09-18 23:24:31 +03:00
|
|
|
util.signal(num, catchterm)
|
2010-04-07 04:41:22 +04:00
|
|
|
except ValueError:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
pass # happens if called in a thread
|
2020-09-23 01:08:35 +03:00
|
|
|
# In some cases, SIGINT handler is set to SIG_IGN on OSX.
|
|
|
|
# Reset it to raise KeyboardInterrupt.
|
|
|
|
sigint = getattr(signal, "SIGINT", None)
|
|
|
|
if sigint is not None and util.getsignal(sigint) == signal.SIG_IGN:
|
|
|
|
util.signal(sigint, signal.default_int_handler)
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2020-09-19 04:46:00 +03:00
|
|
|
realcmd = None
|
|
|
|
try:
|
|
|
|
cmdargs = cliparser.parseargs(req.args[:])
|
|
|
|
cmd = cmdargs[0]
|
|
|
|
aliases, entry = cmdutil.findcmd(cmd, commands.table)
|
|
|
|
realcmd = aliases[0]
|
|
|
|
except (
|
|
|
|
error.UnknownCommand,
|
|
|
|
error.AmbiguousCommand,
|
|
|
|
IndexError,
|
|
|
|
getopt.GetoptError,
|
|
|
|
UnicodeDecodeError,
|
|
|
|
):
|
|
|
|
# Don't handle this here. We know the command is
|
|
|
|
# invalid, but all we're worried about for now is that
|
|
|
|
# it's not a command that server operators expect to
|
|
|
|
# be safe to offer to users in a sandbox.
|
|
|
|
pass
|
2018-01-03 16:35:56 +03:00
|
|
|
|
2020-09-19 04:46:00 +03:00
|
|
|
def _runcatchfunc():
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if realcmd == "serve" and "--read-only" in req.args:
|
|
|
|
req.args.remove("--read-only")
|
2018-01-03 16:35:56 +03:00
|
|
|
|
|
|
|
if not req.ui:
|
|
|
|
req.ui = uimod.ui.load()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.ui.setconfig(
|
|
|
|
"hooks", "pretxnopen.readonlyrejectpush", rejectpush, "dispatch"
|
|
|
|
)
|
|
|
|
req.ui.setconfig(
|
|
|
|
"hooks", "prepushkey.readonlyrejectpush", rejectpush, "dispatch"
|
|
|
|
)
|
|
|
|
|
|
|
|
if realcmd == "serve" and "--stdio" in cmdargs:
|
2019-09-24 03:08:35 +03:00
|
|
|
# Uncontionally turn off narrow-heads. The hg servers use
|
|
|
|
# full, revlog-based repos. Keep them using old revlog-based
|
|
|
|
# algorithms and do not risk switching to new algorithms.
|
2020-07-02 23:11:57 +03:00
|
|
|
if "SSH_CLIENT" in encoding.environ and req.ui.configbool(
|
|
|
|
"experimental", "disable-narrow-heads-ssh-server"
|
|
|
|
):
|
2019-09-24 03:08:35 +03:00
|
|
|
req.ui.setconfig("experimental", "narrow-heads", "false", "serve")
|
|
|
|
|
2017-04-12 21:23:55 +03:00
|
|
|
# We want to constrain 'hg serve --stdio' instances pretty
|
|
|
|
# closely, as many shared-ssh access tools want to grant
|
|
|
|
# access to run *only* 'hg -R $repo serve --stdio'. We
|
|
|
|
# restrict to exactly that set of arguments, and prohibit
|
|
|
|
# any repo name that starts with '--' to prevent
|
|
|
|
# shenanigans wherein a user does something like pass
|
|
|
|
# --debugger or --config=ui.debugger=1 as a repo
|
|
|
|
# name. This used to actually run the debugger.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if (
|
|
|
|
len(req.args) != 4
|
|
|
|
or req.args[0] != "-R"
|
|
|
|
or req.args[1].startswith("--")
|
|
|
|
or req.args[2] != "serve"
|
|
|
|
or req.args[3] != "--stdio"
|
|
|
|
):
|
2017-04-12 21:23:55 +03:00
|
|
|
raise error.Abort(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_("potentially unsafe serve --stdio invocation: %r") % (req.args,)
|
|
|
|
)
|
2017-04-12 21:23:55 +03:00
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
debugger = "pdb"
|
|
|
|
debugtrace = {"pdb": pdb.set_trace}
|
|
|
|
debugmortem = {"pdb": pdb.post_mortem}
|
2013-07-14 01:33:07 +04:00
|
|
|
|
2018-03-20 02:20:55 +03:00
|
|
|
# --config takes prescendence over --configfile, so process
|
|
|
|
# --configfile first --config second.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for configfile in req.earlyoptions["configfile"]:
|
2018-03-20 02:20:55 +03:00
|
|
|
req.ui.readconfig(configfile)
|
|
|
|
|
2013-07-14 01:33:07 +04:00
|
|
|
# read --config before doing anything else
|
|
|
|
# (e.g. to change trust settings for reading .hg/hgrc)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cfgs = _parseconfig(req.ui, req.earlyoptions["config"])
|
2013-07-14 01:33:07 +04:00
|
|
|
|
|
|
|
if req.repo:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for configfile in req.earlyoptions["configfile"]:
|
2018-03-20 02:20:55 +03:00
|
|
|
req.repo.ui.readconfig(configfile)
|
2013-07-14 01:33:07 +04:00
|
|
|
# copy configs that were passed on the cmdline (--config) to
|
|
|
|
# the repo ui
|
2014-03-20 03:04:03 +04:00
|
|
|
for sec, name, val in cfgs:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
req.repo.ui.setconfig(sec, name, val, source="--config")
|
2013-07-14 01:33:07 +04:00
|
|
|
|
2015-06-26 01:45:49 +03:00
|
|
|
# developer config: ui.debugger
|
2013-07-26 07:28:34 +04:00
|
|
|
debugger = ui.config("ui", "debugger")
|
2014-03-07 23:06:52 +04:00
|
|
|
debugmod = pdb
|
2013-11-25 21:20:39 +04:00
|
|
|
if not debugger or ui.plain():
|
2015-06-26 01:45:49 +03:00
|
|
|
# if we are in HGPLAIN mode, then disable custom debugging
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
debugger = "pdb"
|
|
|
|
elif req.earlyoptions["debugger"]:
|
2014-03-07 23:06:52 +04:00
|
|
|
# This import can be slow for fancy debuggers, so only
|
|
|
|
# do it when absolutely necessary, i.e. when actual
|
|
|
|
# debugging has been requested
|
dispatch: disable demandimport for the --debugger option
Something in Python 2.7.9 or so broke the --debugger option with
ui.debugger = ipdb. I get the traceback below. There is some apparent
confusion with demandimport. This should be disabled anyway for the
--debugger option. The debugger must be imported right away, before
any other dispatch. There's no benefit in delaying the debugger
import.
This patch uses the demandimport.deactivated() context manager.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 121, in _runcatch
debugmod = __import__(debugger)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 115, in _demandimport
return _hgextimport(_import, name, globals, locals, fromlist, level)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 47, in _hgextimport
return importfunc(name, globals, *args)
File "/usr/lib/python2.7/dist-packages/ipdb/__init__.py", line 16, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run, runcall, runeval, launch_ipdb_on_exception
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 134, in _demandimport
mod = _hgextimport(_origimport, name, globals, locals)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 47, in _hgextimport
return importfunc(name, globals, *args)
File "/usr/lib/python2.7/dist-packages/ipdb/__main__.py", line 29, in <module>
if IPython.__version__ > '0.10.2':
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 106, in __getattribute__
self._load()
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 78, in _load
mod = _hgextimport(_import, head, globals, locals, None, level)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 47, in _hgextimport
return importfunc(name, globals, *args)
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 45, in <module>
from .config.loader import Config
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 132, in _demandimport
return _origimport(name, globals, locals, fromlist, level)
File "/usr/lib/python2.7/dist-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 115, in _demandimport
return _hgextimport(_import, name, globals, locals, fromlist, level)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 47, in _hgextimport
return importfunc(name, globals, *args)
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 30, in <module>
from IPython.external.decorator import decorator
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 134, in _demandimport
mod = _hgextimport(_origimport, name, globals, locals)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 47, in _hgextimport
return importfunc(name, globals, *args)
File "/usr/lib/python2.7/dist-packages/IPython/external/decorator/__init__.py", line 2, in <module>
from decorator import *
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 115, in _demandimport
return _hgextimport(_import, name, globals, locals, fromlist, level)
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 47, in _hgextimport
return importfunc(name, globals, *args)
File "/usr/lib/python2.7/dist-packages/decorator.py", line 240, in <module>
'ContextManager', (_GeneratorContextManager,), dict(__call__=__call__))
2015-05-28 23:42:21 +03:00
|
|
|
with demandimport.deactivated():
|
|
|
|
try:
|
|
|
|
debugmod = __import__(debugger)
|
|
|
|
except ImportError:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
pass # Leave debugmod = pdb
|
2013-07-26 07:28:34 +04:00
|
|
|
|
|
|
|
debugtrace[debugger] = debugmod.set_trace
|
|
|
|
debugmortem[debugger] = debugmod.post_mortem
|
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
# enter the debugger before command execution
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if req.earlyoptions["debugger"]:
|
2019-08-14 05:09:13 +03:00
|
|
|
ui.disablepager()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.warn(
|
|
|
|
_(
|
|
|
|
"entering debugger - "
|
|
|
|
"type c to continue starting hg or h for help\n"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if debugger != "pdb" and debugtrace[debugger] == debugtrace["pdb"]:
|
|
|
|
ui.warn(
|
|
|
|
_("%s debugger specified " "but its module was not found\n")
|
|
|
|
% debugger
|
|
|
|
)
|
2015-09-13 23:30:21 +03:00
|
|
|
with demandimport.deactivated():
|
2015-09-10 16:30:10 +03:00
|
|
|
debugtrace[debugger]()
|
2007-08-16 01:55:13 +04:00
|
|
|
try:
|
2011-05-26 01:53:23 +04:00
|
|
|
return _dispatch(req)
|
2007-08-16 01:55:13 +04:00
|
|
|
finally:
|
|
|
|
ui.flush()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
except: # re-raises
|
2019-09-26 03:44:11 +03:00
|
|
|
# Potentially enter the debugger when we hit an exception
|
|
|
|
startdebugger = req.earlyoptions["debugger"]
|
|
|
|
if startdebugger:
|
|
|
|
# Enforce the use of ipdb, since it's always available and
|
|
|
|
# we can afford the import overhead here.
|
|
|
|
with demandimport.deactivated():
|
|
|
|
import ipdb
|
|
|
|
|
2010-06-30 19:20:42 +04:00
|
|
|
traceback.print_exc()
|
2019-09-26 03:44:11 +03:00
|
|
|
ipdb.post_mortem(sys.exc_info()[2])
|
2019-09-28 00:58:32 +03:00
|
|
|
os._exit(255)
|
2007-08-16 01:55:13 +04:00
|
|
|
raise
|
|
|
|
|
2020-09-19 04:46:00 +03:00
|
|
|
# IPython (debugshell) has some background (sqlite?) threads that is incompatible
|
|
|
|
# with util.threaded. But "debugshell -c" should use util.threaded.
|
|
|
|
if (
|
|
|
|
ui.configbool("ui", "threaded")
|
|
|
|
and req.args not in [["dbsh"], ["debugsh"], ["debugshell"]]
|
|
|
|
and realcmd != "serve"
|
|
|
|
):
|
2020-09-21 23:12:18 +03:00
|
|
|
# Run command (and maybe start ipdb) in a background thread for
|
|
|
|
# better Ctrl+C handling of long native logic.
|
|
|
|
return util.threaded(_callcatch)(ui, _runcatchfunc)
|
|
|
|
else:
|
|
|
|
# Run in the main thread.
|
|
|
|
return _callcatch(ui, _runcatchfunc)
|
2016-08-09 18:45:28 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-04-15 06:58:06 +03:00
|
|
|
def _callcatch(ui, func):
|
2016-11-24 03:48:40 +03:00
|
|
|
"""like scmutil.callcatch but handles more high-level exceptions about
|
|
|
|
config parsing and commands. besides, use handlecommandexception to handle
|
|
|
|
uncaught exceptions.
|
2016-08-09 18:45:28 +03:00
|
|
|
"""
|
|
|
|
try:
|
2016-11-24 03:48:40 +03:00
|
|
|
return scmutil.callcatch(ui, func)
|
2015-06-24 08:20:08 +03:00
|
|
|
except error.AmbiguousCommand as inst:
|
2019-07-26 02:13:22 +03:00
|
|
|
|
|
|
|
ui.warn(_("hg: command '%s' is ambiguous:\n") % inst.args[0])
|
|
|
|
|
|
|
|
for match in inst.args[1]:
|
|
|
|
cmds = match.split(" or ")
|
|
|
|
parts = [cmd.partition(inst.args[0]) for cmd in cmds]
|
|
|
|
msg = " or ".join(
|
|
|
|
ui.label(part[1], "ui.prefix.component") + part[2] for part in parts
|
|
|
|
)
|
|
|
|
|
|
|
|
ui.write("\t%s\n" % msg)
|
|
|
|
|
2015-06-24 08:20:08 +03:00
|
|
|
except error.CommandError as inst:
|
2009-01-12 22:35:35 +03:00
|
|
|
if inst.args[0]:
|
2017-05-28 22:47:00 +03:00
|
|
|
msgbytes = pycompat.bytestr(inst.args[1])
|
|
|
|
ui.warn(_("hg %s: %s\n") % (inst.args[0], msgbytes))
|
2019-02-21 05:38:56 +03:00
|
|
|
ui.warn(_("(use 'hg %s -h' to get help)\n") % (inst.args[0],))
|
2009-01-12 22:35:35 +03:00
|
|
|
else:
|
|
|
|
ui.warn(_("hg: %s\n") % inst.args[1])
|
2019-02-21 05:38:56 +03:00
|
|
|
ui.warn(_("(use 'hg -h' to get help)\n"))
|
2016-11-24 03:48:40 +03:00
|
|
|
except error.ParseError as inst:
|
|
|
|
_formatparse(ui.warn, inst)
|
|
|
|
return -1
|
2015-06-24 08:20:08 +03:00
|
|
|
except error.UnknownCommand as inst:
|
2019-08-20 05:24:40 +03:00
|
|
|
ui.warn(_("unknown command %r\n(use 'hg help' to get help)\n") % inst.args[0])
|
2018-05-03 14:33:07 +03:00
|
|
|
except error.UnknownSubcommand as inst:
|
cmdutil: remove allcmds from UnknownCommand
Summary:
This makes the backtrace much shorter.
Before:
Traceback (most recent call last):
File "edenscm/mercurial/cmdutil.py", line 876, in findsubcmd
aliases, entry = findcmd(cmd, table)
# cmd = 'foo'
File "edenscm/mercurial/cmdutil.py", line 871, in findcmd
raise error.UnknownCommand(cmd, allcmds)
# allcmds = ['debuggentrees', 'debugsuccessorssets', 'branch', 'br', 'bra', 'bran', 'branc', 'show', ...]
# cmd = 'foo'
UnknownCommand: ('foo', ['debuggentrees', 'debugsuccessorssets', 'branch', 'br', 'bra', 'bran', 'branc', 'show', 'rename', 'move', 'mv', 'ren', 'rena', 'renam', 'mo', 'mov', 'commit', 'ci', 'com', 'comm', 'commi', 'debugremotebookmark', 'gc', 'debugindexedlogdatastore', 'debugexistingcasecollisions', 'debugshell', 'dbsh', 'debugsh', 'debugpython', 'debugpy', 'debugfileset', 'debugdata', 'debugundohistory', 'debugprogress', 'config', 'showconfig', 'debugconfig', 'conf', 'confi', 'paths', 'path', 'bisect', 'bi', 'bis', 'bise', 'bisec', 'debugcheckcasecollisions', 'add', 'debugrename', 'annotate', 'blame', 'blam', 'an', 'ann', 'anno', 'annot', 'annota', 'annotat', 'journal', 'j', 'jo', 'jou', 'jour', 'journ', 'journa', 'parents', 'par', 'pare', 'paren', 'parent', 'rollback', 'debugmergestate', 'identify', 'id', 'ide', 'iden', 'ident', 'identi', 'identif', 'debugformat', 'bookmarks', 'bookmark', 'bo', 'boo', 'book', 'bookm', 'bookma', 'bookmar', 'debugrevspec', 'debugwalk', 'amend', 'am', 'ame', 'amen', 'debughttp', 'hide', 'strip', 'hid', 'str', 'stri', 'tip', 'ti', 'debugcommitmessage', 'hint', 'hin', 'locate', 'loc', 'loca', 'locat', 'debugfilerevision', 'debugfilerev', 'incoming', 'in', 'debugdag', 'next', 'n', 'ne', 'nex', 'unshare', 'rebase', 'unhide', 'unh', 'unhi', 'unhid', 'grep', 'gre', 'archive', 'ar', 'arc', 'arch', 'archi', 'archiv', 'debugmarklanded', 'debugpushkey', 'debugdatapack', 'debugtreestate', 'debugtreedirstate', 'debugtree', 'debuglocks', 'debuglock', 'revert', 'rev', 'reve', 'rever', 'export', 'e', 'ex', 'exp', 'expo', 'expor', 'repack', 'shelve', 'she', 'shel', 'shelv', 'log', 'history', 'debugwaitbackup', 'debugnamecomplete', 'diff', 'd', 'di', 'dif', 'debugdrawdag', 'debugcheckoutidentifier', 'debugdate', 'debuggethistory', 'debugssl', 'init', 'ini', 'debuggetbundle', 'summary', 'sum', 'su', 'summ', 'summa', 'summar', 'unbundle', 'unb', 'unbu', 'unbun', 'unbund', 'unbundl', 'debugwaitonrepack', 'backfilltree', 'debugcrdump', 'outgoing', 'out', 'debugupgraderepo', 'debugmovescratchbookmark', 'debugrebuilddirstate', 'debugrebuildstate', 'debugancestor', 'remove', 'rm', 'rem', 'remo', 'remov', 'debugfillinfinitepushmetadata', 'sparse', 'tags', 'debugcolor', 'debugrunshell', 'debugpathcomplete', 'purge', 'clean', 'undo', 'debugindexedlog-dump', 'debugcheckstate', 'metaedit', 'met', 'meta', 'metae', 'metaed', 'metaedi', 'debugcommands', 'convert', 'debugmutationfromobsmarkers', 'graft', 'gra', 'graf', 'root', 'uncommit', 'unc', 'unco', 'uncom', 'uncomm', 'uncommi', 'verifyremotefilelog', 'copy', 'cp', 'cop', 'debugpreviewbindag', 'files', 'fi', 'fil', 'file', 'debugprocesstree', 'debugproc', 'debugdeltachain', 'fold', 'squash', 'debughistorypack', 'debug-args', 'debugcapabilities', 'debugindexedloghistorystore', 'debuggetfiles', 'debuggetfile', 'debugapplystreamclonebundle', 'redo', 'cloud', 'debugremotefilelog', 'debugsetparents', 'debugmetalog', 'debugindexedlog-repair', 'debugbindag', 'version', 'vers', 'versi', 'versio', 'status', 'st', 'sta', 'stat', 'statu', 'debugmutation', 'debugignore', 'debugobsolete', 'debugupdatecaches', 'debugwaitonprefetch', 'merge', 'mer', 'merg', 'addremove', 'addr', 'addre', 'addrem', 'addremo', 'addremov', 'share', 'debugmanifestdirs', 'serve', 'fastannotate', 'fastblame', 'fa', 'debugdiscovery', 'debugwireargs', 'push', 'debugpickmergetool', 'debugstrip', 'debugbuildannotatecache', 'isbackedup', 'reset', 'debugcomplete', 'debugfsinfo', 'debugfs', 'prune', 'rage', 'unamend', 'una', 'unam', 'uname', 'unamen', 'previous', 'prev', 'previ', 'previo', 'previou', 'continue', 'cont', 'debugsvnlog', 'debugvisibility', 'cat', 'record', 'debugrevlog', 'unshelve', 'unshe', 'unshel', 'unshelv', 'debugrebuildfncache', 'debugdirs', 'import', 'patch', 'im', 'imp', 'impo', 'impor', 'patc', 'backfillmanifestrevlog', 'debuglabelcomplete', 'split', 'spl', 'spli', 'smartlog', 'sl', 'slog', 'sm', 'sma', 'smar', 'smart', 'smartl', 'smartlo', 'debuggettrees', 'debugedenrunpostupdatehook', 'debugstatus', 'manifest', 'mani', 'tag', 'bundle', 'bu', 'bun', 'bund', 'bundl', 'debugtemplate', 'phase', 'ph', 'pha', 'phas', 'dump-trace', 'debugstore', 'rebase', 'reb', 'reba', 'rebas', 'recover', 'debugrefreshwatchmanclock', 'doctor', 'verify', 'forget', 'for', 'forg', 'forge', 'debugextensions', 'pushbackup', 'absorb', 'ab', 'abs', 'abso', 'absor', 'sf', 'debuginstall', 'histgrep', 'debugreadauthforuri', 'prefetch', 'fs', 'blackbox', 'clone', 'histedit', 'histe', 'histed', 'histedi', 'debugpvec', 'resolve', 'reso', 'resol', 'resolv', 'debugcreatestreamclonebundle', 'debugserialgetfiles', 'debugbuilddag', 'debugindex', 'debugcreatescratchbookmark', 'heads', 'hea', 'head', 'debugedenimporthelper', 'githelp', 'git', 'pull', 'pul', 'chistedit', 'debugindexdot', 'debugdirstate', 'debugstate', 'debugknown', 'backout', 'backo', 'backou', 'update', 'up', 'checkout', 'co', 'upd', 'upda', 'updat', 'che', 'chec', 'check', 'checko', 'checkou', 'help', 'hel', 'debugbundle'])
unknown command 'foo'
(use 'hg help' to get help)
After:
Traceback (most recent call last):
File "edenscm/mercurial/cmdutil.py", line 876, in findsubcmd
aliases, entry = findcmd(cmd, table)
# cmd = 'foo'
File "edenscm/mercurial/cmdutil.py", line 871, in findcmd
raise error.UnknownCommand(cmd)
# cmd = 'foo'
UnknownCommand: foo
unknown command 'foo'
(use 'hg help' to get help)
Reviewed By: xavierd
Differential Revision: D19959205
fbshipit-source-id: e3fa6de8edfec7510ecd29defe538dddf8b563a2
2020-02-20 07:11:07 +03:00
|
|
|
cmd, subcmd = inst.args[:2]
|
2018-05-03 14:33:07 +03:00
|
|
|
if subcmd is not None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
nosubcmdmsg = _("hg %s: unknown subcommand '%s'\n") % (cmd, subcmd)
|
2018-05-03 14:33:07 +03:00
|
|
|
else:
|
|
|
|
nosubcmdmsg = _("hg %s: subcommand required\n") % cmd
|
cmdutil: remove allcmds from UnknownCommand
Summary:
This makes the backtrace much shorter.
Before:
Traceback (most recent call last):
File "edenscm/mercurial/cmdutil.py", line 876, in findsubcmd
aliases, entry = findcmd(cmd, table)
# cmd = 'foo'
File "edenscm/mercurial/cmdutil.py", line 871, in findcmd
raise error.UnknownCommand(cmd, allcmds)
# allcmds = ['debuggentrees', 'debugsuccessorssets', 'branch', 'br', 'bra', 'bran', 'branc', 'show', ...]
# cmd = 'foo'
UnknownCommand: ('foo', ['debuggentrees', 'debugsuccessorssets', 'branch', 'br', 'bra', 'bran', 'branc', 'show', 'rename', 'move', 'mv', 'ren', 'rena', 'renam', 'mo', 'mov', 'commit', 'ci', 'com', 'comm', 'commi', 'debugremotebookmark', 'gc', 'debugindexedlogdatastore', 'debugexistingcasecollisions', 'debugshell', 'dbsh', 'debugsh', 'debugpython', 'debugpy', 'debugfileset', 'debugdata', 'debugundohistory', 'debugprogress', 'config', 'showconfig', 'debugconfig', 'conf', 'confi', 'paths', 'path', 'bisect', 'bi', 'bis', 'bise', 'bisec', 'debugcheckcasecollisions', 'add', 'debugrename', 'annotate', 'blame', 'blam', 'an', 'ann', 'anno', 'annot', 'annota', 'annotat', 'journal', 'j', 'jo', 'jou', 'jour', 'journ', 'journa', 'parents', 'par', 'pare', 'paren', 'parent', 'rollback', 'debugmergestate', 'identify', 'id', 'ide', 'iden', 'ident', 'identi', 'identif', 'debugformat', 'bookmarks', 'bookmark', 'bo', 'boo', 'book', 'bookm', 'bookma', 'bookmar', 'debugrevspec', 'debugwalk', 'amend', 'am', 'ame', 'amen', 'debughttp', 'hide', 'strip', 'hid', 'str', 'stri', 'tip', 'ti', 'debugcommitmessage', 'hint', 'hin', 'locate', 'loc', 'loca', 'locat', 'debugfilerevision', 'debugfilerev', 'incoming', 'in', 'debugdag', 'next', 'n', 'ne', 'nex', 'unshare', 'rebase', 'unhide', 'unh', 'unhi', 'unhid', 'grep', 'gre', 'archive', 'ar', 'arc', 'arch', 'archi', 'archiv', 'debugmarklanded', 'debugpushkey', 'debugdatapack', 'debugtreestate', 'debugtreedirstate', 'debugtree', 'debuglocks', 'debuglock', 'revert', 'rev', 'reve', 'rever', 'export', 'e', 'ex', 'exp', 'expo', 'expor', 'repack', 'shelve', 'she', 'shel', 'shelv', 'log', 'history', 'debugwaitbackup', 'debugnamecomplete', 'diff', 'd', 'di', 'dif', 'debugdrawdag', 'debugcheckoutidentifier', 'debugdate', 'debuggethistory', 'debugssl', 'init', 'ini', 'debuggetbundle', 'summary', 'sum', 'su', 'summ', 'summa', 'summar', 'unbundle', 'unb', 'unbu', 'unbun', 'unbund', 'unbundl', 'debugwaitonrepack', 'backfilltree', 'debugcrdump', 'outgoing', 'out', 'debugupgraderepo', 'debugmovescratchbookmark', 'debugrebuilddirstate', 'debugrebuildstate', 'debugancestor', 'remove', 'rm', 'rem', 'remo', 'remov', 'debugfillinfinitepushmetadata', 'sparse', 'tags', 'debugcolor', 'debugrunshell', 'debugpathcomplete', 'purge', 'clean', 'undo', 'debugindexedlog-dump', 'debugcheckstate', 'metaedit', 'met', 'meta', 'metae', 'metaed', 'metaedi', 'debugcommands', 'convert', 'debugmutationfromobsmarkers', 'graft', 'gra', 'graf', 'root', 'uncommit', 'unc', 'unco', 'uncom', 'uncomm', 'uncommi', 'verifyremotefilelog', 'copy', 'cp', 'cop', 'debugpreviewbindag', 'files', 'fi', 'fil', 'file', 'debugprocesstree', 'debugproc', 'debugdeltachain', 'fold', 'squash', 'debughistorypack', 'debug-args', 'debugcapabilities', 'debugindexedloghistorystore', 'debuggetfiles', 'debuggetfile', 'debugapplystreamclonebundle', 'redo', 'cloud', 'debugremotefilelog', 'debugsetparents', 'debugmetalog', 'debugindexedlog-repair', 'debugbindag', 'version', 'vers', 'versi', 'versio', 'status', 'st', 'sta', 'stat', 'statu', 'debugmutation', 'debugignore', 'debugobsolete', 'debugupdatecaches', 'debugwaitonprefetch', 'merge', 'mer', 'merg', 'addremove', 'addr', 'addre', 'addrem', 'addremo', 'addremov', 'share', 'debugmanifestdirs', 'serve', 'fastannotate', 'fastblame', 'fa', 'debugdiscovery', 'debugwireargs', 'push', 'debugpickmergetool', 'debugstrip', 'debugbuildannotatecache', 'isbackedup', 'reset', 'debugcomplete', 'debugfsinfo', 'debugfs', 'prune', 'rage', 'unamend', 'una', 'unam', 'uname', 'unamen', 'previous', 'prev', 'previ', 'previo', 'previou', 'continue', 'cont', 'debugsvnlog', 'debugvisibility', 'cat', 'record', 'debugrevlog', 'unshelve', 'unshe', 'unshel', 'unshelv', 'debugrebuildfncache', 'debugdirs', 'import', 'patch', 'im', 'imp', 'impo', 'impor', 'patc', 'backfillmanifestrevlog', 'debuglabelcomplete', 'split', 'spl', 'spli', 'smartlog', 'sl', 'slog', 'sm', 'sma', 'smar', 'smart', 'smartl', 'smartlo', 'debuggettrees', 'debugedenrunpostupdatehook', 'debugstatus', 'manifest', 'mani', 'tag', 'bundle', 'bu', 'bun', 'bund', 'bundl', 'debugtemplate', 'phase', 'ph', 'pha', 'phas', 'dump-trace', 'debugstore', 'rebase', 'reb', 'reba', 'rebas', 'recover', 'debugrefreshwatchmanclock', 'doctor', 'verify', 'forget', 'for', 'forg', 'forge', 'debugextensions', 'pushbackup', 'absorb', 'ab', 'abs', 'abso', 'absor', 'sf', 'debuginstall', 'histgrep', 'debugreadauthforuri', 'prefetch', 'fs', 'blackbox', 'clone', 'histedit', 'histe', 'histed', 'histedi', 'debugpvec', 'resolve', 'reso', 'resol', 'resolv', 'debugcreatestreamclonebundle', 'debugserialgetfiles', 'debugbuilddag', 'debugindex', 'debugcreatescratchbookmark', 'heads', 'hea', 'head', 'debugedenimporthelper', 'githelp', 'git', 'pull', 'pul', 'chistedit', 'debugindexdot', 'debugdirstate', 'debugstate', 'debugknown', 'backout', 'backo', 'backou', 'update', 'up', 'checkout', 'co', 'upd', 'upda', 'updat', 'che', 'chec', 'check', 'checko', 'checkou', 'help', 'hel', 'debugbundle'])
unknown command 'foo'
(use 'hg help' to get help)
After:
Traceback (most recent call last):
File "edenscm/mercurial/cmdutil.py", line 876, in findsubcmd
aliases, entry = findcmd(cmd, table)
# cmd = 'foo'
File "edenscm/mercurial/cmdutil.py", line 871, in findcmd
raise error.UnknownCommand(cmd)
# cmd = 'foo'
UnknownCommand: foo
unknown command 'foo'
(use 'hg help' to get help)
Reviewed By: xavierd
Differential Revision: D19959205
fbshipit-source-id: e3fa6de8edfec7510ecd29defe538dddf8b563a2
2020-02-20 07:11:07 +03:00
|
|
|
ui.warn(nosubcmdmsg)
|
2016-11-24 03:48:40 +03:00
|
|
|
except IOError:
|
|
|
|
raise
|
2009-01-12 22:35:35 +03:00
|
|
|
except KeyboardInterrupt:
|
2015-12-27 07:38:46 +03:00
|
|
|
raise
|
2016-11-24 03:48:40 +03:00
|
|
|
except: # probably re-raises
|
2019-09-28 00:58:32 +03:00
|
|
|
# Potentially enter ipdb debugger when we hit an uncaught exception
|
2020-08-28 04:11:28 +03:00
|
|
|
ex = sys.exc_info()[1]
|
|
|
|
isipdb = isinstance(ex, NameError) and "'ipdb'" in str(ex)
|
2019-09-28 00:58:32 +03:00
|
|
|
if (
|
2020-08-28 04:11:28 +03:00
|
|
|
(ui.configbool("devel", "debugger") or isipdb)
|
2019-09-28 00:58:32 +03:00
|
|
|
and ui.interactive()
|
|
|
|
and not ui.pageractive
|
|
|
|
and not ui.plain()
|
2020-04-06 21:08:31 +03:00
|
|
|
and ui.formatted
|
2019-09-28 00:58:32 +03:00
|
|
|
):
|
2020-08-28 04:11:28 +03:00
|
|
|
if isipdb:
|
|
|
|
ui.write_err(_("Starting ipdb for 'ipdb'\n"))
|
|
|
|
else:
|
|
|
|
ui.write_err(
|
|
|
|
_(
|
|
|
|
"Starting ipdb for this exception\nIf you don't want the behavior, set devel.debugger to False\n"
|
|
|
|
)
|
2019-09-28 00:58:32 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
with demandimport.deactivated():
|
|
|
|
import ipdb
|
|
|
|
|
|
|
|
if not ui.tracebackflag:
|
|
|
|
traceback.print_exc()
|
|
|
|
ipdb.post_mortem(sys.exc_info()[2])
|
|
|
|
os._exit(255)
|
2016-04-04 19:27:37 +03:00
|
|
|
if not handlecommandexception(ui):
|
|
|
|
raise
|
2007-08-16 01:55:13 +04:00
|
|
|
|
|
|
|
return -1
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
template: add a way to support command-level template cleanly
Summary:
There mercurial template language is a powerful language. But it has some
limitations right now:
- It's focused on "commit". If there is no commit, things become harder.
- The related formatter concept is coupled with "a list of things". If there
is no list, things become impossible.
- Some commands use formatter/template partially, and that does not play
very well with `ui.write`, and is difficult to document.
This patch starts to solve all the issues, by introducing command-level
template state, and with the vision:
- Anything could be used as an "environment" passed to the template
language, a commit, a file, a line, a "command" with customized
properties, etc.
- If a template keyword function is incompatible with the environment, it
should fail gracefully.
- The template language is a super set of other things. `-Tjson` should not
be magical, but an alias of `{some complex expression | json}`.
- Discourage the use of formatter.
- Template keywords can be registered and documented.
This would remove the limitations of the template language and unleash its
full potential.
Note there are still some cases where the formatter is desirable. For example,
`hg log` with a large revset should be able to stream its output. The command
template feature added right now only renders things at the end of a command,
and is not (and requires significant effort to be) streaming-friendly.
Reviewed By: mitrandir77
Differential Revision: D8221078
fbshipit-source-id: 26fed50025c4676af277686382ce2d36f1faed97
2018-06-07 01:21:29 +03:00
|
|
|
class cmdtemplatestate(object):
|
|
|
|
"""Template-related state for a command.
|
|
|
|
|
|
|
|
Used together with cmdtemplate=True.
|
|
|
|
|
|
|
|
In MVC's sense, this is the "M". The template language takes the "M" and
|
|
|
|
renders the "V".
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, ui, opts):
|
|
|
|
self._ui = ui
|
|
|
|
self._templ = opts.get("template")
|
|
|
|
if self._templ:
|
|
|
|
# Suppress traditional outputs.
|
|
|
|
ui.pushbuffer()
|
|
|
|
self._props = {}
|
|
|
|
|
|
|
|
def setprop(self, name, value):
|
|
|
|
self._props[name] = value
|
|
|
|
|
|
|
|
def end(self):
|
|
|
|
if self._templ:
|
|
|
|
ui = self._ui
|
|
|
|
ui.popbuffer()
|
|
|
|
text = cmdutil.rendertemplate(self._ui, self._templ, self._props)
|
|
|
|
self._ui.write(text)
|
|
|
|
|
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
def _parse(ui, args):
|
|
|
|
options = {}
|
|
|
|
cmdoptions = {}
|
|
|
|
|
2019-07-20 11:01:33 +03:00
|
|
|
# -cm foo: --config m foo
|
|
|
|
fullargs = list(args)
|
2019-07-20 11:01:33 +03:00
|
|
|
commandnames = [command for command in commands.table]
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2019-07-30 05:30:30 +03:00
|
|
|
args, options, replace = cliparser.parse(args, True)
|
2019-07-20 11:01:33 +03:00
|
|
|
strict = ui.configbool("ui", "strict")
|
2007-08-16 01:55:13 +04:00
|
|
|
if args:
|
2019-07-20 11:01:33 +03:00
|
|
|
try:
|
|
|
|
replacement, aliases = cliparser.expandargs(
|
2020-03-13 20:47:38 +03:00
|
|
|
ui._rcfg._rcfg, commandnames, args, strict
|
2019-07-20 11:01:33 +03:00
|
|
|
)
|
|
|
|
except cliparser.AmbiguousCommand as e:
|
|
|
|
e.args[2].sort()
|
|
|
|
possibilities = e.args[2]
|
|
|
|
raise error.AmbiguousCommand(e.args[1], possibilities)
|
|
|
|
except cliparser.CircularReference as e:
|
|
|
|
alias = e.args[1]
|
|
|
|
raise error.Abort(_("circular alias: %s") % alias)
|
2019-07-30 05:30:30 +03:00
|
|
|
except cliparser.MalformedAlias as e:
|
2019-07-30 05:30:30 +03:00
|
|
|
msg = e.args[0]
|
|
|
|
raise error.Abort(msg)
|
2019-07-20 11:01:33 +03:00
|
|
|
|
|
|
|
else:
|
|
|
|
replacement = []
|
|
|
|
|
|
|
|
if len(replacement) > 0:
|
2019-07-30 05:30:30 +03:00
|
|
|
# FIXME: Find a way to avoid calling expandargs twice.
|
|
|
|
fullargs = (
|
|
|
|
fullargs[:replace]
|
2020-03-13 20:47:38 +03:00
|
|
|
+ cliparser.expandargs(
|
|
|
|
ui._rcfg._rcfg, commandnames, fullargs[replace:], strict
|
|
|
|
)[0]
|
2019-07-30 05:30:30 +03:00
|
|
|
)
|
2019-07-20 11:01:33 +03:00
|
|
|
|
2019-07-20 11:01:33 +03:00
|
|
|
# Only need to figure out the command name. Parse result is dropped.
|
2019-10-09 21:06:55 +03:00
|
|
|
cmd, _args, a, entry, level = cmdutil.findsubcmd(replacement, commands.table)
|
2009-11-13 17:38:27 +03:00
|
|
|
c = list(entry[1])
|
2007-08-16 01:55:13 +04:00
|
|
|
else:
|
2019-07-20 11:01:33 +03:00
|
|
|
aliases = []
|
2007-08-16 01:55:13 +04:00
|
|
|
cmd = None
|
2019-07-20 11:01:33 +03:00
|
|
|
level = 0
|
2007-08-16 01:55:13 +04:00
|
|
|
c = []
|
|
|
|
|
|
|
|
# combine global options into local
|
2019-07-20 11:01:33 +03:00
|
|
|
c += commands.globalopts
|
2007-08-16 01:55:13 +04:00
|
|
|
|
|
|
|
try:
|
2019-07-20 11:01:33 +03:00
|
|
|
flagdefs = [(flagdef[0], flagdef[1], flagdef[2]) for flagdef in c]
|
|
|
|
|
|
|
|
args, cmdoptions = cliparser.parsecommand(fullargs, flagdefs)
|
2019-07-20 11:01:33 +03:00
|
|
|
args = args[level:]
|
2019-07-20 11:01:33 +03:00
|
|
|
except (
|
|
|
|
cliparser.OptionNotRecognized,
|
|
|
|
cliparser.OptionRequiresArgument,
|
|
|
|
cliparser.OptionAmbiguous,
|
|
|
|
) as e:
|
|
|
|
raise error.CommandError(cmd, e.args[0])
|
|
|
|
except cliparser.OptionArgumentInvalid as e:
|
|
|
|
raise error.Abort(e.args[0])
|
2007-08-16 01:55:13 +04:00
|
|
|
|
|
|
|
# separate global options back out
|
2020-01-28 21:21:58 +03:00
|
|
|
for (k, v) in list(cmdoptions.items()):
|
2019-07-20 11:01:33 +03:00
|
|
|
if "-" in k:
|
|
|
|
orig = k
|
|
|
|
k = k.replace("-", "_")
|
|
|
|
cmdoptions[k] = v
|
|
|
|
del cmdoptions[orig]
|
|
|
|
else:
|
|
|
|
cmdoptions[k] = v
|
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
for o in commands.globalopts:
|
|
|
|
n = o[1]
|
|
|
|
options[n] = cmdoptions[n]
|
|
|
|
del cmdoptions[n]
|
|
|
|
|
2019-07-20 11:01:33 +03:00
|
|
|
return (cmd, cmd and entry[0] or None, args, options, cmdoptions, aliases)
|
2007-08-16 01:55:13 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2009-04-24 00:40:10 +04:00
|
|
|
def _parseconfig(ui, config):
|
2007-08-16 01:55:13 +04:00
|
|
|
"""parse the --config options from the command line"""
|
2011-06-24 20:44:59 +04:00
|
|
|
configs = []
|
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
for cfg in config:
|
|
|
|
try:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
name, value = [cfgelem.strip() for cfgelem in cfg.split("=", 1)]
|
|
|
|
section, name = name.split(".", 1)
|
2007-08-16 01:55:13 +04:00
|
|
|
if not section or not name:
|
|
|
|
raise IndexError
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.setconfig(section, name, value, "--config")
|
2011-06-24 20:44:59 +04:00
|
|
|
configs.append((section, name, value))
|
2007-08-16 01:55:13 +04:00
|
|
|
except (IndexError, ValueError):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(
|
|
|
|
_("malformed --config option: %r " "(use --config section.name=value)")
|
|
|
|
% cfg
|
|
|
|
)
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2011-06-24 20:44:59 +04:00
|
|
|
return configs
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-11-23 16:23:59 +03:00
|
|
|
def _earlyparseopts(ui, args):
|
2019-07-20 11:01:33 +03:00
|
|
|
try:
|
|
|
|
return cliparser.earlyparse(args)
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
raise error.Abort(_("cannot decode command line arguments"))
|
2017-11-23 16:17:03 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2019-04-15 16:52:12 +03:00
|
|
|
def _joinfullargs(fullargs):
|
|
|
|
fullargs = [util.shellquote(arg) for arg in fullargs]
|
|
|
|
return " ".join(fullargs)
|
|
|
|
|
|
|
|
|
2010-06-10 20:32:19 +04:00
|
|
|
def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
|
2009-02-12 19:36:15 +03:00
|
|
|
# run pre-hook, and abort if it fails
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
hook.hook(
|
|
|
|
lui,
|
|
|
|
repo,
|
|
|
|
"pre-%s" % cmd,
|
|
|
|
True,
|
2019-04-15 16:52:12 +03:00
|
|
|
args=_joinfullargs(fullargs),
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
pats=cmdpats,
|
|
|
|
opts=cmdoptions,
|
|
|
|
)
|
2016-04-28 17:37:47 +03:00
|
|
|
try:
|
2018-05-18 21:18:09 +03:00
|
|
|
hintutil.loadhintconfig(lui)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.log("jobid", jobid=encoding.environ.get("HG_JOB_ID", "unknown"))
|
2016-04-28 17:37:47 +03:00
|
|
|
ret = _runcommand(ui, options, cmd, d)
|
|
|
|
# run post-hook, passing command result
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
hook.hook(
|
|
|
|
lui,
|
|
|
|
repo,
|
|
|
|
"post-%s" % cmd,
|
|
|
|
False,
|
|
|
|
args=" ".join(fullargs),
|
|
|
|
result=ret,
|
|
|
|
pats=cmdpats,
|
|
|
|
opts=cmdoptions,
|
|
|
|
)
|
2018-08-17 03:42:35 +03:00
|
|
|
except Exception as e:
|
2016-04-28 17:37:47 +03:00
|
|
|
# run failure hook and re-raise
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
hook.hook(
|
|
|
|
lui,
|
|
|
|
repo,
|
|
|
|
"fail-%s" % cmd,
|
|
|
|
False,
|
|
|
|
args=" ".join(fullargs),
|
|
|
|
pats=cmdpats,
|
|
|
|
opts=cmdoptions,
|
|
|
|
)
|
2018-09-11 08:47:54 +03:00
|
|
|
_log_exception(lui, e)
|
2016-04-28 17:37:47 +03:00
|
|
|
raise
|
2020-09-01 03:32:44 +03:00
|
|
|
if getattr(repo, "_txnreleased", False):
|
|
|
|
hook.hook(lui, repo, "postwritecommand", False)
|
2009-02-12 19:36:15 +03:00
|
|
|
return ret
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-09-11 08:47:54 +03:00
|
|
|
def _log_exception(lui, e):
|
|
|
|
try:
|
2020-07-20 21:44:16 +03:00
|
|
|
typename = None
|
|
|
|
fault = None
|
|
|
|
|
|
|
|
# Extract Rust metadata
|
|
|
|
try:
|
|
|
|
rustmetadata = e.args[0]
|
|
|
|
typename = rustmetadata.typename()
|
|
|
|
fault = rustmetadata.fault()
|
|
|
|
except (IndexError, AttributeError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Extract Python metadata
|
|
|
|
if isinstance(e, error.Tagged):
|
|
|
|
fault = e.fault.value
|
|
|
|
|
|
|
|
lui.log(
|
|
|
|
"exceptions",
|
|
|
|
exception_type=type(e).__name__,
|
|
|
|
exception_msg=str(e),
|
|
|
|
fault=fault,
|
|
|
|
rust_error_type=typename,
|
|
|
|
)
|
|
|
|
|
2018-09-11 08:47:54 +03:00
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-05-06 04:15:26 +03:00
|
|
|
def _getlocal(ui, rpath):
|
2010-08-25 02:25:33 +04:00
|
|
|
"""Return (path, local ui object) for the given target path.
|
2010-10-20 12:13:04 +04:00
|
|
|
|
2010-08-25 02:25:33 +04:00
|
|
|
Takes paths in [cwd]/.hg/hgrc into account."
|
|
|
|
"""
|
2020-05-06 04:15:26 +03:00
|
|
|
if rpath:
|
|
|
|
path = ui.expandpath(rpath)
|
|
|
|
lui = ui.copy()
|
|
|
|
else:
|
2016-02-26 18:07:58 +03:00
|
|
|
try:
|
2016-11-22 16:16:50 +03:00
|
|
|
wd = pycompat.getcwd()
|
2016-02-26 18:07:58 +03:00
|
|
|
except OSError as e:
|
2019-03-08 16:59:13 +03:00
|
|
|
if e.errno == errno.ENOTCONN:
|
|
|
|
ui.warn(_("current working directory is not connected\n"))
|
|
|
|
ui.warn(
|
|
|
|
_(
|
|
|
|
"(for virtual checkouts, run '@prog@ fs doctor' to diagnose issues with edenfs)\n"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return "", ui
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(
|
|
|
|
_("error getting current working directory: %s")
|
|
|
|
% encoding.strtolocal(e.strerror)
|
|
|
|
)
|
2020-05-06 04:15:26 +03:00
|
|
|
path = cmdutil.findrepo(wd) or ""
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2020-05-06 04:15:26 +03:00
|
|
|
if not path:
|
|
|
|
lui = ui
|
|
|
|
else:
|
|
|
|
lui = ui.copy()
|
|
|
|
|
2020-08-25 17:31:29 +03:00
|
|
|
# Don't load repo configs if the path is a bundle file.
|
|
|
|
if path and os.path.isdir(path):
|
2020-08-17 02:53:34 +03:00
|
|
|
lui.reloadconfigs(path)
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2010-08-25 02:25:33 +04:00
|
|
|
return path, lui
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-05-26 01:53:23 +04:00
|
|
|
def _dispatch(req):
|
2011-05-26 01:44:11 +04:00
|
|
|
args = req.args
|
2011-05-26 01:53:23 +04:00
|
|
|
ui = req.ui
|
|
|
|
|
2010-08-25 02:25:33 +04:00
|
|
|
# check for cwd
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cwd = req.earlyoptions["cwd"]
|
2010-08-25 02:25:33 +04:00
|
|
|
if cwd:
|
2017-11-11 11:55:15 +03:00
|
|
|
os.chdir(cwd)
|
2010-08-25 02:25:33 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
rpath = req.earlyoptions["repository"]
|
2010-08-25 02:25:33 +04:00
|
|
|
path, lui = _getlocal(ui, rpath)
|
|
|
|
|
2017-02-11 03:56:29 +03:00
|
|
|
uis = {ui, lui}
|
2011-06-24 20:44:58 +04:00
|
|
|
|
|
|
|
if req.repo:
|
|
|
|
uis.add(req.repo.ui)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if req.earlyoptions["profile"]:
|
2016-08-15 02:35:58 +03:00
|
|
|
for ui_ in uis:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui_.setconfig("profiling", "enabled", "true", "--profile")
|
2016-08-15 02:35:58 +03:00
|
|
|
|
2018-09-15 05:01:31 +03:00
|
|
|
with profiling.profile(lui) as profiler:
|
2017-02-14 07:47:41 +03:00
|
|
|
# Configure extensions in phases: uisetup, extsetup, cmdtable, and
|
2017-06-23 20:39:21 +03:00
|
|
|
# reposetup
|
2017-02-14 07:47:41 +03:00
|
|
|
extensions.loadall(lui)
|
|
|
|
# Propagate any changes to lui.__class__ by extensions
|
|
|
|
ui.__class__ = lui.__class__
|
|
|
|
|
2019-07-26 02:13:22 +03:00
|
|
|
# setup color handling before pager, because setting up pager
|
|
|
|
# might cause incorrect console information
|
|
|
|
coloropt = req.earlyoptions.get("color", False)
|
|
|
|
for ui_ in uis:
|
|
|
|
if coloropt:
|
|
|
|
ui_.setconfig("ui", "color", coloropt, "--color")
|
|
|
|
color.setup(ui_)
|
|
|
|
|
2017-02-14 07:47:41 +03:00
|
|
|
# (uisetup and extsetup are handled in extensions.loadall)
|
|
|
|
|
|
|
|
# (reposetup is handled in hg.repository)
|
|
|
|
|
|
|
|
# check for fallback encoding
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fallback = lui.config("ui", "fallbackencoding")
|
2017-02-14 07:47:41 +03:00
|
|
|
if fallback:
|
|
|
|
encoding.fallbackencoding = fallback
|
|
|
|
|
|
|
|
fullargs = args
|
2019-07-20 11:01:33 +03:00
|
|
|
|
|
|
|
cmd, func, args, options, cmdoptions, foundaliases = _parse(lui, args)
|
2020-06-24 00:09:48 +03:00
|
|
|
lui.cmdname = ui.cmdname = cmd
|
2019-07-20 11:01:33 +03:00
|
|
|
|
2020-08-28 04:11:28 +03:00
|
|
|
# Do not profile the 'debugshell' command.
|
|
|
|
if cmd == "debugshell":
|
|
|
|
profiler.stop()
|
|
|
|
|
2019-07-20 11:01:33 +03:00
|
|
|
if cmd == "help" and len(foundaliases) > 0:
|
|
|
|
cmd = foundaliases[0]
|
|
|
|
options["help"] = True
|
2017-02-14 07:47:41 +03:00
|
|
|
|
2018-05-09 02:58:44 +03:00
|
|
|
if options["encoding"]:
|
|
|
|
encoding.encoding = options["encoding"]
|
|
|
|
if options["encodingmode"]:
|
|
|
|
encoding.encodingmode = options["encodingmode"]
|
2020-03-04 21:58:39 +03:00
|
|
|
if (
|
|
|
|
options["outputencoding"]
|
|
|
|
and options["outputencoding"] != "same as encoding"
|
|
|
|
):
|
|
|
|
encoding.outputencoding = options["outputencoding"]
|
2018-05-09 02:58:44 +03:00
|
|
|
i18n.init()
|
|
|
|
|
2017-11-11 06:40:13 +03:00
|
|
|
if options["config"] != req.earlyoptions["config"]:
|
2017-02-14 07:47:41 +03:00
|
|
|
raise error.Abort(_("option --config may not be abbreviated!"))
|
2018-03-20 02:20:55 +03:00
|
|
|
if options["configfile"] != req.earlyoptions["configfile"]:
|
|
|
|
raise error.Abort(_("option --configfile may not be abbreviated!"))
|
2017-11-11 06:40:13 +03:00
|
|
|
if options["cwd"] != req.earlyoptions["cwd"]:
|
2017-02-14 07:47:41 +03:00
|
|
|
raise error.Abort(_("option --cwd may not be abbreviated!"))
|
2017-11-11 06:40:13 +03:00
|
|
|
if options["repository"] != req.earlyoptions["repository"]:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(
|
|
|
|
_(
|
|
|
|
"option -R has to be separated from other options (e.g. not "
|
|
|
|
"-qR) and --repository may only be abbreviated as --repo!"
|
|
|
|
)
|
|
|
|
)
|
2017-11-11 08:02:41 +03:00
|
|
|
if options["debugger"] != req.earlyoptions["debugger"]:
|
|
|
|
raise error.Abort(_("option --debugger may not be abbreviated!"))
|
|
|
|
# don't validate --profile/--traceback, which can be enabled from now
|
2017-02-14 07:47:41 +03:00
|
|
|
|
|
|
|
if options["time"]:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-02-14 07:47:41 +03:00
|
|
|
def get_times():
|
|
|
|
t = os.times()
|
|
|
|
if t[4] == 0.0:
|
|
|
|
# Windows leaves this as zero, so use time.clock()
|
|
|
|
t = (t[0], t[1], t[2], t[3], time.clock())
|
|
|
|
return t
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-02-14 07:47:41 +03:00
|
|
|
s = get_times()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-02-14 07:47:41 +03:00
|
|
|
def print_time():
|
|
|
|
t = get_times()
|
|
|
|
ui.warn(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n")
|
|
|
|
% (t[4] - s[4], t[0] - s[0], t[2] - s[2], t[1] - s[1], t[3] - s[3])
|
|
|
|
)
|
|
|
|
|
2017-04-12 00:54:12 +03:00
|
|
|
ui.atexit(print_time)
|
2017-06-09 14:36:07 +03:00
|
|
|
if options["profile"]:
|
|
|
|
profiler.start()
|
2017-02-14 07:47:41 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if options["verbose"] or options["debug"] or options["quiet"]:
|
|
|
|
for opt in ("verbose", "debug", "quiet"):
|
2017-02-14 07:47:41 +03:00
|
|
|
val = str(bool(options[opt]))
|
|
|
|
for ui_ in uis:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui_.setconfig("ui", opt, val, "--" + opt)
|
2017-02-14 07:47:41 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if options["traceback"]:
|
2011-06-24 20:44:58 +04:00
|
|
|
for ui_ in uis:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui_.setconfig("ui", "traceback", "on", "--traceback")
|
2011-01-29 17:23:24 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if options["noninteractive"]:
|
2017-02-14 07:47:41 +03:00
|
|
|
for ui_ in uis:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui_.setconfig("ui", "interactive", "off", "-y")
|
2011-01-29 17:23:24 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if cmdoptions.get("insecure", False):
|
2017-02-14 07:47:41 +03:00
|
|
|
for ui_ in uis:
|
|
|
|
ui_.insecureconnections = True
|
2007-08-16 01:55:13 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if util.parsebool(options["pager"]):
|
2017-08-01 12:52:52 +03:00
|
|
|
# ui.pager() expects 'internal-always-' prefix in this case
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.pager("internal-always-" + cmd)
|
|
|
|
elif options["pager"] != "auto":
|
2017-10-09 22:42:28 +03:00
|
|
|
for ui_ in uis:
|
|
|
|
ui_.disablepager()
|
dispatch: setup color before pager for correct console information on windows
Before this patch, "hg CMD --pager on" on Windows shows output
unintentionally decorated with ANSI color escape sequences, if color
mode is "auto". This issue occurs in steps below.
1. dispatch() invokes ui.pager() at detection of "--pager on"
2. stdout of hg process is redirected into stdin of pager process
3. "ui.formatted" = True, because isatty(stdout) is so before (2)
4. color module is loaded for colorization
5. color.w32effects = None, because GetConsoleScreenBufferInfo()
fails on stdout redirected at (2)
6. "ansi" color mode is chosen, because of "not w32effects"
7. output is colorized in "ansi" mode because of "ui.formatted" = True
Even if "ansi" color mode is chosen, ordinarily redirected stdout
makes ui.formatted() return False, and colorization is avoided. But in
this issue case, "ui.formatted" = True at (3) forces output to be
colorized.
For correct console information on win32, it is needed to ensure that
color module is loaded before redirection of stdout for pagination.
BTW, if any of enabled extensions has "colortable" attribute, this
issue is avoided even before this patch, because color module is
imported as a part of loading such extension, and extension loading
occurs before setting up pager. For example, mq and keyword have
"colortable".
2017-05-22 21:29:23 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if options["version"]:
|
2017-02-14 07:47:41 +03:00
|
|
|
return commands.version_(ui)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if options["help"]:
|
2019-07-20 11:01:33 +03:00
|
|
|
if len(foundaliases) > 0:
|
|
|
|
aliascmd = foundaliases[0]
|
|
|
|
return commands.help_(ui, aliascmd, command=cmd is not None)
|
|
|
|
|
2017-02-14 07:47:41 +03:00
|
|
|
return commands.help_(ui, cmd, command=cmd is not None)
|
|
|
|
elif not cmd:
|
2018-10-15 19:35:15 +03:00
|
|
|
return commands.help_(ui)
|
2007-08-16 01:55:13 +04:00
|
|
|
|
2017-03-19 07:18:53 +03:00
|
|
|
msg = _formatargs(fullargs)
|
2019-11-08 01:19:52 +03:00
|
|
|
with perftrace.trace("Main Python Command"):
|
2019-03-26 03:09:11 +03:00
|
|
|
repo = None
|
|
|
|
if func.cmdtemplate:
|
|
|
|
templ = cmdtemplatestate(ui, cmdoptions)
|
|
|
|
args.insert(0, templ)
|
2019-03-26 04:30:01 +03:00
|
|
|
ui.atexit(templ.end)
|
2019-03-26 03:09:11 +03:00
|
|
|
cmdpats = args[:]
|
|
|
|
if not func.norepo:
|
|
|
|
# use the repo from the request only if we don't have -R
|
|
|
|
if not rpath and not cwd:
|
|
|
|
repo = req.repo
|
|
|
|
|
|
|
|
if repo:
|
|
|
|
# set the descriptors of the repo ui to those of ui
|
|
|
|
repo.ui.fin = ui.fin
|
|
|
|
repo.ui.fout = ui.fout
|
|
|
|
repo.ui.ferr = ui.ferr
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
repo = hg.repository(
|
|
|
|
ui, path=path, presetupfuncs=req.prereposetups
|
|
|
|
)
|
|
|
|
if not repo.local():
|
|
|
|
raise error.Abort(_("repository '%s' is not local") % path)
|
2019-06-26 20:59:13 +03:00
|
|
|
_initblackbox(req, repo, func.cmdtype)
|
2019-03-26 03:09:11 +03:00
|
|
|
repo.ui.setconfig("bundle", "mainreporoot", repo.root, "repo")
|
|
|
|
except error.RequirementError:
|
|
|
|
raise
|
|
|
|
except error.RepoError:
|
|
|
|
if rpath: # invalid -R path
|
|
|
|
raise
|
|
|
|
if not func.optionalrepo:
|
|
|
|
if func.inferrepo and args and not path:
|
|
|
|
# try to infer -R from command args
|
|
|
|
repos = pycompat.maplist(cmdutil.findrepo, args)
|
|
|
|
guess = repos[0]
|
|
|
|
if guess and repos.count(guess) == len(repos):
|
|
|
|
req.args = ["--repository", guess] + fullargs
|
|
|
|
req.earlyoptions["repository"] = guess
|
|
|
|
return _dispatch(req)
|
|
|
|
if not path:
|
|
|
|
raise error.RepoError(
|
2019-09-11 04:27:54 +03:00
|
|
|
_(
|
|
|
|
"'%s' is not inside a repository, but this command requires a repository"
|
|
|
|
)
|
|
|
|
% pycompat.getcwd(),
|
|
|
|
hint=_(
|
|
|
|
"use 'cd' to go to a directory inside a repository and try again"
|
|
|
|
),
|
2019-03-26 03:09:11 +03:00
|
|
|
)
|
|
|
|
raise
|
|
|
|
if repo:
|
|
|
|
ui = repo.ui
|
|
|
|
if options["hidden"]:
|
2019-09-26 03:17:39 +03:00
|
|
|
repo.ui.setconfig("visibility", "all-heads", "true", "--hidden")
|
2019-03-26 03:09:11 +03:00
|
|
|
if repo != req.repo:
|
2019-03-26 04:30:01 +03:00
|
|
|
ui.atexit(repo.close)
|
2019-03-26 03:09:11 +03:00
|
|
|
args.insert(0, repo)
|
|
|
|
elif rpath:
|
|
|
|
ui.warn(_("warning: --repository ignored\n"))
|
|
|
|
|
2019-11-13 02:33:03 +03:00
|
|
|
from . import mdiff, match as matchmod
|
2019-03-26 03:09:11 +03:00
|
|
|
|
|
|
|
mdiff.init(ui)
|
2019-11-13 02:33:03 +03:00
|
|
|
matchmod.init(ui)
|
2019-03-26 03:09:11 +03:00
|
|
|
|
|
|
|
ui.log("command", "%s\n", msg)
|
2019-04-04 21:23:55 +03:00
|
|
|
if repo:
|
|
|
|
repo.dirstate.loginfo(ui, "pre")
|
2020-02-01 03:33:39 +03:00
|
|
|
strcmdopt = cmdoptions
|
2019-03-26 03:09:11 +03:00
|
|
|
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
|
2019-03-26 04:30:01 +03:00
|
|
|
ret = runcommand(
|
|
|
|
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
|
|
|
|
)
|
|
|
|
hintutil.show(lui)
|
2019-04-04 21:23:55 +03:00
|
|
|
if repo:
|
|
|
|
repo.dirstate.loginfo(ui, "post")
|
2019-03-26 04:30:01 +03:00
|
|
|
return ret
|
2007-08-16 01:55:13 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2019-06-26 20:59:13 +03:00
|
|
|
def _initblackbox(req, repo, cmdtype):
|
|
|
|
"""Initialize the native blackbox logging at the shared repo path.
|
|
|
|
|
|
|
|
This might choose to disable logging if the blackbox extension is disabled
|
|
|
|
via '--config=extensions.blackbox=!' or '--config=blackbox.track=', and
|
|
|
|
the command is read-only. (In other words, read-write commands will always
|
|
|
|
be logged)
|
|
|
|
"""
|
|
|
|
# See "class command" in registrar.py for valid command types.
|
|
|
|
# Enforce blackbox logging for non-readonly commands, so if an automation
|
|
|
|
# runs commands like `hg commit --config extensions.blackbox=!`, we still
|
|
|
|
# log it.
|
|
|
|
if cmdtype == "readonly":
|
|
|
|
config = req.earlyoptions["config"]
|
|
|
|
if "extensions.blackbox=!" in config or "blackbox.track=" in config:
|
|
|
|
# Explicitly disabled via command line. Do not initialize blackbox.
|
|
|
|
return
|
|
|
|
|
|
|
|
# Create the log in sharedvfs.
|
|
|
|
path = repo.sharedvfs.join("blackbox", "v1")
|
|
|
|
size = repo.ui.configbytes("blackbox", "maxsize")
|
|
|
|
count = repo.ui.configint("blackbox", "maxfiles")
|
|
|
|
try:
|
|
|
|
blackbox.init(path, count, size)
|
|
|
|
except IOError:
|
|
|
|
# Likely permission errors. Not fatal.
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2007-08-16 01:55:13 +04:00
|
|
|
def _runcommand(ui, options, cmd, cmdfunc):
|
2016-08-15 03:51:12 +03:00
|
|
|
"""Run a command function, possibly with profiling enabled."""
|
2016-09-22 22:36:30 +03:00
|
|
|
try:
|
|
|
|
return cmdfunc()
|
|
|
|
except error.SignatureError:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.CommandError(cmd, _("invalid arguments"))
|
|
|
|
|
2016-04-04 19:27:37 +03:00
|
|
|
|
2016-04-05 22:01:23 +03:00
|
|
|
def _exceptionwarning(ui):
|
|
|
|
"""Produce a warning message for the current active exception"""
|
2016-04-04 19:27:37 +03:00
|
|
|
|
2019-04-05 09:34:14 +03:00
|
|
|
return _("** @LongProduct@ (version %s) has crashed:\n") % util.version()
|
2016-04-05 22:01:23 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-05 22:01:23 +03:00
|
|
|
def handlecommandexception(ui):
|
|
|
|
"""Produce a warning message for broken commands
|
|
|
|
|
|
|
|
Called when handling an exception; the exception is reraised if
|
|
|
|
this function returns False, ignored otherwise.
|
|
|
|
"""
|
|
|
|
warning = _exceptionwarning(ui)
|
2019-04-23 12:45:38 +03:00
|
|
|
ui.log("command_exception", "%s\n%s\n", warning, traceback.format_exc())
|
2016-04-04 19:27:37 +03:00
|
|
|
ui.warn(warning)
|
|
|
|
return False # re-raise the exception
|
2018-01-03 16:35:56 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-01-03 16:35:56 +03:00
|
|
|
def rejectpush(ui, **kwargs):
|
2020-05-07 19:05:16 +03:00
|
|
|
ui.warn(_x("Permission denied - blocked by readonlyrejectpush hook\n"))
|
2018-01-03 16:35:56 +03:00
|
|
|
# mercurial hooks use unix process conventions for hook return values
|
|
|
|
# so a truthy return means failure
|
|
|
|
return True
|