2016-06-03 02:19:05 +03:00
|
|
|
# sampling.py - sample collection extension
|
|
|
|
#
|
|
|
|
# Copyright 2016 Facebook
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# - This extension enhances ui.log(category, message, key=value, ...)
|
2016-06-07 20:24:56 +03:00
|
|
|
# to also append filtered logged events as JSON to a file.
|
2016-06-03 02:19:05 +03:00
|
|
|
# - The events are separated by NULL characters: '\0'.
|
2017-02-07 11:39:26 +03:00
|
|
|
# - The file is either specified with the SCM_SAMPLING_FILEPATH environment
|
2016-06-03 02:19:05 +03:00
|
|
|
# variable or the sampling.filepath configuration.
|
|
|
|
# - If the file cannot be created or accessed, fails silently
|
2016-06-07 20:24:56 +03:00
|
|
|
#
|
|
|
|
# The configuration details can be found in the documentation of ui.log below
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 json
|
|
|
|
import os
|
|
|
|
|
2018-05-26 03:39:09 +03:00
|
|
|
from mercurial import encoding, pycompat, registrar, util
|
2016-06-03 02:19:05 +03:00
|
|
|
|
|
|
|
|
2017-10-24 06:02:57 +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
|
|
|
configitem("sampling", "filepath", default="")
|
|
|
|
|
2017-10-24 06:02:57 +03:00
|
|
|
|
2016-06-03 02:19:05 +03:00
|
|
|
def _parentfolderexists(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
|
|
|
return f is not None and os.path.exists(os.path.dirname(os.path.normpath(f)))
|
|
|
|
|
2016-06-03 02:19:05 +03:00
|
|
|
|
|
|
|
def _getcandidatelocation(ui):
|
2017-01-03 16:59:55 +03:00
|
|
|
for candidatelocation in (
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
encoding.environ.get("SCM_SAMPLING_FILEPATH", None),
|
|
|
|
ui.config("sampling", "filepath"),
|
|
|
|
):
|
2016-06-03 02:19:05 +03:00
|
|
|
if _parentfolderexists(candidatelocation):
|
|
|
|
return candidatelocation
|
|
|
|
return 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
|
|
|
|
2016-06-03 02:19:05 +03:00
|
|
|
def uisetup(ui):
|
|
|
|
class logtofile(ui.__class__):
|
2016-06-07 20:24:56 +03:00
|
|
|
@classmethod
|
|
|
|
def computesamplingfilters(cls, self):
|
|
|
|
filtermap = {}
|
|
|
|
for k in ui.configitems("sampling"):
|
|
|
|
if not k[0].startswith("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
|
|
|
continue # not a key
|
|
|
|
filtermap[k[0].lstrip("key.")] = k[1]
|
2016-06-07 20:24:56 +03:00
|
|
|
return filtermap
|
|
|
|
|
2016-06-03 02:19:05 +03:00
|
|
|
def log(self, event, *msg, **opts):
|
2016-06-07 20:24:56 +03:00
|
|
|
"""Redirect filtered log event to a sampling file
|
|
|
|
The configuration looks like:
|
|
|
|
[sampling]
|
|
|
|
filepath = path/to/file
|
|
|
|
key.eventname = value
|
|
|
|
key.eventname2 = value2
|
|
|
|
|
|
|
|
If an event name appears in the config, it is logged to the
|
|
|
|
samplingfile augmented with value stored as ref.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
[sampling]
|
|
|
|
filepath = path/to/file
|
|
|
|
key.perfstatus = perf_status
|
|
|
|
|
|
|
|
Assuming that we call:
|
|
|
|
ui.log('perfstatus', t=3)
|
|
|
|
ui.log('perfcommit', t=3)
|
|
|
|
ui.log('perfstatus', t=42)
|
|
|
|
|
|
|
|
Then we will log in path/to/file, two JSON strings separated by \0
|
|
|
|
one for each perfstatus, like:
|
|
|
|
{"event":"perfstatus",
|
|
|
|
"ref":"perf_status",
|
|
|
|
"msg":"",
|
|
|
|
"opts":{"t":3}}\0
|
|
|
|
{"event":"perfstatus",
|
|
|
|
"ref":"perf_status",
|
|
|
|
"msg":"",
|
|
|
|
"opts":{"t":42}}\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
|
|
|
if not util.safehasattr(self, "samplingfilters"):
|
2016-06-07 20:24:56 +03:00
|
|
|
self.samplingfilters = logtofile.computesamplingfilters(self)
|
|
|
|
if event not in self.samplingfilters:
|
|
|
|
return super(logtofile, self).log(event, *msg, **opts)
|
|
|
|
|
2017-11-01 21:49:13 +03:00
|
|
|
# special case: remove less interesting blocked fields starting
|
|
|
|
# with "unknown_" or "alias_".
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 event == "measuredtimes":
|
|
|
|
opts = {
|
|
|
|
k: v
|
|
|
|
for k, v in opts.items()
|
|
|
|
if (not k.startswith("alias_") and not k.startswith("unknown_"))
|
|
|
|
}
|
2017-11-01 21:49:13 +03:00
|
|
|
|
2016-06-07 20:24:56 +03:00
|
|
|
ref = self.samplingfilters[event]
|
2016-06-03 02:19:05 +03:00
|
|
|
script = _getcandidatelocation(ui)
|
|
|
|
if script:
|
|
|
|
try:
|
2016-06-22 03:07:55 +03:00
|
|
|
opts["metrics_type"] = event
|
|
|
|
if msg:
|
2016-06-25 02:18:34 +03:00
|
|
|
# ui.log treats msg as a format string + format args.
|
|
|
|
opts["msg"] = msg[0] % msg[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
|
|
|
with open(script, "a") as outfile:
|
|
|
|
outfile.write(json.dumps({"data": opts, "category": ref}))
|
2016-06-03 02:19:05 +03:00
|
|
|
outfile.write("\0")
|
|
|
|
except EnvironmentError:
|
|
|
|
pass
|
|
|
|
return super(logtofile, self).log(event, *msg, **opts)
|
|
|
|
|
|
|
|
# Replace the class for this instance and all clones created from it:
|
|
|
|
ui.__class__ = logtofile
|
2018-04-12 15:09:23 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-05-26 03:39:09 +03:00
|
|
|
def getrelativecwd(repo):
|
|
|
|
"""Returns the current directory relative to the working copy root, or
|
|
|
|
None if it's not in the working copy.
|
|
|
|
"""
|
|
|
|
cwd = pycompat.getcwdsafe()
|
|
|
|
if cwd.startswith(repo.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
|
|
|
return os.path.normpath(cwd[len(repo.root) + 1 :])
|
2018-05-26 03:39:09 +03:00
|
|
|
else:
|
|
|
|
return 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
|
|
|
|
2018-05-26 03:39:09 +03:00
|
|
|
def gettopdir(repo):
|
|
|
|
"""Returns the first component of the current directory, if it's in the
|
|
|
|
working copy.
|
|
|
|
"""
|
|
|
|
reldir = getrelativecwd(repo)
|
|
|
|
if reldir:
|
|
|
|
components = reldir.split(pycompat.ossep)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if len(components) > 0 and components[0] != ".":
|
2018-05-26 03:39:09 +03:00
|
|
|
return components[0]
|
|
|
|
else:
|
|
|
|
return 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
|
|
|
|
2018-04-12 15:09:23 +03:00
|
|
|
def reposetup(ui, repo):
|
|
|
|
@repo.ui.atexit
|
|
|
|
def telemetry():
|
2018-06-07 21:24:38 +03:00
|
|
|
try:
|
2018-06-12 23:08:18 +03:00
|
|
|
if util.safehasattr(repo, "requirements"):
|
|
|
|
ui.log(
|
|
|
|
"requirements",
|
|
|
|
generaldelta=str("generaldelta" in repo.requirements).lower(),
|
|
|
|
)
|
|
|
|
ui.log(
|
|
|
|
"requirements",
|
|
|
|
remotefilelog=str("remotefilelog" in repo.requirements).lower(),
|
|
|
|
)
|
|
|
|
|
2018-06-07 21:24:38 +03:00
|
|
|
maxrss = util.getmaxrss()
|
|
|
|
|
|
|
|
# Log maxrss from within the hg process. The wrapper logs its own
|
|
|
|
# value (which is incorrect if chg is used) so the column is
|
|
|
|
# prefixed.
|
|
|
|
ui.log("command_info", hg_maxrss=maxrss)
|
2018-06-12 23:08:18 +03:00
|
|
|
except Exception as e:
|
|
|
|
ui.log("command_info", sampling_failure=e.message)
|
2018-06-07 21:24:38 +03:00
|
|
|
|
2018-05-26 03:39:09 +03:00
|
|
|
# Log other information that we don't want to log in the wrapper, if it's
|
|
|
|
# cheap to do so.
|
|
|
|
|
|
|
|
# Log the current directory bucketed to top-level directories, if enabled.
|
|
|
|
# This provides a very rough approximation of what area the users works in.
|
|
|
|
# developer config: sampling.logtopdir
|
|
|
|
if repo.ui.config("sampling", "logtopdir"):
|
|
|
|
topdir = gettopdir(repo)
|
|
|
|
if topdir:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
ui.log("command_info", topdir=topdir)
|