mirror of
https://github.com/facebook/sapling.git
synced 2024-10-13 02:07:31 +03:00
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
125 lines
3.6 KiB
Python
125 lines
3.6 KiB
Python
# fbshow.py
|
|
#
|
|
# Copyright 2016 Facebook, Inc.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2 or any later version.
|
|
"""show changesets in detail with full log message, patches etc
|
|
|
|
For example, 'hg show' prints something like
|
|
::
|
|
|
|
$ hg show
|
|
changeset: 1:b73358b94785
|
|
tag: tip
|
|
user: test
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
files: x
|
|
description:
|
|
longer
|
|
|
|
diff -r 852a8d467a01 -r b73358b94785 x
|
|
--- a/x Thu Jan 01 00:00:00 1970 +0000
|
|
+++ b/x Thu Jan 01 00:00:00 1970 +0000
|
|
@@ -1,1 +1,2 @@
|
|
show
|
|
+more
|
|
|
|
and 'hg show --stat' prints something like:
|
|
|
|
$ hg show --stat
|
|
changeset: 1:b73358b94785
|
|
tag: tip
|
|
user: test
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
files: x
|
|
description:
|
|
longer
|
|
|
|
x | 1 +
|
|
1 files changed, 1 insertions(+), 0 deletions(-)
|
|
|
|
"""
|
|
|
|
from mercurial import cmdutil, commands, error, registrar, scmutil
|
|
from mercurial.i18n import _
|
|
|
|
|
|
cmdtable = {}
|
|
command = registrar.command(cmdtable)
|
|
testedwith = "ships-with-fb-hgext"
|
|
|
|
|
|
def uisetup(ui):
|
|
permitted_opts = (
|
|
[
|
|
("g", "git", None, _("use git extended diff format")),
|
|
("", "stat", None, _("output diffstat-style summary of changes")),
|
|
]
|
|
+ commands.templateopts
|
|
+ commands.walkopts
|
|
)
|
|
|
|
local_opts = [
|
|
(
|
|
"",
|
|
"nodates",
|
|
None,
|
|
_("omit dates from diff headers " + "(but keeps it in commit header)"),
|
|
),
|
|
("", "noprefix", None, _("omit a/ and b/ prefixes from filenames")),
|
|
("U", "unified", int, _("number of lines of diff context to show")),
|
|
] + commands.diffwsopts
|
|
|
|
aliases, entry = cmdutil.findcmd("log", commands.table)
|
|
allowed_opts = [opt for opt in entry[1] if opt in permitted_opts] + local_opts
|
|
|
|
# manual call of the decorator
|
|
command("^show", allowed_opts, _("[OPTION]... [REV [FILE]...]"), inferrepo=True)(
|
|
show
|
|
)
|
|
|
|
|
|
def show(ui, repo, *args, **opts):
|
|
"""show revision in detail
|
|
|
|
This behaves similarly to :hg:`log -vp -r REV [OPTION]... [FILE]...`, or
|
|
if called without a REV, :hg:`log -vp -r . [OPTION]...` Use
|
|
:hg:`log` for more powerful operations than supported by hg show
|
|
|
|
See :hg:`help templates` for more about pre-packaged styles and
|
|
specifying custom templates.
|
|
|
|
"""
|
|
ui.pager("show")
|
|
if len(args) == 0:
|
|
opts["rev"] = ["."]
|
|
pats = []
|
|
else:
|
|
opts["rev"] = [args[0]]
|
|
pats = args[1:]
|
|
if not scmutil.revrange(repo, opts["rev"]):
|
|
h = _("if %s is a file, try `hg show . %s`") % (args[0], args[0])
|
|
raise error.Abort(_("unknown revision %s") % args[0], hint=h)
|
|
|
|
opts["patch"] = not opts["stat"]
|
|
opts["verbose"] = True
|
|
|
|
# Copy tracking is slow when doing a git diff. Override hgrc, and rely on
|
|
# opts getting us a git diff if it's been requested. Ideally, we'd find and
|
|
# fix the slowness in copy tracking, but this works for now.
|
|
# On a commit with lots of possible copies, Bryan O'Sullivan found that this
|
|
# reduces "time hg show" from 1.76 seconds to 0.81 seconds.
|
|
overrides = {
|
|
("diff", "git"): opts.get("git"),
|
|
("diff", "unified"): opts.get("unified"),
|
|
("ui", "verbose"): True,
|
|
}
|
|
overrides.update({("diff", opt): opts.get(opt) for opt in commands.diffwsopts})
|
|
|
|
logcmd, defaultlogopts = cmdutil.getcmdanddefaultopts("log", commands.table)
|
|
defaultlogopts.update(opts)
|
|
|
|
with ui.configoverride(overrides, "show"):
|
|
logcmd(ui, repo, *pats, **defaultlogopts)
|