2019-11-01 23:24:22 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2015-05-14 02:24:51 +03:00
|
|
|
#
|
2019-11-01 23:24:22 +03:00
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
2019-12-13 14:20:28 +03:00
|
|
|
# scmquery.py
|
|
|
|
# An extension to augement hg with information obtained from SCMQuery
|
2015-05-14 02:24:51 +03:00
|
|
|
|
|
|
|
import json
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 re
|
2015-05-14 02:24:51 +03:00
|
|
|
from urllib import urlencode
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-11-12 23:19:50 +03:00
|
|
|
from edenscm.mercurial import (
|
|
|
|
extensions,
|
|
|
|
namespaces,
|
|
|
|
node,
|
|
|
|
registrar,
|
|
|
|
revset,
|
|
|
|
smartset,
|
|
|
|
templater,
|
|
|
|
)
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial.i18n import _
|
2019-12-03 16:54:17 +03:00
|
|
|
from edenscm.mercurial.node import bin
|
2019-09-27 01:28:09 +03:00
|
|
|
from edenscm.mercurial.pycompat import range
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial.util import httplib
|
2015-05-14 02:24:51 +03:00
|
|
|
|
2019-12-03 16:54:17 +03:00
|
|
|
from .extlib.phabricator import arcconfig, graphql
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-09-17 22:31:17 +03:00
|
|
|
namespacepredicate = registrar.namespacepredicate()
|
|
|
|
|
2017-09-21 17:01:27 +03:00
|
|
|
DEFAULT_TIMEOUT = 60
|
2015-05-14 02:24:51 +03:00
|
|
|
MAX_CONNECT_RETRIES = 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-09-17 22:31:17 +03:00
|
|
|
githashre = re.compile("g([0-9a-f]{40})")
|
2019-03-14 04:30:56 +03:00
|
|
|
svnrevre = re.compile("^r[A-Z]+(\d+)$")
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
phabhashre = re.compile("^r([A-Z]+)([0-9a-f]{12,40})$")
|
|
|
|
|
2015-05-15 23:36:16 +03:00
|
|
|
|
2019-06-04 21:55:49 +03:00
|
|
|
def uisetup(ui):
|
|
|
|
def _globalrevswrapper(loaded):
|
|
|
|
if loaded:
|
|
|
|
globalrevsmod = extensions.find("globalrevs")
|
|
|
|
extensions.wrapfunction(
|
|
|
|
globalrevsmod, "_lookupglobalrev", _scmquerylookupglobalrev
|
|
|
|
)
|
|
|
|
|
|
|
|
if ui.configbool("globalrevs", "scmquerylookup"):
|
|
|
|
extensions.afterloaded("globalrevs", _globalrevswrapper)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revset.symbols["gitnode"] = gitnode
|
2018-06-22 17:26:49 +03:00
|
|
|
gitnode._weight = 10
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-05-14 02:24:51 +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
|
|
|
@templater.templatefunc("mirrornode")
|
2015-05-14 02:24:51 +03:00
|
|
|
def mirrornode(ctx, mapping, 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
|
|
|
"""template: find this commit in other repositories"""
|
2015-05-14 02:24:51 +03:00
|
|
|
|
2019-12-13 14:20:28 +03:00
|
|
|
reponame = mapping["repo"].ui.config("fbscmquery", "reponame")
|
2015-05-14 02:24:51 +03:00
|
|
|
if not reponame:
|
|
|
|
# We don't know who we are, so we can't ask for a translation
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 ""
|
2015-05-14 02:24:51 +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 mapping["ctx"].mutable():
|
2015-05-14 02:24:51 +03:00
|
|
|
# Local commits don't have translations
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 ""
|
2015-05-14 02:24:51 +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
|
|
|
node = mapping["ctx"].hex()
|
2015-05-14 02:24:51 +03:00
|
|
|
args = [f(ctx, mapping, a) for f, a in args]
|
|
|
|
if len(args) == 1:
|
|
|
|
torepo, totype = reponame, args[0]
|
|
|
|
else:
|
|
|
|
torepo, totype = args
|
|
|
|
|
|
|
|
try:
|
2019-12-03 16:54:17 +03:00
|
|
|
client = graphql.Client(repo=mapping["repo"])
|
|
|
|
return client.getmirroredrev(reponame, "hg", torepo, totype, node)
|
|
|
|
except arcconfig.ArcConfigError:
|
|
|
|
mapping["repo"].ui.warn(_("couldn't read .arcconfig or .arcrc"))
|
|
|
|
return ""
|
|
|
|
except graphql.ClientError as e:
|
|
|
|
mapping["repo"].ui.warn((str(e.msg) + "\n"))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 ""
|
|
|
|
|
2015-05-15 23:36:16 +03:00
|
|
|
|
templates: fix help messages for template keywords
Summary:
Many of the template keywords in our extensions were being registered
incorrectly, causing their help output to be rendered incorrectly in the
"hg help templates" output. The ones in smartlog.py were particularly bad, as
most of them showed only their description, without displaying the name of the
template. In smartlog.py only singlepublicsuccessor was being displayed
correctly, because it's docstring explicitly included it's own name at the
start.
This fixes all of our extensions to consistently use the
registrar.templatekeyword() decorator to register the keywords. This decorator
automatically prefixes the help message with the keyword name. The
mercurial/extensions.py code will explicitly check to see if an extension
contains an "templatekeyword" attribute, and if so it will register any
keywords contained in this registry after calling extsetup().
Test Plan:
Added new unit tests to check the output of "hg help templates" for the
affected keywords.
Reviewers: #sourcecontrol, kulshrax, ikostia, rmcelroy
Reviewed By: rmcelroy
Subscribers: rmcelroy, net-systems-diffs@, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4427729
Signature: t1:4427729:1484831476:17b478a5e867dfc3f85402588c381bf8b1831107
2017-01-19 23:52:54 +03:00
|
|
|
templatekeyword = registrar.templatekeyword()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
templates: fix help messages for template keywords
Summary:
Many of the template keywords in our extensions were being registered
incorrectly, causing their help output to be rendered incorrectly in the
"hg help templates" output. The ones in smartlog.py were particularly bad, as
most of them showed only their description, without displaying the name of the
template. In smartlog.py only singlepublicsuccessor was being displayed
correctly, because it's docstring explicitly included it's own name at the
start.
This fixes all of our extensions to consistently use the
registrar.templatekeyword() decorator to register the keywords. This decorator
automatically prefixes the help message with the keyword name. The
mercurial/extensions.py code will explicitly check to see if an extension
contains an "templatekeyword" attribute, and if so it will register any
keywords contained in this registry after calling extsetup().
Test Plan:
Added new unit tests to check the output of "hg help templates" for the
affected keywords.
Reviewers: #sourcecontrol, kulshrax, ikostia, rmcelroy
Reviewed By: rmcelroy
Subscribers: rmcelroy, net-systems-diffs@, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4427729
Signature: t1:4427729:1484831476:17b478a5e867dfc3f85402588c381bf8b1831107
2017-01-19 23:52:54 +03:00
|
|
|
@templatekeyword("gitnode")
|
2015-05-15 23:36:16 +03:00
|
|
|
def showgitnode(repo, ctx, templ, **args):
|
|
|
|
"""Return the git revision corresponding to a given hg rev"""
|
2019-12-21 01:13:41 +03:00
|
|
|
# Try reading from commit extra first.
|
|
|
|
extra = ctx.extra()
|
|
|
|
if "hg-git-rename-source" in extra:
|
|
|
|
hexnode = extra.get("convert_revision")
|
|
|
|
if hexnode:
|
|
|
|
return hexnode
|
2019-12-13 14:20:28 +03:00
|
|
|
reponame = repo.ui.config("fbscmquery", "reponame")
|
2015-05-15 23:36:16 +03:00
|
|
|
if not reponame:
|
|
|
|
# We don't know who we are, so we can't ask for a translation
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 ""
|
2019-12-13 14:20:28 +03:00
|
|
|
backingrepos = repo.ui.configlist("fbscmquery", "backingrepos", default=[reponame])
|
2015-05-15 23:36:16 +03:00
|
|
|
|
|
|
|
if ctx.mutable():
|
|
|
|
# Local commits don't have translations
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 ""
|
2015-07-15 09:04:03 +03:00
|
|
|
|
2015-07-16 00:48:57 +03:00
|
|
|
matches = []
|
|
|
|
for backingrepo in backingrepos:
|
|
|
|
try:
|
2019-12-03 16:54:17 +03:00
|
|
|
client = graphql.Client(repo=repo)
|
|
|
|
githash = client.getmirroredrev(
|
|
|
|
reponame, "hg", backingrepo, "git", ctx.hex()
|
|
|
|
)
|
2015-08-11 07:22:21 +03:00
|
|
|
if githash != "":
|
|
|
|
matches.append((backingrepo, githash))
|
2019-12-03 16:54:17 +03:00
|
|
|
except (graphql.ClientError, arcconfig.ArcConfigError):
|
2015-07-16 00:48:57 +03:00
|
|
|
pass
|
|
|
|
|
|
|
|
if len(matches) == 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
|
|
|
return ""
|
2015-07-16 00:48:57 +03:00
|
|
|
elif len(backingrepos) == 1:
|
|
|
|
return matches[0][1]
|
|
|
|
else:
|
|
|
|
# in case it's not clear, the sort() is to ensure the output is in a
|
|
|
|
# deterministic order.
|
|
|
|
matches.sort()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return "; ".join(["{0}: {1}".format(*match) for match in matches])
|
|
|
|
|
2015-05-15 23:36:16 +03:00
|
|
|
|
|
|
|
def gitnode(repo, subset, x):
|
|
|
|
"""``gitnode(id)``
|
|
|
|
Return the hg revision corresponding to a given git rev."""
|
|
|
|
l = revset.getargs(x, 1, 1, _("id requires one argument"))
|
|
|
|
n = revset.getstring(l[0], _("id requires a string"))
|
|
|
|
|
2019-12-13 14:20:28 +03:00
|
|
|
reponame = repo.ui.config("fbscmquery", "reponame")
|
2015-05-15 23:36:16 +03:00
|
|
|
if not reponame:
|
|
|
|
# We don't know who we are, so we can't ask for a translation
|
2016-11-25 03:23:21 +03:00
|
|
|
return subset.filter(lambda r: False)
|
2019-12-13 14:20:28 +03:00
|
|
|
backingrepos = repo.ui.configlist("fbscmquery", "backingrepos", default=[reponame])
|
2015-05-15 23:36:16 +03:00
|
|
|
|
2017-02-15 23:35:06 +03:00
|
|
|
lasterror = None
|
|
|
|
hghash = None
|
2015-07-16 00:48:57 +03:00
|
|
|
for backingrepo in backingrepos:
|
|
|
|
try:
|
2019-12-03 16:54:17 +03:00
|
|
|
client = graphql.Client(repo=repo)
|
|
|
|
hghash = client.getmirroredrev(backingrepo, "git", reponame, "hg", n)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 hghash != "":
|
2015-08-11 07:22:21 +03:00
|
|
|
break
|
2017-02-15 23:35:06 +03:00
|
|
|
except Exception as ex:
|
|
|
|
lasterror = ex
|
|
|
|
|
|
|
|
if not hghash:
|
|
|
|
if lasterror:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.ui.warn(
|
|
|
|
("Could not translate revision {0}: {1}\n".format(n, lasterror))
|
|
|
|
)
|
2017-02-15 23:35:06 +03:00
|
|
|
else:
|
|
|
|
repo.ui.warn(("Could not translate revision {0}\n".format(n)))
|
2015-07-15 23:40:08 +03:00
|
|
|
return subset.filter(lambda r: False)
|
2015-08-11 07:22:21 +03:00
|
|
|
|
2017-02-15 23:35:06 +03:00
|
|
|
rn = repo[node.bin(hghash)].rev()
|
2019-11-12 23:19:50 +03:00
|
|
|
return subset & smartset.baseset([rn])
|
2015-05-15 23:36: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
|
|
|
|
2018-09-17 22:31:17 +03:00
|
|
|
@namespacepredicate("conduit", priority=70)
|
|
|
|
def _getnamespace(_repo):
|
|
|
|
return namespaces.namespace(
|
|
|
|
listnames=lambda repo: [], namemap=_phablookup, nodemap=lambda repo, node: []
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def _phablookup(repo, phabrev):
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
# Is the given revset a phabricator hg hash (ie: rHGEXTaaacb34aacb34aa)
|
2018-09-17 22:31:17 +03:00
|
|
|
cl = repo.changelog
|
|
|
|
tonode = cl.node
|
|
|
|
|
|
|
|
def gittohg(githash):
|
2018-09-26 02:44:21 +03:00
|
|
|
return [tonode(rev) for rev in repo.revs("gitnode(%s)" % githash)]
|
2018-09-17 22:31:17 +03:00
|
|
|
|
|
|
|
phabmatch = phabhashre.match(phabrev)
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
if phabmatch:
|
|
|
|
phabrepo = phabmatch.group(1)
|
|
|
|
phabhash = phabmatch.group(2)
|
2018-09-17 22:31:17 +03:00
|
|
|
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
# The hash may be a git hash
|
2019-12-13 14:20:28 +03:00
|
|
|
if phabrepo in repo.ui.configlist("fbscmquery", "gitcallsigns", []):
|
2018-09-17 22:31:17 +03:00
|
|
|
return gittohg(phabhash)
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
|
2019-03-13 19:55:32 +03:00
|
|
|
return [repo[phabhash].node()]
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
|
2019-03-14 04:30:56 +03:00
|
|
|
# TODO: 's/svnrev/globalrev' after turning off Subversion servers. We will
|
|
|
|
# know about this when we remove the `svnrev` revset.
|
|
|
|
svnrevmatch = svnrevre.match(phabrev)
|
|
|
|
if svnrevmatch is not None:
|
|
|
|
svnrev = svnrevmatch.group(1)
|
|
|
|
return [tonode(rev) for rev in repo.revs("svnrev(%s)" % svnrev)]
|
|
|
|
|
2018-09-17 22:31:17 +03:00
|
|
|
m = githashre.match(phabrev)
|
2015-05-15 23:36:16 +03:00
|
|
|
if m is not None:
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
githash = m.group(1)
|
|
|
|
if len(githash) == 40:
|
2018-09-17 22:31:17 +03:00
|
|
|
return gittohg(githash)
|
fbconduit: de-phabricator-ize hg and git hashes
Summary:
Remove the need to ommit the rREPO prefix when copy pasting from phabricator and
looking up a commit.
Test Plan:
Ran the following in phabricator enabled HG repos
11/13 12:15 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBS27aa00fb74d9a3b82756dad6ff26fe253f1e9a70 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 992495:27aa00fb74d9
user: Peng Li <pengli@fb.com>
date: Tue Nov 03 10:29:01 2015 -0800
summary: Add a simple root dir arc library
11/13 12:21 cdelahousse@dev4253 ~/fbjava
$ hg log -r rFBA8f1335e6d588 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 18654:8f1335e6d588
user: Ryan Menezes <ryandm@fb.com>
date: Thu Oct 22 09:59:27 2015 -0700
summary: move jenkins hook into fbjava/arcanist (fbjava changes)
Tried the same on a repo with a git mirror that exists in phabricator:
11/16 11:40 cdelahousse@dev4253 ~/fbsource/fbcode
$ hg log -r rFBCODE8272d25d65869ce059024ff38c7051388ad7b802 --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
changeset: 1027287:f26a9c32ae08
user: Oleksandr Kuvshynov <oleksandr@fb.com>
date: Sun Nov 15 19:16:39 2015 -0800
summary: [mf] simple cleanup of feed story view
If a git hash is too small, abort:
$ hg log -r rFBCODE8272d25d65869ce059024f --config extensions.fbconduit=~/local/fb-hgext/fbconduit.py
abort: git hash must be 40 characters
The previous commands depends on a list of repos set in my hgrc. See (D2660070)
[fbconduit]
gitcallsigns=LK, CFPUMA, CFSV, CFGK, CFMF, CFGMON, CF, RSIGMA, FA,·
WAWEBCLIENT, SKY, FBCODE, FBOBJC, WAWP, SV, OVRMOBILEMAIN, WAANDROID, IGSRV,
CPE, MSS, ANDROIDSDK, BUCK, IT-CHEF, WABB, ITINFRA, SIGMA, IOSSDK
Reviewers: #sourcecontrol, durham, ericsumner
Reviewed By: durham, ericsumner
Subscribers: rmcelroy, ericsumner
Differential Revision: https://phabricator.fb.com/D2653497
Tasks: 8361368
Signature: t1:2653497:1447480768:295079a7793e182ddea3aeece9cfaead1bfc1a57
2015-11-18 02:22:08 +03:00
|
|
|
else:
|
2018-09-17 22:31:17 +03:00
|
|
|
return []
|
2019-06-04 21:55:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
def _scmquerylookupglobalrev(orig, repo, rev):
|
2019-12-13 14:20:28 +03:00
|
|
|
reponame = repo.ui.config("fbscmquery", "reponame")
|
2019-06-04 21:55:49 +03:00
|
|
|
if reponame:
|
|
|
|
try:
|
2019-12-03 16:54:17 +03:00
|
|
|
client = graphql.Client(repo=repo)
|
2019-06-04 21:55:49 +03:00
|
|
|
hghash = str(
|
2020-01-03 23:38:15 +03:00
|
|
|
client.getmirroredrev(reponame, "GLOBAL_REV", reponame, "hg", str(rev))
|
2019-06-04 21:55:49 +03:00
|
|
|
)
|
|
|
|
matchedrevs = []
|
|
|
|
if hghash:
|
2019-07-09 23:34:25 +03:00
|
|
|
matchedrevs.append(bin(hghash))
|
2019-06-04 21:55:49 +03:00
|
|
|
return matchedrevs
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return orig(repo, rev)
|