2019-11-01 23:24:22 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2017-10-14 00:51:27 +03:00
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
2019-11-01 23:24:22 +03:00
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
|
|
|
# sparse.py - allow sparse checkouts of the working directory
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
"""allow sparse checkouts of the working directory
|
2018-04-28 09:26:09 +03:00
|
|
|
|
|
|
|
Sparse file format
|
|
|
|
------------------
|
|
|
|
|
|
|
|
Structure
|
|
|
|
.........
|
|
|
|
|
|
|
|
Shared sparse profile files comprise of 4 sections: `%include` directives
|
|
|
|
that pull in another sparse profile, and `[metadata]`, `[include]` and
|
|
|
|
`[exclude]` sections.
|
|
|
|
|
|
|
|
Any line starting with a `;` or `#` character is a comment and is ignored.
|
|
|
|
|
|
|
|
Extending existing profiles
|
|
|
|
...........................
|
|
|
|
|
|
|
|
`%include <absolute path>` directives (one per line) let you extend as
|
|
|
|
an existing profile file, adding more include and exclude rules. Although
|
|
|
|
this directive can appear anywere in the file, it is recommended you
|
|
|
|
keep these at the top of the file.
|
|
|
|
|
|
|
|
Metadata
|
|
|
|
........
|
|
|
|
|
|
|
|
The `[metadata]` section lets you specify key-value pairs for the profile.
|
|
|
|
Anything before the first `:` or `=` is the key, everything after is the
|
|
|
|
value. Values can be extended over multiple lines by indenting additional
|
|
|
|
lines.
|
|
|
|
|
|
|
|
Only the `title`, `description` and `hidden` keys carry meaning to for
|
|
|
|
`hg sparse`, these are used in the `hg sparse list` and
|
|
|
|
`hg sparse explain` commands. Profiles with the `hidden` key (regardless
|
|
|
|
of its value) are excluded from the `hg sparse list` listing unless
|
|
|
|
the `-v` / `--verbose` switch is given.
|
|
|
|
|
|
|
|
Include and exclude rules
|
|
|
|
.........................
|
|
|
|
|
|
|
|
Each line in the `[include]` and `[exclude]` sections is treated as a
|
|
|
|
standard pattern, see :hg:`help patterns`. Exclude rules override include
|
|
|
|
rules.
|
|
|
|
|
|
|
|
Example
|
|
|
|
.......
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
# this profile extends another profile, incorporating all its rules
|
|
|
|
%include some/base/profile
|
|
|
|
|
|
|
|
[metadata]
|
|
|
|
title: This is an example sparse profile
|
|
|
|
description: You can include as much metadata as makes sense for your
|
|
|
|
setup, and values can extend over multiple lines.
|
|
|
|
lorem ipsum = Keys and values are separated by a : or =
|
|
|
|
; hidden: the hidden key lets you mark profiles that should not
|
|
|
|
; generally be discorable. The value doesn't matter, use it to motivate
|
|
|
|
; why it is hidden.
|
|
|
|
|
|
|
|
[include]
|
|
|
|
foo/bar/baz
|
|
|
|
bar/python_project/**/*.py
|
|
|
|
|
|
|
|
[exclude]
|
|
|
|
; exclude rules override include rules, so all files with the extension
|
|
|
|
; .ignore are excluded from this sparse profile.
|
|
|
|
foo/bar/baz/*.ignore
|
|
|
|
|
|
|
|
Configuration options
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
The following config option defines whether sparse treats supplied
|
|
|
|
paths as relative to repo root or to the current working dir for
|
|
|
|
include and exclude options:
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
includereporootpaths = off
|
|
|
|
|
|
|
|
The following config option defines whether sparse treats supplied
|
|
|
|
paths as relative to repo root or to the current working dir for
|
|
|
|
enableprofile and disableprofile options:
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
enablereporootpaths = on
|
|
|
|
|
|
|
|
You can configure a path to find sparse profiles in; this path is
|
|
|
|
used to discover available sparse profiles. Nested directories are
|
|
|
|
reflected in the UI.
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
profile_directory = tools/scm/sparse
|
|
|
|
|
|
|
|
It is not set by default.
|
2018-10-17 00:19:25 +03:00
|
|
|
|
|
|
|
It is also possible to show hints where dirstate size is too large.
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
# Whether to advertise usage of the sparse profiles when the checkout size
|
|
|
|
# is very large.
|
|
|
|
largecheckouthint = False
|
|
|
|
# The number of files in the checkout that constitute a "large checkout".
|
|
|
|
largecheckoutcount = 0
|
2020-02-20 21:57:07 +03:00
|
|
|
|
|
|
|
The following option allows warning when a user is using a full checkout. It
|
|
|
|
allows four values: hint, warn, softblock, hardblock.
|
|
|
|
|
|
|
|
- "hint" shows a suppressable warning message.
|
|
|
|
- "warn" shows a non-supressable warning message.
|
|
|
|
- "softblock" throws an exception that can be bypassed via
|
|
|
|
sparse.bypassfullcheckoutwarn=True
|
|
|
|
- "hardblock" throws an exception that cannot be bypassed.
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
warnfullcheckout = hint
|
|
|
|
|
|
|
|
The following option can be used to bypass a softblock on fullcheckouts.
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
bypassfullcheckoutwarn = True
|
|
|
|
|
2020-08-31 21:36:48 +03:00
|
|
|
The following option can be used to check if a sparse profile includes any files that should not normally
|
|
|
|
be included.
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
unsafe_sparse_profile_marker_files = "somefile, anotherfile"
|
|
|
|
unsafe_sparse_profile_message = "do not do this!"
|
2020-11-05 15:37:49 +03:00
|
|
|
|
|
|
|
The following options can be used to tune the behaviour of tree prefetching when sparse profile changes
|
|
|
|
|
|
|
|
[sparse]
|
|
|
|
force_full_prefetch_on_sparse_profile_change = False
|
2017-10-14 00:51:27 +03:00
|
|
|
"""
|
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
from __future__ import division
|
|
|
|
|
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
|
|
|
import collections
|
|
|
|
import functools
|
|
|
|
import hashlib
|
|
|
|
import os
|
|
|
|
import re
|
2020-03-12 04:31:12 +03:00
|
|
|
from typing import Any, Callable, Optional
|
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-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import (
|
2018-03-15 14:34:09 +03:00
|
|
|
cmdutil,
|
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
|
|
|
commands,
|
2018-03-15 14:34:09 +03:00
|
|
|
context,
|
|
|
|
dirstate,
|
2018-10-17 00:19:25 +03:00
|
|
|
dispatch,
|
2018-03-15 14:34:09 +03:00
|
|
|
error,
|
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
|
|
|
extensions,
|
2018-03-15 14:34:09 +03:00
|
|
|
hg,
|
2018-04-18 20:31:30 +03:00
|
|
|
hintutil,
|
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
|
|
|
localrepo,
|
|
|
|
match as matchmod,
|
|
|
|
merge as mergemod,
|
2018-03-26 18:44:42 +03:00
|
|
|
minirst,
|
2018-03-15 14:34:09 +03:00
|
|
|
patch,
|
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
|
|
|
pathutil,
|
|
|
|
progress,
|
2018-03-15 14:34:09 +03:00
|
|
|
pycompat,
|
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
|
|
|
registrar,
|
2018-04-10 13:37:19 +03:00
|
|
|
scmutil,
|
2020-03-12 04:31:12 +03:00
|
|
|
ui as uimod,
|
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
|
|
|
util,
|
2018-03-15 14:34:09 +03:00
|
|
|
)
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial.i18n import _
|
|
|
|
from edenscm.mercurial.node import nullid, nullrev
|
|
|
|
from edenscm.mercurial.thirdparty import attr
|
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-14 00:51:27 +03:00
|
|
|
|
|
|
|
cmdtable = {}
|
|
|
|
command = registrar.command(cmdtable)
|
2018-10-17 00:19:25 +03:00
|
|
|
configtable = {}
|
|
|
|
configitem = registrar.configitem(configtable)
|
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
|
|
|
testedwith = "ships-with-fb-hgext"
|
2018-10-19 16:49:04 +03:00
|
|
|
colortable = {
|
2021-02-23 15:45:08 +03:00
|
|
|
"sparse.profile.active": "brightyellow:yellow+bold",
|
2018-10-19 16:49:04 +03:00
|
|
|
"sparse.profile.included": "yellow",
|
2021-02-23 15:45:08 +03:00
|
|
|
"sparse.profile.inactive": "brightblack:black+bold",
|
|
|
|
"sparse.include": "brightgreen:green+bold",
|
|
|
|
"sparse.exclude": "brightred:red+bold",
|
|
|
|
"sparse.profile.notfound": "brightcyan:cyan+bold",
|
2018-10-19 16:49:04 +03:00
|
|
|
}
|
2018-10-17 00:19:25 +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
|
|
|
cwdrealtivepatkinds = ("glob", "relpath")
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
|
2018-10-17 22:00:50 +03:00
|
|
|
configitem(
|
|
|
|
"sparse",
|
|
|
|
"largecheckouthint",
|
|
|
|
default=False,
|
|
|
|
alias=[("perftweaks", "largecheckouthint")],
|
|
|
|
)
|
|
|
|
configitem(
|
|
|
|
"sparse",
|
|
|
|
"largecheckoutcount",
|
|
|
|
default=0,
|
|
|
|
alias=[("perftweaks", "largecheckoutcount")],
|
|
|
|
)
|
2020-02-20 21:57:07 +03:00
|
|
|
configitem("sparse", "warnfullcheckout", default=None)
|
|
|
|
configitem("sparse", "bypassfullcheckoutwarn", default=False)
|
2018-10-17 00:19:25 +03:00
|
|
|
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def uisetup(ui):
|
|
|
|
_setupupdates(ui)
|
|
|
|
_setupcommit(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
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def extsetup(ui):
|
2020-03-12 04:31:12 +03:00
|
|
|
extensions.wrapfunction(dispatch, "runcommand", _tracktelemetry)
|
2017-10-14 00:51:27 +03:00
|
|
|
_setupclone(ui)
|
|
|
|
_setuplog(ui)
|
|
|
|
_setupadd(ui)
|
|
|
|
_setupdirstate(ui)
|
|
|
|
_setupdiff(ui)
|
|
|
|
# if fsmonitor is enabled, tell it to use our hash function
|
|
|
|
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
|
|
|
fsmonitor = extensions.find("fsmonitor")
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def _hashignore(orig, ignore):
|
|
|
|
return _hashmatcher(ignore)
|
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
|
|
|
|
|
|
|
extensions.wrapfunction(fsmonitor, "_hashignore", _hashignore)
|
2017-10-14 00:51:27 +03:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
# do the same for hgwatchman, old name
|
|
|
|
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
|
|
|
hgwatchman = extensions.find("hgwatchman")
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def _hashignore(orig, ignore):
|
|
|
|
return _hashmatcher(ignore)
|
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
|
|
|
|
|
|
|
extensions.wrapfunction(hgwatchman, "_hashignore", _hashignore)
|
2017-10-14 00:51:27 +03:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
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-14 00:51:27 +03:00
|
|
|
def reposetup(ui, repo):
|
2018-07-18 00:47:48 +03:00
|
|
|
if not repo.local():
|
2017-10-14 00:51:27 +03:00
|
|
|
return
|
|
|
|
|
2018-04-18 22:10:44 +03:00
|
|
|
# The sparse extension should never be enabled in Eden repositories;
|
|
|
|
# Eden automatically only fetches the parts of the repository that are
|
|
|
|
# actually required.
|
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 "eden" in repo.requirements:
|
2018-04-18 22:10:44 +03:00
|
|
|
return
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
_wraprepo(ui, 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
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def replacefilecache(cls, propname, replacement):
|
|
|
|
"""Replace a filecache property with a new class. This allows changing the
|
|
|
|
cache invalidation condition."""
|
|
|
|
origcls = cls
|
|
|
|
assert callable(replacement)
|
|
|
|
while cls is not object:
|
|
|
|
if propname in cls.__dict__:
|
|
|
|
orig = cls.__dict__[propname]
|
|
|
|
setattr(cls, propname, replacement(orig))
|
|
|
|
break
|
|
|
|
cls = cls.__bases__[0]
|
|
|
|
|
|
|
|
if cls is 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
|
|
|
raise AttributeError(_("type '%s' has no property '%s'") % (origcls, propname))
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-06-09 00:30:12 +03:00
|
|
|
def _checksparse(repo):
|
|
|
|
if "eden" in repo.requirements:
|
|
|
|
raise error.Abort(
|
|
|
|
_(
|
|
|
|
"You're using an Eden repo and thus don't need sparse profiles. "
|
|
|
|
"See https://fburl.com/new-to-eden and enjoy!"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if not util.safehasattr(repo, "sparsematch"):
|
|
|
|
raise error.Abort(_("this is not a sparse repository"))
|
|
|
|
|
|
|
|
|
2018-10-17 00:19:25 +03:00
|
|
|
def _hassparse(repo):
|
|
|
|
return "eden" not in repo.requirements and util.safehasattr(repo, "sparsematch")
|
|
|
|
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def _setupupdates(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
|
|
|
def _calculateupdates(
|
|
|
|
orig, repo, wctx, mctx, ancestors, branchmerge, *arg, **kwargs
|
|
|
|
):
|
2020-10-15 06:19:13 +03:00
|
|
|
"""Filter updates to only lay out files that match the sparse rules."""
|
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
|
|
|
actions, diverge, renamedelete = orig(
|
|
|
|
repo, wctx, mctx, ancestors, branchmerge, *arg, **kwargs
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-01-17 04:43:19 +03:00
|
|
|
# If the working context is in memory (virtual), there's no need to
|
|
|
|
# apply the user's sparse rules at all (and in fact doing so would
|
|
|
|
# cause unexpected behavior in the real working copy).
|
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 not util.safehasattr(repo, "sparsematch") or wctx.isinmemory():
|
2017-10-14 00:51:27 +03:00
|
|
|
return actions, diverge, renamedelete
|
|
|
|
|
|
|
|
files = set()
|
|
|
|
prunedactions = {}
|
|
|
|
oldrevs = [pctx.rev() for pctx in wctx.parents()]
|
|
|
|
oldsparsematch = repo.sparsematch(*oldrevs)
|
|
|
|
|
|
|
|
if branchmerge:
|
|
|
|
# If we're merging, use the wctx filter, since we're merging into
|
|
|
|
# the wctx.
|
|
|
|
sparsematch = repo.sparsematch(wctx.parents()[0].rev())
|
|
|
|
else:
|
|
|
|
# If we're updating, use the target context's filter, since we're
|
|
|
|
# moving to the target context.
|
|
|
|
sparsematch = repo.sparsematch(mctx.rev())
|
|
|
|
|
|
|
|
temporaryfiles = []
|
2020-01-29 03:25:29 +03:00
|
|
|
for file, action in pycompat.iteritems(actions):
|
2017-10-14 00:51:27 +03:00
|
|
|
type, args, msg = action
|
|
|
|
files.add(file)
|
|
|
|
if sparsematch(file):
|
|
|
|
prunedactions[file] = action
|
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
|
|
|
elif type == "m":
|
2017-10-14 00:51:27 +03:00
|
|
|
temporaryfiles.append(file)
|
|
|
|
prunedactions[file] = action
|
|
|
|
elif branchmerge:
|
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 type != "k":
|
2017-10-14 00:51:27 +03:00
|
|
|
temporaryfiles.append(file)
|
|
|
|
prunedactions[file] = action
|
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
|
|
|
elif type == "f":
|
2017-10-14 00:51:27 +03:00
|
|
|
prunedactions[file] = action
|
|
|
|
elif file in wctx:
|
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
|
|
|
prunedactions[file] = ("r", args, msg)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
if len(temporaryfiles) > 0:
|
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.status(
|
|
|
|
_(
|
|
|
|
"temporarily included %d file(s) in the sparse checkout"
|
|
|
|
" for merging\n"
|
|
|
|
)
|
|
|
|
% len(temporaryfiles)
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
repo.addtemporaryincludes(temporaryfiles)
|
|
|
|
|
|
|
|
# Add the new files to the working copy so they can be merged, etc
|
|
|
|
actions = []
|
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
|
|
|
message = "temporarily adding to sparse checkout"
|
2017-10-14 00:51:27 +03:00
|
|
|
wctxmanifest = repo[None].manifest()
|
|
|
|
for file in temporaryfiles:
|
|
|
|
if file in wctxmanifest:
|
|
|
|
fctx = repo[None][file]
|
|
|
|
actions.append((file, (fctx.flags(), False), message))
|
|
|
|
|
|
|
|
typeactions = collections.defaultdict(list)
|
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
|
|
|
typeactions["g"] = actions
|
|
|
|
mergemod.applyupdates(repo, typeactions, repo[None], repo["."], False)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
dirstate = repo.dirstate
|
|
|
|
for file, flags, msg in actions:
|
|
|
|
dirstate.normal(file)
|
|
|
|
|
|
|
|
profiles = repo.getactiveprofiles()
|
|
|
|
changedprofiles = profiles & files
|
|
|
|
# If an active profile changed during the update, refresh the checkout.
|
|
|
|
# Don't do this during a branch merge, since all incoming changes should
|
|
|
|
# have been handled by the temporary includes above.
|
|
|
|
if changedprofiles and not branchmerge:
|
2020-06-23 18:35:08 +03:00
|
|
|
scopename = "Calculating additional actions for sparse profile update"
|
|
|
|
with util.traced(scopename):
|
|
|
|
mf = mctx.manifest()
|
2020-11-05 15:37:49 +03:00
|
|
|
fullprefetchonsparseprofilechange = ui.configbool(
|
|
|
|
"sparse", "force_full_prefetch_on_sparse_profile_change"
|
|
|
|
)
|
|
|
|
fullprefetchonsparseprofilechange |= not util.safehasattr(mf, "walk")
|
|
|
|
|
|
|
|
with ui.configoverride(
|
|
|
|
{("treemanifest", "ondemandfetch"): True}, "sparseprofilechange"
|
|
|
|
):
|
|
|
|
if fullprefetchonsparseprofilechange:
|
|
|
|
# We're going to need a full manifest, so if treemanifest is in
|
|
|
|
# use, we should prefetch. Since our tree might be incomplete
|
|
|
|
# (and its root could be unknown to the server if this is a
|
|
|
|
# local commit), we use BFS prefetching to "complete" our tree.
|
|
|
|
if util.safehasattr(repo, "forcebfsprefetch"):
|
|
|
|
repo.forcebfsprefetch("", [mctx.manifestnode()])
|
|
|
|
|
|
|
|
iter = mf
|
|
|
|
else:
|
2020-11-05 15:37:49 +03:00
|
|
|
match = matchmod.xormatcher(oldsparsematch, sparsematch)
|
2020-11-05 15:37:49 +03:00
|
|
|
iter = mf.walk(match)
|
|
|
|
|
|
|
|
for file in iter:
|
|
|
|
old = oldsparsematch(file)
|
|
|
|
new = sparsematch(file)
|
|
|
|
if not old and new:
|
|
|
|
flags = mf.flags(file)
|
|
|
|
prunedactions[file] = ("g", (flags, False), "")
|
|
|
|
elif old and not new:
|
|
|
|
prunedactions[file] = ("r", [], "")
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
return prunedactions, diverge, renamedelete
|
|
|
|
|
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
|
|
|
extensions.wrapfunction(mergemod, "calculateupdates", _calculateupdates)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _update(orig, repo, node, branchmerge, *args, **kwargs):
|
|
|
|
results = orig(repo, node, branchmerge, *args, **kwargs)
|
|
|
|
|
|
|
|
# If we're updating to a location, clean up any stale temporary includes
|
|
|
|
# (ex: this happens during hg rebase --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
|
|
|
if not branchmerge and util.safehasattr(repo, "sparsematch"):
|
2017-10-14 00:51:27 +03:00
|
|
|
repo.prunetemporaryincludes()
|
|
|
|
return results
|
|
|
|
|
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
|
|
|
extensions.wrapfunction(mergemod, "update", _update)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-03-27 19:54:48 +03:00
|
|
|
def _checkcollision(orig, repo, wmf, actions):
|
2018-10-17 22:00:50 +03:00
|
|
|
# If disablecasecheck is on, this should be a no-op. Run orig just to
|
|
|
|
# be safe.
|
|
|
|
if repo.ui.configbool("perftweaks", "disablecasecheck"):
|
|
|
|
return orig(repo, wmf, actions)
|
|
|
|
|
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(repo, "sparsematch"):
|
2018-03-27 19:54:48 +03:00
|
|
|
# Only check for collisions on files and directories in the
|
|
|
|
# sparse profile
|
|
|
|
wmf = wmf.matches(repo.sparsematch())
|
|
|
|
return orig(repo, wmf, actions)
|
|
|
|
|
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
|
|
|
extensions.wrapfunction(mergemod, "_checkcollision", _checkcollision)
|
|
|
|
|
2018-03-27 19:54:48 +03:00
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def _setupcommit(ui):
|
|
|
|
def _refreshoncommit(orig, self, node):
|
2020-10-15 06:19:13 +03:00
|
|
|
"""Refresh the checkout when commits touch .hgsparse"""
|
2017-10-14 00:51:27 +03:00
|
|
|
orig(self, node)
|
2017-11-20 17:40:41 +03:00
|
|
|
|
|
|
|
# Use unfiltered to avoid computing hidden commits
|
2020-07-07 00:00:16 +03:00
|
|
|
repo = self._repo
|
2017-11-20 17:40: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 util.safehasattr(repo, "getsparsepatterns"):
|
2017-10-14 00:51:27 +03:00
|
|
|
ctx = repo[node]
|
2018-03-13 15:02:35 +03:00
|
|
|
profiles = repo.getsparsepatterns(ctx.rev()).profiles
|
2017-10-14 00:51:27 +03:00
|
|
|
if set(profiles) & set(ctx.files()):
|
|
|
|
origstatus = repo.status()
|
|
|
|
origsparsematch = repo.sparsematch()
|
|
|
|
_refresh(repo.ui, repo, origstatus, origsparsematch, True)
|
|
|
|
|
|
|
|
repo.prunetemporaryincludes()
|
|
|
|
|
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
|
|
|
extensions.wrapfunction(context.committablectx, "markcommitted", _refreshoncommit)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _setuplog(ui):
|
commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.
This diff adds various aliases to "roughly" keep the command prefix matching
behavior.
The list of aliases are obtained by this script in `hg dbsh`:
def unique(prefix, names):
m = __import__('edenscm.mercurial').mercurial
try:
return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
except:
return False
nameslist=sorted([i.replace('^','') for i in m.commands.table])
aliases = {}
for names in nameslist:
names = names.split('|')
for name in names:
if name.startswith('debug'):
continue
for prefix in [name[:i] for i in xrange(1, len(name))]:
if unique(prefix, names):
aliases.setdefault(name, []).append(prefix)
Debug commands, and commands that are rarely used are not changed, including:
'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
'clone': ['clon'],
'cloud': ['clou'],
'convert': ['conv', 'conve', 'conver'],
'copy': ['cop'],
'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
'fold': ['fol'],
'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
'histgrep': ['histg', 'histgr', 'histgre'],
'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
'prune': ['pru', 'prun'],
'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
'rage': ['ra', 'rag'],
'record': ['recor'],
'recover': ['recov', 'recove'],
'redo': ['red'],
'repack': ['rep', 'repa', 'repac'],
'reset': ['rese'],
'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
'root': ['roo'],
'serve': ['se', 'ser', 'serv'],
'share': ['sha', 'shar'],
'sparse': ['spa', 'spar', 'spars'],
'svn': ['sv'],
'undo': ['und'],
'unshare': ['unsha', 'unshar'],
'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],
Reviewed By: sfilipco
Differential Revision: D17644676
fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 19:44:04 +03:00
|
|
|
entry = commands.table["log|history"]
|
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
|
|
|
entry[1].append(
|
|
|
|
("", "sparse", None, "limit to changesets affecting the sparse checkout")
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _logrevs(orig, repo, opts):
|
|
|
|
revs = orig(repo, opts)
|
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 opts.get("sparse"):
|
2020-12-02 14:43:43 +03:00
|
|
|
_checksparse(repo)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
sparsematch = repo.sparsematch()
|
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-14 00:51:27 +03:00
|
|
|
def ctxmatch(rev):
|
|
|
|
ctx = repo[rev]
|
|
|
|
return any(f for f in ctx.files() if sparsematch(f))
|
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-14 00:51:27 +03:00
|
|
|
revs = revs.filter(ctxmatch)
|
|
|
|
return revs
|
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
|
|
|
|
|
|
|
extensions.wrapfunction(cmdutil, "_logrevs", _logrevs)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2020-03-12 04:31:12 +03:00
|
|
|
def _tracktelemetry(
|
|
|
|
runcommand, # type: Callable[[uimod.ui, localrepo.localrepository, Any], Optional[int]]
|
|
|
|
lui, # type: uimod.ui
|
|
|
|
repo, # type: localrepo.localrepository
|
|
|
|
*args # type: Any
|
|
|
|
):
|
|
|
|
# type: (...) -> Optional[int]
|
2018-10-17 00:19:25 +03:00
|
|
|
res = runcommand(lui, repo, *args)
|
|
|
|
if repo is not None and repo.local():
|
2020-03-12 04:31:12 +03:00
|
|
|
try:
|
|
|
|
_tracksparseprofiles(lui, repo)
|
|
|
|
_trackdirstatesizes(lui, repo)
|
|
|
|
except error.Abort as ex:
|
|
|
|
# Ignore Abort errors that occur trying to compute the telemetry data, and
|
|
|
|
# don't let this fail the command. For instance, reading the dirstate could
|
|
|
|
# fail with the error "working directory state may be changed parallelly"
|
|
|
|
lui.debug("error recording dirstate telemetry: %s\n" % (ex,))
|
|
|
|
|
2018-10-17 00:19:25 +03:00
|
|
|
return res
|
|
|
|
|
|
|
|
|
2020-03-12 04:31:12 +03:00
|
|
|
def _tracksparseprofiles(lui, repo):
|
|
|
|
# type: (uimod.ui, localrepo.localrepository) -> None
|
|
|
|
# Reading the sparse profile from the repo can potentially trigger
|
|
|
|
# tree or file fetchings that are quite expensive. Do not read
|
|
|
|
# them. Only read the sparse file on the filesystem.
|
|
|
|
if util.safehasattr(repo, "getactiveprofiles"):
|
|
|
|
profile = repo.localvfs.tryread("sparse")
|
|
|
|
lui.log("sparse_profiles", "", active_profiles=pycompat.decodeutf8(profile))
|
|
|
|
|
|
|
|
|
|
|
|
def _trackdirstatesizes(lui, repo):
|
|
|
|
# type: (uimod.ui, localrepo.localrepository) -> None
|
|
|
|
dirstate = repo.dirstate
|
|
|
|
dirstatesize = None
|
|
|
|
try:
|
|
|
|
# Eden and flat dirstate.
|
2020-08-12 07:43:21 +03:00
|
|
|
# pyre-fixme[16]: treedirstatemap has no attribute _map
|
2020-03-12 04:31:12 +03:00
|
|
|
dirstatesize = len(dirstate._map._map)
|
|
|
|
except AttributeError:
|
|
|
|
# Treestate and treedirstate.
|
2020-07-20 23:26:26 +03:00
|
|
|
dirstatesize = len(dirstate._map)
|
2020-03-12 04:31:12 +03:00
|
|
|
if dirstatesize is not None:
|
|
|
|
lui.log("dirstate_size", dirstate_size=dirstatesize)
|
|
|
|
if (
|
|
|
|
repo.ui.configbool("sparse", "largecheckouthint")
|
|
|
|
and dirstatesize >= repo.ui.configint("sparse", "largecheckoutcount")
|
|
|
|
and _hassparse(repo)
|
|
|
|
):
|
|
|
|
hintutil.trigger("sparse-largecheckout", dirstatesize, repo)
|
2020-09-01 09:20:19 +03:00
|
|
|
f = _find_unsafe_marker_files(repo, lui)
|
|
|
|
if f is not None:
|
|
|
|
hintutil.trigger("sparse-unsafe-profile", f, repo, lui)
|
2018-10-17 00:19:25 +03:00
|
|
|
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def _clonesparsecmd(orig, ui, repo, *args, **opts):
|
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
|
|
|
include_pat = opts.get("include")
|
|
|
|
exclude_pat = opts.get("exclude")
|
|
|
|
enableprofile_pat = opts.get("enable_profile")
|
2017-10-14 00:51:27 +03:00
|
|
|
include = exclude = enableprofile = False
|
|
|
|
if include_pat:
|
|
|
|
pat = include_pat
|
|
|
|
include = True
|
|
|
|
if exclude_pat:
|
|
|
|
pat = exclude_pat
|
|
|
|
exclude = True
|
|
|
|
if enableprofile_pat:
|
|
|
|
pat = enableprofile_pat
|
|
|
|
enableprofile = True
|
|
|
|
if sum([include, exclude, enableprofile]) > 1:
|
|
|
|
raise error.Abort(_("too many flags specified."))
|
|
|
|
if include or exclude or enableprofile:
|
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-14 00:51:27 +03:00
|
|
|
def clone_sparse(orig, self, node, overwrite, *args, **kwargs):
|
|
|
|
# sparse clone is a special snowflake as in that case always
|
|
|
|
# are outside of the repo's dir hierachy, yet we always want
|
|
|
|
# to name our includes/excludes/enables using repo-root
|
|
|
|
# relative paths
|
|
|
|
overrides = {
|
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
|
|
|
("sparse", "includereporootpaths"): True,
|
|
|
|
("sparse", "enablereporootpaths"): True,
|
2017-10-14 00:51:27 +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
|
|
|
with self.ui.configoverride(overrides, "sparse"):
|
|
|
|
_config(
|
|
|
|
self.ui,
|
2020-07-07 00:00:16 +03:00
|
|
|
self,
|
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
|
|
|
pat,
|
|
|
|
{},
|
|
|
|
include=include,
|
|
|
|
exclude=exclude,
|
|
|
|
enableprofile=enableprofile,
|
2020-08-31 21:36:48 +03:00
|
|
|
# Allow unsafe sparse profiles because usually people call
|
|
|
|
# fbclone command which already includes a few safeguards.
|
|
|
|
allowunsafeprofilechanges=True,
|
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-09-26 12:02:36 +03:00
|
|
|
ret = orig(self, node, overwrite, *args, **kwargs)
|
|
|
|
if enableprofile:
|
|
|
|
_checknonexistingprofiles(ui, self, pat)
|
|
|
|
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
|
|
|
|
|
|
|
extensions.wrapfunction(hg, "updaterepo", clone_sparse)
|
2017-10-14 00:51:27 +03:00
|
|
|
return orig(ui, repo, *args, **opts)
|
|
|
|
|
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-14 00:51:27 +03:00
|
|
|
def _setupclone(ui):
|
commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.
This diff adds various aliases to "roughly" keep the command prefix matching
behavior.
The list of aliases are obtained by this script in `hg dbsh`:
def unique(prefix, names):
m = __import__('edenscm.mercurial').mercurial
try:
return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
except:
return False
nameslist=sorted([i.replace('^','') for i in m.commands.table])
aliases = {}
for names in nameslist:
names = names.split('|')
for name in names:
if name.startswith('debug'):
continue
for prefix in [name[:i] for i in xrange(1, len(name))]:
if unique(prefix, names):
aliases.setdefault(name, []).append(prefix)
Debug commands, and commands that are rarely used are not changed, including:
'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
'clone': ['clon'],
'cloud': ['clou'],
'convert': ['conv', 'conve', 'conver'],
'copy': ['cop'],
'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
'fold': ['fol'],
'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
'histgrep': ['histg', 'histgr', 'histgre'],
'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
'prune': ['pru', 'prun'],
'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
'rage': ['ra', 'rag'],
'record': ['recor'],
'recover': ['recov', 'recove'],
'redo': ['red'],
'repack': ['rep', 'repa', 'repac'],
'reset': ['rese'],
'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
'root': ['roo'],
'serve': ['se', 'ser', 'serv'],
'share': ['sha', 'shar'],
'sparse': ['spa', 'spar', 'spars'],
'svn': ['sv'],
'undo': ['und'],
'unshare': ['unsha', 'unshar'],
'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],
Reviewed By: sfilipco
Differential Revision: D17644676
fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 19:44:04 +03:00
|
|
|
entry = commands.table["clone"]
|
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
|
|
|
entry[1].append(("", "enable-profile", [], "enable a sparse profile"))
|
|
|
|
entry[1].append(("", "include", [], "include sparse pattern"))
|
|
|
|
entry[1].append(("", "exclude", [], "exclude sparse pattern"))
|
|
|
|
extensions.wrapcommand(commands.table, "clone", _clonesparsecmd)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _setupadd(ui):
|
commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.
This diff adds various aliases to "roughly" keep the command prefix matching
behavior.
The list of aliases are obtained by this script in `hg dbsh`:
def unique(prefix, names):
m = __import__('edenscm.mercurial').mercurial
try:
return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
except:
return False
nameslist=sorted([i.replace('^','') for i in m.commands.table])
aliases = {}
for names in nameslist:
names = names.split('|')
for name in names:
if name.startswith('debug'):
continue
for prefix in [name[:i] for i in xrange(1, len(name))]:
if unique(prefix, names):
aliases.setdefault(name, []).append(prefix)
Debug commands, and commands that are rarely used are not changed, including:
'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
'clone': ['clon'],
'cloud': ['clou'],
'convert': ['conv', 'conve', 'conver'],
'copy': ['cop'],
'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
'fold': ['fol'],
'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
'histgrep': ['histg', 'histgr', 'histgre'],
'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
'prune': ['pru', 'prun'],
'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
'rage': ['ra', 'rag'],
'record': ['recor'],
'recover': ['recov', 'recove'],
'redo': ['red'],
'repack': ['rep', 'repa', 'repac'],
'reset': ['rese'],
'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
'root': ['roo'],
'serve': ['se', 'ser', 'serv'],
'share': ['sha', 'shar'],
'sparse': ['spa', 'spar', 'spars'],
'svn': ['sv'],
'undo': ['und'],
'unshare': ['unsha', 'unshar'],
'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],
Reviewed By: sfilipco
Differential Revision: D17644676
fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 19:44:04 +03:00
|
|
|
entry = commands.table["add"]
|
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
|
|
|
entry[1].append(
|
|
|
|
(
|
|
|
|
"s",
|
|
|
|
"sparse",
|
|
|
|
None,
|
|
|
|
"also include directories of added files in sparse config",
|
|
|
|
)
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _add(orig, ui, repo, *pats, **opts):
|
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 opts.get("sparse"):
|
2017-10-14 00:51:27 +03:00
|
|
|
dirs = set()
|
|
|
|
for pat in pats:
|
|
|
|
dirname, basename = util.split(pat)
|
|
|
|
dirs.add(dirname)
|
2020-08-31 21:36:48 +03:00
|
|
|
_config(
|
|
|
|
ui, repo, list(dirs), opts, include=True, allowunsafeprofilechanges=True
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
return orig(ui, repo, *pats, **opts)
|
|
|
|
|
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
|
|
|
extensions.wrapcommand(commands.table, "add", _add)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _setupdirstate(ui):
|
|
|
|
"""Modify the dirstate to prevent stat'ing excluded files,
|
|
|
|
and to prevent modifications to files outside the checkout.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def _dirstate(orig, repo):
|
|
|
|
dirstate = orig(repo)
|
|
|
|
dirstate.repo = repo
|
|
|
|
return 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
|
|
|
|
|
|
|
extensions.wrapfunction(localrepo.localrepository.dirstate, "func", _dirstate)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# The atrocity below is needed to wrap dirstate._ignore. It is a cached
|
|
|
|
# property, which means normal function wrapping doesn't work.
|
|
|
|
class ignorewrapper(object):
|
|
|
|
def __init__(self, orig):
|
|
|
|
self.orig = orig
|
|
|
|
self.origignore = None
|
|
|
|
self.func = None
|
|
|
|
self.sparsematch = None
|
|
|
|
|
|
|
|
def __get__(self, obj, type=None):
|
2018-09-28 17:08:56 +03:00
|
|
|
repo = obj.repo if util.safehasattr(obj, "repo") else None
|
2017-10-14 00:51:27 +03:00
|
|
|
origignore = self.orig.__get__(obj)
|
2018-09-28 17:08:56 +03:00
|
|
|
if repo is None or not util.safehasattr(repo, "sparsematch"):
|
2017-10-14 00:51:27 +03:00
|
|
|
return origignore
|
|
|
|
|
|
|
|
sparsematch = repo.sparsematch()
|
|
|
|
if self.sparsematch != sparsematch or self.origignore != origignore:
|
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
|
|
|
self.func = unionmatcher([origignore, negatematcher(sparsematch)])
|
2017-10-14 00:51:27 +03:00
|
|
|
self.sparsematch = sparsematch
|
|
|
|
self.origignore = origignore
|
|
|
|
return self.func
|
|
|
|
|
|
|
|
def __set__(self, obj, value):
|
|
|
|
return self.orig.__set__(obj, value)
|
|
|
|
|
|
|
|
def __delete__(self, obj):
|
|
|
|
return self.orig.__delete__(obj)
|
|
|
|
|
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
|
|
|
replacefilecache(dirstate.dirstate, "_ignore", ignorewrapper)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# dirstate.rebuild should not add non-matching files
|
2018-05-03 03:08:29 +03:00
|
|
|
def _rebuild(orig, self, parent, allfiles, changedfiles=None, exact=False):
|
2018-05-03 03:08:33 +03:00
|
|
|
if exact:
|
|
|
|
# If exact=True, files outside "changedfiles" are assumed unchanged.
|
|
|
|
# In this case, do not check files outside sparse profile. This
|
|
|
|
# skips O(working copy) scans, and affect absorb perf.
|
|
|
|
return orig(self, parent, allfiles, changedfiles, exact=exact)
|
|
|
|
|
2018-09-28 17:08:56 +03:00
|
|
|
if util.safehasattr(self, "repo") and util.safehasattr(
|
|
|
|
self.repo, "sparsematch"
|
|
|
|
):
|
|
|
|
with progress.spinner(ui, "applying sparse profile"):
|
2018-08-17 21:26:48 +03:00
|
|
|
matcher = self.repo.sparsematch()
|
|
|
|
allfiles = allfiles.matches(matcher)
|
|
|
|
if changedfiles:
|
|
|
|
changedfiles = [f for f in changedfiles if matcher(f)]
|
|
|
|
|
|
|
|
if changedfiles is not None:
|
|
|
|
# In _rebuild, these files will be deleted from the dirstate
|
|
|
|
# when they are not found to be in allfiles
|
|
|
|
# This is O(working copy) and is expensive.
|
|
|
|
dirstatefilestoremove = set(f for f in self if not matcher(f))
|
|
|
|
changedfiles = dirstatefilestoremove.union(changedfiles)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
return orig(self, parent, allfiles, changedfiles)
|
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
|
|
|
|
|
|
|
extensions.wrapfunction(dirstate.dirstate, "rebuild", _rebuild)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# Prevent adding files that are outside the sparse checkout
|
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
|
|
|
editfuncs = ["normal", "add", "normallookup", "copy", "remove", "merge"]
|
|
|
|
hint = _(
|
|
|
|
"include file with `hg sparse include <pattern>` or use "
|
|
|
|
+ "`hg add -s <file>` to include file directory while adding"
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
for func in editfuncs:
|
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-14 00:51:27 +03:00
|
|
|
def _wrapper(orig, self, *args):
|
2018-09-28 17:08:56 +03:00
|
|
|
if util.safehasattr(self, "repo"):
|
|
|
|
repo = self.repo
|
|
|
|
if util.safehasattr(repo, "sparsematch"):
|
|
|
|
dirstate = repo.dirstate
|
|
|
|
sparsematch = repo.sparsematch()
|
|
|
|
for f in args:
|
|
|
|
if f is not None and not sparsematch(f) and f not in dirstate:
|
|
|
|
raise error.Abort(
|
|
|
|
_("cannot add '%s' - it is outside the sparse checkout")
|
|
|
|
% f,
|
|
|
|
hint=hint,
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
return orig(self, *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
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
extensions.wrapfunction(dirstate.dirstate, func, _wrapper)
|
|
|
|
|
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-14 00:51:27 +03:00
|
|
|
def _setupdiff(ui):
|
commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.
This diff adds various aliases to "roughly" keep the command prefix matching
behavior.
The list of aliases are obtained by this script in `hg dbsh`:
def unique(prefix, names):
m = __import__('edenscm.mercurial').mercurial
try:
return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
except:
return False
nameslist=sorted([i.replace('^','') for i in m.commands.table])
aliases = {}
for names in nameslist:
names = names.split('|')
for name in names:
if name.startswith('debug'):
continue
for prefix in [name[:i] for i in xrange(1, len(name))]:
if unique(prefix, names):
aliases.setdefault(name, []).append(prefix)
Debug commands, and commands that are rarely used are not changed, including:
'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
'clone': ['clon'],
'cloud': ['clou'],
'convert': ['conv', 'conve', 'conver'],
'copy': ['cop'],
'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
'fold': ['fol'],
'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
'histgrep': ['histg', 'histgr', 'histgre'],
'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
'prune': ['pru', 'prun'],
'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
'rage': ['ra', 'rag'],
'record': ['recor'],
'recover': ['recov', 'recove'],
'redo': ['red'],
'repack': ['rep', 'repa', 'repac'],
'reset': ['rese'],
'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
'root': ['roo'],
'serve': ['se', 'ser', 'serv'],
'share': ['sha', 'shar'],
'sparse': ['spa', 'spar', 'spars'],
'svn': ['sv'],
'undo': ['und'],
'unshare': ['unsha', 'unshar'],
'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],
Reviewed By: sfilipco
Differential Revision: D17644676
fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 19:44:04 +03:00
|
|
|
entry = commands.table["diff|d|di|dif"]
|
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
|
|
|
entry[1].append(
|
|
|
|
("s", "sparse", None, "only show changes in files in the sparse config")
|
|
|
|
)
|
2017-11-21 00:56:55 +03:00
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def workingfilectxdata(orig, self):
|
2017-11-21 00:56:55 +03:00
|
|
|
try:
|
|
|
|
# Try lookup working copy first.
|
2017-10-14 00:51:27 +03:00
|
|
|
return orig(self)
|
2017-11-21 00:56:55 +03:00
|
|
|
except IOError:
|
|
|
|
# Then try working copy parent if the file is outside 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
|
|
|
if util.safehasattr(self._repo, "sparsematch"):
|
2017-11-21 00:56:55 +03:00
|
|
|
sparsematch = self._repo.sparsematch()
|
|
|
|
if not sparsematch(self._path):
|
|
|
|
basectx = self._changectx._parents[0]
|
|
|
|
return basectx[self._path].data()
|
|
|
|
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
|
|
|
extensions.wrapfunction(context.workingfilectx, "data", workingfilectxdata)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# wrap trydiff to filter diffs if '--sparse' is set
|
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 trydiff(
|
|
|
|
orig,
|
|
|
|
repo,
|
|
|
|
revs,
|
|
|
|
ctx1,
|
|
|
|
ctx2,
|
|
|
|
modified,
|
|
|
|
added,
|
|
|
|
removed,
|
|
|
|
copy,
|
|
|
|
getfilectx,
|
|
|
|
opts,
|
|
|
|
losedatafn,
|
|
|
|
prefix,
|
|
|
|
relroot,
|
|
|
|
):
|
2017-10-14 00:51:27 +03:00
|
|
|
sparsematch = repo.sparsematch()
|
2020-02-18 01:47:28 +03:00
|
|
|
modified = list(filter(sparsematch, modified))
|
|
|
|
added = list(filter(sparsematch, added))
|
|
|
|
removed = list(filter(sparsematch, removed))
|
2017-10-14 00:51:27 +03:00
|
|
|
copy = dict((d, s) for d, s in copy.items() if sparsematch(s))
|
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 orig(
|
|
|
|
repo,
|
|
|
|
revs,
|
|
|
|
ctx1,
|
|
|
|
ctx2,
|
|
|
|
modified,
|
|
|
|
added,
|
|
|
|
removed,
|
|
|
|
copy,
|
|
|
|
getfilectx,
|
|
|
|
opts,
|
|
|
|
losedatafn,
|
|
|
|
prefix,
|
|
|
|
relroot,
|
|
|
|
)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def diff(orig, ui, repo, *pats, **opts):
|
2020-08-29 09:46:17 +03:00
|
|
|
issparse = False
|
|
|
|
# Make sure --sparse option is just ignored when it's not
|
|
|
|
# a sparse repo e.g. on eden checkouts.
|
|
|
|
if _hassparse(repo):
|
|
|
|
issparse = bool(opts.get("sparse"))
|
2017-10-14 00:51:27 +03:00
|
|
|
if issparse:
|
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
|
|
|
extensions.wrapfunction(patch, "trydiff", trydiff)
|
2017-10-14 00:51:27 +03:00
|
|
|
try:
|
|
|
|
orig(ui, repo, *pats, **opts)
|
|
|
|
finally:
|
|
|
|
if issparse:
|
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
|
|
|
extensions.unwrapfunction(patch, "trydiff", trydiff)
|
|
|
|
|
|
|
|
extensions.wrapcommand(commands.table, "diff", diff)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
@attr.s(frozen=True, slots=True, cmp=False)
|
2018-03-13 15:02:35 +03:00
|
|
|
class SparseConfig(object):
|
2018-03-29 12:34:01 +03:00
|
|
|
path = attr.ib()
|
2018-04-10 13:37:14 +03:00
|
|
|
includes = attr.ib(convert=frozenset)
|
|
|
|
excludes = attr.ib(convert=frozenset)
|
|
|
|
profiles = attr.ib(convert=tuple)
|
2018-03-14 16:49:45 +03:00
|
|
|
metadata = attr.ib(default=attr.Factory(dict))
|
2018-03-13 15:02:35 +03:00
|
|
|
|
|
|
|
def __iter__(self):
|
2018-03-14 16:49:45 +03:00
|
|
|
# The metadata field is deliberately not included
|
2018-03-13 15:02:35 +03:00
|
|
|
for field in (self.includes, self.excludes, self.profiles):
|
|
|
|
yield field
|
|
|
|
|
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-14 00:51:27 +03:00
|
|
|
def _wraprepo(ui, repo):
|
2018-03-14 16:49:45 +03:00
|
|
|
# metadata parsing expression
|
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
|
|
|
metadata_key_value = re.compile(r"(?P<key>.*)\s*[:=]\s*(?P<value>.*)")
|
2018-03-14 16:49:45 +03:00
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
class SparseRepo(repo.__class__):
|
2018-05-04 17:28:34 +03:00
|
|
|
def readsparseconfig(self, raw, filename=None, warn=True):
|
2018-03-13 15:02:35 +03:00
|
|
|
"""Takes a string sparse config and returns a SparseConfig
|
|
|
|
|
|
|
|
This object contains the includes, excludes, and profiles from the
|
|
|
|
raw profile.
|
|
|
|
|
2018-05-04 17:28:34 +03:00
|
|
|
The filename is used to report errors and warnings, unless warn is
|
|
|
|
set to False.
|
2018-03-14 16:49:43 +03:00
|
|
|
|
2017-10-14 00:51:27 +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
|
|
|
filename = filename or "<sparse profile>"
|
2018-03-14 16:49:45 +03:00
|
|
|
metadata = {}
|
|
|
|
last_key = None
|
2017-10-14 00:51:27 +03:00
|
|
|
includes = set()
|
|
|
|
excludes = set()
|
2018-03-13 15:02:37 +03:00
|
|
|
|
|
|
|
sections = {
|
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
|
|
|
"[include]": includes,
|
|
|
|
"[exclude]": excludes,
|
|
|
|
"[metadata]": metadata,
|
2018-03-13 15:02:37 +03:00
|
|
|
}
|
|
|
|
current = includes # no sections == includes
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
profiles = []
|
2018-05-04 17:28:34 +03:00
|
|
|
uiwarn = self.ui.warn if warn else (lambda *ignored: None)
|
2018-03-13 15:02:37 +03:00
|
|
|
|
2018-03-14 16:49:45 +03:00
|
|
|
for i, line in enumerate(raw.splitlines(), start=1):
|
|
|
|
stripped = line.strip()
|
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 not stripped or stripped.startswith(("#", ";")):
|
2017-10-14 00:51:27 +03:00
|
|
|
# empty or comment line, skip
|
|
|
|
continue
|
2018-03-13 15:02:37 +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 stripped.startswith("%include "):
|
2018-03-13 15:02:37 +03:00
|
|
|
# include another profile
|
2018-03-14 16:49:45 +03:00
|
|
|
stripped = stripped[9:].strip()
|
|
|
|
if stripped:
|
|
|
|
profiles.append(stripped)
|
2017-10-14 00:51:27 +03:00
|
|
|
continue
|
2018-03-13 15:02:37 +03:00
|
|
|
|
2018-03-14 16:49:45 +03:00
|
|
|
if stripped in sections:
|
|
|
|
if sections[stripped] is includes and current is excludes:
|
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(
|
|
|
|
_(
|
|
|
|
"A sparse file cannot have includes after excludes "
|
|
|
|
"in %s:%i"
|
|
|
|
)
|
|
|
|
% (filename, i)
|
|
|
|
)
|
2018-03-14 16:49:45 +03:00
|
|
|
current = sections[stripped]
|
|
|
|
continue
|
|
|
|
|
|
|
|
if current is metadata:
|
|
|
|
# Metadata parsing, INI-style format
|
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 line.startswith((" ", "\t")): # continuation
|
2018-03-14 16:49:45 +03:00
|
|
|
if last_key is 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
|
|
|
uiwarn(
|
|
|
|
_(
|
|
|
|
"warning: sparse profile [metadata] section "
|
|
|
|
"indented lines that do not belong to a "
|
|
|
|
"multi-line entry, ignoring, in %s:%i\n"
|
|
|
|
)
|
|
|
|
% (filename, i)
|
|
|
|
)
|
2018-03-14 16:49:45 +03:00
|
|
|
continue
|
|
|
|
key, value = last_key, stripped
|
|
|
|
else:
|
|
|
|
match = metadata_key_value.match(stripped)
|
|
|
|
if match is 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
|
|
|
uiwarn(
|
|
|
|
_(
|
|
|
|
"warning: sparse profile [metadata] section "
|
|
|
|
"does not appear to have a valid option "
|
|
|
|
"definition, ignoring, in %s:%i\n"
|
|
|
|
)
|
|
|
|
% (filename, i)
|
|
|
|
)
|
2018-03-14 16:49:45 +03:00
|
|
|
last_key = None
|
|
|
|
continue
|
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
|
|
|
key, value = (s.strip() for s in match.group("key", "value"))
|
2018-03-14 16:49:45 +03:00
|
|
|
metadata[key] = []
|
|
|
|
|
|
|
|
metadata[key].append(value)
|
|
|
|
last_key = key
|
2018-03-13 15:02:37 +03:00
|
|
|
continue
|
|
|
|
|
|
|
|
# inclusion or exclusion line
|
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 stripped.startswith("/"):
|
|
|
|
self.ui.warn(
|
|
|
|
_(
|
|
|
|
"warning: sparse profile cannot use paths starting "
|
|
|
|
"with /, ignoring %s, in %s:%i\n"
|
|
|
|
)
|
|
|
|
% (line, filename, i)
|
|
|
|
)
|
2018-03-13 15:02:37 +03:00
|
|
|
continue
|
|
|
|
current.add(line)
|
2017-10-14 00:51:27 +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
|
|
|
metadata = {
|
|
|
|
key: "\n".join(value).strip() for key, value in metadata.items()
|
|
|
|
}
|
|
|
|
return SparseConfig(filename, includes, excludes, profiles, metadata)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
def getsparsepatterns(self, rev, config=None):
|
2018-03-13 15:02:35 +03:00
|
|
|
"""Produce the full sparse config for a revision as a SparseConfig
|
|
|
|
|
|
|
|
This includes all patterns from included profiles, transitively.
|
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
if config is None, use the active profile, in .hg/sparse
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
"""
|
2017-11-20 17:40:41 +03:00
|
|
|
# Use unfiltered to avoid computing hidden commits
|
2017-10-14 00:51:27 +03:00
|
|
|
if rev is 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
|
|
|
raise error.Abort(_("cannot parse sparse patterns from working copy"))
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2020-07-07 00:00:16 +03:00
|
|
|
repo = self
|
2018-03-29 12:34:01 +03:00
|
|
|
if config is None:
|
2018-09-28 17:08:56 +03:00
|
|
|
if not self.localvfs.exists("sparse"):
|
2020-02-20 21:57:07 +03:00
|
|
|
self._warnfullcheckout()
|
2018-03-29 12:34:01 +03:00
|
|
|
return SparseConfig(None, set(), set(), [])
|
|
|
|
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = self.localvfs.readutf8("sparse")
|
2018-09-28 17:08:56 +03:00
|
|
|
config = self.readsparseconfig(
|
|
|
|
raw, filename=self.localvfs.join("sparse")
|
|
|
|
)
|
2018-03-29 12:34:01 +03:00
|
|
|
|
2018-04-10 13:37:14 +03:00
|
|
|
# create copies, as these datastructures are updated further on
|
|
|
|
includes, excludes, profiles = (
|
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
|
|
|
set(config.includes),
|
|
|
|
set(config.excludes),
|
|
|
|
list(config.profiles),
|
2018-04-10 13:37:14 +03:00
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2017-11-20 17:40:41 +03:00
|
|
|
ctx = repo[rev]
|
2017-10-14 00:51:27 +03:00
|
|
|
if profiles:
|
|
|
|
visited = set()
|
|
|
|
while profiles:
|
|
|
|
profile = profiles.pop()
|
|
|
|
if profile in visited:
|
|
|
|
continue
|
|
|
|
visited.add(profile)
|
|
|
|
|
|
|
|
try:
|
2018-04-10 13:37:19 +03:00
|
|
|
raw = self.getrawprofile(profile, ctx.hex())
|
2017-10-14 00:51:27 +03:00
|
|
|
except error.ManifestLookupError:
|
|
|
|
msg = (
|
|
|
|
"warning: sparse profile '%s' not found "
|
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
|
|
|
"in rev %s - ignoring it\n" % (profile, ctx)
|
|
|
|
)
|
2018-10-31 05:20:42 +03:00
|
|
|
# experimental config: sparse.missingwarning
|
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 self.ui.configbool("sparse", "missingwarning"):
|
2017-10-14 00:51:27 +03:00
|
|
|
self.ui.warn(msg)
|
|
|
|
else:
|
|
|
|
self.ui.debug(msg)
|
|
|
|
continue
|
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
|
|
|
pincludes, pexcludes, subprofs = self.readsparseconfig(
|
|
|
|
raw, filename=profile
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
includes.update(pincludes)
|
|
|
|
excludes.update(pexcludes)
|
|
|
|
for subprofile in subprofs:
|
|
|
|
profiles.append(subprofile)
|
|
|
|
|
|
|
|
profiles = visited
|
|
|
|
|
|
|
|
if includes:
|
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
|
|
|
includes.add(".hg*")
|
2020-02-20 21:57:07 +03:00
|
|
|
|
|
|
|
if not includes and not excludes and not profiles:
|
|
|
|
self._warnfullcheckout()
|
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
return SparseConfig(
|
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
|
|
|
"<aggregated from %s>".format(config.path), includes, excludes, profiles
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
def _warnfullcheckout(self):
|
|
|
|
# Only warn once per command
|
|
|
|
if self._warnedfullcheckout:
|
|
|
|
return
|
|
|
|
self._warnedfullcheckout = True
|
|
|
|
|
|
|
|
warnlevel = self.ui.config("sparse", "warnfullcheckout")
|
|
|
|
if warnlevel is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if warnlevel == "hardblock":
|
|
|
|
raise error.Abort(
|
|
|
|
_("full checkouts are not supported for this repository"),
|
|
|
|
hint=_("use EdenFS or hg sparse"),
|
|
|
|
)
|
|
|
|
if warnlevel == "softblock":
|
|
|
|
if self.ui.configbool("sparse", "bypassfullcheckoutwarn", False):
|
|
|
|
warnlevel = "warn"
|
|
|
|
else:
|
|
|
|
raise error.Abort(
|
|
|
|
_("full checkouts are not supported for this repository"),
|
|
|
|
hint=_("use EdenFS or hg sparse"),
|
|
|
|
)
|
|
|
|
if warnlevel == "hint":
|
|
|
|
hintutil.trigger("sparse-fullcheckout")
|
|
|
|
else:
|
|
|
|
self.ui.warn(
|
|
|
|
_(
|
|
|
|
"warning: full checkouts will soon be disabled in "
|
|
|
|
"this repository. Use EdenFS or hg sparse to get a "
|
|
|
|
"smaller repository."
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def getrawprofile(self, profile, changeid):
|
2020-07-07 00:00:16 +03:00
|
|
|
repo = self
|
2017-10-14 00:51:27 +03: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
|
|
|
simplecache = extensions.find("simplecache")
|
2017-11-20 17:40:41 +03:00
|
|
|
|
|
|
|
# Use unfiltered to avoid computing hidden commits
|
|
|
|
node = repo[changeid].hex()
|
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-14 00:51:27 +03:00
|
|
|
def func():
|
2020-08-12 07:43:21 +03:00
|
|
|
return pycompat.decodeutf8(
|
|
|
|
repo.filectx(profile, changeid=changeid).data()
|
|
|
|
)
|
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
|
|
|
|
|
|
|
key = "sparseprofile:%s:%s" % (profile.replace("/", "__"), node)
|
|
|
|
return simplecache.memoize(
|
|
|
|
func, key, simplecache.stringserializer, self.ui
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
except KeyError:
|
2020-08-12 07:43:21 +03:00
|
|
|
return pycompat.decodeutf8(
|
|
|
|
repo.filectx(profile, changeid=changeid).data()
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-04-10 13:37:13 +03:00
|
|
|
def _sparsesignature(self, includetemp=True, config=None, revs=()):
|
2017-10-14 00:51:27 +03:00
|
|
|
"""Returns the signature string representing the contents of the
|
|
|
|
current project sparse configuration. This can be used to cache the
|
|
|
|
sparse matcher for a given set of revs."""
|
|
|
|
signaturecache = self.signaturecache
|
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
|
|
|
sigkey = config.path if config else ".hg/sparse"
|
2018-04-10 13:37:13 +03:00
|
|
|
signature = signaturecache.get(sigkey)
|
2017-10-14 00:51:27 +03:00
|
|
|
if includetemp:
|
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
|
|
|
tempsignature = signaturecache.get("tempsignature")
|
2017-10-14 00:51:27 +03:00
|
|
|
else:
|
|
|
|
tempsignature = 0
|
|
|
|
|
|
|
|
if signature is None or (includetemp and tempsignature is None):
|
|
|
|
signature = 0
|
2018-03-29 12:34:01 +03:00
|
|
|
if config is None:
|
2018-04-10 13:37:13 +03:00
|
|
|
try:
|
2018-09-28 17:08:56 +03:00
|
|
|
sparsedata = self.localvfs.read("sparse")
|
2018-04-10 13:37:13 +03:00
|
|
|
signature = hashlib.sha1(sparsedata).hexdigest()
|
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
2018-03-29 12:34:01 +03:00
|
|
|
else:
|
2018-04-10 13:37:13 +03:00
|
|
|
sha1 = hashlib.sha1()
|
|
|
|
for r in revs:
|
|
|
|
try:
|
2020-08-12 07:43:21 +03:00
|
|
|
sha1.update(
|
|
|
|
pycompat.encodeutf8(self.getrawprofile(config.path, r))
|
|
|
|
)
|
2018-04-10 13:37:13 +03:00
|
|
|
signature = sha1.hexdigest()
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
signaturecache[sigkey] = signature
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
tempsignature = 0
|
|
|
|
if includetemp:
|
|
|
|
try:
|
2018-09-28 17:08:56 +03:00
|
|
|
tempsparsepath = self.localvfs.read("tempsparse")
|
2018-04-10 13:37:13 +03:00
|
|
|
tempsignature = hashlib.sha1(tempsparsepath).hexdigest()
|
2017-10-14 00:51:27 +03:00
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
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
|
|
|
signaturecache["tempsignature"] = tempsignature
|
|
|
|
return "%s:%s" % (signature, tempsignature)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def invalidatecaches(self):
|
|
|
|
self.invalidatesignaturecache()
|
|
|
|
return super(SparseRepo, self).invalidatecaches()
|
|
|
|
|
|
|
|
def invalidatesignaturecache(self):
|
|
|
|
self.signaturecache.clear()
|
|
|
|
|
|
|
|
def sparsematch(self, *revs, **kwargs):
|
2018-03-29 12:34:01 +03:00
|
|
|
"""Returns the sparse match function for the given revs
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
If multiple revs are specified, the match function is the union
|
|
|
|
of all the revs.
|
|
|
|
|
|
|
|
`includetemp` is used to indicate if the temporarily included file
|
|
|
|
should be part of the matcher.
|
2018-03-29 12:34:01 +03:00
|
|
|
|
|
|
|
`config` can be used to specify a different sparse profile
|
|
|
|
from the default .hg/sparse active profile
|
|
|
|
|
|
|
|
"""
|
|
|
|
return self._sparsematch_and_key(*revs, **kwargs)[0]
|
|
|
|
|
|
|
|
def _sparsematch_and_key(self, *revs, **kwargs):
|
|
|
|
"""Implementation of sparsematch() with the cache key included.
|
|
|
|
|
|
|
|
This lets us reuse the key elsewhere without having to hit each
|
|
|
|
profile file twice.
|
2017-10-14 00:51:27 +03:00
|
|
|
"""
|
|
|
|
if not revs or revs == (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
|
|
|
revs = [
|
|
|
|
self.changelog.rev(node)
|
|
|
|
for node in self.dirstate.parents()
|
|
|
|
if node != nullid
|
|
|
|
]
|
2018-12-11 07:06:01 +03:00
|
|
|
if not revs:
|
|
|
|
# Need a revision to read .hg/sparse
|
|
|
|
revs = [nullrev]
|
2017-10-14 00:51:27 +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
|
|
|
includetemp = kwargs.get("includetemp", True)
|
|
|
|
config = kwargs.get("config")
|
2018-03-29 12:34:01 +03:00
|
|
|
signature = self._sparsesignature(
|
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
|
|
|
includetemp=includetemp, config=config, revs=revs
|
|
|
|
)
|
2017-10-14 00:51:27 +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
|
|
|
key = "%s:%s" % (signature, ":".join([str(r) for r in revs]))
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
result = self.sparsecache.get(key, None)
|
|
|
|
if result:
|
2018-03-29 12:34:01 +03:00
|
|
|
return result, key
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
matchers = []
|
2019-11-13 02:33:03 +03:00
|
|
|
isalways = False
|
2017-10-14 00:51:27 +03:00
|
|
|
for rev in revs:
|
|
|
|
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
|
|
|
includes, excludes, profiles = self.getsparsepatterns(rev, config)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
if includes or excludes:
|
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
|
|
|
matcher = matchmod.match(
|
|
|
|
self.root,
|
|
|
|
"",
|
|
|
|
[],
|
|
|
|
include=includes,
|
|
|
|
exclude=excludes,
|
|
|
|
default="relpath",
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
matchers.append(matcher)
|
2019-11-13 02:33:03 +03:00
|
|
|
else:
|
|
|
|
isalways = True
|
2017-10-14 00:51:27 +03:00
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
|
2019-11-13 02:33:03 +03:00
|
|
|
if isalways:
|
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
|
|
|
result = matchmod.always(self.root, "")
|
2017-10-14 00:51:27 +03:00
|
|
|
else:
|
2019-11-13 02:33:03 +03:00
|
|
|
result = matchmod.union(matchers, self.root, "")
|
2017-10-14 00:51:27 +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 kwargs.get("includetemp", True):
|
2017-10-14 00:51:27 +03:00
|
|
|
tempincludes = self.gettemporaryincludes()
|
2019-11-13 02:33:03 +03:00
|
|
|
if tempincludes:
|
|
|
|
result = forceincludematcher(result, tempincludes)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
self.sparsecache[key] = result
|
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
return result, key
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def getactiveprofiles(self):
|
2017-11-20 17:40:41 +03:00
|
|
|
# Use unfiltered to avoid computing hidden commits
|
2020-07-07 00:00:16 +03:00
|
|
|
repo = self
|
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
|
|
|
revs = [
|
|
|
|
repo.changelog.rev(node)
|
|
|
|
for node in repo.dirstate.parents()
|
|
|
|
if node != nullid
|
|
|
|
]
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
activeprofiles = set()
|
|
|
|
for rev in revs:
|
2018-03-13 15:02:35 +03:00
|
|
|
profiles = self.getsparsepatterns(rev).profiles
|
2017-10-14 00:51:27 +03:00
|
|
|
activeprofiles.update(profiles)
|
|
|
|
|
|
|
|
return activeprofiles
|
|
|
|
|
|
|
|
def writesparseconfig(self, include, exclude, profiles):
|
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
|
|
|
raw = "%s[include]\n%s\n[exclude]\n%s\n" % (
|
|
|
|
"".join(["%%include %s\n" % p for p in sorted(profiles)]),
|
|
|
|
"\n".join(sorted(include)),
|
|
|
|
"\n".join(sorted(exclude)),
|
|
|
|
)
|
2020-02-18 01:47:28 +03:00
|
|
|
self.localvfs.writeutf8("sparse", raw)
|
2017-10-14 00:51:27 +03:00
|
|
|
self.invalidatesignaturecache()
|
|
|
|
|
|
|
|
def addtemporaryincludes(self, files):
|
|
|
|
includes = self.gettemporaryincludes()
|
|
|
|
for file in files:
|
|
|
|
includes.add(file)
|
|
|
|
self._writetemporaryincludes(includes)
|
|
|
|
|
|
|
|
def gettemporaryincludes(self):
|
|
|
|
existingtemp = set()
|
2018-09-28 17:08:56 +03:00
|
|
|
if self.localvfs.exists("tempsparse"):
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = self.localvfs.readutf8("tempsparse")
|
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
|
|
|
existingtemp.update(raw.split("\n"))
|
2017-10-14 00:51:27 +03:00
|
|
|
return existingtemp
|
|
|
|
|
|
|
|
def _writetemporaryincludes(self, includes):
|
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
|
|
|
raw = "\n".join(sorted(includes))
|
2020-02-18 01:47:28 +03:00
|
|
|
self.localvfs.writeutf8("tempsparse", raw)
|
2017-10-14 00:51:27 +03:00
|
|
|
self.invalidatesignaturecache()
|
|
|
|
|
|
|
|
def prunetemporaryincludes(self):
|
2018-09-28 17:08:56 +03:00
|
|
|
if self.localvfs.exists("tempsparse"):
|
2017-10-14 00:51:27 +03:00
|
|
|
origstatus = self.status()
|
|
|
|
modified, added, removed, deleted, a, b, c = origstatus
|
|
|
|
if modified or added or removed or deleted:
|
|
|
|
# Still have pending changes. Don't bother trying to prune.
|
|
|
|
return
|
|
|
|
|
|
|
|
sparsematch = self.sparsematch(includetemp=False)
|
|
|
|
dirstate = self.dirstate
|
|
|
|
actions = []
|
|
|
|
dropped = []
|
|
|
|
tempincludes = self.gettemporaryincludes()
|
|
|
|
for file in tempincludes:
|
|
|
|
if file in dirstate and not sparsematch(file):
|
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
|
|
|
message = "dropping temporarily included sparse files"
|
2017-10-14 00:51:27 +03:00
|
|
|
actions.append((file, None, message))
|
|
|
|
dropped.append(file)
|
|
|
|
|
|
|
|
typeactions = collections.defaultdict(list)
|
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
|
|
|
typeactions["r"] = actions
|
|
|
|
mergemod.applyupdates(self, typeactions, self[None], self["."], False)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# Fix dirstate
|
|
|
|
for file in dropped:
|
2018-10-12 19:35:04 +03:00
|
|
|
dirstate.untrack(file)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-09-28 17:08:56 +03:00
|
|
|
self.localvfs.unlink("tempsparse")
|
2017-10-14 00:51:27 +03:00
|
|
|
self.invalidatesignaturecache()
|
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
|
|
|
msg = _(
|
|
|
|
"cleaned up %d temporarily added file(s) from the "
|
|
|
|
"sparse checkout\n"
|
|
|
|
)
|
2018-06-29 00:08:51 +03:00
|
|
|
self.ui.status(msg % len(tempincludes))
|
2017-10-14 00:51:27 +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 "dirstate" in repo._filecache:
|
2017-10-14 00:51:27 +03:00
|
|
|
repo.dirstate.repo = repo
|
|
|
|
repo.sparsecache = {}
|
|
|
|
repo.signaturecache = {}
|
2020-02-20 21:57:07 +03:00
|
|
|
repo._warnedfullcheckout = False
|
2017-10-14 00:51:27 +03:00
|
|
|
repo.__class__ = SparseRepo
|
|
|
|
|
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-10 17:39:11 +03:00
|
|
|
# A profile is either active, inactive or included; the latter is a profile
|
|
|
|
# included (transitively) by an active profile.
|
2018-03-13 15:02:32 +03:00
|
|
|
PROFILE_INACTIVE, PROFILE_ACTIVE, PROFILE_INCLUDED = _profile_flags = range(3)
|
|
|
|
|
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-03-13 15:02:32 +03:00
|
|
|
@attr.s(slots=True, frozen=True)
|
2020-02-18 01:47:28 +03:00
|
|
|
class ProfileInfo(pycompat.Mapping):
|
2018-03-13 15:02:32 +03:00
|
|
|
path = attr.ib()
|
|
|
|
active = attr.ib()
|
2018-03-14 16:49:45 +03:00
|
|
|
_metadata = attr.ib(default=attr.Factory(dict))
|
2018-03-13 15:02:32 +03:00
|
|
|
|
|
|
|
@active.validator
|
|
|
|
def checkactive(self, attribute, value):
|
|
|
|
if not any(value is flag for flag in _profile_flags):
|
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 ValueError("Invalid active flag value")
|
2017-11-10 17:39:11 +03:00
|
|
|
|
2018-03-14 16:49:45 +03:00
|
|
|
# Mapping methods for metadata access
|
|
|
|
def __getitem__(self, key):
|
|
|
|
return self._metadata[key]
|
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-03-14 16:49:45 +03:00
|
|
|
def __iter__(self):
|
|
|
|
return iter(self._metadata)
|
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-03-14 16:49:45 +03:00
|
|
|
def __len__(self):
|
|
|
|
return len(self._metadata)
|
|
|
|
|
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-01 00:04:15 +03:00
|
|
|
def _discover(ui, repo, rev=None):
|
2018-03-14 16:49:45 +03:00
|
|
|
"""Generate a list of available profiles with metadata
|
2017-11-10 17:39:11 +03:00
|
|
|
|
2018-03-14 16:49:45 +03:00
|
|
|
Returns a generator yielding ProfileInfo objects, paths are relative to the
|
|
|
|
repository root, the sequence is sorted by path.
|
2017-11-10 17:39:11 +03:00
|
|
|
|
|
|
|
If no sparse.profile_directory path is configured, will only
|
2018-03-14 16:49:45 +03:00
|
|
|
yield active and included profiles.
|
2017-11-10 17:39:11 +03:00
|
|
|
|
|
|
|
README(.*) files are filtered out.
|
|
|
|
|
2018-04-25 18:46:01 +03:00
|
|
|
If rev is given, show profiles available at that revision. The working copy
|
|
|
|
sparse configuration is ignored and no active profile information is
|
|
|
|
made available (all profiles are marked as 'inactive').
|
|
|
|
|
2017-11-10 17:39:11 +03:00
|
|
|
"""
|
2018-04-25 18:46:01 +03:00
|
|
|
if not rev:
|
|
|
|
included = repo.getactiveprofiles()
|
2020-07-23 04:57:00 +03:00
|
|
|
sparse = repo.localvfs.readutf8("sparse")
|
2018-04-25 18:46:01 +03:00
|
|
|
active = repo.readsparseconfig(sparse).profiles
|
|
|
|
active = frozenset(active)
|
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
|
|
|
rev = "."
|
2018-04-25 18:46:01 +03:00
|
|
|
else:
|
|
|
|
included = active = frozenset()
|
2017-11-10 17:39: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
|
|
|
profile_directory = ui.config("sparse", "profile_directory")
|
2017-11-10 17:39:11 +03:00
|
|
|
available = set()
|
2018-05-04 17:28:34 +03:00
|
|
|
ctx = scmutil.revsingle(repo, rev)
|
2017-11-10 17:39:11 +03:00
|
|
|
if profile_directory 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
|
|
|
if os.path.isabs(profile_directory) or profile_directory.startswith("../"):
|
2017-11-10 17:39:11 +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
|
|
|
_("sparse.profile_directory must be relative to the " "repository root")
|
|
|
|
)
|
|
|
|
if not profile_directory.endswith("/"):
|
|
|
|
profile_directory += "/"
|
2017-11-10 17:39:11 +03:00
|
|
|
|
|
|
|
mf = ctx.manifest()
|
|
|
|
|
2018-03-06 16:11:41 +03:00
|
|
|
matcher = matchmod.match(
|
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
|
|
|
repo.root,
|
|
|
|
repo.getcwd(),
|
|
|
|
patterns=["path:" + profile_directory],
|
|
|
|
exclude=["relglob:README.*", "relglob:README"],
|
|
|
|
)
|
2018-03-06 16:11:41 +03:00
|
|
|
available.update(mf.matches(matcher))
|
2017-11-10 17:39:11 +03:00
|
|
|
|
2018-03-14 16:49:45 +03:00
|
|
|
# sort profiles and read profile metadata as we iterate
|
|
|
|
for p in sorted(available | included):
|
2018-04-24 19:43:06 +03:00
|
|
|
try:
|
2018-05-04 17:28:34 +03:00
|
|
|
raw = repo.getrawprofile(p, ctx.hex())
|
2018-04-24 19:43:06 +03:00
|
|
|
except error.ManifestLookupError:
|
|
|
|
# ignore a missing profile; this should only happen for 'included'
|
|
|
|
# profiles, however. repo.getactiveprofiles() above will already
|
|
|
|
# have printed a warning about such profiles.
|
|
|
|
if p not in included:
|
|
|
|
raise
|
|
|
|
continue
|
2018-03-29 12:34:06 +03:00
|
|
|
md = repo.readsparseconfig(raw, filename=p).metadata
|
2018-05-01 00:04:15 +03:00
|
|
|
yield ProfileInfo(
|
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
|
|
|
p,
|
|
|
|
(
|
|
|
|
PROFILE_ACTIVE
|
|
|
|
if p in active
|
|
|
|
else PROFILE_INCLUDED
|
|
|
|
if p in included
|
|
|
|
else PROFILE_INACTIVE
|
|
|
|
),
|
|
|
|
md,
|
|
|
|
)
|
|
|
|
|
2017-11-10 17:39:11 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
def _profilesizeinfo(ui, repo, *config, **kwargs):
|
|
|
|
"""Get size stats for a given set of profiles
|
|
|
|
|
|
|
|
Returns a dictionary of config -> (count, bytes) tuples. The
|
|
|
|
special key `None` represents the total manifest count and
|
|
|
|
bytecount. bytes is the total size of the files.
|
|
|
|
|
|
|
|
Note: for performance reasons we don't calculate the total repository size
|
|
|
|
and the value for the `None` key is always set to (count, None) to reflect
|
|
|
|
this.
|
|
|
|
|
|
|
|
"""
|
|
|
|
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
|
|
|
cache = extensions.find("simplecache")
|
2018-03-29 12:34:01 +03:00
|
|
|
cacheget = functools.partial(
|
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
|
|
|
cache.cacheget, serializer=cache.jsonserializer, ui=ui
|
|
|
|
)
|
2018-03-29 12:34:01 +03:00
|
|
|
cacheset = functools.partial(
|
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
|
|
|
cache.cacheset, serializer=cache.jsonserializer, ui=ui
|
|
|
|
)
|
2018-03-29 12:34:01 +03:00
|
|
|
except KeyError:
|
|
|
|
cacheget = cacheset = lambda *args: 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
|
|
|
collectsize = kwargs.get("collectsize", False)
|
2018-03-29 12:34:01 +03:00
|
|
|
|
|
|
|
results = {}
|
|
|
|
matchers = {}
|
|
|
|
to_store = {}
|
|
|
|
|
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
|
|
|
rev = kwargs.get("rev", ".")
|
2018-04-10 13:37:19 +03:00
|
|
|
ctx = scmutil.revsingle(repo, rev)
|
2018-03-29 12:34:01 +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
|
|
|
templ = "sparseprofilestats:%s:{}" % util.split(repo.root)[-1]
|
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
def _genkey(path, *parts):
|
|
|
|
# paths need to be ascii-safe with
|
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
|
|
|
path = path.replace("/", "__")
|
|
|
|
return templ.format(":".join((path,) + parts))
|
2018-03-29 12:34:01 +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
|
|
|
key = _genkey("unfiltered", ctx.hex())
|
2018-03-29 12:34:01 +03:00
|
|
|
cached = cacheget(key)
|
|
|
|
results[None] = cached if cached else [0, None]
|
|
|
|
if cached is None:
|
|
|
|
# gather complete working copy data
|
|
|
|
matchers[None] = matchmod.always(repo.root, repo.root)
|
|
|
|
to_store[None] = key
|
|
|
|
|
|
|
|
for c in config:
|
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
|
|
|
matcher, key = repo._sparsematch_and_key(ctx.hex(), includetemp=False, config=c)
|
2018-03-29 12:34:01 +03:00
|
|
|
key = _genkey(c.path, key, str(collectsize))
|
|
|
|
cached = cacheget(key)
|
|
|
|
if not cached and not collectsize:
|
|
|
|
# if not collecting the full size, but we have a cached copy
|
|
|
|
# for a full run, use the file count from that
|
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
|
|
|
cached = cacheget(_genkey(c.path, key, "True"))
|
2018-03-29 12:34:01 +03:00
|
|
|
cached = cached and [cached[0], 0]
|
|
|
|
results[c] = cached or [0, 0]
|
|
|
|
if cached is None:
|
|
|
|
matchers[c] = matcher
|
|
|
|
to_store[c] = key
|
|
|
|
|
|
|
|
if matchers:
|
|
|
|
mf = ctx.manifest()
|
|
|
|
if results[None][0]:
|
|
|
|
# use cached working copy size
|
|
|
|
totalfiles = results[None][0]
|
|
|
|
else:
|
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
|
|
|
with progress.spinner(ui, "calculating total manifest size"):
|
2018-03-29 12:34:01 +03:00
|
|
|
try:
|
|
|
|
totalfiles = len(mf)
|
2018-04-03 17:27:34 +03:00
|
|
|
except TypeError:
|
2018-03-29 12:34:01 +03:00
|
|
|
# treemanifest does not implement __len__ :-(
|
|
|
|
totalfiles = sum(1 for __ in mf)
|
|
|
|
|
|
|
|
if collectsize and len(matchers) - (None in matchers):
|
|
|
|
# we may need to prefetch file data, to calculate the size of each
|
|
|
|
# profile
|
|
|
|
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
|
|
|
remotefilelog = extensions.find("remotefilelog")
|
2018-03-29 12:34:01 +03:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if remotefilelog.shallowrepo.requirement in repo.requirements:
|
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
|
|
|
profilematchers = unionmatcher([matchers[k] for k in matchers if k])
|
|
|
|
repo.prefetch(repo.revs(ctx.hex()), matcher=profilematchers)
|
2018-03-29 12:34:01 +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
|
|
|
with progress.bar(ui, _("calculating"), total=totalfiles) as prog:
|
2018-03-29 12:34:01 +03:00
|
|
|
# only matchers for which there was no cache are processed
|
2020-02-18 01:47:28 +03:00
|
|
|
for file in ctx.walk(unionmatcher(list(matchers.values()))):
|
2018-03-29 12:34:01 +03:00
|
|
|
prog.value += 1
|
|
|
|
for c, matcher in matchers.items():
|
|
|
|
if matcher(file):
|
|
|
|
results[c][0] += 1
|
|
|
|
if collectsize and c is not None:
|
2018-04-10 13:37:19 +03:00
|
|
|
results[c][1] += ctx.filectx(file).size()
|
2018-03-29 12:34:01 +03:00
|
|
|
|
|
|
|
results = {k: tuple(v) for k, v in results.items()}
|
|
|
|
for c, key in to_store.items():
|
|
|
|
cacheset(key, results[c])
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
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-04-18 20:31:30 +03:00
|
|
|
# hints
|
|
|
|
hint = registrar.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
|
|
|
|
2018-10-17 00:19:25 +03:00
|
|
|
@hint("sparse-largecheckout")
|
|
|
|
def hintlargecheckout(dirstatesize, repo):
|
|
|
|
return (
|
|
|
|
_(
|
|
|
|
"Your repository checkout has %s files which makes Many mercurial "
|
|
|
|
"commands slower. Learn how to make it smaller at "
|
|
|
|
"https://fburl.com/hgsparse"
|
|
|
|
)
|
|
|
|
% dirstatesize
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-09-01 09:20:19 +03:00
|
|
|
@hint("sparse-unsafe-profile")
|
|
|
|
def hintsparseunsafeprofile(file, repo, ui):
|
|
|
|
msg = _(
|
|
|
|
"Your sparse profile might be incorrect, and it can lead to "
|
|
|
|
"downloading too much data and slower mercurial operations."
|
|
|
|
)
|
|
|
|
additionalmsg = ui.config("sparse", "unsafe_sparse_profile_message")
|
|
|
|
if additionalmsg:
|
|
|
|
msg = "{}\n{}".format(msg, additionalmsg)
|
|
|
|
return msg
|
|
|
|
|
|
|
|
|
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
|
|
|
@hint("sparse-explain-verbose")
|
2018-04-18 20:31:30 +03:00
|
|
|
def hintexplainverbose(*profiles):
|
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 _(
|
|
|
|
"use 'hg sparse explain --verbose %s' to include the total file "
|
|
|
|
"size for a give profile"
|
|
|
|
) % " ".join(profiles)
|
2018-05-01 00:04:16 +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
|
|
|
|
|
|
|
@hint("sparse-list-verbose")
|
2018-05-04 17:28:34 +03:00
|
|
|
def hintlistverbose(profiles, filters, load_matcher):
|
2018-05-01 00:04:16 +03:00
|
|
|
# move the hidden flag from the without to the with pile and count
|
|
|
|
# the matches
|
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
|
|
|
filters["with"].add("hidden")
|
|
|
|
filters["without"].remove("hidden")
|
2018-05-04 17:28:34 +03:00
|
|
|
pred = _build_profile_filter(filters, load_matcher)
|
2018-05-01 00:04:16 +03:00
|
|
|
hidden_count = sum(1 for p in filter(pred, profiles))
|
|
|
|
if hidden_count:
|
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 (
|
|
|
|
_("%d hidden profiles not shown; " "add '--verbose' to include these")
|
|
|
|
% hidden_count
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
@hint("sparse-fullcheckout")
|
|
|
|
def hintwarnfullcheckout():
|
|
|
|
return _(
|
|
|
|
"warning: full checkouts will eventually be disabled in "
|
|
|
|
"this repository. Use EdenFS or hg sparse to get a "
|
|
|
|
"smaller 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
|
|
|
_deprecate = (
|
|
|
|
lambda o, l=_("(DEPRECATED)"): (o[:3] + (" ".join([o[4], l]),) + o[4:])
|
|
|
|
if l not in o[4]
|
|
|
|
else l
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@command(
|
commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.
This diff adds various aliases to "roughly" keep the command prefix matching
behavior.
The list of aliases are obtained by this script in `hg dbsh`:
def unique(prefix, names):
m = __import__('edenscm.mercurial').mercurial
try:
return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
except:
return False
nameslist=sorted([i.replace('^','') for i in m.commands.table])
aliases = {}
for names in nameslist:
names = names.split('|')
for name in names:
if name.startswith('debug'):
continue
for prefix in [name[:i] for i in xrange(1, len(name))]:
if unique(prefix, names):
aliases.setdefault(name, []).append(prefix)
Debug commands, and commands that are rarely used are not changed, including:
'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
'clone': ['clon'],
'cloud': ['clou'],
'convert': ['conv', 'conve', 'conver'],
'copy': ['cop'],
'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
'fold': ['fol'],
'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
'histgrep': ['histg', 'histgr', 'histgre'],
'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
'prune': ['pru', 'prun'],
'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
'rage': ['ra', 'rag'],
'record': ['recor'],
'recover': ['recov', 'recove'],
'redo': ['red'],
'repack': ['rep', 'repa', 'repac'],
'reset': ['rese'],
'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
'root': ['roo'],
'serve': ['se', 'ser', 'serv'],
'share': ['sha', 'shar'],
'sparse': ['spa', 'spar', 'spars'],
'svn': ['sv'],
'undo': ['und'],
'unshare': ['unsha', 'unshar'],
'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],
Reviewed By: sfilipco
Differential Revision: D17644676
fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 19:44:04 +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
|
|
|
[
|
|
|
|
(
|
|
|
|
"f",
|
|
|
|
"force",
|
|
|
|
False,
|
|
|
|
_("allow changing rules even with pending changes" "(DEPRECATED)"),
|
|
|
|
),
|
2020-08-31 21:36:48 +03:00
|
|
|
(
|
|
|
|
"",
|
|
|
|
"allow-unsafe-profile-changes",
|
|
|
|
False,
|
|
|
|
_(
|
|
|
|
"allow sparse profile change even if this change might be unsafe"
|
|
|
|
"(DEPRECATED)"
|
|
|
|
),
|
|
|
|
),
|
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
|
|
|
(
|
|
|
|
"I",
|
|
|
|
"include",
|
|
|
|
False,
|
|
|
|
_("include files in the sparse checkout " "(DEPRECATED)"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"X",
|
|
|
|
"exclude",
|
|
|
|
False,
|
|
|
|
_("exclude files in the sparse checkout " "(DEPRECATED)"),
|
|
|
|
),
|
|
|
|
("d", "delete", False, _("delete an include/exclude rule " "(DEPRECATED)")),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"enable-profile",
|
|
|
|
False,
|
|
|
|
_("enables the specified profile " "(DEPRECATED)"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"disable-profile",
|
|
|
|
False,
|
|
|
|
_("disables the specified profile " "(DEPRECATED)"),
|
|
|
|
),
|
|
|
|
("", "import-rules", False, _("imports rules from a file (DEPRECATED)")),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"clear-rules",
|
|
|
|
False,
|
|
|
|
_("clears local include/exclude rules " "(DEPRECATED)"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"refresh",
|
|
|
|
False,
|
|
|
|
_("updates the working after sparseness changes " "(DEPRECATED)"),
|
|
|
|
),
|
|
|
|
("", "reset", False, _("makes the repo full again (DEPRECATED)")),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"cwd-list",
|
|
|
|
False,
|
|
|
|
_("list the full contents of the current " "directory (DEPRECATED)"),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
+ [_deprecate(o) for o in commands.templateopts],
|
|
|
|
_("SUBCOMMAND ..."),
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
def sparse(ui, repo, *pats, **opts):
|
|
|
|
"""make the current checkout sparse, or edit the existing checkout
|
|
|
|
|
|
|
|
The sparse command is used to make the current checkout sparse.
|
|
|
|
This means files that don't meet the sparse condition will not be
|
|
|
|
written to disk, or show up in any working copy operations. It does
|
|
|
|
not affect files in history in any way.
|
|
|
|
|
2018-03-29 12:34:04 +03:00
|
|
|
All the work is done in subcommands such as `hg sparse enableprofile`;
|
|
|
|
passing no subcommand prints the currently applied sparse rules.
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-03-29 12:34:04 +03:00
|
|
|
The `include` and `exclude` subcommands are used to add and remove files
|
|
|
|
from the sparse checkout, while delete removes an existing include/exclude
|
|
|
|
rule.
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-05-03 14:33:09 +03:00
|
|
|
Sparse profiles can also be shared with other users of the repository by
|
2018-03-29 12:34:04 +03:00
|
|
|
committing a file with include and exclude rules in a separate file. Use the
|
|
|
|
`enableprofile` and `disableprofile` subcommands to enable or disable
|
|
|
|
such profiles. Changes to shared profiles are not applied until they have
|
|
|
|
been committed.
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-04-28 09:26:09 +03:00
|
|
|
See :hg:`help -e sparse` and :hg:`help sparse [subcommand]` to get
|
|
|
|
additional information.
|
2017-10-14 00:51:27 +03:00
|
|
|
"""
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(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
|
|
|
|
|
|
|
include = opts.get("include")
|
|
|
|
exclude = opts.get("exclude")
|
|
|
|
force = opts.get("force")
|
|
|
|
enableprofile = opts.get("enable_profile")
|
|
|
|
disableprofile = opts.get("disable_profile")
|
|
|
|
importrules = opts.get("import_rules")
|
|
|
|
clearrules = opts.get("clear_rules")
|
|
|
|
delete = opts.get("delete")
|
|
|
|
refresh = opts.get("refresh")
|
|
|
|
reset = opts.get("reset")
|
|
|
|
cwdlist = opts.get("cwd_list")
|
2020-08-31 21:36:48 +03:00
|
|
|
allowunsafeprofilechanges = opts.get("allow_unsafe_profile_changes")
|
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
|
|
|
count = sum(
|
|
|
|
[
|
|
|
|
include,
|
|
|
|
exclude,
|
|
|
|
enableprofile,
|
|
|
|
disableprofile,
|
|
|
|
delete,
|
|
|
|
importrules,
|
|
|
|
refresh,
|
|
|
|
clearrules,
|
|
|
|
reset,
|
|
|
|
cwdlist,
|
|
|
|
]
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
if count > 1:
|
|
|
|
raise error.Abort(_("too many flags specified"))
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
# Disable sparse warnings when running sparse commands, so users can get
|
|
|
|
# sparse checkouts.
|
|
|
|
origwarnfull = repo.ui.config("sparse", "warnfullcheckout")
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", None)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
if count == 0:
|
2018-09-28 17:08:56 +03:00
|
|
|
if repo.localvfs.exists("sparse"):
|
2020-07-23 04:57:00 +03:00
|
|
|
ui.status(repo.localvfs.readutf8("sparse") + "\n")
|
2017-10-14 00:51:27 +03:00
|
|
|
temporaryincludes = repo.gettemporaryincludes()
|
|
|
|
if temporaryincludes:
|
|
|
|
ui.status(_("Temporarily Included Files (for merge/rebase):\n"))
|
2020-05-07 19:05:16 +03:00
|
|
|
msg = "\n".join(temporaryincludes) + "\n"
|
|
|
|
ui.status(msg)
|
2017-10-14 00:51:27 +03:00
|
|
|
else:
|
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.status(_("repo is not sparse\n"))
|
2017-10-14 00:51:27 +03:00
|
|
|
return
|
|
|
|
|
|
|
|
if include or exclude or delete or reset or enableprofile or disableprofile:
|
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
|
|
|
_config(
|
|
|
|
ui,
|
|
|
|
repo,
|
|
|
|
pats,
|
|
|
|
opts,
|
|
|
|
include=include,
|
|
|
|
exclude=exclude,
|
|
|
|
reset=reset,
|
|
|
|
delete=delete,
|
|
|
|
enableprofile=enableprofile,
|
|
|
|
disableprofile=disableprofile,
|
|
|
|
force=force,
|
2020-08-31 21:36:48 +03:00
|
|
|
allowunsafeprofilechanges=allowunsafeprofilechanges,
|
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-09-26 12:02:36 +03:00
|
|
|
if enableprofile:
|
|
|
|
_checknonexistingprofiles(ui, repo, pats)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
if importrules:
|
|
|
|
_import(ui, repo, pats, opts, force=force)
|
|
|
|
|
|
|
|
if clearrules:
|
2020-02-20 21:57:07 +03:00
|
|
|
# Put the check back in to warn people about full checkouts
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", origwarnfull)
|
2017-10-14 00:51:27 +03:00
|
|
|
_clear(ui, repo, pats, force=force)
|
|
|
|
|
|
|
|
if refresh:
|
2018-03-15 14:34:07 +03:00
|
|
|
with repo.wlock():
|
|
|
|
c = _refresh(ui, repo, repo.status(), repo.sparsematch(), force)
|
2020-01-29 05:22:50 +03:00
|
|
|
fcounts = list(map(len, c))
|
2017-10-14 00:51:27 +03:00
|
|
|
_verbose_output(ui, opts, 0, 0, 0, *fcounts)
|
|
|
|
|
|
|
|
if cwdlist:
|
|
|
|
_cwdlist(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
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
subcmd = sparse.subcommand(
|
|
|
|
categories=[
|
2018-10-19 16:49:04 +03:00
|
|
|
(
|
|
|
|
"Show information about sparse profiles",
|
|
|
|
["show", "list", "explain", "files"],
|
|
|
|
),
|
2018-10-19 16:49:04 +03:00
|
|
|
("Change which profiles are active", ["switch", "enable", "disable"]),
|
|
|
|
(
|
|
|
|
"Manage additional files to include or exclude",
|
2018-10-19 16:49:05 +03:00
|
|
|
["include", "uninclude", "exclude", "unexclude", "clear"],
|
2018-10-19 16:49:04 +03:00
|
|
|
),
|
|
|
|
("Refresh the checkout and apply sparse profile changes", ["refresh"]),
|
|
|
|
]
|
|
|
|
)
|
2018-03-23 00:34:29 +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-10-19 16:49:04 +03:00
|
|
|
@subcmd("show", commands.templateopts)
|
|
|
|
def show(ui, repo, **opts):
|
|
|
|
"""show the currently enabled sparse profile"""
|
|
|
|
_checksparse(repo)
|
|
|
|
if not repo.localvfs.exists("sparse"):
|
|
|
|
if not ui.plain():
|
|
|
|
ui.status(_("No sparse profile enabled\n"))
|
|
|
|
return
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
# Disable fullcheckout warnings to allow users to sparse their fullcheckouts
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", None)
|
|
|
|
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = repo.localvfs.readutf8("sparse")
|
2020-01-29 05:22:50 +03:00
|
|
|
include, exclude, profiles = list(map(set, repo.readsparseconfig(raw)))
|
2018-10-19 16:49:04 +03:00
|
|
|
|
2020-05-08 00:49:13 +03:00
|
|
|
LOOKUP_SUCCESS, LOOKUP_NOT_FOUND = range(0, 2)
|
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
def getprofileinfo(profile, depth):
|
|
|
|
"""Returns a list of (depth, profilename, title) for this profile
|
|
|
|
and all its children."""
|
2020-05-08 00:49:13 +03:00
|
|
|
try:
|
|
|
|
raw = repo.getrawprofile(profile, ".")
|
|
|
|
except KeyError:
|
|
|
|
return [(depth, profile, LOOKUP_NOT_FOUND, "")]
|
|
|
|
sc = repo.readsparseconfig(raw)
|
|
|
|
|
|
|
|
profileinfo = [(depth, profile, LOOKUP_SUCCESS, sc.metadata.get("title"))]
|
2018-10-19 16:49:04 +03:00
|
|
|
for profile in sorted(sc.profiles):
|
|
|
|
profileinfo.extend(getprofileinfo(profile, depth + 1))
|
|
|
|
return profileinfo
|
|
|
|
|
|
|
|
ui.pager("sparse show")
|
|
|
|
with ui.formatter("sparse", opts) as fm:
|
|
|
|
if profiles:
|
|
|
|
profileinfo = []
|
|
|
|
fm.plain(_("Enabled Profiles:\n\n"))
|
|
|
|
profileinfo = sum((getprofileinfo(p, 0) for p in sorted(profiles)), [])
|
2020-05-08 00:49:13 +03:00
|
|
|
maxwidth = max(len(name) for depth, name, lookup, title in profileinfo)
|
|
|
|
maxdepth = max(depth for depth, name, lookup, title in profileinfo)
|
|
|
|
|
|
|
|
for depth, name, lookup, title in profileinfo:
|
|
|
|
if lookup == LOOKUP_SUCCESS:
|
|
|
|
if depth > 0:
|
|
|
|
label = "sparse.profile.included"
|
|
|
|
status = "~"
|
|
|
|
else:
|
|
|
|
label = "sparse.profile.active"
|
|
|
|
status = "*"
|
|
|
|
else:
|
|
|
|
label = "sparse.profile.notfound"
|
|
|
|
status = "!"
|
2018-10-19 16:49:04 +03:00
|
|
|
|
|
|
|
fm.startitem()
|
2020-05-08 00:49:13 +03:00
|
|
|
fm.data(type="profile", depth=depth, status=status)
|
2020-05-08 00:49:13 +03:00
|
|
|
fm.plain(" " * depth + " " + status + " ", label=label)
|
2018-10-19 16:49:04 +03:00
|
|
|
fm.write(
|
|
|
|
"name",
|
|
|
|
"%%-%ds" % (maxwidth + (maxdepth - depth) * 2),
|
|
|
|
name,
|
|
|
|
label=label,
|
|
|
|
)
|
|
|
|
if title:
|
|
|
|
fm.write("title", " %s", title, label=label + ".title")
|
|
|
|
fm.plain("\n")
|
|
|
|
if include or exclude:
|
|
|
|
fm.plain("\n")
|
2020-05-08 00:49:13 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
if include:
|
|
|
|
fm.plain(_("Additional Included Paths:\n\n"))
|
|
|
|
for fname in sorted(include):
|
|
|
|
fm.startitem()
|
|
|
|
fm.data(type="include")
|
|
|
|
fm.write("name", " %s\n", fname, label="sparse.include")
|
|
|
|
if exclude:
|
|
|
|
fm.plain("\n")
|
2020-05-08 00:49:13 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
if exclude:
|
|
|
|
fm.plain(_("Additional Excluded Paths:\n\n"))
|
|
|
|
for fname in sorted(exclude):
|
|
|
|
fm.startitem()
|
|
|
|
fm.data(type="exclude")
|
|
|
|
fm.write("name", " %s\n", fname, label="sparse.exclude")
|
|
|
|
|
|
|
|
|
2020-08-14 19:44:17 +03:00
|
|
|
@command(
|
|
|
|
"debugsparsematch",
|
|
|
|
[
|
|
|
|
("s", "sparse-profile", [], "sparse profile to include"),
|
|
|
|
("x", "exclude-sparse-profile", [], "sparse profile to exclude"),
|
|
|
|
],
|
|
|
|
_("-s SPARSE_PROFILE [OPTION]... FILE..."),
|
|
|
|
)
|
2020-06-26 04:01:16 +03:00
|
|
|
def debugsparsematch(ui, repo, *args, **opts):
|
|
|
|
"""Filter paths using the given sparse profile
|
|
|
|
|
|
|
|
Print paths that match the given sparse profile.
|
2020-08-14 19:44:17 +03:00
|
|
|
Paths are relative to repo root, and can use `listfile:` prefix.
|
2020-06-26 04:01:16 +03:00
|
|
|
|
|
|
|
Unlike 'sparse files', paths to test do not have to be present in the
|
|
|
|
working copy.
|
|
|
|
"""
|
|
|
|
# Make it work in an edenfs checkout.
|
|
|
|
if "eden" in repo.requirements:
|
|
|
|
_wraprepo(ui, repo)
|
2020-08-14 19:44:17 +03:00
|
|
|
profiles = opts.get("sparse_profile")
|
|
|
|
if not profiles:
|
2020-06-26 04:01:16 +03:00
|
|
|
raise error.Abort(_("--sparse-profile is required"))
|
2020-08-14 19:44:17 +03:00
|
|
|
ctx = repo[None] # use changes in cwd
|
|
|
|
|
2020-08-14 19:44:17 +03:00
|
|
|
m = scmutil.match(ctx, pats=args, opts=opts, default="path")
|
|
|
|
files = m.files()
|
2020-08-14 19:44:17 +03:00
|
|
|
ui.status_err(_("considering %d file(s)\n") % len(files))
|
|
|
|
|
|
|
|
def getmatcher(profile):
|
|
|
|
raw = pycompat.decodeutf8(ctx[profile].data())
|
|
|
|
return repo.sparsematch(
|
|
|
|
revs=[nullrev], config=repo.readsparseconfig(raw=raw, filename=profile)
|
|
|
|
)
|
|
|
|
|
|
|
|
def getunionmatcher(profiles):
|
|
|
|
matchers = [getmatcher(p) for p in profiles]
|
|
|
|
if not matchers:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return matchmod.union(matchers, "", "")
|
|
|
|
|
|
|
|
includematcher = getunionmatcher(opts.get("sparse_profile"))
|
|
|
|
excludematcher = getunionmatcher(opts.get("exclude_sparse_profile"))
|
|
|
|
if excludematcher is None:
|
|
|
|
matcher = includematcher
|
|
|
|
else:
|
|
|
|
matcher = matchmod.intersectmatchers(
|
|
|
|
includematcher, negatematcher(excludematcher)
|
|
|
|
)
|
|
|
|
|
|
|
|
for path in files:
|
2020-06-26 04:01:16 +03:00
|
|
|
if matcher(path):
|
|
|
|
ui.write(_("%s\n") % path)
|
|
|
|
|
|
|
|
|
2018-05-04 17:28:34 +03:00
|
|
|
def _contains_files(load_matcher, profile, files):
|
|
|
|
matcher = load_matcher(profile)
|
|
|
|
return all(matcher(f) for f in files)
|
|
|
|
|
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-04 17:28:34 +03:00
|
|
|
def _build_profile_filter(filters, load_matcher):
|
2018-05-01 00:04:15 +03:00
|
|
|
"""Create a callable function to filter a profile, returning a boolean"""
|
|
|
|
predicates = {
|
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
|
|
|
# we need *all* fields in a with filter to be present, so with
|
|
|
|
# should be a subset
|
|
|
|
"with": lambda fields: fields.issubset,
|
2018-05-01 00:04:15 +03:00
|
|
|
# set.isdisjoint returns true when the iterable (dictionary keys)
|
|
|
|
# doesn't have any names in common
|
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
|
|
|
"without": lambda fields: fields.isdisjoint,
|
|
|
|
"filter": lambda field_values: lambda md: (
|
2018-05-01 00:04:18 +03:00
|
|
|
# all fields to test and all values for those fields are present
|
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
|
|
|
all(
|
|
|
|
f in md and all(v in md[f].lower() for v in vs)
|
|
|
|
for f, vs in field_values.items()
|
|
|
|
)
|
|
|
|
),
|
|
|
|
"contains_file": lambda files: lambda md: _contains_files(
|
|
|
|
load_matcher, md["path"], files
|
|
|
|
),
|
2018-05-01 00:04:15 +03:00
|
|
|
}
|
|
|
|
tests = [predicates[k](v) for k, v in sorted(filters.items()) if v]
|
2018-05-01 00:04:18 +03:00
|
|
|
# pass in a dictionary with all metadata and the path as an extra key
|
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 lambda p: all(t(dict(p, path=p.path)) for t in tests) # dict-from-generator
|
|
|
|
|
|
|
|
|
|
|
|
@subcmd(
|
|
|
|
"list",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"r",
|
|
|
|
"rev",
|
|
|
|
"",
|
|
|
|
_("explain the profile(s) against the specified revision"),
|
|
|
|
_("REV"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"with-field",
|
|
|
|
[],
|
|
|
|
_("Only show profiles that have defined the named metadata field"),
|
|
|
|
_("FIELD"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"without-field",
|
|
|
|
[],
|
|
|
|
_("Only show profiles that do have not defined the named metadata field"),
|
|
|
|
_("FIELD"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"filter",
|
|
|
|
[],
|
|
|
|
_(
|
|
|
|
"Only show profiles that contain the given value as a substring in a "
|
|
|
|
"specific metadata field."
|
|
|
|
),
|
|
|
|
_("FIELD:VALUE"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"contains-file",
|
|
|
|
[],
|
|
|
|
_("Only show profiles that would include the named file if enabled."),
|
|
|
|
_("FILE"),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
+ commands.templateopts,
|
|
|
|
"[OPTION]...",
|
|
|
|
)
|
2018-05-03 14:33:09 +03:00
|
|
|
def _listprofiles(ui, repo, *pats, **opts):
|
|
|
|
"""list available sparse profiles
|
2018-03-26 18:44:42 +03:00
|
|
|
|
|
|
|
Show all available sparse profiles, with the active profiles marked.
|
2018-05-01 00:04:15 +03:00
|
|
|
|
2018-05-01 00:04:18 +03:00
|
|
|
You can filter profiles with `--with-field [FIELD]`, `--without-field
|
2018-05-04 17:28:34 +03:00
|
|
|
[FIELD]`, `--filter [FIELD:VALUE]` and `--contains-file [FILENAME]`; you can
|
|
|
|
specify these options more than once to set multiple criteria, which all
|
|
|
|
must match for a profile to be listed. The field `path` is always available,
|
|
|
|
and is the path of the profile file in the repository.
|
2018-05-01 00:04:18 +03:00
|
|
|
|
|
|
|
`--filter` takes a fieldname and value to look for, separated by a colon.
|
|
|
|
The field must be present in the metadata, and the value present in the
|
|
|
|
value for that field, to match; testing is done case-insensitively.
|
|
|
|
Multiple filters for the same fieldname are accepted and must all match;
|
|
|
|
e.g. --filter path:foo --filter path:bar only matches profile paths with the
|
|
|
|
substrings foo and bar both present.
|
2018-05-01 00:04:15 +03:00
|
|
|
|
2018-05-04 17:28:34 +03:00
|
|
|
`--contains-file` takes a file path relative to the current directory. No
|
|
|
|
check is made if the file actually exists; any profile that would include
|
|
|
|
the file if it did exist will match.
|
|
|
|
|
2018-05-01 00:04:15 +03:00
|
|
|
By default, `--without-field hidden` is implied unless you use the --verbose
|
|
|
|
switch to include hidden profiles.
|
2018-03-26 18:44:42 +03:00
|
|
|
|
2020-09-28 20:02:05 +03:00
|
|
|
If `--rev` is given, show profiles available at that revision. The working copy
|
|
|
|
sparse configuration is ignored and no active profile information is
|
|
|
|
made available (all profiles are marked as 'inactive').
|
|
|
|
|
2018-03-26 18:44:42 +03:00
|
|
|
"""
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(repo)
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
# Disable fullcheckout warnings to allow users to sparse their fullcheckouts
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", 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
|
|
|
rev = scmutil.revsingle(repo, opts.get("rev")).hex()
|
2018-05-04 17:28:34 +03:00
|
|
|
tocanon = functools.partial(pathutil.canonpath, repo.root, repo.getcwd())
|
2018-05-01 00:04:15 +03:00
|
|
|
filters = {
|
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
|
|
|
"with": set(opts.get("with_field", ())),
|
|
|
|
"without": set(opts.get("without_field", ())),
|
|
|
|
"filter": {}, # dictionary of fieldnames to sets of values
|
|
|
|
"contains_file": {tocanon(f) for f in opts.get("contains_file", ())},
|
2018-05-01 00:04:15 +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
|
|
|
for fieldvalue in opts.get("filter", ()):
|
|
|
|
fieldname, __, value = fieldvalue.partition(":")
|
2018-05-01 00:04:18 +03:00
|
|
|
if not value:
|
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(_("Missing value for filter on %s") % fieldname)
|
|
|
|
filters["filter"].setdefault(fieldname, set()).add(value.lower())
|
2018-05-01 00:04:15 +03:00
|
|
|
|
|
|
|
# It's an error to put a field both in the 'with' and 'without' buckets
|
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 filters["with"] & filters["without"]:
|
2018-05-01 00:04:15 +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
|
|
|
_(
|
|
|
|
"You can't specify fields in both --with-field and "
|
|
|
|
"--without-field, please use only one or the other, for "
|
|
|
|
"%s"
|
|
|
|
)
|
|
|
|
% ",".join(filters["with"] & filters["without"])
|
|
|
|
)
|
2018-05-01 00:04:15 +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 not (ui.verbose or "hidden" in filters["with"]):
|
2018-05-01 00:04:15 +03:00
|
|
|
# without the -v switch, hide profiles that have 'hidden' set. Unless,
|
|
|
|
# of course, we specifically are filtering on hidden profiles!
|
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
|
|
|
filters["without"].add("hidden")
|
2018-05-01 00:04:15 +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
|
|
|
chars = {PROFILE_INACTIVE: "", PROFILE_INCLUDED: "~", PROFILE_ACTIVE: "*"}
|
2018-03-23 00:34:29 +03:00
|
|
|
labels = {
|
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
|
|
|
PROFILE_INACTIVE: "inactive",
|
|
|
|
PROFILE_INCLUDED: "included",
|
|
|
|
PROFILE_ACTIVE: "active",
|
2018-03-23 00:34:29 +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
|
|
|
ui.pager("sparse list")
|
|
|
|
with ui.formatter("sparse", opts) as fm:
|
2018-10-19 16:49:04 +03:00
|
|
|
fm.plain("Available Profiles:\n\n")
|
2018-05-04 17:28:34 +03:00
|
|
|
load_matcher = lambda p: repo.sparsematch(
|
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
|
|
|
rev=rev,
|
|
|
|
config=repo.readsparseconfig(
|
|
|
|
repo.getrawprofile(p, rev), filename=p, warn=False
|
|
|
|
),
|
|
|
|
)
|
2018-05-04 17:28:34 +03:00
|
|
|
|
|
|
|
predicate = _build_profile_filter(filters, load_matcher)
|
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
|
|
|
profiles = list(_discover(ui, repo, rev=opts.get("rev")))
|
2018-05-01 00:04:16 +03:00
|
|
|
filtered = list(filter(predicate, profiles))
|
|
|
|
max_width = 0
|
|
|
|
if not filtered:
|
2018-05-01 00:04:15 +03:00
|
|
|
if fm.isplain():
|
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.write_err(_("No profiles matched the filter criteria\n"))
|
2018-05-01 00:04:16 +03:00
|
|
|
else:
|
|
|
|
max_width = max(len(p.path) for p in filtered)
|
2018-03-23 00:34:29 +03:00
|
|
|
|
2018-05-01 00:04:16 +03:00
|
|
|
for info in filtered:
|
2018-03-23 00:34:29 +03:00
|
|
|
fm.startitem()
|
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
|
|
|
label = "sparse.profile." + labels[info.active]
|
2018-10-19 16:49:04 +03:00
|
|
|
fm.plain(" %-1s " % chars[info.active], label=label)
|
2018-03-23 00:34:29 +03:00
|
|
|
fm.data(active=labels[info.active], metadata=dict(info))
|
2020-02-18 01:47:28 +03:00
|
|
|
fm.write("path", "%-{}s".format(max_width), info.path, label=label)
|
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 "title" in info:
|
2020-02-18 01:47:28 +03:00
|
|
|
fm.plain(" %s" % info.get("title", ""), label=label + ".title")
|
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
|
|
|
fm.plain("\n")
|
|
|
|
|
|
|
|
if not (ui.verbose or "hidden" in filters["with"]):
|
|
|
|
hintutil.trigger("sparse-list-verbose", profiles, filters, load_matcher)
|
|
|
|
|
|
|
|
|
|
|
|
@subcmd(
|
|
|
|
"explain",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"r",
|
|
|
|
"rev",
|
|
|
|
"",
|
|
|
|
_("explain the profile(s) against the specified revision"),
|
|
|
|
_("REV"),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
+ commands.templateopts,
|
|
|
|
_("[OPTION]... [PROFILE]..."),
|
|
|
|
)
|
2018-05-03 14:33:09 +03:00
|
|
|
def _explainprofile(ui, repo, *profiles, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""show information about a sparse profile
|
2018-03-29 12:34:01 +03:00
|
|
|
|
|
|
|
If --verbose is given, calculates the file size impact of a profile (slow).
|
|
|
|
"""
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(repo)
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
# Disable fullcheckout warnings to allow users to sparse their fullcheckouts
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", 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
|
|
|
if ui.plain() and not opts.get("template"):
|
|
|
|
hint = _("invoke with -T/--template to control output format")
|
|
|
|
raise error.Abort(_("must specify a template in plain mode"), hint=hint)
|
2018-03-26 18:44:48 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
if not profiles:
|
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(_("no profiles specified"))
|
2018-03-29 12:34:01 +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
|
|
|
rev = scmutil.revrange(repo, [opts.get("rev") or "."]).last()
|
2018-04-10 13:37:19 +03:00
|
|
|
if rev is 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
|
|
|
raise error.Abort(_("empty revision set"))
|
2018-04-10 13:37:19 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
configs = []
|
|
|
|
for i, p in enumerate(profiles):
|
|
|
|
try:
|
2018-04-10 13:37:19 +03:00
|
|
|
raw = repo.getrawprofile(p, rev)
|
2018-03-29 12:34:01 +03:00
|
|
|
except KeyError:
|
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(_("The profile %s was not found\n") % p)
|
2018-03-29 12:34:01 +03:00
|
|
|
exitcode = 255
|
|
|
|
continue
|
|
|
|
profile = repo.readsparseconfig(raw, p)
|
|
|
|
configs.append(profile)
|
|
|
|
|
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
|
|
|
stats = _profilesizeinfo(ui, repo, *configs, rev=rev, collectsize=ui.verbose)
|
2018-03-29 12:34:01 +03:00
|
|
|
filecount, totalsize = stats[None]
|
|
|
|
|
2018-03-26 18:44:48 +03:00
|
|
|
exitcode = 0
|
2018-03-29 12:34:01 +03:00
|
|
|
|
|
|
|
def sortedsets(d):
|
2018-04-10 13:37:14 +03:00
|
|
|
return {
|
2020-07-23 04:57:00 +03:00
|
|
|
k: sorted(v) if isinstance(v, pycompat.Set) else v for k, v in d.items()
|
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-03-29 12:34:01 +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
|
|
|
ui.pager("sparse explain")
|
|
|
|
with ui.formatter("sparse", opts) as fm:
|
2018-03-29 12:34:01 +03:00
|
|
|
for i, profile in enumerate(configs):
|
2018-03-26 18:44:48 +03:00
|
|
|
if i:
|
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
|
|
|
fm.plain("\n")
|
2018-03-26 18:44:48 +03:00
|
|
|
fm.startitem()
|
|
|
|
|
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
|
|
|
fm.write("path", "%s\n\n", profile.path)
|
2018-03-26 18:44:48 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
pfilecount, ptotalsize = stats.get(profile, (-1, -1))
|
|
|
|
pfileperc = 0.0
|
|
|
|
if pfilecount > -1 and filecount > 0:
|
|
|
|
pfileperc = (pfilecount / filecount) * 100
|
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
|
|
|
profilestats = {"filecount": pfilecount, "filecountpercentage": pfileperc}
|
2018-03-29 12:34:01 +03:00
|
|
|
if ptotalsize:
|
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
|
|
|
profilestats["totalsize"] = ptotalsize
|
2018-03-29 12:34:01 +03:00
|
|
|
fm.data(
|
|
|
|
stats=profilestats,
|
|
|
|
**sortedsets(attr.asdict(profile, retain_collection_types=True))
|
|
|
|
)
|
2018-03-26 18:44:48 +03:00
|
|
|
|
|
|
|
if fm.isplain():
|
|
|
|
md = profile.metadata
|
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
|
|
|
title = md.get("title", _("(untitled)"))
|
|
|
|
lines = [minirst.section(title)]
|
|
|
|
description = md.get("description")
|
2018-03-26 18:44:48 +03:00
|
|
|
if description:
|
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
|
|
|
lines.append("%s\n\n" % description)
|
2018-03-26 18:44:48 +03:00
|
|
|
|
2018-03-29 12:34:01 +03:00
|
|
|
if pfileperc or ptotalsize:
|
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
|
|
|
lines.append(
|
|
|
|
minirst.subsection(_("Size impact compared to a full checkout"))
|
|
|
|
)
|
2018-03-29 12:34:01 +03:00
|
|
|
|
|
|
|
if pfileperc:
|
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
|
|
|
lines.append(
|
|
|
|
":file count: {:d} ({:.2f}%)\n".format(
|
|
|
|
pfilecount, pfileperc
|
|
|
|
)
|
|
|
|
)
|
2018-03-29 12:34:01 +03:00
|
|
|
if ptotalsize:
|
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
|
|
|
lines.append(
|
|
|
|
":total size: {:s}\n".format(util.bytecount(ptotalsize))
|
|
|
|
)
|
|
|
|
lines.append("\n")
|
2018-03-29 12:34:01 +03:00
|
|
|
|
2020-02-18 01:47:28 +03:00
|
|
|
other = set(md.keys()) - {"title", "description"}
|
2018-03-26 18:44:48 +03:00
|
|
|
if other:
|
|
|
|
lines += (
|
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
|
|
|
minirst.subsection(_("Additional metadata")),
|
|
|
|
"".join(
|
|
|
|
[
|
|
|
|
":%s: %s\n" % (key, "\n ".join(md[key].splitlines()))
|
|
|
|
for key in sorted(other)
|
|
|
|
]
|
|
|
|
),
|
|
|
|
"\n",
|
|
|
|
)
|
2018-03-26 18:44:48 +03:00
|
|
|
|
|
|
|
sections = (
|
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
|
|
|
("profiles", _("Profiles included")),
|
|
|
|
("includes", _("Inclusion rules")),
|
|
|
|
("excludes", _("Exclusion rules")),
|
2018-03-26 18:44:48 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
for attrib, label in sections:
|
|
|
|
section = getattr(profile, attrib)
|
|
|
|
if not section:
|
|
|
|
continue
|
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
|
|
|
lines += (minirst.subsection(label), "::\n\n")
|
|
|
|
lines += (" %s\n" % entry for entry in sorted(section))
|
|
|
|
lines += ("\n",)
|
2018-03-26 18:44:48 +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
|
|
|
textwidth = ui.configint("ui", "textwidth")
|
2018-03-26 18:44:48 +03:00
|
|
|
termwidth = ui.termwidth() - 2
|
|
|
|
if not (0 < textwidth <= termwidth):
|
|
|
|
textwidth = termwidth
|
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
|
|
|
fm.plain(minirst.format("".join(lines), textwidth))
|
2018-03-26 18:44:48 +03:00
|
|
|
|
2018-04-18 20:31:30 +03:00
|
|
|
if not ui.verbose:
|
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
|
|
|
hintutil.trigger("sparse-explain-verbose", *profiles)
|
2018-04-18 20:31:30 +03:00
|
|
|
|
2018-03-26 18:44:48 +03:00
|
|
|
return exitcode
|
|
|
|
|
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-10-19 16:49:03 +03:00
|
|
|
@subcmd("files", commands.templateopts, _("[OPTION]... PROFILE [FILES]..."))
|
|
|
|
def _listfilessubcmd(ui, repo, profile, *files, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""list all files included in a sparse profile
|
2018-03-29 12:34:02 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
If files are given to match, print the names of the files in the profile
|
|
|
|
that match those patterns.
|
2018-03-29 12:34:02 +03:00
|
|
|
|
|
|
|
"""
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(repo)
|
2020-02-20 21:57:07 +03:00
|
|
|
|
|
|
|
# Disable fullcheckout warnings to allow users to sparse their fullcheckouts
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", None)
|
|
|
|
|
2018-03-29 12:34:02 +03: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
|
|
|
raw = repo.getrawprofile(profile, ".")
|
2018-03-29 12:34:02 +03:00
|
|
|
except KeyError:
|
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(_("The profile %s was not found\n") % profile)
|
2018-03-29 12:34:02 +03:00
|
|
|
|
|
|
|
config = repo.readsparseconfig(raw, profile)
|
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
|
|
|
ctx = repo["."]
|
2018-03-29 12:34:02 +03:00
|
|
|
matcher = matchmod.intersectmatchers(
|
|
|
|
matchmod.match(repo.root, repo.getcwd(), files),
|
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
|
|
|
repo.sparsematch(ctx.hex(), includetemp=False, config=config),
|
|
|
|
)
|
2018-03-29 12:34:02 +03:00
|
|
|
|
|
|
|
exitcode = 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
|
|
|
ui.pager("sparse listfiles")
|
|
|
|
with ui.formatter("files", opts) as fm:
|
2018-03-29 12:34:02 +03:00
|
|
|
for f in ctx.matches(matcher):
|
|
|
|
fm.startitem()
|
|
|
|
fm.data(abspath=f)
|
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
|
|
|
fm.write("path", "%s\n", matcher.rel(f))
|
2018-03-29 12:34:02 +03:00
|
|
|
exitcode = 0
|
|
|
|
return exitcode
|
|
|
|
|
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-03 14:33:09 +03:00
|
|
|
_common_config_opts = [
|
2020-08-31 21:36:48 +03:00
|
|
|
("f", "force", False, _("allow changing rules even with pending changes")),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"allow-unsafe-profile-changes",
|
|
|
|
False,
|
|
|
|
_("allow sparse profile change even if this change might be unsafe"),
|
|
|
|
),
|
2018-05-03 14:33:09 +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
|
|
|
|
|
|
|
|
2020-08-31 21:36:48 +03:00
|
|
|
def getcommonopts(opts):
|
|
|
|
allowunsafeprofilechanges = opts.get("allow_unsafe_profile_changes")
|
|
|
|
force = opts.get("force")
|
|
|
|
return {"allowunsafeprofilechanges": allowunsafeprofilechanges, "force": force}
|
|
|
|
|
|
|
|
|
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
|
|
|
@subcmd("reset", _common_config_opts + commands.templateopts)
|
2018-05-03 14:33:09 +03:00
|
|
|
def resetsubcmd(ui, repo, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""disable all sparse profiles and convert to a full checkout"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, [], opts, reset=True, **commonopts)
|
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-03 14:33:09 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
@subcmd("disable|disableprofile", _common_config_opts, "[PROFILE]...")
|
2018-05-03 14:33:09 +03:00
|
|
|
def disableprofilesubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""disable a sparse profile"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, disableprofile=True, **commonopts)
|
2018-05-03 14:33:09 +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-10-19 16:49:04 +03:00
|
|
|
@subcmd("enable|enableprofile", _common_config_opts, "[PROFILE]...")
|
2018-05-03 14:33:09 +03:00
|
|
|
def enableprofilesubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""enable a sparse profile"""
|
2019-09-26 12:02:36 +03:00
|
|
|
_checknonexistingprofiles(ui, repo, pats)
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, enableprofile=True, **commonopts)
|
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-03 14:33:09 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
@subcmd("switch|switchprofile", _common_config_opts, "[PROFILE]...")
|
2018-10-02 13:29:00 +03:00
|
|
|
def switchprofilesubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""switch to another sparse profile
|
2018-10-02 13:29:00 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
Disables all other profiles and stops including and excluding any additional
|
|
|
|
files you have previously included or excluded.
|
2018-10-02 13:29:00 +03:00
|
|
|
"""
|
2019-10-07 23:00:19 +03:00
|
|
|
_checknonexistingprofiles(ui, repo, pats)
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, reset=True, enableprofile=True, **commonopts)
|
2018-10-02 13:29:00 +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
|
|
|
@subcmd("delete", _common_config_opts, "[RULE]...")
|
2018-05-03 14:33:09 +03:00
|
|
|
def deletesubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:05 +03:00
|
|
|
"""delete an include or exclude rule (DEPRECATED)"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, delete=True, **commonopts)
|
2018-05-03 14:33:09 +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
|
|
|
|
|
|
|
@subcmd("exclude", _common_config_opts, "[RULE]...")
|
2018-05-03 14:33:09 +03:00
|
|
|
def excludesubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""exclude some additional files"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, exclude=True, **commonopts)
|
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-03 14:33:09 +03:00
|
|
|
|
2018-10-19 16:49:05 +03:00
|
|
|
@subcmd("unexclude", _common_config_opts, "[RULE]...")
|
|
|
|
def unexcludesubcmd(ui, repo, *pats, **opts):
|
|
|
|
"""stop excluding some additional files"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, unexclude=True, **commonopts)
|
2018-10-19 16:49:05 +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
|
|
|
@subcmd("include", _common_config_opts, "[RULE]...")
|
2018-05-03 14:33:09 +03:00
|
|
|
def includesubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""include some additional files"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, include=True, **commonopts)
|
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-03 14:33:09 +03:00
|
|
|
|
2018-10-19 16:49:05 +03:00
|
|
|
@subcmd("uninclude", _common_config_opts, "[RULE]...")
|
|
|
|
def unincludesubcmd(ui, repo, *pats, **opts):
|
|
|
|
"""stop including some additional files"""
|
2020-08-31 21:36:48 +03:00
|
|
|
commonopts = getcommonopts(opts)
|
|
|
|
_config(ui, repo, pats, opts, uninclude=True, **commonopts)
|
2018-10-19 16:49:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
for c in deletesubcmd, excludesubcmd, includesubcmd, unexcludesubcmd, unincludesubcmd:
|
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
|
|
|
c.__doc__ += """\n
|
2018-03-29 12:34:04 +03:00
|
|
|
The effects of adding or deleting an include or exclude rule are applied
|
|
|
|
immediately. If applying the new rule would cause a file with pending
|
|
|
|
changes to be added or removed, the command will fail. Pass --force to
|
|
|
|
force a rule change even with pending changes (the changes on disk will
|
|
|
|
be preserved).
|
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-03-29 12:34:04 +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
|
|
|
|
|
|
|
@subcmd("importrules", _common_config_opts, _("[OPTION]... [FILE]..."))
|
2018-05-03 14:33:09 +03:00
|
|
|
def _importsubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""import sparse profile rules
|
2018-03-26 18:44:44 +03:00
|
|
|
|
|
|
|
Accepts a path to a file containing rules in the .hgsparse format.
|
|
|
|
|
|
|
|
This allows you to add *include*, *exclude* and *enable* rules
|
|
|
|
in bulk. Like the include, exclude and enable subcommands, the
|
|
|
|
changes are applied immediately.
|
|
|
|
|
|
|
|
"""
|
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
|
|
|
_import(ui, repo, pats, opts, force=opts.get("force"))
|
|
|
|
|
2018-03-26 18:44:44 +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
|
|
|
@subcmd("clear", _common_config_opts, _("[OPTION]..."))
|
2018-05-03 14:33:09 +03:00
|
|
|
def _clearsubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""clear all extra files included or excluded
|
2018-03-26 18:44:44 +03:00
|
|
|
|
2018-10-19 16:49:04 +03:00
|
|
|
Removes all extra include and exclude rules, without changing which
|
|
|
|
profiles are enabled.
|
2018-03-26 18:44:44 +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
|
|
|
_clear(ui, repo, pats, force=opts.get("force"))
|
2018-03-26 18:44:44 +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
|
|
|
|
|
|
|
@subcmd("refresh", _common_config_opts, _("[OPTION]..."))
|
2018-05-03 14:33:09 +03:00
|
|
|
def _refreshsubcmd(ui, repo, *pats, **opts):
|
2018-10-19 16:49:04 +03:00
|
|
|
"""refresh the files on disk based on the enabled sparse profiles
|
2018-03-26 18:44:44 +03:00
|
|
|
|
|
|
|
This is only necessary if .hg/sparse was changed by hand.
|
|
|
|
"""
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(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
|
|
|
force = opts.get("force")
|
2018-03-26 18:44:44 +03:00
|
|
|
with repo.wlock():
|
2019-11-13 02:33:03 +03:00
|
|
|
# Since we don't know the "original" sparse matcher, use the
|
|
|
|
# always matcher so it checks everything.
|
|
|
|
origmatcher = matchmod.always(repo.root, "")
|
|
|
|
c = _refresh(ui, repo, repo.status(), origmatcher, force)
|
2020-01-29 05:22:50 +03:00
|
|
|
fcounts = list(map(len, c))
|
2018-03-26 18:44:44 +03:00
|
|
|
_verbose_output(ui, opts, 0, 0, 0, *fcounts)
|
|
|
|
|
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
|
|
|
|
|
|
|
@subcmd("cwd")
|
2018-05-03 14:33:09 +03:00
|
|
|
def _cwdsubcmd(ui, repo, *pats, **opts):
|
|
|
|
"""list all names in this directory
|
2018-03-26 18:44:44 +03:00
|
|
|
|
|
|
|
The list includes any names that are excluded by the current sparse
|
|
|
|
checkout; these are annotated with a hyphen ('-') before the name.
|
|
|
|
|
|
|
|
"""
|
|
|
|
_cwdlist(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
|
|
|
|
|
|
|
def _config(
|
|
|
|
ui,
|
|
|
|
repo,
|
|
|
|
pats,
|
|
|
|
opts,
|
|
|
|
include=False,
|
|
|
|
exclude=False,
|
|
|
|
reset=False,
|
|
|
|
delete=False,
|
2018-10-19 16:49:05 +03:00
|
|
|
uninclude=False,
|
|
|
|
unexclude=False,
|
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
|
|
|
enableprofile=False,
|
|
|
|
disableprofile=False,
|
|
|
|
force=False,
|
2020-08-31 21:36:48 +03:00
|
|
|
allowunsafeprofilechanges=False,
|
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-06-09 00:30:12 +03:00
|
|
|
_checksparse(repo)
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
if not reset:
|
|
|
|
# Disable fullcheckout warnings to allow users to sparse their fullcheckouts
|
|
|
|
repo.ui.setconfig("sparse", "warnfullcheckout", None)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
"""
|
|
|
|
Perform a sparse config update. Only one of the kwargs may be specified.
|
|
|
|
"""
|
|
|
|
wlock = repo.wlock()
|
|
|
|
try:
|
|
|
|
oldsparsematch = repo.sparsematch()
|
|
|
|
|
2018-09-28 17:08:56 +03:00
|
|
|
if repo.localvfs.exists("sparse"):
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = repo.localvfs.readutf8("sparse")
|
2020-01-29 05:22:50 +03:00
|
|
|
oldinclude, oldexclude, oldprofiles = list(
|
|
|
|
map(set, repo.readsparseconfig(raw))
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
else:
|
|
|
|
oldinclude = set()
|
|
|
|
oldexclude = set()
|
|
|
|
oldprofiles = set()
|
|
|
|
|
|
|
|
try:
|
|
|
|
if reset:
|
|
|
|
newinclude = set()
|
|
|
|
newexclude = set()
|
|
|
|
newprofiles = set()
|
|
|
|
else:
|
|
|
|
newinclude = set(oldinclude)
|
|
|
|
newexclude = set(oldexclude)
|
|
|
|
newprofiles = set(oldprofiles)
|
|
|
|
|
|
|
|
if any(os.path.isabs(pat) for pat in pats):
|
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
|
|
|
err = _("paths cannot be absolute")
|
2017-10-14 00:51:27 +03:00
|
|
|
raise error.Abort(err)
|
|
|
|
|
2018-10-19 16:49:05 +03:00
|
|
|
adjustpats = False
|
|
|
|
if include or exclude or delete or uninclude or unexclude:
|
|
|
|
if not ui.configbool("sparse", "includereporootpaths", False):
|
|
|
|
adjustpats = True
|
|
|
|
if enableprofile or disableprofile:
|
|
|
|
if not ui.configbool("sparse", "enablereporootpaths", True):
|
|
|
|
adjustpats = True
|
2017-10-14 00:51:27 +03:00
|
|
|
if adjustpats:
|
|
|
|
# supplied file patterns should be treated as relative
|
|
|
|
# to current working dir, so we need to convert them first
|
|
|
|
root, cwd = repo.root, repo.getcwd()
|
|
|
|
abspats = []
|
|
|
|
for kindpat in pats:
|
|
|
|
kind, pat = matchmod._patsplit(kindpat, None)
|
|
|
|
if kind in cwdrealtivepatkinds or kind is 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
|
|
|
kindpat = (kind + ":" if kind else "") + pathutil.canonpath(
|
|
|
|
root, cwd, pat
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
abspats.append(kindpat)
|
|
|
|
pats = abspats
|
|
|
|
|
|
|
|
oldstatus = repo.status()
|
|
|
|
if include:
|
2018-10-19 16:49:05 +03:00
|
|
|
newexclude.difference_update(pats)
|
2017-10-14 00:51:27 +03:00
|
|
|
newinclude.update(pats)
|
|
|
|
elif exclude:
|
2018-10-19 16:49:05 +03:00
|
|
|
newinclude.difference_update(pats)
|
2017-10-14 00:51:27 +03:00
|
|
|
newexclude.update(pats)
|
|
|
|
elif enableprofile:
|
|
|
|
newprofiles.update(pats)
|
|
|
|
elif disableprofile:
|
|
|
|
newprofiles.difference_update(pats)
|
2018-10-19 16:49:05 +03:00
|
|
|
elif uninclude:
|
|
|
|
newinclude.difference_update(pats)
|
|
|
|
elif unexclude:
|
|
|
|
newexclude.difference_update(pats)
|
2017-10-14 00:51:27 +03:00
|
|
|
elif delete:
|
|
|
|
newinclude.difference_update(pats)
|
|
|
|
newexclude.difference_update(pats)
|
|
|
|
|
2020-08-31 21:36:48 +03:00
|
|
|
unsafemarkerfile = _find_unsafe_marker_files(repo, ui)
|
2017-10-14 00:51:27 +03:00
|
|
|
repo.writesparseconfig(newinclude, newexclude, newprofiles)
|
2020-08-31 21:36:48 +03:00
|
|
|
# Check that new sparse profile is safe, however do it only
|
|
|
|
# if previous sparse profile was safe as well
|
|
|
|
if unsafemarkerfile is None and not allowunsafeprofilechanges:
|
|
|
|
_validate_new_sparse_config(repo, ui)
|
|
|
|
|
2020-01-29 05:22:50 +03:00
|
|
|
fcounts = list(
|
|
|
|
map(len, _refresh(ui, repo, oldstatus, oldsparsematch, force))
|
|
|
|
)
|
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
|
|
|
|
|
|
|
profilecount = len(newprofiles - oldprofiles) - len(
|
|
|
|
oldprofiles - newprofiles
|
|
|
|
)
|
|
|
|
includecount = len(newinclude - oldinclude) - len(oldinclude - newinclude)
|
|
|
|
excludecount = len(newexclude - oldexclude) - len(oldexclude - newexclude)
|
2017-10-14 00:51:27 +03:00
|
|
|
_verbose_output(
|
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, opts, profilecount, includecount, excludecount, *fcounts
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
except Exception:
|
|
|
|
repo.writesparseconfig(oldinclude, oldexclude, oldprofiles)
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
wlock.release()
|
|
|
|
|
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-08-31 21:36:48 +03:00
|
|
|
def _find_unsafe_marker_files(repo, ui):
|
|
|
|
if not _hassparse(repo):
|
|
|
|
return None
|
|
|
|
unsafesparseprofilemarkerfiles = ui.configlist(
|
|
|
|
"sparse", "unsafe_sparse_profile_marker_files"
|
|
|
|
)
|
2020-09-01 09:20:19 +03:00
|
|
|
if not unsafesparseprofilemarkerfiles:
|
|
|
|
return None
|
2020-08-31 21:36:48 +03:00
|
|
|
sparsematch = repo.sparsematch()
|
|
|
|
for f in unsafesparseprofilemarkerfiles:
|
|
|
|
if sparsematch(f):
|
|
|
|
return f
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def _validate_new_sparse_config(repo, ui):
|
|
|
|
unsafemarkerfile = _find_unsafe_marker_files(repo, ui)
|
|
|
|
if unsafemarkerfile is not None:
|
|
|
|
msg = (
|
|
|
|
"'{}' file is included in sparse profile, "
|
|
|
|
+ "it might not be safe because it may introduce a large "
|
|
|
|
+ "amount of data into your repository"
|
|
|
|
).format(unsafemarkerfile)
|
|
|
|
additionalmsg = ui.config("sparse", "unsafe_sparse_profile_message")
|
|
|
|
if additionalmsg:
|
|
|
|
msg = "{}\n{}".format(msg, additionalmsg)
|
|
|
|
raise error.Abort(
|
|
|
|
msg,
|
|
|
|
hint=(
|
|
|
|
"If you are know what you are doing re-run with allow-unsafe-profile-changes, "
|
|
|
|
+ "otherwise contact Source control @ fb"
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-09-26 12:02:36 +03:00
|
|
|
def _checknonexistingprofiles(ui, repo, profiles):
|
|
|
|
for p in profiles:
|
|
|
|
try:
|
|
|
|
repo.filectx(p, changeid=".").data()
|
|
|
|
except error.ManifestLookupError:
|
|
|
|
ui.warn(
|
|
|
|
_(
|
|
|
|
"the profile '%s' does not exist in the "
|
|
|
|
"current commit, it will only take effect "
|
|
|
|
"when you check out a commit containing a "
|
|
|
|
"profile with that name\n"
|
2020-04-06 23:54:32 +03:00
|
|
|
"(if the path is a typo, use 'hg sparse disableprofile' to remove it)\n"
|
2019-09-26 12:02:36 +03:00
|
|
|
)
|
|
|
|
% p
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def _import(ui, repo, files, opts, force=False):
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(repo)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
with repo.wlock():
|
|
|
|
# load union of current active profile
|
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
|
|
|
revs = [
|
|
|
|
repo.changelog.rev(node)
|
|
|
|
for node in repo.dirstate.parents()
|
|
|
|
if node != nullid
|
|
|
|
]
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# read current configuration
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = ""
|
2018-09-28 17:08:56 +03:00
|
|
|
if repo.localvfs.exists("sparse"):
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = repo.localvfs.readutf8("sparse")
|
2017-10-14 00:51:27 +03:00
|
|
|
oincludes, oexcludes, oprofiles = repo.readsparseconfig(raw)
|
2020-01-29 05:22:50 +03:00
|
|
|
includes, excludes, profiles = list(map(set, (oincludes, oexcludes, oprofiles)))
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# all active rules
|
|
|
|
aincludes, aexcludes, aprofiles = set(), set(), set()
|
|
|
|
for rev in revs:
|
|
|
|
rincludes, rexcludes, rprofiles = repo.getsparsepatterns(rev)
|
|
|
|
aincludes.update(rincludes)
|
|
|
|
aexcludes.update(rexcludes)
|
|
|
|
aprofiles.update(rprofiles)
|
|
|
|
|
|
|
|
# import rules on top; only take in rules that are not yet
|
|
|
|
# part of the active rules.
|
|
|
|
changed = False
|
|
|
|
for file in files:
|
2020-02-18 01:47:28 +03:00
|
|
|
with util.posixfile(util.expandpath(file), "rb") as importfile:
|
2017-10-14 00:51:27 +03:00
|
|
|
iincludes, iexcludes, iprofiles = repo.readsparseconfig(
|
2020-07-23 04:57:00 +03:00
|
|
|
pycompat.decodeutf8(importfile.read()), filename=file
|
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-14 00:51:27 +03:00
|
|
|
oldsize = len(includes) + len(excludes) + len(profiles)
|
|
|
|
includes.update(iincludes - aincludes)
|
|
|
|
excludes.update(iexcludes - aexcludes)
|
|
|
|
profiles.update(set(iprofiles) - aprofiles)
|
|
|
|
if len(includes) + len(excludes) + len(profiles) > oldsize:
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
profilecount = includecount = excludecount = 0
|
|
|
|
fcounts = (0, 0, 0)
|
|
|
|
|
|
|
|
if changed:
|
|
|
|
profilecount = len(profiles - aprofiles)
|
|
|
|
includecount = len(includes - aincludes)
|
|
|
|
excludecount = len(excludes - aexcludes)
|
|
|
|
|
|
|
|
oldstatus = repo.status()
|
|
|
|
oldsparsematch = repo.sparsematch()
|
|
|
|
repo.writesparseconfig(includes, excludes, profiles)
|
|
|
|
|
|
|
|
try:
|
2020-01-29 05:22:50 +03:00
|
|
|
fcounts = list(
|
|
|
|
map(len, _refresh(ui, repo, oldstatus, oldsparsematch, force))
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
except Exception:
|
|
|
|
repo.writesparseconfig(oincludes, oexcludes, oprofiles)
|
|
|
|
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
|
|
|
_verbose_output(ui, opts, profilecount, includecount, excludecount, *fcounts)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _clear(ui, repo, files, force=False):
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(repo)
|
|
|
|
|
2020-02-20 21:57:07 +03:00
|
|
|
repo._warnfullcheckout()
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
with repo.wlock():
|
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
|
|
|
raw = ""
|
2018-09-28 17:08:56 +03:00
|
|
|
if repo.localvfs.exists("sparse"):
|
2020-07-23 04:57:00 +03:00
|
|
|
raw = repo.localvfs.readutf8("sparse")
|
2017-10-14 00:51:27 +03:00
|
|
|
includes, excludes, profiles = repo.readsparseconfig(raw)
|
|
|
|
|
|
|
|
if includes or excludes:
|
|
|
|
oldstatus = repo.status()
|
|
|
|
oldsparsematch = repo.sparsematch()
|
|
|
|
repo.writesparseconfig(set(), set(), profiles)
|
|
|
|
_refresh(ui, repo, oldstatus, oldsparsematch, force)
|
|
|
|
|
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-14 00:51:27 +03:00
|
|
|
def _refresh(ui, repo, origstatus, origsparsematch, force):
|
|
|
|
"""Refreshes which files are on disk by comparing the old status and
|
|
|
|
sparsematch with the new sparsematch.
|
|
|
|
|
|
|
|
Will raise an exception if a file with pending changes is being excluded
|
|
|
|
or included (unless force=True).
|
|
|
|
"""
|
|
|
|
modified, added, removed, deleted, unknown, ignored, clean = origstatus
|
|
|
|
|
|
|
|
# Verify there are no pending changes
|
|
|
|
pending = set()
|
|
|
|
pending.update(modified)
|
|
|
|
pending.update(added)
|
|
|
|
pending.update(removed)
|
|
|
|
sparsematch = repo.sparsematch()
|
|
|
|
abort = False
|
2018-02-06 01:13:19 +03:00
|
|
|
if len(pending) > 0:
|
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.note(_("verifying pending changes for refresh\n"))
|
2017-10-14 00:51:27 +03:00
|
|
|
for file in pending:
|
|
|
|
if not sparsematch(file):
|
|
|
|
ui.warn(_("pending changes to '%s'\n") % file)
|
|
|
|
abort = not force
|
|
|
|
if abort:
|
2019-03-13 21:36:22 +03:00
|
|
|
raise error.Abort(_("could not update sparseness due to pending changes"))
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# Calculate actions
|
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.note(_("calculating actions for refresh\n"))
|
|
|
|
with progress.spinner(ui, "populating file set"):
|
2018-03-15 14:34:09 +03:00
|
|
|
dirstate = repo.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
|
|
|
ctx = repo["."]
|
2018-03-15 14:34:09 +03:00
|
|
|
added = []
|
|
|
|
lookup = []
|
|
|
|
dropped = []
|
|
|
|
mf = ctx.manifest()
|
2019-11-13 02:33:03 +03:00
|
|
|
# Only care about files covered by the old or the new matcher.
|
|
|
|
unionedmatcher = matchmod.unionmatcher([origsparsematch, sparsematch])
|
|
|
|
files = set(mf.walk(unionedmatcher))
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
actions = {}
|
|
|
|
|
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
|
|
|
with progress.bar(ui, _("calculating"), total=len(files)) as prog:
|
2018-03-21 23:45:28 +03:00
|
|
|
for file in files:
|
|
|
|
prog.value += 1
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-03-21 23:45:28 +03:00
|
|
|
old = origsparsematch(file)
|
|
|
|
new = sparsematch(file)
|
|
|
|
# Add files that are newly included, or that don't exist in
|
|
|
|
# the dirstate yet.
|
|
|
|
if (new and not old) or (old and new and not file in dirstate):
|
|
|
|
fl = mf.flags(file)
|
|
|
|
if repo.wvfs.exists(file):
|
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
|
|
|
actions[file] = ("e", (fl,), "")
|
2018-03-21 23:45:28 +03:00
|
|
|
lookup.append(file)
|
|
|
|
else:
|
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
|
|
|
actions[file] = ("g", (fl, False), "")
|
2018-03-21 23:45:28 +03:00
|
|
|
added.append(file)
|
|
|
|
# Drop files that are newly excluded, or that still exist in
|
|
|
|
# the 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
|
|
|
elif (old and not new) or (not (old or new) and file in dirstate):
|
2018-03-21 23:45:28 +03:00
|
|
|
dropped.append(file)
|
|
|
|
if file not in pending:
|
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
|
|
|
actions[file] = ("r", [], "")
|
2018-03-15 14:34:11 +03:00
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
# Verify there are no pending changes in newly included files
|
2018-02-06 01:13:19 +03:00
|
|
|
if len(lookup) > 0:
|
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.note(_("verifying no pending changes in newly included files\n"))
|
2017-10-14 00:51:27 +03:00
|
|
|
abort = False
|
|
|
|
for file in lookup:
|
|
|
|
ui.warn(_("pending changes to '%s'\n") % file)
|
|
|
|
abort = not force
|
|
|
|
if 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
|
|
|
raise error.Abort(
|
|
|
|
_(
|
|
|
|
"cannot change sparseness due to "
|
|
|
|
+ "pending changes (delete the files or use --force "
|
|
|
|
+ "to bring them back dirty)"
|
|
|
|
)
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# Check for files that were only in the dirstate.
|
2020-01-29 03:25:29 +03:00
|
|
|
for file, state in pycompat.iteritems(dirstate):
|
2017-10-14 00:51:27 +03:00
|
|
|
if not file in files:
|
|
|
|
old = origsparsematch(file)
|
|
|
|
new = sparsematch(file)
|
|
|
|
if old and not new:
|
|
|
|
dropped.append(file)
|
|
|
|
|
|
|
|
# Apply changes to disk
|
2018-02-06 01:13:19 +03:00
|
|
|
if len(actions) > 0:
|
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.note(_("applying changes to disk (%d actions)\n") % len(actions))
|
2020-04-20 08:46:20 +03:00
|
|
|
typeactions = dict((m, []) for m in "a f g am cd dc r rg dm dg m e k p pr".split())
|
2018-03-21 23: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
|
|
|
with progress.bar(ui, _("applying"), total=len(actions)) as prog:
|
2020-01-29 03:25:29 +03:00
|
|
|
for f, (m, args, msg) in pycompat.iteritems(actions):
|
2018-03-21 23:45:28 +03:00
|
|
|
prog.value += 1
|
|
|
|
if m not in typeactions:
|
|
|
|
typeactions[m] = []
|
|
|
|
typeactions[m].append((f, args, msg))
|
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
|
|
|
mergemod.applyupdates(repo, typeactions, repo[None], repo["."], False)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
# Fix dirstate
|
2018-02-06 01:13:19 +03:00
|
|
|
filecount = len(added) + len(dropped) + len(lookup)
|
|
|
|
if filecount > 0:
|
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.note(_("updating dirstate\n"))
|
|
|
|
with progress.bar(ui, _("recording"), _("files"), filecount) as prog:
|
2018-03-21 23:45:28 +03:00
|
|
|
for file in added:
|
|
|
|
prog.value += 1
|
|
|
|
dirstate.normal(file)
|
|
|
|
|
|
|
|
for file in dropped:
|
|
|
|
prog.value += 1
|
2018-10-12 19:35:04 +03:00
|
|
|
dirstate.untrack(file)
|
2018-03-21 23:45:28 +03:00
|
|
|
|
|
|
|
for file in lookup:
|
|
|
|
prog.value += 1
|
|
|
|
# File exists on disk, and we're bringing it back in an unknown
|
|
|
|
# state.
|
|
|
|
dirstate.normallookup(file)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
return added, dropped, lookup
|
|
|
|
|
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 _verbose_output(
|
|
|
|
ui, opts, profilecount, includecount, excludecount, added, dropped, lookup
|
|
|
|
):
|
2017-10-14 00:51:27 +03:00
|
|
|
"""Produce --verbose and templatable output
|
|
|
|
|
|
|
|
This specifically enables -Tjson, providing machine-readable stats on how
|
|
|
|
the sparse profile changed.
|
|
|
|
|
|
|
|
"""
|
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
|
|
|
with ui.formatter("sparse", opts) as fm:
|
2017-10-14 00:51:27 +03:00
|
|
|
fm.startitem()
|
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
|
|
|
fm.condwrite(
|
|
|
|
ui.verbose, "profiles_added", "Profile # change: %d\n", profilecount
|
|
|
|
)
|
|
|
|
fm.condwrite(
|
|
|
|
ui.verbose,
|
|
|
|
"include_rules_added",
|
|
|
|
"Include rule # change: %d\n",
|
|
|
|
includecount,
|
|
|
|
)
|
|
|
|
fm.condwrite(
|
|
|
|
ui.verbose,
|
|
|
|
"exclude_rules_added",
|
|
|
|
"Exclude rule # change: %d\n",
|
|
|
|
excludecount,
|
|
|
|
)
|
2017-10-14 00:51:27 +03:00
|
|
|
# In 'plain' verbose mode, mergemod.applyupdates already outputs what
|
|
|
|
# files are added or removed outside of the templating formatter
|
|
|
|
# framework. No point in repeating ourselves in that case.
|
|
|
|
if not fm.isplain():
|
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
|
|
|
fm.condwrite(ui.verbose, "files_added", "Files added: %d\n", added)
|
|
|
|
fm.condwrite(ui.verbose, "files_dropped", "Files dropped: %d\n", dropped)
|
|
|
|
fm.condwrite(
|
|
|
|
ui.verbose, "files_conflicting", "Files conflicting: %d\n", lookup
|
|
|
|
)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
def _cwdlist(repo):
|
2020-10-15 06:19:13 +03:00
|
|
|
"""List the contents in the current directory. Annotate
|
2017-10-14 00:51:27 +03:00
|
|
|
the files in the sparse profile.
|
|
|
|
"""
|
2018-06-09 00:30:12 +03:00
|
|
|
_checksparse(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
|
|
|
ctx = repo["."]
|
2017-10-14 00:51:27 +03:00
|
|
|
mf = ctx.manifest()
|
|
|
|
|
|
|
|
# Get the root of the repo so that we remove the content of
|
|
|
|
# the root from the current working directory
|
|
|
|
root = repo.root
|
2018-02-27 22:13:59 +03:00
|
|
|
cwd = util.normpath(pycompat.getcwd())
|
|
|
|
cwd = os.path.relpath(cwd, root)
|
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 = "" if cwd == os.curdir else cwd + pycompat.ossep
|
2018-02-27 22:13:59 +03:00
|
|
|
if cwd.startswith(os.pardir + pycompat.ossep):
|
|
|
|
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
|
|
|
_("the current working directory should begin " "with the root %s") % root
|
|
|
|
)
|
2017-10-14 00:51:27 +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
|
|
|
matcher = matchmod.match(repo.root, repo.getcwd(), patterns=["path:" + cwd])
|
2018-03-06 15:23:56 +03:00
|
|
|
files = mf.matches(matcher)
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
sparsematch = repo.sparsematch(ctx.rev())
|
|
|
|
checkedoutentries = set()
|
|
|
|
allentries = set()
|
2018-02-27 22:13:59 +03:00
|
|
|
cwdlength = len(cwd)
|
|
|
|
|
2018-03-06 15:23:56 +03:00
|
|
|
for filepath in files:
|
|
|
|
entryname = filepath[cwdlength:].partition(pycompat.ossep)[0]
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-03-06 15:23:56 +03:00
|
|
|
allentries.add(entryname)
|
|
|
|
if sparsematch(filepath):
|
|
|
|
checkedoutentries.add(entryname)
|
2017-10-14 00:51:27 +03:00
|
|
|
|
|
|
|
ui = repo.ui
|
|
|
|
for entry in sorted(allentries):
|
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
|
|
|
marker = " " if entry in checkedoutentries else "-"
|
2017-10-14 00:51:27 +03:00
|
|
|
ui.status("%s %s\n" % (marker, entry))
|
|
|
|
|
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-03-29 12:34:01 +03:00
|
|
|
class forceincludematcher(matchmod.basematcher):
|
2017-10-14 00:51:27 +03:00
|
|
|
"""A matcher that returns true for any of the forced includes before testing
|
|
|
|
against the actual matcher."""
|
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-14 00:51:27 +03:00
|
|
|
def __init__(self, matcher, includes):
|
2018-03-29 12:34:01 +03:00
|
|
|
super(forceincludematcher, self).__init__(matcher._root, matcher._cwd)
|
2017-10-14 00:51:27 +03:00
|
|
|
self._matcher = matcher
|
2018-10-11 02:40:42 +03:00
|
|
|
self._includes = set(includes).union([""])
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2019-11-13 02:33:03 +03:00
|
|
|
def matchfn(self, value):
|
2018-10-11 02:40:42 +03:00
|
|
|
return bool(value in self._includes or self._matcher(value))
|
2017-10-14 00:51:27 +03:00
|
|
|
|
2018-04-16 22:30:35 +03:00
|
|
|
def __repr__(self):
|
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 "<forceincludematcher matcher=%r includes=%r>" % (
|
|
|
|
self._matcher,
|
|
|
|
self._includes,
|
|
|
|
)
|
2018-04-16 22:30:35 +03:00
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def visitdir(self, dir):
|
|
|
|
if any(True for path in self._includes if path.startswith(dir)):
|
|
|
|
return True
|
|
|
|
return self._matcher.visitdir(dir)
|
|
|
|
|
|
|
|
def hash(self):
|
|
|
|
sha1 = hashlib.sha1()
|
|
|
|
sha1.update(_hashmatcher(self._matcher))
|
|
|
|
for include in sorted(self._includes):
|
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
|
|
|
sha1.update(include + "\0")
|
2017-10-14 00:51:27 +03:00
|
|
|
return sha1.hexdigest()
|
|
|
|
|
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-03-29 12:34:01 +03:00
|
|
|
class unionmatcher(matchmod.unionmatcher):
|
2017-10-14 00:51:27 +03:00
|
|
|
def hash(self):
|
|
|
|
sha1 = hashlib.sha1()
|
|
|
|
for m in self._matchers:
|
|
|
|
sha1.update(_hashmatcher(m))
|
|
|
|
return sha1.hexdigest()
|
|
|
|
|
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-03-29 12:34:01 +03:00
|
|
|
class negatematcher(matchmod.basematcher):
|
2017-10-14 00:51:27 +03:00
|
|
|
def __init__(self, matcher):
|
2018-03-29 12:34:01 +03:00
|
|
|
super(negatematcher, self).__init__(matcher._root, matcher._cwd)
|
2017-10-14 00:51:27 +03:00
|
|
|
self._matcher = matcher
|
|
|
|
|
|
|
|
def __call__(self, value):
|
|
|
|
return not self._matcher(value)
|
|
|
|
|
2018-04-16 22:30:35 +03:00
|
|
|
def __repr__(self):
|
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 "<negatematcher matcher=%r>" % self._matcher
|
2018-04-16 22:30:35 +03:00
|
|
|
|
2018-10-20 01:53:36 +03:00
|
|
|
def visitdir(self, dir):
|
|
|
|
orig = self._matcher.visitdir(dir)
|
|
|
|
if orig == "all":
|
|
|
|
return False
|
|
|
|
elif orig is False:
|
|
|
|
return "all"
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
2017-10-14 00:51:27 +03:00
|
|
|
def hash(self):
|
|
|
|
sha1 = hashlib.sha1()
|
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
|
|
|
sha1.update("negate")
|
2017-10-14 00:51:27 +03:00
|
|
|
sha1.update(_hashmatcher(self._matcher))
|
|
|
|
return sha1.hexdigest()
|
|
|
|
|
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-14 00:51:27 +03:00
|
|
|
def _hashmatcher(matcher):
|
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(matcher, "hash"):
|
2017-10-14 00:51:27 +03:00
|
|
|
return matcher.hash()
|
|
|
|
|
|
|
|
sha1 = hashlib.sha1()
|
|
|
|
sha1.update(repr(matcher))
|
|
|
|
return sha1.hexdigest()
|