2019-11-01 23:24:22 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2013-10-18 03:46:12 +04: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.
|
|
|
|
|
2018-01-03 17:35:21 +03:00
|
|
|
# no-check-code
|
2018-09-26 02:04:12 +03:00
|
|
|
"""sync hg repos with MySQL
|
|
|
|
|
|
|
|
Config::
|
|
|
|
|
|
|
|
[hgsql]
|
|
|
|
# Seconds. If it's non-negative. Try pulling from the database in a loop
|
|
|
|
# before entering the critical section. This is done by changing the SQL lock
|
|
|
|
# timeout to syncinterval, which should be much smaller than locktimeout.
|
|
|
|
# This could make the repo closer to the SQL state after entering the
|
|
|
|
# critical section so pulling from database might take less time there. If
|
2018-09-27 00:08:48 +03:00
|
|
|
# it's a negative value, do not sync before entering the critical section.
|
2018-09-26 02:04:12 +03:00
|
|
|
# (default: -1)
|
|
|
|
syncinterval = -1
|
2018-09-26 02:04:16 +03:00
|
|
|
|
2019-11-21 18:43:29 +03:00
|
|
|
# Seconds. Do not attempt to sync for read-only commands. If last sync was
|
|
|
|
# within the specified time.
|
|
|
|
synclimit = 30
|
|
|
|
|
2018-09-26 02:04:16 +03:00
|
|
|
# Enable faster "need sync or not" check. It could be 6x faster, and
|
2018-10-18 06:02:12 +03:00
|
|
|
# removes some time in the critical section.
|
2018-09-26 02:04:16 +03:00
|
|
|
# (default: true)
|
|
|
|
fastsynccheck = true
|
2018-10-18 06:02:12 +03:00
|
|
|
|
|
|
|
# Whether to do an initial "best-effort" pull from the database.
|
|
|
|
# (default: true)
|
|
|
|
initialsync = true
|
2018-10-31 05:25:32 +03:00
|
|
|
|
|
|
|
# Timeout (in seconds) set at the socket connection.
|
|
|
|
sockettimeout = 60
|
2018-09-26 02:04:12 +03:00
|
|
|
"""
|
2018-09-25 06:39:40 +03:00
|
|
|
|
2013-10-18 03:46:12 +04:00
|
|
|
|
2018-01-03 17:35:21 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-09-26 02:04:16 +03:00
|
|
|
import hashlib
|
2018-01-03 17:35:21 +03:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
import warnings
|
|
|
|
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import (
|
2018-01-03 17:35:21 +03:00
|
|
|
bookmarks,
|
|
|
|
bundle2,
|
|
|
|
bundlerepo,
|
|
|
|
changegroup,
|
|
|
|
commands,
|
|
|
|
demandimport,
|
|
|
|
error,
|
|
|
|
exchange,
|
|
|
|
extensions,
|
|
|
|
hg,
|
|
|
|
localrepo,
|
2018-09-29 02:46:42 +03:00
|
|
|
lock as lockmod,
|
2018-01-03 17:35:21 +03:00
|
|
|
mdiff,
|
|
|
|
phases,
|
2018-03-21 23:45:35 +03:00
|
|
|
progress,
|
2018-07-23 22:51:47 +03:00
|
|
|
pycompat,
|
2018-01-03 17:35:21 +03:00
|
|
|
registrar,
|
|
|
|
repair,
|
|
|
|
revlog,
|
|
|
|
util,
|
|
|
|
wireproto,
|
|
|
|
)
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial.i18n import _
|
|
|
|
from edenscm.mercurial.node import bin, hex, nullid, nullrev
|
2020-02-04 05:24:33 +03:00
|
|
|
from edenscm.mercurial.pycompat import encodeutf8, queue, range
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-01-03 17:35:21 +03:00
|
|
|
|
|
|
|
wrapcommand = extensions.wrapcommand
|
|
|
|
wrapfunction = extensions.wrapfunction
|
2013-10-18 03:46:12 +04:00
|
|
|
|
|
|
|
cmdtable = {}
|
2017-05-23 03:27:50 +03:00
|
|
|
command = registrar.command(cmdtable)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 = "3.9.1"
|
2013-10-18 03:46:12 +04:00
|
|
|
|
2017-10-25 01:15:42 +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("hgsql", "database", default=None)
|
|
|
|
configitem("hgsql", "host", default=None)
|
|
|
|
configitem("hgsql", "reponame", default=None)
|
|
|
|
configitem("hgsql", "password", default="")
|
|
|
|
configitem("hgsql", "port", default=0)
|
|
|
|
configitem("hgsql", "user", default=None)
|
|
|
|
|
2018-09-25 06:39:40 +03:00
|
|
|
configitem("format", "usehgsql", default=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
|
|
|
configitem("hgsql", "bypass", default=False)
|
|
|
|
configitem("hgsql", "enabled", default=False)
|
|
|
|
configitem("hgsql", "engine", default="innodb")
|
2018-09-26 02:04:16 +03:00
|
|
|
configitem("hgsql", "fastsynccheck", default=True)
|
2018-10-18 06:02:12 +03:00
|
|
|
configitem("hgsql", "initialsync", default=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
|
|
|
configitem("hgsql", "locktimeout", default=60)
|
|
|
|
configitem("hgsql", "maxcommitsize", default=52428800)
|
|
|
|
configitem("hgsql", "maxinsertsize", default=1048576)
|
|
|
|
configitem("hgsql", "maxrowsize", default=1048576)
|
|
|
|
configitem("hgsql", "profileoutput", default="/tmp")
|
|
|
|
configitem("hgsql", "profiler", default=None)
|
2018-08-01 03:01:25 +03:00
|
|
|
configitem("hgsql", "rootpidnsonly", default=False)
|
2018-10-31 05:25:32 +03:00
|
|
|
configitem("hgsql", "sockettimeout", default=60)
|
2018-10-25 04:01:52 +03:00
|
|
|
configitem("hgsql", "sqltimeout", default=120)
|
2018-09-26 02:04:12 +03:00
|
|
|
configitem("hgsql", "syncinterval", default=-1)
|
2019-11-21 18:43:29 +03:00
|
|
|
configitem("hgsql", "synclimit", default=0)
|
2018-09-25 06:39:40 +03:00
|
|
|
configitem("hgsql", "verbose", default=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
|
|
|
configitem("hgsql", "verifybatchsize", default=1000)
|
|
|
|
configitem("hgsql", "waittimeout", default=300)
|
|
|
|
|
2018-09-26 02:04:12 +03:00
|
|
|
# developer config: hgsql.debugminsqllockwaittime
|
|
|
|
# do not get the sql lock unless specified time has passed
|
|
|
|
configitem("hgsql", "debugminsqllockwaittime", default=0)
|
|
|
|
|
2018-09-08 02:41:35 +03:00
|
|
|
mysql = 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
|
|
|
writelock = "write_lock"
|
|
|
|
|
|
|
|
INITIAL_SYNC_NORMAL = "normal"
|
|
|
|
INITIAL_SYNC_DISABLE = "disabled"
|
|
|
|
INITIAL_SYNC_FORCE = "force"
|
2014-10-27 23:56:13 +03:00
|
|
|
|
|
|
|
initialsync = INITIAL_SYNC_NORMAL
|
2013-10-18 03:46:12 +04:00
|
|
|
|
2016-04-29 19:55:23 +03:00
|
|
|
cls = localrepo.localrepository
|
2017-05-08 23:19:01 +03:00
|
|
|
# Do NOT add hgsql to localrepository.supportedformats. Doing that breaks
|
|
|
|
# streaming clones.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 reqs in ["openerreqs", "_basesupported"]:
|
|
|
|
getattr(cls, reqs).add("hgsql")
|
|
|
|
|
2016-04-29 19:55:23 +03:00
|
|
|
|
|
|
|
def newreporequirements(orig, repo):
|
|
|
|
reqs = orig(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
|
|
|
if repo.ui.configbool("format", "usehgsql"):
|
|
|
|
reqs.add("hgsql")
|
2016-04-29 19:55:23 +03:00
|
|
|
return reqs
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-10-29 05:57:18 +04:00
|
|
|
class CorruptionException(Exception):
|
|
|
|
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
|
|
|
|
2018-08-01 03:01:25 +03:00
|
|
|
def isrootpidns():
|
|
|
|
"""False if we're sure it's not a root pid namespace. True otherwise."""
|
|
|
|
try:
|
|
|
|
# Linux implementation detail - inode number is 0xeffffffc for root
|
|
|
|
# namespaces.
|
2018-10-01 17:15:19 +03:00
|
|
|
return os.stat("/proc/self/ns/pid").st_ino == 0xEFFFFFFC
|
2018-08-01 03:01:25 +03:00
|
|
|
except Exception:
|
|
|
|
# Cannot tell (not Linux, or no /proc mounted).
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2018-06-15 20:15:50 +03:00
|
|
|
def ishgsqlbypassed(ui):
|
2018-08-01 03:01:25 +03:00
|
|
|
# developer config: hgsql.rootpidnsonly
|
|
|
|
if ui.configbool("hgsql", "rootpidnsonly") and not isrootpidns():
|
|
|
|
return True
|
2018-06-15 20:15:50 +03:00
|
|
|
return ui.configbool("hgsql", "bypass")
|
|
|
|
|
|
|
|
|
2015-11-18 00:28:15 +03:00
|
|
|
def issqlrepo(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
|
|
|
return repo.ui.configbool("hgsql", "enabled")
|
|
|
|
|
2015-11-18 00:28:15 +03:00
|
|
|
|
2015-11-18 00:28:56 +03:00
|
|
|
def cansyncwithsql(repo):
|
|
|
|
return issqlrepo(repo) and not isinstance(repo, bundlerepo.bundlerepository)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-10-18 03:46:12 +04:00
|
|
|
def uisetup(ui):
|
2018-06-15 20:15:50 +03:00
|
|
|
if ishgsqlbypassed(ui):
|
2016-05-11 23:54:24 +03:00
|
|
|
return
|
2018-06-15 20:15:50 +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
|
|
|
wrapfunction(localrepo, "newreporequirements", newreporequirements)
|
2016-04-29 19:55:23 +03:00
|
|
|
|
2014-11-05 04:41:13 +03:00
|
|
|
# Enable SQL for local commands that write to the 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
|
|
|
wrapcommand(commands.table, "pull", pull)
|
|
|
|
wrapcommand(commands.table, "commit", commit)
|
2014-01-29 08:46:23 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
wrapcommand(commands.table, "bookmark", bookmarkcommand)
|
|
|
|
wrapfunction(exchange, "_localphasemove", _localphasemove)
|
|
|
|
wrapfunction(exchange.pulloperation, "__init__", pullop_init)
|
|
|
|
wrapfunction(exchange, "push", push)
|
2014-11-05 04:41:13 +03:00
|
|
|
|
|
|
|
# Enable SQL for remote commands that write to the 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
|
|
|
wireproto.commands["unbundle"] = (wireproto.unbundle, "heads")
|
|
|
|
wrapfunction(exchange, "unbundle", unbundle)
|
2013-10-29 23:55:14 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
wrapfunction(wireproto, "pushkey", pushkey)
|
|
|
|
wireproto.commands["pushkey"] = (wireproto.pushkey, "namespace key old new")
|
2014-01-29 08:46:23 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
wrapfunction(bookmarks, "updatefromremote", updatefromremote)
|
|
|
|
if util.safehasattr(changegroup, "addchangegroup"):
|
|
|
|
wrapfunction(changegroup, "addchangegroup", addchangegroup)
|
2015-10-27 01:47:53 +03:00
|
|
|
else:
|
|
|
|
# Mercurial 3.6+
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
wrapfunction(changegroup.cg1unpacker, "apply", changegroupapply)
|
2014-02-19 05:16:45 +04:00
|
|
|
|
2017-03-30 19:39:44 +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
|
|
|
treemfmod = extensions.find("treemanifest")
|
|
|
|
wrapcommand(treemfmod.cmdtable, "backfilltree", backfilltree)
|
2017-03-30 19:39:44 +03:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
2014-11-05 04:41:13 +03:00
|
|
|
# Record revlog writes
|
2014-01-04 00:01:50 +04:00
|
|
|
def writeentry(orig, self, transaction, ifh, dfh, entry, data, link, offset):
|
2014-01-22 04:05:27 +04:00
|
|
|
"""records each revlog write to the repo's pendingrev list"""
|
2014-02-19 03:59:46 +04:00
|
|
|
if not util.safehasattr(transaction, "repo"):
|
|
|
|
return orig(self, transaction, ifh, dfh, entry, data, link, offset)
|
|
|
|
|
2017-07-17 15:49:39 +03:00
|
|
|
e = revlog.indexformatng.unpack(entry)
|
2018-07-23 22:51:57 +03:00
|
|
|
hexnode = hex(e[7])
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
data0 = data[0] or ""
|
|
|
|
transaction.repo.pendingrevs.append(
|
2018-07-23 22:51:57 +03:00
|
|
|
(self.indexfile, link, len(self) - 1, hexnode, entry, data0, data[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
|
|
|
)
|
2014-01-04 00:01:50 +04:00
|
|
|
return orig(self, transaction, ifh, dfh, entry, data, link, offset)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
wrapfunction(revlog.revlog, "_writeentry", writeentry)
|
2014-01-04 00:01:50 +04:00
|
|
|
|
2014-11-05 04:41:13 +03:00
|
|
|
# Reorder incoming revs to be in linkrev order
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
wrapfunction(revlog.revlog, "addgroup", addgroup)
|
|
|
|
|
2019-02-27 00:11:04 +03:00
|
|
|
def memcommitwrapper(loaded):
|
|
|
|
if loaded:
|
|
|
|
memcommitmod = extensions.find("memcommit")
|
|
|
|
wrapfunction(memcommitmod, "_memcommit", _memcommit)
|
|
|
|
|
|
|
|
extensions.afterloaded("memcommit", memcommitwrapper)
|
|
|
|
|
2014-02-19 05:16:45 +04:00
|
|
|
|
2018-09-08 02:41:35 +03:00
|
|
|
def _importmysqlconnector():
|
|
|
|
# mysql.connector does not import nicely with the demandimporter, so
|
|
|
|
# temporarily disable it.
|
|
|
|
with demandimport.deactivated():
|
|
|
|
global mysql
|
|
|
|
mysql = __import__("mysql.connector")
|
|
|
|
|
|
|
|
|
2014-10-27 23:56:13 +03:00
|
|
|
def extsetup(ui):
|
2018-09-08 02:41:35 +03:00
|
|
|
# Importing MySQL connector here allows other modules to import code from
|
|
|
|
# `hgsql` without requiring the MySQL connector. There are cases where this
|
|
|
|
# makes sense. For example, there is no need for MySQL connector on a
|
|
|
|
# repository which does not have `hgsql` enabled.
|
|
|
|
_importmysqlconnector()
|
|
|
|
|
2018-06-15 20:15:50 +03:00
|
|
|
if ishgsqlbypassed(ui):
|
2016-05-11 23:54:24 +03:00
|
|
|
return
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.configbool("hgsql", "enabled"):
|
2014-10-27 23:56:13 +03:00
|
|
|
commands.globalopts.append(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
(
|
|
|
|
"",
|
|
|
|
"forcesync",
|
|
|
|
False,
|
|
|
|
_("force hgsql sync even on read-only commands"),
|
|
|
|
_("TYPE"),
|
|
|
|
)
|
|
|
|
)
|
2014-10-27 23:56:13 +03:00
|
|
|
|
2018-10-18 06:02:12 +03:00
|
|
|
global initialsync
|
|
|
|
if not ui.configbool("hgsql", "initialsync"):
|
|
|
|
initialsync = INITIAL_SYNC_DISABLE
|
|
|
|
|
2014-10-27 23:56:13 +03:00
|
|
|
# Directly examining argv seems like a terrible idea, but it seems
|
2018-09-25 20:57:04 +03:00
|
|
|
# necessary unless we refactor mercurial dispatch code. This is because
|
2014-10-27 23:56:13 +03:00
|
|
|
# the first place we have access to parsed options is in the same function
|
|
|
|
# (dispatch.dispatch) that created the repo and the repo creation initiates
|
|
|
|
# the sync operation in which the lock is elided unless we set this.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 "--forcesync" in sys.argv:
|
|
|
|
ui.debug("forcesync enabled\n")
|
2014-10-27 23:56:13 +03:00
|
|
|
initialsync = INITIAL_SYNC_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
|
|
|
|
2013-10-18 03:46:12 +04:00
|
|
|
def reposetup(ui, repo):
|
2018-06-15 20:15:50 +03:00
|
|
|
if ishgsqlbypassed(ui):
|
2016-05-11 23:54:24 +03:00
|
|
|
return
|
|
|
|
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2013-11-22 00:32:05 +04:00
|
|
|
wraprepo(repo)
|
2013-10-29 03:09:47 +04:00
|
|
|
|
2015-11-18 00:28:56 +03:00
|
|
|
if initialsync != INITIAL_SYNC_DISABLE and cansyncwithsql(repo):
|
2014-01-03 00:19:50 +04:00
|
|
|
# Use a noop to force a sync
|
|
|
|
def noop():
|
|
|
|
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
|
|
|
|
2018-09-29 02:46:45 +03:00
|
|
|
enforcepullfromdb = initialsync == INITIAL_SYNC_FORCE
|
|
|
|
executewithsql(repo, noop, enforcepullfromdb=enforcepullfromdb)
|
2013-10-29 03:09:47 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-09-27 02:32:10 +03:00
|
|
|
# Incoming commits are only allowed via push and pull.
|
|
|
|
# This changes repo.transaction to take a sql write lock. Note:
|
|
|
|
# repo.transaction outside unbundle is not changed. Question: is it better
|
|
|
|
# to change repo.transaction for everything?
|
2015-10-09 23:13:18 +03:00
|
|
|
def unbundle(orig, repo, cg, *args, **kwargs):
|
2015-11-18 00:28:15 +03:00
|
|
|
if not issqlrepo(repo):
|
2015-10-09 23:13:18 +03:00
|
|
|
return orig(repo, cg, *args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
isbundle2 = util.safehasattr(cg, "params")
|
|
|
|
islazylocking = repo.ui.configbool("experimental", "bundle2lazylocking")
|
2015-10-09 23:13:18 +03:00
|
|
|
if isbundle2 and islazylocking:
|
|
|
|
# lazy locked bundle2
|
|
|
|
exception = None
|
|
|
|
oldopclass = None
|
|
|
|
context = None
|
|
|
|
try:
|
2018-09-29 02:46:45 +03:00
|
|
|
context = sqlcontext(repo, dbwritable=True, enforcepullfromdb=True)
|
2015-10-09 23:13:18 +03:00
|
|
|
|
|
|
|
# Temporarily replace bundleoperation so we can hook into it's
|
|
|
|
# locking mechanism.
|
|
|
|
oldopclass = bundle2.bundleoperation
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-29 02:46:42 +03:00
|
|
|
repolocks = []
|
|
|
|
|
2015-10-09 23:13:18 +03:00
|
|
|
class sqllockedoperation(bundle2.bundleoperation):
|
|
|
|
def __init__(self, repo, transactiongetter, *args, **kwargs):
|
|
|
|
def sqllocktr():
|
2018-09-29 02:46:42 +03:00
|
|
|
# Get local repo locks first.
|
|
|
|
repolocks.append(repo.wlock(wait=True))
|
|
|
|
repolocks.append(repo.lock(wait=True))
|
2015-10-09 23:13:18 +03:00
|
|
|
if not context.active():
|
2018-09-29 02:46:42 +03:00
|
|
|
# Get global SQL transaction inside local lock.
|
|
|
|
# This could change the repo.
|
2015-10-09 23:13:18 +03:00
|
|
|
context.__enter__()
|
|
|
|
return transactiongetter()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
super(sqllockedoperation, self).__init__(
|
|
|
|
repo, sqllocktr, *args, **kwargs
|
|
|
|
)
|
2015-10-09 23:13:18 +03:00
|
|
|
# undo our temporary wrapping
|
|
|
|
bundle2.bundleoperation = oldopclass
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-10-09 23:13:18 +03:00
|
|
|
bundle2.bundleoperation = sqllockedoperation
|
|
|
|
|
|
|
|
return orig(repo, cg, *args, **kwargs)
|
|
|
|
except Exception as ex:
|
|
|
|
exception = ex
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
# Be extra sure to undo our wrapping
|
|
|
|
if oldopclass:
|
|
|
|
bundle2.bundleoperation = oldopclass
|
|
|
|
# release sqllock here in exit
|
|
|
|
if context:
|
|
|
|
type = value = traceback = None
|
|
|
|
if exception:
|
|
|
|
type = exception.__class__
|
|
|
|
value = exception
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
traceback = [] # This isn't really important
|
2015-10-09 23:13:18 +03:00
|
|
|
context.__exit__(type, value, traceback)
|
2018-09-29 02:46:42 +03:00
|
|
|
for lock in reversed(repolocks):
|
|
|
|
lockmod.release(lock)
|
2014-02-19 03:59:46 +04:00
|
|
|
else:
|
2015-10-09 23:13:18 +03:00
|
|
|
# bundle1 or non-lazy locked
|
|
|
|
return executewithsql(repo, orig, True, repo, cg, *args, **kwargs)
|
2014-01-03 00:19:50 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-01-03 00:19:50 +04:00
|
|
|
def pull(orig, *args, **kwargs):
|
|
|
|
repo = args[1]
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2014-03-12 23:35:04 +04:00
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
2014-02-19 03:59:46 +04:00
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
2013-10-29 05:57:18 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-05-09 15:58:03 +03:00
|
|
|
def pullop_init(orig, self, repo, *args, **kwargs):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if issqlrepo(repo) or "hgsql" in repo.requirements:
|
|
|
|
kwargs["exactbyteclone"] = True
|
2018-05-09 15:58:03 +03:00
|
|
|
return orig(self, repo, *args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-01-06 21:16:35 +03:00
|
|
|
def push(orig, *args, **kwargs):
|
|
|
|
repo = args[0]
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2015-01-06 21:16:35 +03:00
|
|
|
# A push locks the local repo in order to update phase data, so we need
|
|
|
|
# to take the lock for the local repo during a push.
|
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-03-13 23:42:20 +04:00
|
|
|
def commit(orig, *args, **kwargs):
|
|
|
|
repo = args[1]
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2014-03-13 23:42:20 +04:00
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-02-19 05:16:45 +04:00
|
|
|
def updatefromremote(orig, *args, **kwargs):
|
|
|
|
repo = args[1]
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2014-03-12 23:35:04 +04:00
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
2014-02-19 05:16:45 +04:00
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-04-09 21:56:53 +04:00
|
|
|
def addchangegroup(orig, *args, **kwargs):
|
|
|
|
repo = args[0]
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2015-10-27 01:47:53 +03:00
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-03-30 19:39:44 +03:00
|
|
|
def backfilltree(orig, ui, repo, *args, **kwargs):
|
|
|
|
if issqlrepo(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-03-30 19:39:44 +03:00
|
|
|
def _helper():
|
|
|
|
return orig(ui, repo, *args, **kwargs)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-03-30 23:36:37 +03:00
|
|
|
try:
|
|
|
|
repo.sqlreplaytransaction = True
|
|
|
|
return executewithsql(repo, _helper, True)
|
|
|
|
finally:
|
|
|
|
repo.sqlreplaytransaction = False
|
2017-03-30 19:39:44 +03:00
|
|
|
else:
|
|
|
|
return orig(ui, repo, *args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2019-02-27 00:11:04 +03:00
|
|
|
def _memcommit(orig, *args, **kwargs):
|
|
|
|
repo = args[0]
|
|
|
|
if issqlrepo(repo):
|
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
|
|
|
|
|
|
|
|
2015-10-27 01:47:53 +03:00
|
|
|
def changegroupapply(orig, *args, **kwargs):
|
|
|
|
repo = args[1]
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2014-04-09 21:56:53 +04:00
|
|
|
return executewithsql(repo, orig, True, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return orig(*args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-08-26 14:51:11 +04:00
|
|
|
def _localphasemove(orig, pushop, *args, **kwargs):
|
|
|
|
repo = pushop.repo
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(repo):
|
2014-08-26 14:51:11 +04:00
|
|
|
return executewithsql(repo, orig, True, pushop, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return orig(pushop, *args, **kwargs)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-10-08 02:42:52 +03:00
|
|
|
class sqlcontext(object):
|
2018-09-29 02:46:45 +03:00
|
|
|
def __init__(self, repo, dbwritable=False, enforcepullfromdb=False):
|
2018-09-29 02:46:48 +03:00
|
|
|
if dbwritable and not enforcepullfromdb:
|
|
|
|
raise error.ProgrammingError(
|
|
|
|
"enforcepullfromdb must be True if dbwritable is True"
|
|
|
|
)
|
2015-10-08 02:42:52 +03:00
|
|
|
self.repo = repo
|
2018-09-29 02:46:45 +03:00
|
|
|
self.dbwritable = dbwritable
|
|
|
|
self.enforcepullfromdb = enforcepullfromdb
|
2015-10-08 02:42:52 +03:00
|
|
|
self._connected = False
|
|
|
|
self._locked = False
|
|
|
|
self._used = False
|
|
|
|
self._startlocktime = 0
|
2015-10-09 23:13:18 +03:00
|
|
|
self._active = False
|
2016-04-29 19:53:17 +03:00
|
|
|
self._profiler = None
|
2015-10-09 23:13:18 +03:00
|
|
|
|
|
|
|
def active(self):
|
|
|
|
return self._active
|
2015-10-08 02:42:52 +03:00
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
if self._used:
|
|
|
|
raise Exception("error: using sqlcontext twice")
|
|
|
|
self._used = True
|
2015-10-09 23:13:18 +03:00
|
|
|
self._active = True
|
2015-10-08 02:42:52 +03:00
|
|
|
|
|
|
|
repo = self.repo
|
2018-09-27 02:32:10 +03:00
|
|
|
repo._sqlreadrows = 0
|
|
|
|
repo._sqlwriterows = 0
|
|
|
|
|
2015-10-08 02:42:52 +03:00
|
|
|
if not repo.sqlconn:
|
|
|
|
repo.sqlconnect()
|
|
|
|
self._connected = True
|
|
|
|
|
2018-09-29 02:46:45 +03:00
|
|
|
if self.dbwritable and not writelock in repo.heldlocks:
|
2015-10-08 02:42:52 +03:00
|
|
|
startwait = time.time()
|
2016-12-08 02:46:09 +03:00
|
|
|
try:
|
2018-09-26 02:04:12 +03:00
|
|
|
repo.sqlwritelock(trysync=True)
|
2016-12-08 02:46:09 +03:00
|
|
|
except error.Abort:
|
|
|
|
elapsed = time.time() - startwait
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.log(
|
|
|
|
"sqllock",
|
2018-09-27 02:32:10 +03:00
|
|
|
"failed to get sql lock after %s seconds\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
|
|
|
elapsed,
|
|
|
|
elapsed=elapsed * 1000,
|
|
|
|
valuetype="lockwait",
|
|
|
|
success="false",
|
|
|
|
repository=repo.root,
|
|
|
|
)
|
2018-09-25 06:39:40 +03:00
|
|
|
repo._hgsqlnote("failed to get lock after %.2f seconds" % elapsed)
|
2016-12-08 02:46:09 +03:00
|
|
|
raise
|
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
self._startprofile()
|
2015-10-08 02:42:52 +03:00
|
|
|
self._locked = True
|
2016-04-01 13:11:34 +03:00
|
|
|
elapsed = time.time() - startwait
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.log(
|
|
|
|
"sqllock",
|
2018-09-27 02:32:10 +03:00
|
|
|
"waited for sql lock for %s seconds (read %s rows)\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
|
|
|
elapsed,
|
2018-09-27 02:32:10 +03:00
|
|
|
repo._sqlreadrows,
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
elapsed=elapsed * 1000,
|
|
|
|
valuetype="lockwait",
|
|
|
|
success="true",
|
2018-09-27 02:32:10 +03:00
|
|
|
readrows=repo._sqlreadrows,
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
repository=repo.root,
|
|
|
|
)
|
2018-09-27 02:32:10 +03:00
|
|
|
repo._hgsqlnote(
|
|
|
|
"got lock after %.2f seconds (read %s rows)"
|
|
|
|
% (elapsed, repo._sqlreadrows)
|
|
|
|
)
|
|
|
|
repo._sqlreadrows = 0
|
2015-10-08 02:42:52 +03:00
|
|
|
self._startlocktime = time.time()
|
|
|
|
|
|
|
|
if self._connected:
|
2018-09-29 02:46:45 +03:00
|
|
|
repo.pullfromdb(enforcepullfromdb=self.enforcepullfromdb)
|
2015-10-08 02:42:52 +03:00
|
|
|
|
|
|
|
def __exit__(self, type, value, traceback):
|
|
|
|
try:
|
|
|
|
repo = self.repo
|
|
|
|
if self._locked:
|
2016-04-01 13:11:34 +03:00
|
|
|
elapsed = time.time() - self._startlocktime
|
2018-09-27 02:32:10 +03:00
|
|
|
repo.sqlwriteunlock()
|
|
|
|
self._stopprofile(elapsed)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.log(
|
|
|
|
"sqllock",
|
2018-09-27 02:32:10 +03:00
|
|
|
"held sql lock for %s seconds (read %s rows; write %s rows)\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
|
|
|
elapsed,
|
2018-09-27 02:32:10 +03:00
|
|
|
repo._sqlreadrows,
|
|
|
|
repo._sqlwriterows,
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
elapsed=elapsed * 1000,
|
|
|
|
valuetype="lockheld",
|
|
|
|
repository=repo.root,
|
2018-09-27 02:32:10 +03:00
|
|
|
readrows=repo._sqlreadrows,
|
|
|
|
writerows=repo._sqlwriterows,
|
|
|
|
)
|
|
|
|
repo._hgsqlnote(
|
|
|
|
"held lock for %.2f seconds (read %s rows; write %s rows)"
|
|
|
|
% (elapsed, repo._sqlreadrows, repo._sqlwriterows)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-10-08 02:42:52 +03:00
|
|
|
|
|
|
|
if self._connected:
|
|
|
|
repo.sqlclose()
|
2015-10-09 23:13:18 +03:00
|
|
|
|
|
|
|
self._active = False
|
2015-11-18 00:34:00 +03:00
|
|
|
except mysql.connector.errors.Error:
|
2015-10-08 02:42:52 +03:00
|
|
|
# Only raise sql exceptions if the wrapped code threw no exception
|
|
|
|
if type is None:
|
|
|
|
raise
|
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
def _startprofile(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
|
|
|
profiler = self.repo.ui.config("hgsql", "profiler")
|
2016-04-29 19:53:17 +03:00
|
|
|
if not profiler:
|
|
|
|
return
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
freq = self.repo.ui.configint("profiling", "freq")
|
|
|
|
if profiler == "ls":
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import lsprof
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
self._profiler = lsprof.Profiler()
|
|
|
|
self._profiler.enable(subcalls=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
|
|
|
elif profiler == "stat":
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import statprof
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
statprof.reset(freq)
|
|
|
|
statprof.start()
|
|
|
|
else:
|
|
|
|
raise Exception("unknown profiler: %s" % profiler)
|
|
|
|
|
|
|
|
def _stopprofile(self, elapsed):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
profiler = self.repo.ui.config("hgsql", "profiler")
|
2016-04-29 19:53:17 +03:00
|
|
|
if not profiler:
|
|
|
|
return
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
outputdir = self.repo.ui.config("hgsql", "profileoutput")
|
2016-04-29 19:53:17 +03:00
|
|
|
import random
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
pid = os.getpid()
|
|
|
|
rand = random.random()
|
|
|
|
timestamp = time.time()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if profiler == "ls":
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import lsprof
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
self._profiler.disable()
|
|
|
|
stats = lsprof.Stats(self._profiler.getstats())
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.sort("inlinetime")
|
|
|
|
path = os.path.join(
|
|
|
|
outputdir, "hgsql-profile-%s-%s-%s" % (pid, timestamp, rand)
|
|
|
|
)
|
|
|
|
with open(path, "a+") as f:
|
2016-04-29 19:53:17 +03:00
|
|
|
stats.pprint(limit=30, file=f, climit=0)
|
|
|
|
f.write("Total Elapsed Time: %s\n" % elapsed)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 profiler == "stat":
|
2019-01-30 03:25:33 +03:00
|
|
|
from edenscm.mercurial import statprof
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-29 19:53:17 +03:00
|
|
|
statprof.stop()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 = os.path.join(
|
|
|
|
outputdir, "hgsql-profile-%s-%s-%s" % (pid, timestamp, rand)
|
|
|
|
)
|
|
|
|
with open(path, "a+") as f:
|
2016-04-29 19:53:17 +03:00
|
|
|
statprof.display(f)
|
|
|
|
f.write("Total Elapsed Time: %s\n" % elapsed)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-03-12 23:35:04 +04:00
|
|
|
def executewithsql(repo, action, sqllock=False, *args, **kwargs):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Executes the given action while having a SQL connection open.
|
2014-03-11 22:25:23 +04:00
|
|
|
If a locks are specified, those locks are held for the duration of the
|
2014-01-24 07:22:49 +04:00
|
|
|
action.
|
|
|
|
"""
|
|
|
|
# executewithsql can be executed in a nested scenario (ex: writing
|
|
|
|
# bookmarks during a pull), so track whether this call performed
|
|
|
|
# the connect.
|
Make forcesync only acquire local repo lock
Summary:
Previously, the --forcesync flag would cause the command to acquire the
sqllock, which would mean a read only command would block for any ongoing write
commands to complete, which is undesirable. Now, we will wait for the lcoal repo
lock only, instead of skipping the sync as we did before the initial patch.
This ensures that forcesync operations will see all committed changes, but won't
wait for ongoing write transactions from other masters.
Test Plan: updated test
Reviewers: sid0, davidsp, pyd, mpm, durham
Reviewed By: durham
Differential Revision: https://phabricator.fb.com/D1682970
Signature: t1:1682970:1416014352:e7f3daa09e79abd43a16c8eb74bc69272d73c83d
2014-11-14 21:53:35 +03:00
|
|
|
|
2018-09-29 02:46:45 +03:00
|
|
|
enforcepullfromdb = sqllock
|
|
|
|
if "enforcepullfromdb" in kwargs:
|
|
|
|
if not enforcepullfromdb:
|
|
|
|
enforcepullfromdb = kwargs["enforcepullfromdb"]
|
|
|
|
del kwargs["enforcepullfromdb"]
|
Make forcesync only acquire local repo lock
Summary:
Previously, the --forcesync flag would cause the command to acquire the
sqllock, which would mean a read only command would block for any ongoing write
commands to complete, which is undesirable. Now, we will wait for the lcoal repo
lock only, instead of skipping the sync as we did before the initial patch.
This ensures that forcesync operations will see all committed changes, but won't
wait for ongoing write transactions from other masters.
Test Plan: updated test
Reviewers: sid0, davidsp, pyd, mpm, durham
Reviewed By: durham
Differential Revision: https://phabricator.fb.com/D1682970
Signature: t1:1682970:1416014352:e7f3daa09e79abd43a16c8eb74bc69272d73c83d
2014-11-14 21:53:35 +03:00
|
|
|
|
2018-09-29 02:46:52 +03:00
|
|
|
# Take repo lock if sqllock is set.
|
|
|
|
if sqllock:
|
|
|
|
wlock = repo.wlock()
|
|
|
|
lock = repo.lock()
|
|
|
|
else:
|
|
|
|
wlock = util.nullcontextmanager()
|
|
|
|
lock = util.nullcontextmanager()
|
|
|
|
|
|
|
|
with wlock, lock, sqlcontext(
|
|
|
|
repo, dbwritable=sqllock, enforcepullfromdb=enforcepullfromdb
|
|
|
|
):
|
2015-10-08 02:42:52 +03:00
|
|
|
return action(*args, **kwargs)
|
2014-01-03 00:19:50 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
def wraprepo(repo):
|
|
|
|
class sqllocalrepo(repo.__class__):
|
|
|
|
def sqlconnect(self):
|
|
|
|
if self.sqlconn:
|
2019-04-02 03:58:01 +03:00
|
|
|
return
|
|
|
|
|
2015-09-08 04:18:37 +03:00
|
|
|
retry = 3
|
|
|
|
while True:
|
|
|
|
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
|
|
|
self.sqlconn = mysql.connector.connect(
|
|
|
|
force_ipv6=True, **self.sqlargs
|
|
|
|
)
|
2015-11-18 00:34:00 +03:00
|
|
|
|
|
|
|
# The default behavior is to return byte arrays, when we
|
|
|
|
# need strings. This custom convert returns strings.
|
|
|
|
self.sqlconn.set_converter_class(CustomConverter)
|
2015-09-08 04:18:37 +03:00
|
|
|
break
|
2015-11-18 00:34:00 +03:00
|
|
|
except mysql.connector.errors.Error:
|
2015-09-08 04:18:37 +03:00
|
|
|
# mysql can be flakey occasionally, so do some minimal
|
|
|
|
# retrying.
|
|
|
|
retry -= 1
|
|
|
|
if retry == 0:
|
|
|
|
raise
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
waittimeout = self.ui.config("hgsql", "waittimeout")
|
2018-10-25 04:01:52 +03:00
|
|
|
sqltimeout = self.ui.configint("hgsql", "sqltimeout") * 1000
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
waittimeout = self.sqlconn.converter.escape("%s" % waittimeout)
|
2015-11-18 00:34: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
|
|
|
self.engine = self.ui.config("hgsql", "engine")
|
|
|
|
self.locktimeout = self.ui.config("hgsql", "locktimeout")
|
|
|
|
self.locktimeout = self.sqlconn.converter.escape("%s" % self.locktimeout)
|
2015-11-18 00:34:00 +03:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
self.sqlcursor = self.sqlconn.cursor()
|
2018-09-27 02:32:10 +03:00
|
|
|
self._sqlreadrows = 0
|
|
|
|
self._sqlwriterows = 0
|
|
|
|
|
|
|
|
# Patch sqlcursor so it updates the read write counters.
|
|
|
|
def _fetchallupdatereadcount(orig):
|
|
|
|
result = orig()
|
|
|
|
self._sqlreadrows += self.sqlcursor.rowcount
|
|
|
|
return result
|
|
|
|
|
|
|
|
def _executeupdatewritecount(orig, sql, *args, **kwargs):
|
|
|
|
result = orig(sql, *args, **kwargs)
|
|
|
|
# naive ways to detect "writes"
|
|
|
|
if sql.split(" ", 1)[0].upper() in {"DELETE", "UPDATE", "INSERT"}:
|
|
|
|
self._sqlwriterows += self.sqlcursor.rowcount
|
|
|
|
return result
|
|
|
|
|
|
|
|
wrapfunction(self.sqlcursor, "fetchall", _fetchallupdatereadcount)
|
|
|
|
wrapfunction(self.sqlcursor, "execute", _executeupdatewritecount)
|
|
|
|
|
2015-11-18 00:34:00 +03:00
|
|
|
self.sqlcursor.execute("SET wait_timeout=%s" % waittimeout)
|
2018-10-25 04:01:52 +03:00
|
|
|
self.sqlcursor.execute("SET SESSION MAX_STATEMENT_TIME=%s" % sqltimeout)
|
2018-02-21 16:55:07 +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 self.engine == "rocksdb":
|
|
|
|
self.sqlcursor.execute(
|
|
|
|
"SET rocksdb_lock_wait_timeout=%s" % self.locktimeout
|
|
|
|
)
|
|
|
|
elif self.engine == "innodb":
|
|
|
|
self.sqlcursor.execute(
|
|
|
|
"SET innodb_lock_wait_timeout=%s" % self.locktimeout
|
|
|
|
)
|
2018-02-21 16:55:07 +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
|
|
|
raise RuntimeError("unsupported hgsql.engine %s" % self.engine)
|
2013-11-22 00:32:05 +04:00
|
|
|
|
|
|
|
def sqlclose(self):
|
2014-04-17 22:09:48 +04:00
|
|
|
with warnings.catch_warnings():
|
|
|
|
warnings.simplefilter("ignore")
|
|
|
|
self.sqlcursor.close()
|
|
|
|
self.sqlconn.close()
|
2013-11-22 00:32:05 +04:00
|
|
|
self.sqlcursor = None
|
|
|
|
self.sqlconn = None
|
|
|
|
|
2019-05-02 19:03:40 +03:00
|
|
|
def sqlreporeadonlystate(self):
|
2019-03-18 19:38:31 +03:00
|
|
|
NO_WRITE = 0
|
|
|
|
MONONOKE_WRITE = 2
|
2019-05-02 19:03:40 +03:00
|
|
|
DEFAULT_REASON = "no reason was provided"
|
|
|
|
MONONOKE_REASON = "writes are being served by Mononoke (fburl.com/mononoke)"
|
|
|
|
query = "SELECT state, reason FROM repo_lock WHERE repo = %s"
|
2019-04-02 03:58:01 +03:00
|
|
|
|
|
|
|
self.sqlconnect()
|
|
|
|
|
2019-03-18 19:38:31 +03:00
|
|
|
self.sqlcursor.execute(query, (self.sqlreponame,))
|
|
|
|
rows = self.sqlcursor.fetchall()
|
|
|
|
|
|
|
|
if not rows:
|
|
|
|
# If there isn't an entry for this repo, let's treat it as
|
|
|
|
# unlocked.
|
2019-05-02 19:03:40 +03:00
|
|
|
return (False, DEFAULT_REASON)
|
|
|
|
|
|
|
|
state, reason = rows[0]
|
|
|
|
|
|
|
|
readonly = state == NO_WRITE or state == MONONOKE_WRITE
|
2019-03-18 19:38:31 +03:00
|
|
|
|
2019-05-02 19:03:40 +03:00
|
|
|
if reason is None:
|
|
|
|
reason = {MONONOKE_WRITE: MONONOKE_REASON}.get(state, DEFAULT_REASON)
|
|
|
|
|
|
|
|
return (readonly, reason)
|
|
|
|
|
|
|
|
def sqlisreporeadonly(self):
|
|
|
|
"""deprecated: use sqlreporeadonlystate() to also get the reason"""
|
|
|
|
return self.sqlreporeadonlystate()[0]
|
2019-03-18 19:38:31 +03:00
|
|
|
|
2018-09-25 06:39:40 +03:00
|
|
|
def _hgsqlnote(self, message):
|
|
|
|
if self.ui.configbool("hgsql", "verbose"):
|
|
|
|
self.ui.write_err("[hgsql] %s\n" % message)
|
|
|
|
self.ui.debug("%s\n" % message)
|
|
|
|
|
2015-11-18 00:34:00 +03:00
|
|
|
def _lockname(self, name):
|
|
|
|
lockname = "%s_%s" % (name, self.sqlreponame)
|
|
|
|
return self.sqlconn.converter.escape(lockname)
|
|
|
|
|
2018-09-26 02:04:12 +03:00
|
|
|
def _sqllock(self, name, trysync):
|
|
|
|
"""If trysync is True, try to sync the repo outside the lock so it
|
|
|
|
stays closer to the actual repo when the lock is acquired.
|
|
|
|
"""
|
2015-11-18 00:34:00 +03:00
|
|
|
lockname = self._lockname(name)
|
2018-09-26 02:04:12 +03:00
|
|
|
syncinterval = float(self.ui.config("hgsql", "syncinterval") or -1)
|
|
|
|
if syncinterval < 0:
|
|
|
|
trysync = False
|
|
|
|
|
|
|
|
if trysync:
|
|
|
|
minwaittime = self.ui.configint("hgsql", "debugminsqllockwaittime")
|
|
|
|
# SELECT GET_LOCK(...) will block. Break the lock attempt into
|
|
|
|
# smaller lock attempts
|
|
|
|
starttime = time.time()
|
|
|
|
while True:
|
|
|
|
elapsed = time.time() - starttime
|
|
|
|
if elapsed >= self.locktimeout:
|
|
|
|
raise util.Abort(
|
|
|
|
"timed out waiting for mysql repo lock (%s)" % lockname
|
|
|
|
)
|
|
|
|
# Sync outside the SQL lock hoping that the repo is closer
|
|
|
|
# to the SQL repo when we got the lock.
|
2018-09-29 02:46:45 +03:00
|
|
|
self.pullfromdb(enforcepullfromdb=True)
|
2018-09-26 02:04:12 +03:00
|
|
|
if elapsed < minwaittime:
|
|
|
|
# Pretend we wait and timed out, without actually
|
|
|
|
# getting the SQL lock. This is useful for testing.
|
|
|
|
time.sleep(syncinterval)
|
|
|
|
else:
|
|
|
|
# Try to acquire SQL lock, with a small timeout. So
|
|
|
|
# "forcesync" can get executed more frequently.
|
|
|
|
self.sqlcursor.execute(
|
|
|
|
"SELECT GET_LOCK('%s', %s)" % (lockname, syncinterval)
|
|
|
|
)
|
|
|
|
result = int(self.sqlcursor.fetchall()[0][0])
|
|
|
|
if result == 1:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.sqlcursor.execute(
|
|
|
|
"SELECT GET_LOCK('%s', %s)" % (lockname, self.locktimeout)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-26 02:04:12 +03:00
|
|
|
# cast to int to prevent passing bad sql data
|
|
|
|
result = int(self.sqlcursor.fetchall()[0][0])
|
|
|
|
if result != 1:
|
|
|
|
raise util.Abort(
|
|
|
|
"timed out waiting for mysql repo lock (%s)" % lockname
|
|
|
|
)
|
2014-01-29 08:46:23 +04:00
|
|
|
self.heldlocks.add(name)
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2018-09-26 02:04:12 +03:00
|
|
|
def sqlwritelock(self, trysync=False):
|
2018-09-29 02:46:41 +03:00
|
|
|
self._enforcelocallocktaken()
|
2018-09-26 02:04:12 +03:00
|
|
|
self._sqllock(writelock, trysync)
|
2018-09-25 20:57:06 +03:00
|
|
|
|
|
|
|
def _hassqllock(self, name, checkserver=True):
|
2014-03-12 23:52:27 +04:00
|
|
|
if not name in self.heldlocks:
|
|
|
|
return False
|
|
|
|
|
2016-01-07 03:37:46 +03:00
|
|
|
if not checkserver:
|
|
|
|
return True
|
|
|
|
|
2015-11-18 00:34:00 +03:00
|
|
|
lockname = self._lockname(name)
|
|
|
|
self.sqlcursor.execute("SELECT IS_USED_LOCK('%s')" % (lockname,))
|
|
|
|
lockheldby = self.sqlcursor.fetchall()[0][0]
|
2014-03-12 23:52:27 +04:00
|
|
|
if lockheldby == None:
|
2015-11-18 00:34:00 +03:00
|
|
|
raise Exception("unable to check %s lock" % lockname)
|
2014-03-12 23:52:27 +04:00
|
|
|
|
2015-11-18 00:34:00 +03:00
|
|
|
self.sqlcursor.execute("SELECT CONNECTION_ID()")
|
|
|
|
myconnectid = self.sqlcursor.fetchall()[0][0]
|
2014-03-12 23:52:27 +04:00
|
|
|
if myconnectid == None:
|
|
|
|
raise Exception("unable to read connection id")
|
|
|
|
|
|
|
|
return lockheldby == myconnectid
|
|
|
|
|
2018-09-25 20:57:06 +03:00
|
|
|
def hassqlwritelock(self, checkserver=True):
|
|
|
|
return self._hassqllock(writelock, checkserver)
|
|
|
|
|
|
|
|
def _sqlunlock(self, name):
|
2015-11-18 00:34:00 +03:00
|
|
|
lockname = self._lockname(name)
|
|
|
|
self.sqlcursor.execute("SELECT RELEASE_LOCK('%s')" % (lockname,))
|
|
|
|
self.sqlcursor.fetchall()
|
2014-01-29 08:46:23 +04:00
|
|
|
self.heldlocks.discard(name)
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2016-01-07 03:37:46 +03:00
|
|
|
for callback in self.sqlpostrelease:
|
|
|
|
callback()
|
|
|
|
self.sqlpostrelease = []
|
|
|
|
|
2018-09-25 20:57:06 +03:00
|
|
|
def sqlwriteunlock(self):
|
2018-09-29 02:46:41 +03:00
|
|
|
self._enforcelocallocktaken()
|
|
|
|
self._sqlunlock(writelock)
|
|
|
|
|
|
|
|
def _enforcelocallocktaken(self):
|
|
|
|
if self._issyncing:
|
|
|
|
return
|
|
|
|
if self._currentlock(self._lockref):
|
|
|
|
return
|
|
|
|
raise error.ProgrammingError("invalid lock order")
|
2016-12-07 03:04:20 +03:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
def transaction(self, *args, **kwargs):
|
|
|
|
tr = super(sqllocalrepo, self).transaction(*args, **kwargs)
|
2014-01-04 00:03:52 +04:00
|
|
|
if tr.count > 1:
|
|
|
|
return tr
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2015-04-23 01:10:26 +03:00
|
|
|
validator = tr.validator
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-04-23 01:10:26 +03:00
|
|
|
def pretxnclose(tr):
|
|
|
|
validator(tr)
|
|
|
|
self.committodb(tr)
|
|
|
|
del self.pendingrevs[:]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-04-23 01:10:26 +03:00
|
|
|
tr.validator = pretxnclose
|
2014-01-03 00:19:50 +04:00
|
|
|
|
|
|
|
def transactionabort(orig):
|
|
|
|
del self.pendingrevs[:]
|
|
|
|
return orig()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-01-03 00:19:50 +04:00
|
|
|
wrapfunction(tr, "_abort", transactionabort)
|
2015-04-23 01:10:26 +03:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
tr.repo = self
|
|
|
|
return tr
|
|
|
|
|
2018-09-26 02:04:16 +03:00
|
|
|
def needsyncfast(self):
|
|
|
|
"""Returns True if the local repo might be out of sync.
|
|
|
|
False otherwise.
|
|
|
|
|
|
|
|
Faster than needsync. But do not return bookmarks or heads.
|
|
|
|
"""
|
|
|
|
# Calculate local checksum in background.
|
|
|
|
localsynchashes = []
|
|
|
|
localthread = threading.Thread(
|
|
|
|
target=lambda results, repo: results.append(repo._localsynchash()),
|
|
|
|
args=(localsynchashes, self),
|
|
|
|
)
|
|
|
|
localthread.start()
|
|
|
|
# Let MySQL do the same calculation on their side
|
|
|
|
sqlsynchash = self._sqlsynchash()
|
|
|
|
localthread.join()
|
|
|
|
return sqlsynchash != localsynchashes[0]
|
|
|
|
|
|
|
|
def _localsynchash(self):
|
|
|
|
refs = dict(self._bookmarks)
|
|
|
|
refs["tip"] = self["tip"].rev()
|
|
|
|
sha = ""
|
2020-01-29 03:25:29 +03:00
|
|
|
for k, v in sorted(pycompat.iteritems(refs)):
|
2018-09-26 02:04:16 +03:00
|
|
|
if k != "tip":
|
|
|
|
v = hex(v)
|
2020-02-04 05:24:33 +03:00
|
|
|
sha = hashlib.sha1(encodeutf8("%s%s%s" % (sha, k, v))).hexdigest()
|
2018-09-26 02:04:16 +03:00
|
|
|
return sha
|
|
|
|
|
|
|
|
def _sqlsynchash(self):
|
|
|
|
sql = """
|
|
|
|
SET @sha := '', @id = 0;
|
|
|
|
SELECT sha FROM (
|
|
|
|
SELECT
|
|
|
|
@id := @id + 1 as id,
|
|
|
|
@sha := sha1(concat(@sha, name, value)) as sha
|
|
|
|
FROM revision_references
|
|
|
|
WHERE repo = %s AND namespace IN ('bookmarks', 'tip') ORDER BY name
|
|
|
|
) AS t ORDER BY id DESC LIMIT 1;
|
|
|
|
"""
|
|
|
|
|
|
|
|
sqlresults = [
|
|
|
|
sqlresult.fetchall()
|
|
|
|
for sqlresult in repo.sqlcursor.execute(
|
|
|
|
sql, (self.sqlreponame,), multi=True
|
|
|
|
)
|
|
|
|
if sqlresult.with_rows
|
|
|
|
]
|
|
|
|
# is it a new repo with empty references?
|
|
|
|
if sqlresults == [[]]:
|
2020-02-04 05:24:33 +03:00
|
|
|
return hashlib.sha1(encodeutf8("%s%s" % ("tip", -1))).hexdigest()
|
2018-09-26 02:04:16 +03:00
|
|
|
# sqlresults looks like [[('59237a7416a6a1764ea088f0bc1189ea58d5b592',)]]
|
|
|
|
sqlsynchash = sqlresults[0][0][0]
|
|
|
|
if len(sqlsynchash) != 40:
|
|
|
|
raise RuntimeError("malicious SHA1 returned by MySQL: %r" % sqlsynchash)
|
|
|
|
return sqlsynchash
|
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
def needsync(self):
|
2013-12-11 07:00:55 +04:00
|
|
|
"""Returns True if the local repo is not in sync with the database.
|
|
|
|
If it returns False, the heads and bookmarks match the database.
|
2018-09-26 02:04:16 +03:00
|
|
|
|
|
|
|
Also return bookmarks and heads.
|
2013-12-11 07:00:55 +04:00
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.sqlcursor.execute(
|
|
|
|
"""SELECT namespace, name, value
|
|
|
|
FROM revision_references WHERE repo = %s""",
|
|
|
|
(self.sqlreponame,),
|
|
|
|
)
|
2013-11-22 00:32:05 +04:00
|
|
|
sqlheads = set()
|
|
|
|
sqlbookmarks = {}
|
2014-01-24 06:40:55 +04:00
|
|
|
tip = -1
|
|
|
|
for namespace, name, value in self.sqlcursor:
|
2014-01-02 23:06:45 +04:00
|
|
|
if namespace == "heads":
|
2014-01-24 06:40:55 +04:00
|
|
|
sqlheads.add(bin(value))
|
2014-01-02 23:06:45 +04:00
|
|
|
elif namespace == "bookmarks":
|
2014-01-24 06:40:55 +04:00
|
|
|
sqlbookmarks[name] = bin(value)
|
|
|
|
elif namespace == "tip":
|
|
|
|
tip = int(value)
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2016-03-19 03:02:48 +03:00
|
|
|
# Since we don't have the lock right now, and since this is the
|
|
|
|
# first place we load the changelog and bookmarks off disk, it's
|
|
|
|
# important that we load bookmarks before the changelog here. This
|
|
|
|
# way we know that the bookmarks point to valid nodes. Otherwise,
|
|
|
|
# the bookmarks might change between us reading the changelog and
|
|
|
|
# the bookmark file.
|
2013-11-22 00:32:05 +04:00
|
|
|
bookmarks = self._bookmarks
|
2016-03-19 03:02:48 +03:00
|
|
|
heads = set(self.heads())
|
2013-11-22 00:32:05 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
outofsync = (
|
|
|
|
heads != sqlheads or bookmarks != sqlbookmarks or tip != len(self) - 1
|
|
|
|
)
|
2014-01-24 06:40:55 +04:00
|
|
|
return outofsync, sqlheads, sqlbookmarks, tip
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2015-12-14 23:34:06 +03:00
|
|
|
def synclimiter(self):
|
|
|
|
"""Attempts to acquire the lock used to rate limit how many
|
|
|
|
read-only clients perform database syncs at the same time. If None
|
|
|
|
is returned, it means the limiter was not acquired, and readonly
|
|
|
|
clients should not attempt to perform a sync."""
|
2019-11-21 18:43:29 +03:00
|
|
|
|
|
|
|
synclimit = self.ui.configint("hgsql", "synclimit")
|
|
|
|
if synclimit > 0:
|
|
|
|
lastsync = 0
|
|
|
|
try:
|
|
|
|
lastsync = int(self.sharedvfs.tryread("lastsqlsync"))
|
|
|
|
except Exception:
|
|
|
|
# This can happen if the file cannot be read or is not an int.
|
|
|
|
# Not fatal.
|
|
|
|
pass
|
|
|
|
if time.time() - lastsync < synclimit:
|
|
|
|
# Hit limit. Skip sync.
|
|
|
|
self._hgsqlnote("skipping database sync due to rate limit")
|
|
|
|
return None
|
2015-12-14 23:34:06 +03:00
|
|
|
try:
|
|
|
|
wait = 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
|
|
|
return self._lock(
|
|
|
|
self.svfs,
|
|
|
|
"synclimiter",
|
|
|
|
wait,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
_("repository %s") % self.origroot,
|
|
|
|
)
|
2015-12-14 23:34:06 +03:00
|
|
|
except error.LockHeld:
|
2019-11-21 18:43:29 +03:00
|
|
|
# Someone else is already checking and updating the repo
|
|
|
|
self._hgsqlnote(
|
|
|
|
"skipping database sync because another "
|
|
|
|
"process is already syncing"
|
|
|
|
)
|
2015-12-14 23:34:06 +03:00
|
|
|
return None
|
|
|
|
|
2018-09-29 02:46:45 +03:00
|
|
|
def pullfromdb(self, enforcepullfromdb=False):
|
2015-12-14 23:34:06 +03:00
|
|
|
"""Attempts to sync the local repository with the latest bits in the
|
|
|
|
database.
|
|
|
|
|
2018-09-29 02:46:45 +03:00
|
|
|
If `enforcepullfromdb` is False, the sync is on a best effort basis,
|
2015-12-14 23:34:06 +03:00
|
|
|
and the repo may not actually be up-to-date afterwards. If
|
2018-09-29 02:46:45 +03:00
|
|
|
`enforcepullfromdb` is True, we guarantee that the repo is up-to-date when
|
2015-12-14 23:34:06 +03:00
|
|
|
this function returns, otherwise an exception will be thrown."""
|
2016-12-07 04:10:25 +03:00
|
|
|
try:
|
|
|
|
self._issyncing = True
|
2018-09-29 02:46:45 +03:00
|
|
|
if enforcepullfromdb:
|
|
|
|
return self._pullfromdb(enforcepullfromdb)
|
2016-12-07 04:10:25 +03:00
|
|
|
else:
|
|
|
|
# For operations that do not require the absolute latest bits,
|
|
|
|
# only let one process update the repo at a time.
|
|
|
|
limiter = self.synclimiter()
|
|
|
|
if not limiter:
|
|
|
|
|
|
|
|
# It's important that we load bookmarks before the
|
|
|
|
# changelog. This way we know that the bookmarks point to
|
|
|
|
# valid nodes. Otherwise, the bookmarks might change between
|
|
|
|
# us reading the changelog and the bookmark file. Normally
|
|
|
|
# this would be done in needsync(), but since we're skipping
|
|
|
|
# the sync, we can do it here. Accessing self._bookmarks
|
|
|
|
# loads both the bookmarks and the changelog.
|
|
|
|
self._bookmarks
|
|
|
|
return
|
|
|
|
|
|
|
|
try:
|
2018-09-29 02:46:45 +03:00
|
|
|
return self._pullfromdb(enforcepullfromdb)
|
2016-12-07 04:10:25 +03:00
|
|
|
finally:
|
|
|
|
limiter.release()
|
|
|
|
finally:
|
|
|
|
self._issyncing = False
|
2015-12-14 23:34:06 +03:00
|
|
|
|
2018-09-29 02:46:45 +03:00
|
|
|
def _pullfromdb(self, enforcepullfromdb):
|
2018-09-26 02:04:12 +03:00
|
|
|
# MySQL could take a snapshot of the database view.
|
|
|
|
# Start a new transaction to get new changes.
|
|
|
|
self.sqlconn.rollback()
|
2018-09-26 02:04:16 +03:00
|
|
|
if self.ui.configbool("hgsql", "fastsynccheck"):
|
|
|
|
if not self.needsyncfast():
|
|
|
|
self.ui.debug("syncing not needed\n")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
if not self.needsync()[0]:
|
|
|
|
self.ui.debug("syncing not needed\n")
|
|
|
|
return
|
2018-09-25 06:39:40 +03:00
|
|
|
self.ui.debug("syncing with mysql\n")
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2015-09-30 01:41:30 +03:00
|
|
|
# Save a copy of the old manifest cache so we can put it back
|
|
|
|
# afterwards.
|
2016-11-17 21:51:40 +03:00
|
|
|
oldmancache = self.manifestlog._dirmancache
|
2015-09-30 01:41:30 +03:00
|
|
|
|
2018-08-10 07:07:09 +03:00
|
|
|
wlock = util.nullcontextmanager()
|
|
|
|
lock = util.nullcontextmanager()
|
2014-02-07 02:39:57 +04:00
|
|
|
try:
|
2018-09-29 02:46:45 +03:00
|
|
|
wlock = self.wlock(wait=enforcepullfromdb)
|
|
|
|
lock = self.lock(wait=enforcepullfromdb)
|
2014-02-07 02:39:57 +04:00
|
|
|
except error.LockHeld:
|
2018-09-29 02:46:45 +03:00
|
|
|
if enforcepullfromdb:
|
hgsql: Do not succeed in syncing if we failed to take locks
Summary:
We sometimes "succeeded" in syncing to the database if we could not get local write locks, because we assumed that the only time we can't get those locks is if we're not waiting for them. However, if another process holds the local write locks and is not releasing them, we hit a timeout.
If you're doing a write operation, this is harmless - the MySQL lock ensures that only one client at a time can be syncing anyway. However, for read operations run with `--forcesync`, this can cause us to succeed without syncing, breaking our contract with our users.
Test Plan:
Run the test suite and confirm no change.
Manually take the local write locks, run against the test DB `hg log -r . --forcesync`, and confirm that we fail correctly with this change but not without it.
Confirm that even with the local locks taken, `hg log -r .` returns success
Reviewers: durham
Reviewed By: durham
Subscribers: tja, #mercurial
Differential Revision: https://phabricator.intern.facebook.com/D3976452
Tasks: 13484857
Signature: t1:3976452:1475757832:e8370819bc345ce8e1bde0b057755803adb9896c
2016-10-07 15:25:21 +03:00
|
|
|
raise
|
2014-10-27 23:56:13 +03:00
|
|
|
# Oh well. Don't block this non-critical read-only operation.
|
2018-09-25 06:39:40 +03:00
|
|
|
self._hgsqlnote("skipping sync for current operation")
|
2014-02-07 02:39:57 +04:00
|
|
|
return
|
|
|
|
|
2018-08-10 07:07:09 +03:00
|
|
|
# Disable all pretxnclose hooks, since these revisions are
|
|
|
|
# technically already committed.
|
|
|
|
overrides = {}
|
|
|
|
for name, value in ui.configitems("hooks"):
|
2015-06-19 22:45:16 +03:00
|
|
|
# The hg-ssh wrapper installs a hook to block all writes. We need to
|
|
|
|
# circumvent this when we sync from the server.
|
2018-08-10 07:07:09 +03:00
|
|
|
if name.startswith("pretxnclose") or name in {
|
|
|
|
"pretxnopen.hg-ssh",
|
|
|
|
"pretxnopen.hg-rsh",
|
|
|
|
"pretxnopen.readonlyrejectpush",
|
|
|
|
}:
|
|
|
|
overrides[("hooks", name)] = None
|
|
|
|
|
|
|
|
with ui.configoverride(overrides, "hgsql"), wlock, lock:
|
2014-01-24 06:40:55 +04:00
|
|
|
outofsync, sqlheads, sqlbookmarks, fetchend = self.needsync()
|
2014-01-04 00:03:52 +04:00
|
|
|
if not outofsync:
|
2013-12-11 07:00:55 +04:00
|
|
|
return
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2018-09-25 06:39:40 +03:00
|
|
|
self._hgsqlnote(
|
|
|
|
"getting %s commits from database"
|
|
|
|
% (fetchend - len(self.changelog) + 1)
|
|
|
|
)
|
2018-09-29 02:46:45 +03:00
|
|
|
transaction = self.transaction("pullfromdb")
|
2013-11-22 00:32:05 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self.hook("presyncdb", throw=True)
|
2014-02-07 02:39:57 +04:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
try:
|
2013-12-11 07:00:55 +04:00
|
|
|
# Inspect the changelog now that we have the lock
|
|
|
|
fetchstart = len(self.changelog)
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2019-09-27 01:28:09 +03:00
|
|
|
q = queue.Queue()
|
2013-12-11 07:00:55 +04:00
|
|
|
abort = threading.Event()
|
2013-11-22 00:32:05 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
t = threading.Thread(
|
2019-09-27 01:28:09 +03:00
|
|
|
target=self.fetchthread, args=(q, abort, fetchstart, fetchend)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2013-12-11 07:00:55 +04:00
|
|
|
t.setDaemon(True)
|
|
|
|
try:
|
|
|
|
t.start()
|
2019-09-27 01:28:09 +03:00
|
|
|
addentries(self, q, transaction)
|
2013-12-11 07:00:55 +04:00
|
|
|
finally:
|
|
|
|
abort.set()
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
transaction.close()
|
|
|
|
finally:
|
|
|
|
transaction.release()
|
|
|
|
|
|
|
|
# We circumvent the changelog and manifest when we add entries to
|
|
|
|
# the revlogs. So clear all the caches.
|
|
|
|
self.invalidate()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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._filecache.pop("changelog", None)
|
|
|
|
self._filecache.pop("manifestlog", None)
|
|
|
|
self._filecache.pop("_phasecache", None)
|
2013-12-11 07:00:55 +04:00
|
|
|
|
2020-01-11 05:59:42 +03:00
|
|
|
# hgsql only writes to revlogs. Sync revlog to zstore.
|
|
|
|
# This is for test compatibility. Do not use it in production.
|
|
|
|
if "zstorecommitdata" in self.storerequirements:
|
|
|
|
if not util.istest():
|
|
|
|
raise error.Abort(
|
|
|
|
_(
|
|
|
|
"zstore commit data is forbidden for hgsql production use due to performance concerns"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self._syncrevlogtozstore()
|
|
|
|
|
2017-03-29 00:48:49 +03:00
|
|
|
# Refill the cache. We can't just reuse the exact contents of
|
|
|
|
# the old cached ctx, since the old ctx contains a reference to
|
|
|
|
# the old revlog, which is now out of date.
|
|
|
|
mfl = self.manifestlog
|
2020-01-29 03:25:29 +03:00
|
|
|
for dirname, lrucache in pycompat.iteritems(oldmancache):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 dirname == "":
|
2017-03-29 00:48:49 +03:00
|
|
|
for oldmfnode in lrucache:
|
|
|
|
oldmfctx = lrucache[oldmfnode]
|
|
|
|
if oldmfctx._data is not None:
|
|
|
|
mfl[oldmfnode]._data = oldmfctx._data
|
2015-09-30 01:41:30 +03:00
|
|
|
|
2014-01-04 00:03:52 +04:00
|
|
|
heads = set(self.heads())
|
|
|
|
heads.discard(nullid)
|
|
|
|
if heads != sqlheads:
|
|
|
|
raise CorruptionException("heads don't match after sync")
|
2013-12-11 07:00:55 +04:00
|
|
|
|
2014-01-24 06:40:55 +04:00
|
|
|
if len(self) - 1 != fetchend:
|
|
|
|
raise CorruptionException("tip doesn't match after sync")
|
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
self.disablesync = True
|
2018-09-29 02:46:45 +03:00
|
|
|
transaction = self.transaction("pullfromdb_bookmarks")
|
2013-12-11 07:00:55 +04:00
|
|
|
try:
|
|
|
|
bm = self._bookmarks
|
2017-03-30 00:47:53 +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
|
|
|
self.sqlcursor.execute(
|
|
|
|
"""SELECT name, value FROM revision_references
|
2014-01-02 23:06:45 +04:00
|
|
|
WHERE namespace = 'bookmarks' AND repo = %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
|
|
|
(self.sqlreponame,),
|
|
|
|
)
|
2017-03-30 00:47:53 +03:00
|
|
|
fetchedbookmarks = self.sqlcursor.fetchall()
|
|
|
|
|
2017-07-19 17:19:47 +03:00
|
|
|
changes = []
|
2017-03-30 00:47:53 +03:00
|
|
|
for name, node in fetchedbookmarks:
|
2013-12-11 07:00:55 +04:00
|
|
|
node = bin(node)
|
2017-07-19 17:19:47 +03:00
|
|
|
if node != bm.get(name):
|
|
|
|
changes.append((name, node))
|
2017-03-30 00:47:53 +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 deletebm in set(bm.keys()).difference(
|
|
|
|
k for k, v in fetchedbookmarks
|
|
|
|
):
|
2017-07-19 17:19:47 +03:00
|
|
|
changes.append((deletebm, None))
|
2017-03-30 00:47:53 +03:00
|
|
|
|
2017-07-19 17:19:47 +03:00
|
|
|
bm.applychanges(self, transaction, changes)
|
bookmarks: remove use of bookmark.write()
Summary:
Upstream has moved almost all bookmark writes to use bookmark.recordchange()
instead of write, which works inside a transaction. For hgsql, we need to
perform our bookmark writes inside a transaction now.
Additionally, we need to check self.disablesync inside committodb. disablesync
is used to allow us to write bookmarks during a syncdb without triggering the
bookmark writes to the db (since that would be a infinite loop). Previously we
only needed the syncdb check for bookmark writes, but since that has moved to
transactions, we need to do the check there too (committodb fires on
pretxnclose).
Lastly, in theory we could remove our wrapping of bookmark.write now, since
nothing should use it. But since upstream still has code for bookmark.write to
write bookmarks when outside a transaction, we can't remove our code just yet,
in case some extension still uses bookmark.write.
Test Plan: Ran the tests
Reviewers: ttung, lcharignon, #sourcecontrol, mitrandir
Reviewed By: mitrandir
Differential Revision: https://phabricator.fb.com/D2808601
Signature: t1:2808601:1452116992:ed34107a97ac633281ad8934266b35e3375cb247
2016-01-07 01:52:23 +03:00
|
|
|
transaction.close()
|
2013-12-11 07:00:55 +04:00
|
|
|
finally:
|
bookmarks: remove use of bookmark.write()
Summary:
Upstream has moved almost all bookmark writes to use bookmark.recordchange()
instead of write, which works inside a transaction. For hgsql, we need to
perform our bookmark writes inside a transaction now.
Additionally, we need to check self.disablesync inside committodb. disablesync
is used to allow us to write bookmarks during a syncdb without triggering the
bookmark writes to the db (since that would be a infinite loop). Previously we
only needed the syncdb check for bookmark writes, but since that has moved to
transactions, we need to do the check there too (committodb fires on
pretxnclose).
Lastly, in theory we could remove our wrapping of bookmark.write now, since
nothing should use it. But since upstream still has code for bookmark.write to
write bookmarks when outside a transaction, we can't remove our code just yet,
in case some extension still uses bookmark.write.
Test Plan: Ran the tests
Reviewers: ttung, lcharignon, #sourcecontrol, mitrandir
Reviewed By: mitrandir
Differential Revision: https://phabricator.fb.com/D2808601
Signature: t1:2808601:1452116992:ed34107a97ac633281ad8934266b35e3375cb247
2016-01-07 01:52:23 +03:00
|
|
|
transaction.release()
|
2013-12-11 07:00:55 +04:00
|
|
|
self.disablesync = False
|
2014-01-04 00:03:52 +04:00
|
|
|
|
|
|
|
if bm != sqlbookmarks:
|
|
|
|
raise CorruptionException("bookmarks don't match after sync")
|
2013-11-22 00:32:05 +04:00
|
|
|
|
2016-03-19 03:02:48 +03:00
|
|
|
# Since we just exited the lock, the changelog and bookmark
|
|
|
|
# in-memory structures will need to be reloaded. If we loaded
|
|
|
|
# changelog before bookmarks, we might accidentally load bookmarks
|
|
|
|
# that don't exist in the loaded changelog. So let's force loading
|
|
|
|
# bookmarks now.
|
|
|
|
bm = self._bookmarks
|
2019-11-21 18:43:29 +03:00
|
|
|
self.sharedvfs.write("lastsqlsync", str(int(time.time())))
|
2016-03-19 03:02:48 +03:00
|
|
|
|
2014-01-24 06:40:55 +04:00
|
|
|
def fetchthread(self, queue, abort, fetchstart, fetchend):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Fetches every revision from fetchstart to fetchend (inclusive)
|
|
|
|
and places them on the queue. This function is meant to run on a
|
|
|
|
background thread and listens to the abort event to abort early.
|
|
|
|
"""
|
2013-11-22 00:32:05 +04:00
|
|
|
clrev = fetchstart
|
|
|
|
chunksize = 1000
|
2015-08-12 21:10:25 +03:00
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
if abort.isSet():
|
|
|
|
break
|
|
|
|
|
|
|
|
maxrev = min(clrev + chunksize, fetchend + 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
|
|
|
self.sqlcursor.execute(
|
|
|
|
"""SELECT path, chunk, chunkcount,
|
2015-08-12 21:10:25 +03:00
|
|
|
linkrev, entry, data0, data1 FROM revisions WHERE repo = %s
|
|
|
|
AND linkrev > %s AND linkrev < %s ORDER BY linkrev ASC""",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.sqlreponame, clrev - 1, maxrev),
|
|
|
|
)
|
2015-08-12 21:10:25 +03:00
|
|
|
|
|
|
|
# Put split chunks back together into a single revision
|
|
|
|
groupedrevdata = {}
|
|
|
|
for revdata in self.sqlcursor:
|
|
|
|
name = revdata[0]
|
|
|
|
chunk = revdata[1]
|
|
|
|
linkrev = revdata[3]
|
2018-04-24 20:56:46 +03:00
|
|
|
|
|
|
|
# Some versions of the MySQL Python connector have a
|
|
|
|
# bug where it converts aa column containing a single
|
|
|
|
# null byte into None. hgsql needs this workaround to
|
|
|
|
# handle file revisions that are exactly a single null
|
|
|
|
# byte.
|
|
|
|
#
|
|
|
|
# The only column that can contain a single null byte
|
|
|
|
# here is data1 (column 6):
|
|
|
|
# * path is a path, so Unix rules prohibit it from
|
|
|
|
# containing null bytes.
|
|
|
|
# * chunk, chunkcount and linkrev are integers.
|
|
|
|
# * entry is a binary blob that matches a revlog index
|
|
|
|
# entry, which cannot be "\0".
|
|
|
|
# * data0 is either empty or "u".
|
|
|
|
if revdata[6] 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
|
|
|
revdata = revdata[:6] + (b"\0",)
|
2018-04-24 20:56:46 +03:00
|
|
|
|
2015-08-12 21:10:25 +03:00
|
|
|
groupedrevdata.setdefault((name, linkrev), {})[chunk] = revdata
|
|
|
|
|
|
|
|
if not groupedrevdata:
|
|
|
|
break
|
|
|
|
|
|
|
|
fullrevisions = []
|
2020-01-29 03:25:29 +03:00
|
|
|
for chunks in pycompat.itervalues(groupedrevdata):
|
2015-08-12 21:10:25 +03:00
|
|
|
chunkcount = chunks[0][2]
|
|
|
|
if chunkcount == 1:
|
|
|
|
fullrevisions.append(chunks[0])
|
|
|
|
elif chunkcount == len(chunks):
|
|
|
|
fullchunk = list(chunks[0])
|
|
|
|
data1 = ""
|
|
|
|
for i in range(0, chunkcount):
|
|
|
|
data1 += chunks[i][6]
|
|
|
|
fullchunk[6] = data1
|
|
|
|
fullrevisions.append(tuple(fullchunk))
|
|
|
|
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
|
|
|
raise Exception(
|
|
|
|
"missing revision chunk - expected %s got %s"
|
|
|
|
% (chunkcount, len(chunks))
|
|
|
|
)
|
2015-08-12 21:10: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
|
|
|
fullrevisions = sorted(
|
|
|
|
fullrevisions, key=lambda revdata: revdata[3]
|
|
|
|
)
|
2015-08-12 21:10:25 +03:00
|
|
|
for revdata in fullrevisions:
|
|
|
|
queue.put(revdata)
|
|
|
|
|
|
|
|
clrev += chunksize
|
|
|
|
except Exception as ex:
|
|
|
|
queue.put(ex)
|
|
|
|
return
|
2013-10-31 21:37:49 +04:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
queue.put(False)
|
2013-10-31 21:37:49 +04:00
|
|
|
|
2014-02-19 05:16:45 +04:00
|
|
|
def pushkey(self, namespace, key, old, new):
|
|
|
|
def _pushkey():
|
|
|
|
return super(sqllocalrepo, self).pushkey(namespace, key, old, new)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 executewithsql(self, _pushkey, namespace == "bookmarks")
|
2014-02-19 05:16:45 +04:00
|
|
|
|
2018-06-27 01:03:59 +03:00
|
|
|
def _updaterevisionreferences(self):
|
|
|
|
reponame = self.sqlreponame
|
|
|
|
cursor = self.sqlcursor
|
|
|
|
|
|
|
|
# Compute new heads, and delete old heads
|
|
|
|
newheads = set(hex(n) for n in self.heads())
|
|
|
|
oldheads = []
|
|
|
|
cursor.execute(
|
|
|
|
"SELECT value FROM revision_references "
|
|
|
|
"WHERE repo = %s AND namespace='heads'",
|
|
|
|
(reponame,),
|
|
|
|
)
|
2019-04-13 13:16:30 +03:00
|
|
|
headsindb = cursor.fetchall()
|
|
|
|
for head in headsindb:
|
2018-06-27 01:03:59 +03:00
|
|
|
head = head[0]
|
|
|
|
if head in newheads:
|
|
|
|
newheads.discard(head)
|
|
|
|
else:
|
|
|
|
oldheads.append(head)
|
|
|
|
|
|
|
|
if oldheads:
|
|
|
|
headargs = ",".join(["%s"] * len(oldheads))
|
|
|
|
cursor.execute(
|
|
|
|
"DELETE revision_references FROM revision_references "
|
|
|
|
+ "FORCE INDEX (bookmarkindex) "
|
|
|
|
+ "WHERE namespace = 'heads' "
|
|
|
|
+ "AND repo = %s AND value IN ("
|
|
|
|
+ headargs
|
|
|
|
+ ")",
|
|
|
|
(reponame,) + tuple(oldheads),
|
|
|
|
)
|
|
|
|
|
|
|
|
# Compute new bookmarks, and delete old bookmarks
|
2020-01-29 03:25:29 +03:00
|
|
|
newbookmarks = dict(
|
|
|
|
(k, hex(v)) for k, v in pycompat.iteritems(self._bookmarks)
|
|
|
|
)
|
2018-06-27 01:03:59 +03:00
|
|
|
oldbookmarks = []
|
|
|
|
cursor.execute(
|
|
|
|
"SELECT name, value FROM revision_references "
|
|
|
|
"WHERE namespace = 'bookmarks' AND repo = %s",
|
|
|
|
(reponame,),
|
|
|
|
)
|
2019-04-13 13:16:30 +03:00
|
|
|
bookmarksindb = cursor.fetchall()
|
|
|
|
for k, v in bookmarksindb:
|
2018-06-27 01:03:59 +03:00
|
|
|
if newbookmarks.get(k) == v:
|
|
|
|
del newbookmarks[k]
|
|
|
|
else:
|
|
|
|
oldbookmarks.append(k)
|
|
|
|
|
|
|
|
if oldbookmarks:
|
|
|
|
bookargs = ",".join(["%s"] * len(oldbookmarks))
|
|
|
|
cursor.execute(
|
|
|
|
"DELETE revision_references FROM revision_references "
|
|
|
|
+ "FORCE INDEX (bookmarkindex) "
|
|
|
|
+ "WHERE namespace = 'bookmarks' AND repo = %s "
|
|
|
|
+ "AND name IN ("
|
|
|
|
+ bookargs
|
|
|
|
+ ")",
|
|
|
|
(repo.sqlreponame,) + tuple(oldbookmarks),
|
|
|
|
)
|
|
|
|
|
|
|
|
tmpl = []
|
|
|
|
values = []
|
|
|
|
for head in newheads:
|
|
|
|
tmpl.append("(%s, 'heads', NULL, %s)")
|
|
|
|
values.append(reponame)
|
|
|
|
values.append(head)
|
|
|
|
|
2020-01-29 03:25:29 +03:00
|
|
|
for k, v in pycompat.iteritems(newbookmarks):
|
2018-06-27 01:03:59 +03:00
|
|
|
tmpl.append("(%s, 'bookmarks', %s, %s)")
|
|
|
|
values.append(repo.sqlreponame)
|
|
|
|
values.append(k)
|
|
|
|
values.append(v)
|
|
|
|
|
|
|
|
if tmpl:
|
|
|
|
cursor.execute(
|
|
|
|
"INSERT INTO "
|
|
|
|
+ "revision_references(repo, namespace, name, value) "
|
|
|
|
+ "VALUES %s" % ",".join(tmpl),
|
|
|
|
tuple(values),
|
|
|
|
)
|
|
|
|
|
|
|
|
# revision_references has multiple keys (primary key, and a unique
|
|
|
|
# index), so mysql gives a warning when using ON DUPLICATE KEY since
|
|
|
|
# it would only update one row despite multiple key duplicates. This
|
|
|
|
# doesn't matter for us, since we know there is only one row that
|
|
|
|
# will share the same key. So suppress the warning.
|
|
|
|
cursor.execute(
|
|
|
|
"INSERT INTO revision_references(repo, namespace, name, value) "
|
|
|
|
+ "VALUES(%s, 'tip', 'tip', %s) "
|
|
|
|
+ "ON DUPLICATE KEY UPDATE value=%s",
|
|
|
|
(reponame, len(self) - 1, len(self) - 1),
|
|
|
|
)
|
|
|
|
|
2014-12-02 04:30:20 +03:00
|
|
|
def committodb(self, tr):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Commits all pending revisions to the database
|
|
|
|
"""
|
2017-04-02 01:25:44 +03:00
|
|
|
if self.disablesync:
|
|
|
|
return
|
|
|
|
|
2014-01-03 00:19:50 +04:00
|
|
|
if self.sqlconn == 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 util.Abort(
|
2018-06-27 01:03:59 +03:00
|
|
|
"invalid repo change - only hg push and pull are allowed"
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2014-01-03 00:19:50 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if not self.pendingrevs and not "bookmark_moved" in tr.hookargs:
|
2014-08-26 14:51:11 +04:00
|
|
|
return
|
|
|
|
|
2014-01-03 00:19:50 +04:00
|
|
|
try:
|
2018-07-23 22:51:49 +03:00
|
|
|
self._committodb(self.pendingrevs)
|
2015-06-09 03:35:09 +03:00
|
|
|
|
2018-06-27 01:03:59 +03:00
|
|
|
# Just to be super sure, check the write lock before doing the
|
|
|
|
# final commit
|
2018-09-25 20:57:06 +03:00
|
|
|
if not self.hassqlwritelock():
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 Exception(
|
2018-06-27 01:03:59 +03:00
|
|
|
"attempting to write to sql "
|
|
|
|
+ "without holding %s (precommit)" % writelock
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2014-01-03 00:19:50 +04:00
|
|
|
self.sqlconn.commit()
|
|
|
|
except:
|
|
|
|
self.sqlconn.rollback()
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
del self.pendingrevs[:]
|
|
|
|
|
2018-07-23 22:51:49 +03:00
|
|
|
def _committodb(self, revisions, ignoreduplicates=False):
|
|
|
|
if revisions:
|
|
|
|
self._validatependingrevs(revisions, ignoreduplicates=ignoreduplicates)
|
|
|
|
|
|
|
|
self._addrevstosql(revisions, ignoreduplicates=ignoreduplicates)
|
|
|
|
self._updaterevisionreferences()
|
|
|
|
|
2018-06-02 02:32:48 +03:00
|
|
|
def _addrevstosql(self, revisions, ignoreduplicates=False):
|
|
|
|
"""Inserts the given revisions into the `revisions` table. If
|
|
|
|
`ignoreduplicates` is True, the insert for that row is a no-op
|
|
|
|
to allow ignoring existing rows during a bulk update.
|
|
|
|
"""
|
2018-06-06 08:05:00 +03:00
|
|
|
|
2018-05-21 21:02:47 +03:00
|
|
|
def insert(args, values):
|
2018-06-02 02:32:48 +03:00
|
|
|
query = (
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"INSERT INTO revisions(repo, path, "
|
2018-05-21 21:02:47 +03:00
|
|
|
"chunk, chunkcount, linkrev, rev, node, entry, "
|
2018-06-02 02:32:48 +03:00
|
|
|
"data0, data1, createdtime) VALUES %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
|
|
|
)
|
2018-06-02 02:32:48 +03:00
|
|
|
if ignoreduplicates:
|
|
|
|
# Do nothing
|
|
|
|
query += " ON DUPLICATE KEY UPDATE repo = %%s"
|
|
|
|
args = list(args)
|
|
|
|
values = list(values)
|
|
|
|
values.append(values[0])
|
|
|
|
|
|
|
|
argstring = ",".join(args)
|
|
|
|
cursor.execute(query % argstring, values)
|
2018-05-21 21:02:47 +03:00
|
|
|
|
|
|
|
reponame = self.sqlreponame
|
|
|
|
cursor = self.sqlcursor
|
|
|
|
|
|
|
|
maxcommitsize = self.maxcommitsize
|
|
|
|
maxinsertsize = self.maxinsertsize
|
|
|
|
maxrowsize = self.maxrowsize
|
|
|
|
commitsize = 0
|
|
|
|
insertsize = 0
|
|
|
|
|
|
|
|
args = []
|
|
|
|
values = []
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
now = time.strftime("%Y-%m-%d %H:%M:%S")
|
2018-05-21 21:02:47 +03:00
|
|
|
for revision in revisions:
|
|
|
|
path, linkrev, rev, node, entry, data0, data1 = revision
|
|
|
|
|
|
|
|
start = 0
|
|
|
|
chunk = 0
|
|
|
|
datalen = len(data1)
|
|
|
|
chunkcount = datalen / maxrowsize
|
|
|
|
if datalen % maxrowsize != 0 or datalen == 0:
|
|
|
|
chunkcount += 1
|
|
|
|
|
|
|
|
# We keep row size down by breaking large revisions down into
|
|
|
|
# smaller chunks.
|
|
|
|
while chunk == 0 or start < len(data1):
|
|
|
|
end = min(len(data1), start + maxrowsize)
|
|
|
|
datachunk = data1[start:end]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
args.append("(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
|
|
|
|
values.extend(
|
|
|
|
(
|
|
|
|
reponame,
|
|
|
|
path,
|
|
|
|
chunk,
|
|
|
|
chunkcount,
|
|
|
|
linkrev,
|
|
|
|
rev,
|
|
|
|
node,
|
|
|
|
entry,
|
|
|
|
data0,
|
|
|
|
datachunk,
|
|
|
|
now,
|
|
|
|
)
|
|
|
|
)
|
2018-05-21 21:02:47 +03:00
|
|
|
|
|
|
|
size = len(datachunk)
|
|
|
|
commitsize += size
|
|
|
|
insertsize += size
|
|
|
|
|
|
|
|
chunk += 1
|
|
|
|
start = end
|
|
|
|
|
|
|
|
# Minimize roundtrips by doing bulk inserts
|
|
|
|
if insertsize > maxinsertsize:
|
|
|
|
insert(args, values)
|
|
|
|
del args[:]
|
|
|
|
del values[:]
|
|
|
|
insertsize = 0
|
|
|
|
|
|
|
|
# MySQL transactions can only reach a certain size, so we commit
|
|
|
|
# every so often. As long as we don't update the tip pushkey,
|
|
|
|
# this is ok.
|
|
|
|
if commitsize > maxcommitsize:
|
|
|
|
self.sqlconn.commit()
|
|
|
|
commitsize = 0
|
|
|
|
|
|
|
|
if args:
|
|
|
|
insert(args, values)
|
|
|
|
|
|
|
|
# commit at the end just to make sure we're clean
|
|
|
|
self.sqlconn.commit()
|
|
|
|
|
2018-07-23 22:51:49 +03:00
|
|
|
def _validatependingrevs(self, revisions, ignoreduplicates=False):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Validates that the current pending revisions will be valid when
|
2014-01-22 04:09:08 +04:00
|
|
|
written to the database.
|
|
|
|
"""
|
|
|
|
reponame = self.sqlreponame
|
|
|
|
cursor = self.sqlcursor
|
|
|
|
|
2014-03-12 23:52:27 +04:00
|
|
|
# Ensure we hold the write lock
|
2018-09-25 20:57:06 +03:00
|
|
|
if not self.hassqlwritelock():
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 Exception(
|
|
|
|
"attempting to write to sql without holding %s (prevalidate)"
|
|
|
|
% writelock
|
|
|
|
)
|
2014-03-12 23:52:27 +04:00
|
|
|
|
2014-01-22 04:09:08 +04:00
|
|
|
# Validate that we are appending to the correct linkrev
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cursor.execute(
|
|
|
|
"""SELECT value FROM revision_references WHERE repo = %s AND
|
|
|
|
namespace = 'tip'""",
|
|
|
|
(reponame,),
|
|
|
|
)
|
2014-01-24 06:40:55 +04:00
|
|
|
tipresults = cursor.fetchall()
|
|
|
|
if len(tipresults) == 0:
|
|
|
|
maxlinkrev = -1
|
|
|
|
elif len(tipresults) == 1:
|
|
|
|
maxlinkrev = int(tipresults[0][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
|
|
|
raise CorruptionException(
|
2019-03-13 21:36:22 +03:00
|
|
|
("multiple tips for %s in the database") % reponame
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2014-01-24 06:40:55 +04:00
|
|
|
|
2018-07-23 22:51:49 +03:00
|
|
|
if (not ignoreduplicates) and (
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
not util.safehasattr(self, "sqlreplaytransaction")
|
|
|
|
or not self.sqlreplaytransaction
|
|
|
|
):
|
2018-07-23 22:51:49 +03:00
|
|
|
minlinkrev = min(revisions, key=lambda x: x[1])[1]
|
2017-03-30 23:36:37 +03:00
|
|
|
if maxlinkrev == None or maxlinkrev != minlinkrev - 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
|
|
|
raise CorruptionException(
|
|
|
|
"attempting to write non-sequential "
|
|
|
|
+ "linkrev %s, expected %s" % (minlinkrev, maxlinkrev + 1)
|
|
|
|
)
|
2014-01-24 06:40:55 +04:00
|
|
|
|
|
|
|
# Clean up excess revisions left from interrupted commits.
|
|
|
|
# Since MySQL can only hold so much data in a transaction, we allow
|
|
|
|
# committing across multiple db transactions. That means if
|
|
|
|
# the commit is interrupted, the next transaction needs to clean
|
2014-01-24 07:22:49 +04:00
|
|
|
# up bad revisions.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cursor.execute(
|
|
|
|
"""DELETE FROM revisions WHERE repo = %s AND
|
|
|
|
linkrev > %s""",
|
|
|
|
(reponame, maxlinkrev),
|
|
|
|
)
|
2014-01-22 04:09:08 +04:00
|
|
|
|
|
|
|
# Validate that all rev dependencies (base, p1, p2) have the same
|
|
|
|
# node in the database
|
2018-07-23 22:51:49 +03:00
|
|
|
pending = set([(path, rev) for path, _, rev, _, _, _, _ in revisions])
|
2014-01-22 04:09:08 +04:00
|
|
|
expectedrevs = set()
|
2018-07-23 22:51:49 +03:00
|
|
|
for revision in revisions:
|
2014-01-22 04:09:08 +04:00
|
|
|
path, linkrev, rev, node, entry, data0, data1 = revision
|
2017-07-17 15:49:39 +03:00
|
|
|
e = revlog.indexformatng.unpack(entry)
|
2014-01-22 04:09:08 +04:00
|
|
|
_, _, _, base, _, p1r, p2r, _ = e
|
|
|
|
|
|
|
|
if p1r != nullrev and not (path, p1r) in pending:
|
|
|
|
expectedrevs.add((path, p1r))
|
|
|
|
if p2r != nullrev and not (path, p2r) in pending:
|
|
|
|
expectedrevs.add((path, p2r))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 base != nullrev and base != rev and not (path, base) in pending:
|
2014-01-22 04:09:08 +04:00
|
|
|
expectedrevs.add((path, base))
|
|
|
|
|
|
|
|
if not expectedrevs:
|
|
|
|
return
|
|
|
|
|
2015-08-29 04:14:19 +03:00
|
|
|
missingrevs = []
|
|
|
|
expectedlist = list(expectedrevs)
|
|
|
|
expectedcount = len(expectedrevs)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
batchsize = self.ui.configint("hgsql", "verifybatchsize")
|
2015-08-29 04:14:19 +03:00
|
|
|
i = 0
|
|
|
|
while i < expectedcount:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
checkrevs = set(expectedlist[i : i + batchsize])
|
2015-08-29 04:14:19 +03:00
|
|
|
i += batchsize
|
|
|
|
|
|
|
|
whereclauses = []
|
|
|
|
args = []
|
|
|
|
args.append(reponame)
|
|
|
|
for path, rev in checkrevs:
|
|
|
|
whereclauses.append("(path, rev, chunk) = (%s, %s, 0)")
|
|
|
|
args.append(path)
|
|
|
|
args.append(rev)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
whereclause = " OR ".join(whereclauses)
|
|
|
|
cursor.execute(
|
|
|
|
"""SELECT path, rev, node FROM revisions WHERE
|
|
|
|
repo = %s AND ("""
|
|
|
|
+ whereclause
|
|
|
|
+ ")",
|
|
|
|
args,
|
|
|
|
)
|
2015-08-29 04:14:19 +03:00
|
|
|
|
|
|
|
for path, rev, node in cursor:
|
|
|
|
rev = int(rev)
|
|
|
|
checkrevs.remove((path, rev))
|
|
|
|
rl = 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 path == "00changelog.i":
|
2015-08-29 04:14:19 +03:00
|
|
|
rl = self.changelog
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 path == "00manifest.i":
|
2016-11-17 21:51:40 +03:00
|
|
|
rl = self.manifestlog._revlog
|
2015-08-29 04:14:19 +03:00
|
|
|
else:
|
2019-05-23 20:46:21 +03:00
|
|
|
rl = revlog.revlog(self.svfs, path, mmaplargeindex=True)
|
2015-08-29 04:14:19 +03:00
|
|
|
localnode = hex(rl.node(rev))
|
|
|
|
if localnode != node:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 CorruptionException(
|
2018-09-27 02:32:10 +03:00
|
|
|
("expected node %s at rev %d of %s but found %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
|
|
|
% (node, rev, path, localnode)
|
|
|
|
)
|
2015-08-29 04:14:19 +03:00
|
|
|
|
|
|
|
if len(checkrevs) > 0:
|
|
|
|
missingrevs.extend(checkrevs)
|
|
|
|
|
|
|
|
if missingrevs:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 CorruptionException(
|
|
|
|
(
|
|
|
|
"unable to verify %d dependent "
|
|
|
|
+ "revisions before adding a commit"
|
|
|
|
)
|
|
|
|
% (len(missingrevs))
|
|
|
|
)
|
2014-01-22 04:09:08 +04:00
|
|
|
|
2016-01-07 03:37:46 +03:00
|
|
|
def _afterlock(self, callback):
|
2018-09-25 20:57:06 +03:00
|
|
|
if self.hassqlwritelock(checkserver=False):
|
2016-01-07 03:37:46 +03:00
|
|
|
self.sqlpostrelease.append(callback)
|
|
|
|
else:
|
|
|
|
return super(sqllocalrepo, self)._afterlock(callback)
|
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
ui = repo.ui
|
2014-01-24 07:22:49 +04:00
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
sqlargs = {}
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
sqlargs["host"] = ui.config("hgsql", "host")
|
|
|
|
sqlargs["database"] = ui.config("hgsql", "database")
|
|
|
|
sqlargs["user"] = ui.config("hgsql", "user")
|
|
|
|
sqlargs["port"] = ui.configint("hgsql", "port")
|
2018-10-31 05:25:32 +03:00
|
|
|
sqlargs["connection_timeout"] = ui.configint("hgsql", "sockettimeout")
|
2017-10-25 01:15:42 +03:00
|
|
|
password = ui.config("hgsql", "password")
|
2013-12-11 07:00:55 +04:00
|
|
|
if password:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
sqlargs["password"] = password
|
2013-12-11 07:00:55 +04:00
|
|
|
|
2014-01-24 07:22:49 +04:00
|
|
|
repo.sqlargs = sqlargs
|
|
|
|
|
2014-01-02 23:06:45 +04:00
|
|
|
repo.sqlreponame = ui.config("hgsql", "reponame")
|
|
|
|
if not repo.sqlreponame:
|
|
|
|
raise Exception("missing hgsql.reponame")
|
2017-10-25 01:15:42 +03:00
|
|
|
repo.maxcommitsize = ui.configbytes("hgsql", "maxcommitsize")
|
|
|
|
repo.maxinsertsize = ui.configbytes("hgsql", "maxinsertsize")
|
|
|
|
repo.maxrowsize = ui.configbytes("hgsql", "maxrowsize")
|
2013-11-22 00:32:05 +04:00
|
|
|
repo.sqlconn = None
|
|
|
|
repo.sqlcursor = None
|
|
|
|
repo.disablesync = False
|
|
|
|
repo.pendingrevs = []
|
2014-01-29 08:46:23 +04:00
|
|
|
repo.heldlocks = set()
|
2016-01-07 03:37:46 +03:00
|
|
|
repo.sqlpostrelease = []
|
2016-12-07 04:10:25 +03:00
|
|
|
repo._issyncing = False
|
2014-01-24 06:40:55 +04:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
repo.__class__ = sqllocalrepo
|
2013-10-31 21:37:49 +04:00
|
|
|
|
2018-09-08 02:41:35 +03:00
|
|
|
class CustomConverter(mysql.connector.conversion.MySQLConverter):
|
|
|
|
"""Ensure that all values being returned are returned as python string
|
|
|
|
(versus the default byte arrays)."""
|
|
|
|
|
|
|
|
def _STRING_to_python(self, value, dsc=None):
|
|
|
|
return str(value)
|
|
|
|
|
|
|
|
def _VAR_STRING_to_python(self, value, dsc=None):
|
|
|
|
return str(value)
|
|
|
|
|
|
|
|
def _BLOB_to_python(self, value, dsc=None):
|
|
|
|
return str(value)
|
|
|
|
|
2019-02-12 00:37:59 +03:00
|
|
|
def _bytearray_to_mysql(self, value, dsc=None):
|
|
|
|
return str(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
|
|
|
|
2013-10-31 21:37:49 +04:00
|
|
|
class bufferedopener(object):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Opener implementation that buffers all writes in memory until
|
|
|
|
flush or close is called.
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-10-31 21:37:49 +04:00
|
|
|
def __init__(self, opener, path, mode):
|
|
|
|
self.opener = opener
|
|
|
|
self.path = path
|
|
|
|
self.mode = mode
|
|
|
|
self.buffer = []
|
|
|
|
self.closed = False
|
|
|
|
|
|
|
|
def write(self, value):
|
2013-12-11 07:00:55 +04:00
|
|
|
if self.closed:
|
2014-01-24 07:22:49 +04:00
|
|
|
raise Exception("attempted to write to a closed bufferedopener")
|
2013-10-31 21:37:49 +04:00
|
|
|
self.buffer.append(value)
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
buffer = self.buffer
|
|
|
|
self.buffer = []
|
2014-10-27 23:56:13 +03:00
|
|
|
|
2013-10-31 21:37:49 +04:00
|
|
|
if buffer:
|
|
|
|
fp = self.opener(self.path, self.mode)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
fp.write("".join(buffer))
|
2013-10-31 21:37:49 +04:00
|
|
|
fp.close()
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
self.flush()
|
|
|
|
self.closed = 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
|
|
|
|
2017-03-30 19:39:50 +03:00
|
|
|
def addentries(repo, queue, transaction, ignoreexisting=False):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Reads new rev entries from a queue and writes them to a buffered
|
|
|
|
revlog. At the end it flushes all the new data to disk.
|
|
|
|
"""
|
2015-07-09 07:23:54 +03:00
|
|
|
opener = repo.svfs
|
2013-10-18 03:46:12 +04:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
revlogs = {}
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
def writeentry(revdata):
|
2014-01-24 07:22:49 +04:00
|
|
|
# Instantiates pseudo-revlogs for us to write data directly to
|
2014-01-02 23:06:45 +04:00
|
|
|
path, chunk, chunkcount, link, entry, data0, data1 = revdata
|
2013-11-22 00:32:05 +04:00
|
|
|
revlog = revlogs.get(path)
|
|
|
|
if not revlog:
|
|
|
|
revlog = EntryRevlog(opener, path)
|
|
|
|
revlogs[path] = revlog
|
|
|
|
|
2014-01-24 07:22:49 +04:00
|
|
|
# Replace the existing openers with buffered ones so we can
|
|
|
|
# perform the flush to disk all at once at the end.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 hasattr(revlog, "ifh") or revlog.ifh.closed:
|
2013-11-22 00:32:05 +04:00
|
|
|
dfh = None
|
|
|
|
if not revlog._inline:
|
2015-11-05 23:57:17 +03:00
|
|
|
dfh = bufferedopener(opener, revlog.datafile, "a+")
|
2013-11-22 00:32:05 +04:00
|
|
|
ifh = bufferedopener(opener, revlog.indexfile, "a+")
|
|
|
|
revlog.ifh = ifh
|
|
|
|
revlog.dfh = dfh
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revlog.addentry(
|
|
|
|
transaction,
|
|
|
|
revlog.ifh,
|
|
|
|
revlog.dfh,
|
|
|
|
entry,
|
|
|
|
data0,
|
|
|
|
data1,
|
|
|
|
ignoreexisting=ignoreexisting,
|
|
|
|
)
|
2013-11-22 00:32:05 +04:00
|
|
|
|
|
|
|
leftover = None
|
|
|
|
exit = False
|
2013-12-11 07:00:55 +04:00
|
|
|
|
2014-10-27 23:56:13 +03:00
|
|
|
# Read one linkrev at a time from the queue
|
2013-11-22 00:32:05 +04:00
|
|
|
while not exit:
|
|
|
|
currentlinkrev = -1
|
|
|
|
|
|
|
|
revisions = []
|
|
|
|
if leftover:
|
|
|
|
revisions.append(leftover)
|
|
|
|
leftover = None
|
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
# Read everything from the current linkrev
|
2013-10-31 21:37:49 +04:00
|
|
|
while True:
|
2013-11-22 00:32:05 +04:00
|
|
|
revdata = queue.get()
|
|
|
|
if not revdata:
|
|
|
|
exit = True
|
2013-10-31 21:37:49 +04:00
|
|
|
break
|
|
|
|
|
2015-08-12 21:10:25 +03:00
|
|
|
# The background thread had an exception, rethrow from the
|
|
|
|
# foreground thread.
|
|
|
|
if isinstance(revdata, Exception):
|
|
|
|
raise revdata
|
|
|
|
|
2014-01-02 23:06:45 +04:00
|
|
|
linkrev = revdata[3]
|
2013-11-22 00:32:05 +04:00
|
|
|
if currentlinkrev == -1:
|
|
|
|
currentlinkrev = linkrev
|
|
|
|
if linkrev == currentlinkrev:
|
|
|
|
revisions.append(revdata)
|
|
|
|
elif linkrev < currentlinkrev:
|
2014-01-24 07:22:49 +04:00
|
|
|
raise CorruptionException("SQL data is not in linkrev order")
|
2013-11-22 00:32:05 +04:00
|
|
|
else:
|
|
|
|
leftover = revdata
|
|
|
|
currentlinkrev = linkrev
|
|
|
|
break
|
2013-10-29 23:55:14 +04:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
if not revisions:
|
|
|
|
continue
|
2013-10-31 21:37:49 +04:00
|
|
|
|
2013-11-22 00:32:05 +04:00
|
|
|
for revdata in revisions:
|
|
|
|
writeentry(revdata)
|
2013-10-29 23:55:14 +04:00
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
# Flush filelogs, then manifest, then changelog
|
|
|
|
changelog = revlogs.pop("00changelog.i", None)
|
|
|
|
manifest = revlogs.pop("00manifest.i", None)
|
2013-10-31 21:37:49 +04:00
|
|
|
|
2013-12-11 07:00:55 +04:00
|
|
|
def flushrevlog(revlog):
|
2013-11-22 00:32:05 +04:00
|
|
|
if not revlog.ifh.closed:
|
|
|
|
revlog.ifh.flush()
|
|
|
|
if revlog.dfh and not revlog.dfh.closed:
|
|
|
|
revlog.dfh.flush()
|
2013-12-11 07:00:55 +04:00
|
|
|
|
2020-01-29 03:25:29 +03:00
|
|
|
for filelog in pycompat.itervalues(revlogs):
|
2013-12-11 07:00:55 +04:00
|
|
|
flushrevlog(filelog)
|
|
|
|
|
|
|
|
if manifest:
|
|
|
|
flushrevlog(manifest)
|
|
|
|
if changelog:
|
|
|
|
flushrevlog(changelog)
|
2013-10-18 03:46:12 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-10-18 03:46:12 +04:00
|
|
|
class EntryRevlog(revlog.revlog):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Pseudo-revlog implementation that allows applying data directly to
|
|
|
|
the end of the revlog.
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-04-19 08:07:07 +03:00
|
|
|
def __init__(self, opener, path):
|
|
|
|
super(EntryRevlog, self).__init__(opener, path)
|
|
|
|
|
|
|
|
# This is a copy of the changelog init implementation.
|
|
|
|
# It hard codes no generaldelta.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 path == "00changelog.i" and self._initempty:
|
2019-08-31 00:56:12 +03:00
|
|
|
self.version &= ~(revlog.FLAG_GENERALDELTA | revlog.FLAG_INLINE_DATA)
|
2016-04-19 08:07:07 +03:00
|
|
|
self._generaldelta = False
|
2019-08-31 00:56:12 +03:00
|
|
|
self._inline = False
|
2016-04-19 08:07:07 +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
|
|
|
def addentry(
|
|
|
|
self, transaction, ifh, dfh, entry, data0, data1, ignoreexisting=False
|
|
|
|
):
|
2013-10-18 04:15:41 +04:00
|
|
|
curr = len(self)
|
2013-12-11 07:00:55 +04:00
|
|
|
offset = self.end(curr - 1)
|
2013-10-18 04:15:41 +04:00
|
|
|
|
2017-07-17 15:49:39 +03:00
|
|
|
e = revlog.indexformatng.unpack(entry)
|
2013-10-29 05:57:18 +04:00
|
|
|
offsettype, datalen, textlen, base, link, p1r, p2r, node = e
|
2014-01-24 07:22:49 +04:00
|
|
|
|
|
|
|
# The first rev has special metadata encoded in it that should be
|
|
|
|
# stripped before being added to the index.
|
2013-10-18 04:15:41 +04:00
|
|
|
if curr == 0:
|
|
|
|
elist = list(e)
|
2013-10-29 05:57:18 +04:00
|
|
|
type = revlog.gettype(offsettype)
|
|
|
|
offsettype = revlog.offset_type(0, type)
|
|
|
|
elist[0] = offsettype
|
2013-10-18 04:15:41 +04:00
|
|
|
e = tuple(elist)
|
|
|
|
|
2017-03-30 19:39:50 +03:00
|
|
|
if ignoreexisting and node in self.nodemap:
|
|
|
|
return
|
|
|
|
|
2014-01-24 07:22:49 +04:00
|
|
|
# Verify that the rev's parents and base appear earlier in the revlog
|
2013-10-29 05:57:18 +04:00
|
|
|
if p1r >= curr or p2r >= curr:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 CorruptionException(
|
|
|
|
"parent revision is not in revlog: %s" % self.indexfile
|
|
|
|
)
|
2013-10-29 05:57:18 +04:00
|
|
|
if base > curr:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 CorruptionException(
|
|
|
|
"base revision is not in revlog: %s" % self.indexfile
|
|
|
|
)
|
2013-10-29 05:57:18 +04:00
|
|
|
|
|
|
|
expectedoffset = revlog.getoffset(offsettype)
|
2013-12-11 07:00:55 +04:00
|
|
|
if expectedoffset != 0 and expectedoffset != offset:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 CorruptionException(
|
|
|
|
"revision offset doesn't match prior length "
|
|
|
|
+ "(%s offset vs %s length): %s"
|
|
|
|
% (expectedoffset, offset, self.indexfile)
|
|
|
|
)
|
2013-10-29 05:57:18 +04:00
|
|
|
|
|
|
|
if node not in self.nodemap:
|
2013-10-18 03:46:12 +04:00
|
|
|
self.index.insert(-1, e)
|
2013-10-29 05:57:18 +04:00
|
|
|
self.nodemap[node] = len(self) - 1
|
2013-10-18 03:46:12 +04:00
|
|
|
|
|
|
|
if not self._inline:
|
2013-10-18 03:47:34 +04:00
|
|
|
transaction.add(self.datafile, offset)
|
|
|
|
transaction.add(self.indexfile, curr * len(entry))
|
2013-10-18 03:46:12 +04:00
|
|
|
if data0:
|
|
|
|
dfh.write(data0)
|
|
|
|
dfh.write(data1)
|
|
|
|
ifh.write(entry)
|
|
|
|
else:
|
2013-10-18 03:47:34 +04:00
|
|
|
offset += curr * self._io.size
|
|
|
|
transaction.add(self.indexfile, offset, curr)
|
2013-10-18 03:46:12 +04:00
|
|
|
ifh.write(entry)
|
|
|
|
ifh.write(data0)
|
|
|
|
ifh.write(data1)
|
2013-10-18 04:15:41 +04:00
|
|
|
self.checkinlinesize(transaction, ifh)
|
2013-10-18 03:46:12 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-09-19 04:53:50 +03:00
|
|
|
def addgroup(orig, self, deltas, linkmapper, transaction, addrevisioncb=None):
|
2014-01-24 07:22:49 +04:00
|
|
|
"""Copy paste of revlog.addgroup, but we ensure that the revisions are
|
|
|
|
added in linkrev order.
|
2013-10-30 02:55:43 +04:00
|
|
|
"""
|
2014-02-19 03:59:46 +04:00
|
|
|
if not util.safehasattr(transaction, "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
|
|
|
return orig(self, deltas, linkmapper, transaction, addrevisioncb=addrevisioncb)
|
2014-02-19 03:59:46 +04:00
|
|
|
|
2013-10-30 02:55:43 +04:00
|
|
|
# track the base of the current delta log
|
|
|
|
content = []
|
|
|
|
node = None
|
|
|
|
|
|
|
|
r = len(self)
|
|
|
|
end = 0
|
|
|
|
if r:
|
|
|
|
end = self.end(r - 1)
|
|
|
|
ifh = self.opener(self.indexfile, "a+")
|
|
|
|
isize = r * self._io.size
|
|
|
|
if self._inline:
|
|
|
|
transaction.add(self.indexfile, end + isize, r)
|
|
|
|
dfh = None
|
|
|
|
else:
|
|
|
|
transaction.add(self.indexfile, isize, r)
|
|
|
|
transaction.add(self.datafile, end)
|
2015-11-04 00:13:39 +03:00
|
|
|
dfh = self.opener(self.datafile, "a+")
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
try:
|
|
|
|
# loop through our set of deltas
|
|
|
|
chunkdatas = []
|
|
|
|
chunkmap = {}
|
|
|
|
|
|
|
|
lastlinkrev = -1
|
|
|
|
reorder = False
|
|
|
|
|
2014-01-28 06:50:24 +04:00
|
|
|
# Read all of the data from the stream
|
2017-09-19 04:53:50 +03:00
|
|
|
for data in deltas:
|
|
|
|
node, p1, p2, linknode, deltabase, delta, flags = data
|
2013-10-30 02:55:43 +04:00
|
|
|
|
2017-09-19 04:53:50 +03:00
|
|
|
link = linkmapper(linknode)
|
2013-10-30 02:55:43 +04:00
|
|
|
if link < lastlinkrev:
|
|
|
|
reorder = True
|
|
|
|
lastlinkrev = link
|
2017-09-19 04:53:50 +03:00
|
|
|
chunkdata = {
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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": node,
|
|
|
|
"p1": p1,
|
|
|
|
"p2": p2,
|
|
|
|
"cs": linknode,
|
|
|
|
"deltabase": deltabase,
|
|
|
|
"delta": delta,
|
|
|
|
"flags": flags,
|
2017-09-19 04:53:50 +03:00
|
|
|
}
|
2013-10-30 02:55:43 +04:00
|
|
|
chunkdatas.append((link, chunkdata))
|
|
|
|
chunkmap[node] = chunkdata
|
|
|
|
|
2014-01-28 06:50:24 +04:00
|
|
|
# If we noticed a incoming rev was not in linkrev order
|
|
|
|
# we reorder all the revs appropriately.
|
2013-10-30 02:55:43 +04:00
|
|
|
if reorder:
|
|
|
|
chunkdatas = sorted(chunkdatas)
|
|
|
|
|
|
|
|
fulltexts = {}
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-10-30 02:55:43 +04:00
|
|
|
def getfulltext(node):
|
|
|
|
if node in fulltexts:
|
|
|
|
return fulltexts[node]
|
|
|
|
if node in self.nodemap:
|
2017-03-31 08:17:27 +03:00
|
|
|
return self.revision(node, raw=True)
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
chunkdata = chunkmap[node]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
deltabase = chunkdata["deltabase"]
|
|
|
|
delta = chunkdata["delta"]
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
deltachain = []
|
|
|
|
currentbase = deltabase
|
|
|
|
while True:
|
|
|
|
if currentbase in fulltexts:
|
|
|
|
deltachain.append(fulltexts[currentbase])
|
|
|
|
break
|
|
|
|
elif currentbase in self.nodemap:
|
2017-03-31 08:17:27 +03:00
|
|
|
deltachain.append(self.revision(currentbase, raw=True))
|
2013-10-30 02:55:43 +04:00
|
|
|
break
|
|
|
|
elif currentbase == nullid:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
deltachunk = chunkmap[currentbase]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
currentbase = deltachunk["deltabase"]
|
|
|
|
deltachain.append(deltachunk["delta"])
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
prevtext = deltachain.pop()
|
|
|
|
while deltachain:
|
|
|
|
prevtext = mdiff.patch(prevtext, deltachain.pop())
|
|
|
|
|
|
|
|
fulltext = mdiff.patch(prevtext, delta)
|
|
|
|
fulltexts[node] = fulltext
|
|
|
|
return fulltext
|
|
|
|
|
|
|
|
visited = set()
|
|
|
|
prevnode = self.node(len(self) - 1)
|
|
|
|
for link, chunkdata in chunkdatas:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 = chunkdata["node"]
|
|
|
|
deltabase = chunkdata["deltabase"]
|
|
|
|
if not deltabase in self.nodemap and not deltabase in visited:
|
2013-10-30 02:55:43 +04:00
|
|
|
fulltext = getfulltext(node)
|
|
|
|
ptext = getfulltext(prevnode)
|
|
|
|
delta = mdiff.textdiff(ptext, fulltext)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
chunkdata["delta"] = delta
|
|
|
|
chunkdata["deltabase"] = prevnode
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
prevnode = node
|
|
|
|
visited.add(node)
|
|
|
|
|
2014-01-28 06:50:24 +04:00
|
|
|
# Apply the reordered revs to the revlog
|
2013-10-30 02:55:43 +04:00
|
|
|
for link, chunkdata in chunkdatas:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 = chunkdata["node"]
|
|
|
|
p1 = chunkdata["p1"]
|
|
|
|
p2 = chunkdata["p2"]
|
|
|
|
cs = chunkdata["cs"]
|
|
|
|
deltabase = chunkdata["deltabase"]
|
|
|
|
delta = chunkdata["delta"]
|
|
|
|
flags = chunkdata["flags"] or revlog.REVIDX_DEFAULT_FLAGS
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
content.append(node)
|
|
|
|
|
|
|
|
link = linkmapper(cs)
|
|
|
|
if node in self.nodemap:
|
|
|
|
# this can happen if two branches make the same change
|
|
|
|
continue
|
|
|
|
|
|
|
|
for p in (p1, p2):
|
|
|
|
if p not in self.nodemap:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 LookupError(p, self.indexfile, _("unknown parent"))
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
if deltabase not in self.nodemap:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 LookupError(deltabase, self.indexfile, _("unknown delta base"))
|
2013-10-30 02:55:43 +04:00
|
|
|
|
|
|
|
baserev = self.rev(deltabase)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
chain = self._addrevision(
|
|
|
|
node, None, transaction, link, p1, p2, flags, (baserev, delta), ifh, dfh
|
|
|
|
)
|
2015-07-23 01:50:55 +03:00
|
|
|
|
|
|
|
if addrevisioncb:
|
|
|
|
# Data for added revision can't be read unless flushed
|
|
|
|
# because _loadchunk always opensa new file handle and
|
|
|
|
# there is no guarantee data was actually written yet.
|
|
|
|
if dfh:
|
|
|
|
dfh.flush()
|
|
|
|
ifh.flush()
|
|
|
|
addrevisioncb(self, chain)
|
|
|
|
|
2013-10-30 02:55:43 +04:00
|
|
|
if not dfh and not self._inline:
|
|
|
|
# addrevision switched from inline to conventional
|
|
|
|
# reopen the index
|
|
|
|
ifh.close()
|
2015-11-04 00:13:39 +03:00
|
|
|
dfh = self.opener(self.datafile, "a+")
|
|
|
|
ifh = self.opener(self.indexfile, "a+")
|
2013-10-30 02:55:43 +04:00
|
|
|
finally:
|
|
|
|
if dfh:
|
|
|
|
dfh.close()
|
|
|
|
ifh.close()
|
|
|
|
|
|
|
|
return content
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-02-19 05:16:45 +04:00
|
|
|
def bookmarkcommand(orig, ui, repo, *names, **opts):
|
2015-11-18 00:28:15 +03:00
|
|
|
if not issqlrepo(repo):
|
2014-02-19 05:16:45 +04:00
|
|
|
return orig(ui, repo, *names, **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
|
|
|
write = opts.get("delete") or opts.get("rename") or opts.get("inactive") or names
|
2014-02-19 05:16:45 +04:00
|
|
|
|
|
|
|
def _bookmarkcommand():
|
|
|
|
return orig(ui, repo, *names, **opts)
|
|
|
|
|
|
|
|
if write:
|
2014-03-12 23:35:04 +04:00
|
|
|
return executewithsql(repo, _bookmarkcommand, True)
|
2014-02-19 05:16:45 +04:00
|
|
|
else:
|
|
|
|
return _bookmarkcommand()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-01-29 08:46:23 +04:00
|
|
|
def pushkey(orig, repo, proto, namespace, key, old, new):
|
2015-11-18 00:28:15 +03:00
|
|
|
if issqlrepo(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
|
|
|
|
2014-02-19 03:59:46 +04:00
|
|
|
def commitpushkey():
|
|
|
|
return orig(repo, proto, namespace, key, old, new)
|
2014-01-29 08:46:23 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return executewithsql(repo, commitpushkey, namespace == "bookmarks")
|
2014-02-19 03:59:46 +04:00
|
|
|
else:
|
|
|
|
return orig(repo, proto, namespace, key, old, new)
|
2013-10-29 23:55:14 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2013-10-29 23:55:14 +04:00
|
|
|
# recover must be a norepo command because loading the repo fails
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
@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
|
|
|
"sqlrecover",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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", "", _("strips as far back as necessary"), ""),
|
|
|
|
("", "no-backup", None, _("does not produce backup bundles for strips")),
|
|
|
|
],
|
|
|
|
_("hg sqlrecover"),
|
|
|
|
norepo=True,
|
|
|
|
)
|
2013-10-29 23:55:14 +04:00
|
|
|
def sqlrecover(ui, *args, **opts):
|
|
|
|
"""
|
|
|
|
Strips commits from the local repo until it is back in sync with the SQL
|
|
|
|
server.
|
|
|
|
"""
|
|
|
|
|
2014-10-27 23:56:13 +03:00
|
|
|
global initialsync
|
|
|
|
initialsync = INITIAL_SYNC_DISABLE
|
2018-07-23 22:51:47 +03:00
|
|
|
repo = hg.repository(ui, pycompat.getcwd())
|
2013-11-22 00:32:05 +04:00
|
|
|
repo.disablesync = True
|
|
|
|
|
|
|
|
if repo.recover():
|
|
|
|
ui.status("recovered from incomplete transaction")
|
2013-10-29 23:55:14 +04:00
|
|
|
|
|
|
|
def iscorrupt():
|
2013-11-22 00:32:05 +04:00
|
|
|
repo.sqlconnect()
|
2013-10-29 23:55:14 +04:00
|
|
|
try:
|
2018-09-29 02:46:45 +03:00
|
|
|
repo.pullfromdb()
|
2013-12-11 07:00:55 +04:00
|
|
|
except:
|
2013-10-29 23:55:14 +04:00
|
|
|
return True
|
|
|
|
finally:
|
2013-11-22 00:32:05 +04:00
|
|
|
repo.sqlclose()
|
2013-10-29 23:55:14 +04:00
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
reposize = len(repo)
|
|
|
|
|
|
|
|
stripsize = 10
|
2014-01-24 07:22:49 +04:00
|
|
|
while iscorrupt() and len(repo) > 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 opts.get("force") and reposize > len(repo) + 10000:
|
|
|
|
ui.warn(
|
|
|
|
"unable to fix repo after stripping 10000 commits "
|
|
|
|
+ "(use -f to strip more)"
|
|
|
|
)
|
2014-01-24 07:22:49 +04:00
|
|
|
|
2013-10-29 23:55:14 +04:00
|
|
|
striprev = max(0, len(repo) - stripsize)
|
|
|
|
nodelist = [repo[striprev].node()]
|
2014-01-24 07:22:49 +04:00
|
|
|
ui.status("stripping back to %s commits" % (striprev))
|
|
|
|
|
2017-08-17 17:14:50 +03:00
|
|
|
backup = not opts.get("no_backup")
|
2014-01-24 07:22:49 +04:00
|
|
|
repair.strip(ui, repo, nodelist, backup=backup, topic="sqlrecover")
|
|
|
|
|
|
|
|
stripsize = min(stripsize * 5, 10000)
|
2013-10-29 23:55:14 +04:00
|
|
|
|
|
|
|
if len(repo) == 0:
|
|
|
|
ui.warn(_("unable to fix repo corruption\n"))
|
|
|
|
elif len(repo) == reposize:
|
|
|
|
ui.status(_("local repo was not corrupt - no action taken\n"))
|
|
|
|
else:
|
|
|
|
ui.status(_("local repo now matches SQL\n"))
|
2014-07-08 03:10:26 +04:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
@command(
|
|
|
|
"sqltreestrip",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"local-only",
|
|
|
|
None,
|
|
|
|
_("only strips the commits locally, and not from sql"),
|
|
|
|
),
|
2018-06-07 20:36:00 +03:00
|
|
|
(
|
|
|
|
"",
|
|
|
|
"root-only",
|
|
|
|
None,
|
|
|
|
_("only strip the root tree manifest, not the sub-trees"),
|
|
|
|
),
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-know-what-i-am-doing",
|
|
|
|
None,
|
2018-09-27 02:32:10 +03:00
|
|
|
_("only run sqltreestrip if you know exactly what you're doing"),
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
),
|
|
|
|
],
|
|
|
|
_("hg sqltreestrip REV"),
|
|
|
|
)
|
2018-05-21 21:02:45 +03:00
|
|
|
def sqltreestrip(ui, repo, rev, *args, **opts):
|
|
|
|
"""Strips trees from local and sql history
|
|
|
|
"""
|
|
|
|
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
|
|
|
treemfmod = extensions.find("treemanifest")
|
2018-05-21 21:02:45 +03:00
|
|
|
except KeyError:
|
|
|
|
ui.warn(_("treemanifest is not enabled for this repository\n"))
|
|
|
|
return 1
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if not repo.ui.configbool("treemanifest", "server"):
|
2018-09-27 02:32:10 +03:00
|
|
|
ui.warn(_("this repository is not configured to be a treemanifest server\n"))
|
2018-05-21 21:02:45 +03:00
|
|
|
return 1
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if not opts.get("i_know_what_i_am_doing"):
|
|
|
|
raise util.Abort(
|
|
|
|
"You must pass --i-know-what-i-am-doing to run this "
|
|
|
|
+ "command. If you have multiple servers using the database, this "
|
|
|
|
+ "command will break your servers until you run it on each one. "
|
|
|
|
+ "Only the Mercurial server admins should ever run this."
|
|
|
|
)
|
2018-05-21 21:02:45 +03:00
|
|
|
|
2018-06-07 20:36:00 +03:00
|
|
|
rootonly = opts.get("root_only")
|
2018-05-21 21:02:45 +03:00
|
|
|
rev = int(rev)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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(
|
|
|
|
_(
|
|
|
|
"*** YOU ARE ABOUT TO DELETE TREE HISTORY INCLUDING AND AFTER %s "
|
|
|
|
"(MANDATORY 5 SECOND WAIT) ***\n"
|
|
|
|
)
|
|
|
|
% rev
|
|
|
|
)
|
2018-05-21 21:02:45 +03:00
|
|
|
import time
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2018-05-21 21:02:45 +03:00
|
|
|
time.sleep(5)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 opts.get("local_only"):
|
2018-05-21 21:02:45 +03:00
|
|
|
# strip from sql
|
|
|
|
reponame = repo.sqlreponame
|
2018-09-29 02:46:52 +03:00
|
|
|
with repo.lock():
|
|
|
|
repo.sqlconnect()
|
|
|
|
repo.sqlwritelock()
|
|
|
|
try:
|
|
|
|
cursor = repo.sqlcursor
|
2018-06-07 20:36:00 +03:00
|
|
|
|
2018-09-29 02:46:52 +03:00
|
|
|
if rootonly:
|
|
|
|
ui.status(
|
|
|
|
_("mysql: deleting root trees with linkrevs >= %s\n") % rev
|
|
|
|
)
|
|
|
|
pathfilter = "(path = '00manifesttree.i')"
|
|
|
|
else:
|
|
|
|
ui.status(_("mysql: deleting trees with linkrevs >= %s\n") % rev)
|
|
|
|
pathfilter = "(path LIKE 'meta/%%' OR path = '00manifesttree.i')"
|
2018-06-07 20:36:00 +03:00
|
|
|
|
2018-09-29 02:46:52 +03:00
|
|
|
cursor.execute(
|
|
|
|
"""DELETE FROM revisions WHERE repo = %s AND linkrev >= %s
|
|
|
|
AND """
|
|
|
|
+ pathfilter,
|
|
|
|
(reponame, rev),
|
|
|
|
)
|
|
|
|
repo.sqlconn.commit()
|
|
|
|
finally:
|
|
|
|
repo.sqlwriteunlock()
|
|
|
|
repo.sqlclose()
|
2018-05-21 21:02:45 +03:00
|
|
|
|
|
|
|
# strip from local
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 repo.wlock(), repo.lock(), repo.transaction("treestrip") as tr:
|
2018-05-21 21:02:45 +03:00
|
|
|
repo.disablesync = True
|
|
|
|
|
|
|
|
# Duplicating some logic from repair.py
|
|
|
|
offset = len(tr.entries)
|
|
|
|
tr.startgroup()
|
2018-06-07 20:36:00 +03:00
|
|
|
if opts.get("root_only"):
|
|
|
|
ui.status(_("local: deleting root trees with linkrevs >= %s\n") % rev)
|
|
|
|
treerevlog = repo.manifestlog.treemanifestlog._revlog
|
|
|
|
treerevlog.strip(rev, tr)
|
|
|
|
else:
|
|
|
|
ui.status(_("local: deleting trees with linkrevs >= %s\n") % rev)
|
|
|
|
files = treemfmod.collectfiles(None, repo, rev)
|
|
|
|
treemfmod.striptrees(None, repo, tr, rev, files)
|
2018-05-21 21:02:45 +03:00
|
|
|
tr.endgroup()
|
|
|
|
|
2019-09-27 01:28:09 +03:00
|
|
|
for i in range(offset, len(tr.entries)):
|
2018-05-21 21:02:45 +03:00
|
|
|
file, troffset, ignore = tr.entries[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
|
|
|
with repo.svfs(file, "a", checkambig=True) as fp:
|
2018-05-31 04:18:32 +03:00
|
|
|
util.truncate(fp, troffset)
|
2018-05-21 21:02:45 +03:00
|
|
|
if troffset == 0:
|
|
|
|
repo.store.markremoved(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
|
|
|
|
2018-06-02 02:32:48 +03:00
|
|
|
def _parsecompressedrevision(data):
|
|
|
|
"""Takes a compressed revision and parses it into the data0 (compression
|
|
|
|
indicator) and data1 (payload). Ideally we'd refactor revlog.decompress to
|
|
|
|
have this logic be separate, but there are comments in the code about perf
|
|
|
|
implications of the hotpath."""
|
|
|
|
t = data[0:1]
|
|
|
|
|
|
|
|
if t == "u":
|
|
|
|
return "u", data[1:]
|
|
|
|
else:
|
|
|
|
return "", data
|
|
|
|
|
|
|
|
|
|
|
|
def _discoverrevisions(repo, startrev):
|
|
|
|
# Tuple of revlog name and rev number for revisions introduced by commits
|
|
|
|
# greater than or equal to startrev (path, rlrev)
|
|
|
|
revisions = []
|
|
|
|
|
|
|
|
mfrevlog = repo.manifestlog._revlog
|
|
|
|
for rev in repo.revs("%s:", startrev):
|
|
|
|
# Changelog
|
|
|
|
revisions.append(("00changelog.i", rev))
|
|
|
|
|
|
|
|
# Manifestlog
|
|
|
|
mfrev = mfrevlog.rev(repo[rev].manifestnode())
|
|
|
|
revisions.append(("00manifest.i", mfrev))
|
|
|
|
|
|
|
|
files = repair._collectfiles(repo, startrev)
|
|
|
|
|
|
|
|
# Trees
|
|
|
|
if repo.ui.configbool("treemanifest", "server"):
|
|
|
|
rootmflog = repo.manifestlog.treemanifestlog._revlog
|
|
|
|
striprev, brokenrevs = rootmflog.getstrippoint(startrev)
|
|
|
|
for mfrev in range(striprev, len(rootmflog)):
|
|
|
|
revisions.append((rootmflog.indexfile, mfrev))
|
|
|
|
|
|
|
|
for dir in util.dirs(files):
|
|
|
|
submflog = rootmflog.dirlog(dir)
|
|
|
|
striprev, brokenrevs = submflog.getstrippoint(startrev)
|
|
|
|
for mfrev in range(striprev, len(submflog)):
|
|
|
|
revisions.append((submflog.indexfile, mfrev))
|
|
|
|
|
|
|
|
# Files
|
|
|
|
for file in files:
|
|
|
|
filelog = repo.file(file)
|
|
|
|
striprev, brokenrevs = filelog.getstrippoint(startrev)
|
|
|
|
for filerev in range(striprev, len(filelog)):
|
|
|
|
revisions.append((filelog.indexfile, filerev))
|
|
|
|
|
|
|
|
return revisions
|
|
|
|
|
|
|
|
|
|
|
|
@command(
|
|
|
|
"sqlrefill",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"i-know-what-i-am-doing",
|
|
|
|
None,
|
|
|
|
_("only run sqlrefill if you know exactly what you're doing"),
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"skip-initial-sync",
|
|
|
|
None,
|
|
|
|
_(
|
|
|
|
"skips the initial sync; useful when the "
|
|
|
|
"local repo is correct and the database "
|
|
|
|
"is incorrect"
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
_("hg sqlrefill REV"),
|
|
|
|
norepo=True,
|
|
|
|
)
|
|
|
|
def sqlrefill(ui, startrev, **opts):
|
|
|
|
"""Inserts the given revs into the database
|
|
|
|
"""
|
|
|
|
if not opts.get("i_know_what_i_am_doing"):
|
|
|
|
|
|
|
|
raise util.Abort(
|
|
|
|
"You must pass --i-know-what-i-am-doing to run this "
|
|
|
|
"command. If you have multiple servers using the database, you "
|
|
|
|
"will need to run sqlreplay on the other servers to get this "
|
|
|
|
"data onto them as well."
|
|
|
|
)
|
|
|
|
|
|
|
|
if not opts.get("skip_initial_sync"):
|
|
|
|
global initialsync
|
|
|
|
initialsync = INITIAL_SYNC_DISABLE
|
2018-07-23 22:51:47 +03:00
|
|
|
repo = hg.repository(ui, pycompat.getcwd())
|
2018-06-02 02:32:48 +03:00
|
|
|
repo.disablesync = True
|
|
|
|
|
|
|
|
startrev = int(startrev)
|
|
|
|
|
|
|
|
repo = repo.unfiltered()
|
2018-09-29 02:46:52 +03:00
|
|
|
with repo.lock():
|
|
|
|
repo.sqlconnect()
|
|
|
|
repo.sqlwritelock()
|
|
|
|
try:
|
|
|
|
revlogs = {}
|
|
|
|
pendingrevs = []
|
|
|
|
# totalrevs = len(repo.changelog)
|
|
|
|
# with progress.bar(ui, 'refilling', total=totalrevs - startrev) as prog:
|
|
|
|
# prog.value += 1
|
|
|
|
revlogrevs = _discoverrevisions(repo, startrev)
|
|
|
|
|
|
|
|
for path, rlrev in revlogrevs:
|
|
|
|
rl = revlogs.get(path)
|
|
|
|
if rl is None:
|
|
|
|
rl = revlog.revlog(repo.svfs, path)
|
|
|
|
revlogs[path] = rl
|
|
|
|
|
|
|
|
entry = rl.index[rlrev]
|
|
|
|
_, _, _, baserev, linkrev, p1r, p2r, node = entry
|
|
|
|
data = rl._getsegmentforrevs(rlrev, rlrev)[1]
|
|
|
|
data0, data1 = _parsecompressedrevision(data)
|
|
|
|
|
|
|
|
hexnode = hex(node)
|
|
|
|
sqlentry = rl._io.packentry(entry, hexnode, rl.version, rlrev)
|
|
|
|
revdata = (path, linkrev, rlrev, hexnode, sqlentry, data0, data1)
|
|
|
|
pendingrevs.append(revdata)
|
|
|
|
|
|
|
|
repo._committodb(pendingrevs, ignoreduplicates=True)
|
|
|
|
repo.sqlconn.commit()
|
|
|
|
finally:
|
|
|
|
repo.sqlwriteunlock()
|
|
|
|
repo.sqlclose()
|
2018-06-02 02:32: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
|
|
|
@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
|
|
|
"sqlstrip",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-know-what-i-am-doing",
|
|
|
|
None,
|
2019-03-13 21:36:22 +03:00
|
|
|
_("only run sqlstrip if you know exactly what you're doing"),
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"no-backup-permanent-data-loss",
|
|
|
|
None,
|
|
|
|
_("does not produce backup bundles (for use with corrupt revlogs)"),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
_("hg sqlstrip [OPTIONS] REV"),
|
|
|
|
norepo=True,
|
|
|
|
)
|
2014-07-08 03:10:26 +04:00
|
|
|
def sqlstrip(ui, rev, *args, **opts):
|
|
|
|
"""strips all revisions greater than or equal to the given revision from the sql database
|
|
|
|
|
|
|
|
Deletes all revisions with linkrev >= the given revision from the local
|
|
|
|
repo and from the sql database. This is permanent and cannot be undone.
|
|
|
|
Once the revisions are deleted from the database, you will need to run
|
|
|
|
this command on each master server before proceeding to write new revisions.
|
|
|
|
"""
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 opts.get("i_know_what_i_am_doing"):
|
|
|
|
raise util.Abort(
|
|
|
|
"You must pass --i-know-what-i-am-doing to run this "
|
|
|
|
+ "command. If you have multiple servers using the database, this "
|
|
|
|
+ "command will break your servers until you run it on each one. "
|
|
|
|
+ "Only the Mercurial server admins should ever run this."
|
|
|
|
)
|
2014-07-08 03:10:26 +04:00
|
|
|
|
2015-10-16 02:21:31 +03:00
|
|
|
ui.warn("*** YOU ARE ABOUT TO DELETE HISTORY (MANDATORY 5 SECOND WAIT) ***\n")
|
|
|
|
import time
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-10-16 02:21:31 +03:00
|
|
|
time.sleep(5)
|
|
|
|
|
2017-08-17 17:14:50 +03:00
|
|
|
backup = not opts.get("no_backup_permanent_data_loss")
|
|
|
|
if not backup:
|
|
|
|
ui.warn("*** *** *** *** *** *** *** *** * *** *** *** *** *** *** *** ***\n")
|
|
|
|
ui.warn("*** THERE ARE NO BACKUPS! * (MANDATORY 10 SECOND WAIT) ***\n")
|
|
|
|
ui.warn("*** *** *** *** *** *** *** *** * *** *** *** *** *** *** *** ***\n")
|
|
|
|
time.sleep(10)
|
|
|
|
|
2014-10-27 23:56:13 +03:00
|
|
|
global initialsync
|
|
|
|
initialsync = INITIAL_SYNC_DISABLE
|
2018-07-23 22:51:47 +03:00
|
|
|
repo = hg.repository(ui, pycompat.getcwd())
|
2014-07-08 03:10:26 +04:00
|
|
|
repo.disablesync = True
|
|
|
|
|
2014-09-26 05:15:17 +04:00
|
|
|
try:
|
|
|
|
rev = int(rev)
|
|
|
|
except ValueError:
|
|
|
|
raise util.Abort("specified rev must be an integer: '%s'" % rev)
|
|
|
|
|
2015-10-27 01:48:14 +03:00
|
|
|
wlock = lock = None
|
|
|
|
wlock = repo.wlock()
|
2014-07-08 03:10:26 +04:00
|
|
|
lock = repo.lock()
|
|
|
|
try:
|
|
|
|
repo.sqlconnect()
|
|
|
|
try:
|
2018-09-25 20:57:06 +03:00
|
|
|
repo.sqlwritelock()
|
2014-07-08 03:10:26 +04:00
|
|
|
|
|
|
|
if rev not in repo:
|
|
|
|
raise util.Abort("revision %s is not in the repo" % rev)
|
|
|
|
|
|
|
|
reponame = repo.sqlreponame
|
|
|
|
cursor = repo.sqlcursor
|
|
|
|
changelog = repo.changelog
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.revs("%s:" % rev)
|
2014-07-08 03:10:26 +04:00
|
|
|
# strip locally
|
|
|
|
ui.status("stripping locally\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
|
|
|
repair.strip(
|
|
|
|
ui,
|
|
|
|
repo,
|
|
|
|
[changelog.node(r) for r in revs],
|
|
|
|
backup=backup,
|
|
|
|
topic="sqlstrip",
|
|
|
|
)
|
2014-07-08 03:10:26 +04:00
|
|
|
|
|
|
|
ui.status("stripping from the database\n")
|
|
|
|
ui.status("deleting old references\n")
|
2019-05-01 20:41:38 +03:00
|
|
|
repo._updaterevisionreferences()
|
2014-07-08 03:10:26 +04:00
|
|
|
|
|
|
|
ui.status("deleting revision data\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
|
|
|
cursor.execute(
|
2018-09-29 02:46:55 +03:00
|
|
|
"""DELETE FROM revisions WHERE repo = %s and linkrev >= %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
|
|
|
(reponame, rev),
|
|
|
|
)
|
2014-07-08 03:10:26 +04:00
|
|
|
|
|
|
|
repo.sqlconn.commit()
|
|
|
|
finally:
|
2018-09-25 20:57:06 +03:00
|
|
|
repo.sqlwriteunlock()
|
2014-07-08 03:10:26 +04:00
|
|
|
repo.sqlclose()
|
|
|
|
finally:
|
2015-10-27 01:48:14 +03:00
|
|
|
if lock:
|
|
|
|
lock.release()
|
|
|
|
if wlock:
|
|
|
|
wlock.release()
|
2015-11-18 00:34: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
|
|
|
|
|
|
|
@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
|
|
|
"sqlreplay",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
[
|
|
|
|
("", "start", "", _("the rev to start with"), ""),
|
|
|
|
("", "end", "", _("the rev to end with"), ""),
|
|
|
|
],
|
|
|
|
_("hg sqlreplay"),
|
|
|
|
)
|
2017-03-30 19:39:50 +03:00
|
|
|
def sqlreplay(ui, repo, *args, **opts):
|
|
|
|
"""goes through the entire sql history and performs missing revlog writes
|
|
|
|
|
|
|
|
This is useful for adding entirely new revlogs to history, like when
|
|
|
|
converting repos to a new format. The replays perform the same validation
|
|
|
|
before appending to a revlog, so you will never end up with incorrect
|
|
|
|
revlogs from things being appended out of order.
|
|
|
|
"""
|
|
|
|
maxrev = len(repo.changelog) - 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
|
|
|
startrev = int(opts.get("start") or "0")
|
|
|
|
endrev = int(opts.get("end") or str(maxrev))
|
2017-03-31 01:51:59 +03:00
|
|
|
|
|
|
|
startrev = max(startrev, 0)
|
|
|
|
endrev = min(endrev, maxrev)
|
2017-03-30 19:39:50 +03:00
|
|
|
|
|
|
|
def _helper():
|
2017-03-31 01:51:59 +03:00
|
|
|
_sqlreplay(repo, startrev, endrev)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-03-30 19:39:50 +03:00
|
|
|
executewithsql(repo, _helper, 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
|
|
|
|
2017-03-30 19:39:50 +03:00
|
|
|
def _sqlreplay(repo, startrev, endrev):
|
|
|
|
wlock = lock = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
wlock = repo.wlock()
|
|
|
|
lock = repo.lock()
|
|
|
|
# Disable all pretxnclose hooks, since these revisions are
|
2018-09-25 20:57:04 +03:00
|
|
|
# technically already committed.
|
2017-03-30 19:39:50 +03:00
|
|
|
for name, value in repo.ui.configitems("hooks"):
|
|
|
|
if name.startswith("pretxnclose"):
|
|
|
|
repo.ui.setconfig("hooks", name, None)
|
|
|
|
|
|
|
|
transaction = repo.transaction("sqlreplay")
|
|
|
|
|
|
|
|
try:
|
2017-03-30 23:36:37 +03:00
|
|
|
repo.sqlreplaytransaction = True
|
2019-09-27 01:28:09 +03:00
|
|
|
q = queue.Queue()
|
2017-03-30 19:39:50 +03:00
|
|
|
abort = threading.Event()
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
t = threading.Thread(
|
2019-09-27 01:28:09 +03:00
|
|
|
target=repo.fetchthread, args=(q, abort, startrev, endrev)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
)
|
2017-03-30 19:39:50 +03:00
|
|
|
t.setDaemon(True)
|
|
|
|
try:
|
|
|
|
t.start()
|
2019-09-27 01:28:09 +03:00
|
|
|
addentries(repo, q, transaction, ignoreexisting=True)
|
2017-03-30 19:39:50 +03:00
|
|
|
finally:
|
|
|
|
abort.set()
|
|
|
|
|
|
|
|
transaction.close()
|
|
|
|
finally:
|
|
|
|
transaction.release()
|
2017-03-30 23:36:37 +03:00
|
|
|
repo.sqlreplaytransaction = False
|
2017-03-30 19:39:50 +03:00
|
|
|
finally:
|
|
|
|
if lock:
|
|
|
|
lock.release()
|
|
|
|
if wlock:
|
|
|
|
wlock.release()
|
2017-04-07 21:05: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
|
|
|
|
|
|
|
@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
|
|
|
"sqlverify",
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
[("", "earliest-rev", "", _("the earliest rev to process"), "")],
|
|
|
|
_("hg sqlverify"),
|
|
|
|
)
|
2017-04-07 21:05:00 +03:00
|
|
|
def sqlverify(ui, repo, *args, **opts):
|
|
|
|
"""verifies the current revlog indexes match the data in mysql
|
|
|
|
|
|
|
|
Runs in reverse order, so it verifies the latest commits first.
|
|
|
|
"""
|
|
|
|
maxrev = len(repo.changelog) - 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
|
|
|
minrev = int(opts.get("earliest_rev") or "0")
|
2017-04-07 21:05:00 +03:00
|
|
|
|
|
|
|
def _helper():
|
|
|
|
stepsize = 1000
|
|
|
|
firstrev = max(minrev, maxrev - stepsize)
|
|
|
|
lastrev = maxrev
|
|
|
|
|
2017-05-08 20:57:42 +03:00
|
|
|
insql = set()
|
2017-05-08 20:57:34 +03:00
|
|
|
revlogcache = {}
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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, "verifying", total=maxrev - minrev) as prog:
|
2018-03-21 23:45:35 +03:00
|
|
|
while True:
|
|
|
|
insql.update(_sqlverify(repo, firstrev, lastrev, revlogcache))
|
|
|
|
prog.value = maxrev - firstrev
|
|
|
|
if firstrev == minrev:
|
|
|
|
break
|
|
|
|
lastrev = firstrev - 1
|
|
|
|
firstrev = max(minrev, firstrev - stepsize)
|
2017-04-07 21:05:00 +03:00
|
|
|
|
2017-05-08 20:57:42 +03:00
|
|
|
# Check that on disk revlogs don't have extra information that isn't in
|
|
|
|
# hgsql
|
|
|
|
earliestmtime = time.time() - (3600 * 24 * 7)
|
|
|
|
corrupted = 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
|
|
|
with progress.bar(ui, "verifying revlogs") as prog:
|
2018-03-21 23:45:35 +03:00
|
|
|
for filepath, x, x in repo.store.walk():
|
|
|
|
prog.value += 1
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if filepath[-2:] != ".i":
|
2018-03-21 23:45:35 +03:00
|
|
|
continue
|
|
|
|
|
|
|
|
# If the revlog is recent, check it
|
|
|
|
stat = repo.svfs.lstat(path=filepath)
|
|
|
|
if stat.st_mtime <= earliestmtime:
|
|
|
|
continue
|
|
|
|
|
|
|
|
rl = revlogcache.get(filepath)
|
|
|
|
if rl 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
|
|
|
if filepath == "00changelog.i":
|
2018-03-21 23:45:35 +03:00
|
|
|
rl = repo.unfiltered().changelog
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 filepath == "00manifest.i":
|
2018-03-21 23:45:35 +03:00
|
|
|
rl = repo.manifestlog._revlog
|
|
|
|
else:
|
|
|
|
rl = revlog.revlog(repo.svfs, filepath)
|
2019-09-27 01:28:09 +03:00
|
|
|
for rev in range(len(rl) - 1, -1, -1):
|
2018-03-21 23:45:35 +03:00
|
|
|
node = rl.node(rev)
|
|
|
|
linkrev = rl.linkrev(rev)
|
|
|
|
if linkrev < minrev:
|
|
|
|
break
|
|
|
|
if (filepath, node) not in insql:
|
|
|
|
corrupted = 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
|
|
|
msg = (
|
|
|
|
"corruption: '%s:%s' with linkrev %s "
|
|
|
|
"exists on local disk, but not in sql\n"
|
|
|
|
) % (filepath, hex(node), linkrev)
|
2018-03-21 23:45:35 +03:00
|
|
|
repo.ui.status(msg)
|
2017-05-08 20:57:42 +03:00
|
|
|
|
|
|
|
if corrupted:
|
|
|
|
raise error.Abort("Verification failed")
|
|
|
|
|
2017-04-07 21:05:00 +03:00
|
|
|
ui.status("Verification passed\n")
|
|
|
|
|
|
|
|
executewithsql(repo, _helper, 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
|
|
|
|
2017-05-08 20:57:34 +03:00
|
|
|
def _sqlverify(repo, minrev, maxrev, revlogcache):
|
2019-09-27 01:28:09 +03:00
|
|
|
q = queue.Queue()
|
2017-04-07 21:05:00 +03:00
|
|
|
abort = threading.Event()
|
2019-09-27 01:28:09 +03:00
|
|
|
t = threading.Thread(target=repo.fetchthread, args=(q, abort, minrev, maxrev))
|
2017-04-07 21:05:00 +03:00
|
|
|
t.setDaemon(True)
|
|
|
|
|
2017-05-08 20:57:42 +03:00
|
|
|
insql = set()
|
2017-04-07 21:05:00 +03:00
|
|
|
try:
|
|
|
|
t.start()
|
|
|
|
|
|
|
|
while True:
|
2019-09-27 01:28:09 +03:00
|
|
|
revdata = q.get()
|
2017-04-07 21:05:00 +03:00
|
|
|
if not revdata:
|
2017-05-08 20:57:42 +03:00
|
|
|
return insql
|
2017-04-07 21:05:00 +03:00
|
|
|
|
|
|
|
# The background thread had an exception, rethrow from the
|
|
|
|
# foreground thread.
|
|
|
|
if isinstance(revdata, Exception):
|
|
|
|
raise revdata
|
|
|
|
|
|
|
|
# Validate revdata
|
|
|
|
path = revdata[0]
|
|
|
|
linkrev = revdata[3]
|
|
|
|
packedentry = revdata[4]
|
|
|
|
|
2017-07-17 15:49:39 +03:00
|
|
|
sqlentry = revlog.indexformatng.unpack(packedentry)
|
2017-04-07 21:05:00 +03:00
|
|
|
|
2017-05-08 20:57:34 +03:00
|
|
|
rl = revlogcache.get(path)
|
|
|
|
if rl 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
|
|
|
if path == "00changelog.i":
|
2017-05-08 20:57:34 +03:00
|
|
|
rl = repo.unfiltered().changelog
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 path == "00manifest.i":
|
2017-05-08 20:57:34 +03:00
|
|
|
rl = repo.manifestlog._revlog
|
|
|
|
else:
|
|
|
|
rl = revlog.revlog(repo.svfs, path)
|
|
|
|
revlogcache[path] = rl
|
2017-04-07 21:05:00 +03:00
|
|
|
|
|
|
|
node = sqlentry[7]
|
|
|
|
rev = rl.rev(node)
|
|
|
|
if rev == 0:
|
|
|
|
# The first entry has special whole-revlog flags in place of the
|
|
|
|
# offset in entry[0] that are not returned from revlog.index,
|
|
|
|
# so strip that data.
|
|
|
|
type = revlog.gettype(sqlentry[0])
|
|
|
|
sqlentry = (revlog.offset_type(0, type),) + sqlentry[1:]
|
|
|
|
|
2017-05-08 20:57:42 +03:00
|
|
|
insql.add((path, node))
|
|
|
|
|
2017-04-07 21:05:00 +03:00
|
|
|
revlogentry = rl.index[rev]
|
|
|
|
if revlogentry != sqlentry:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 CorruptionException(
|
2018-09-27 02:32:10 +03:00
|
|
|
("'%s:%s' with linkrev %s, disk does not match mysql")
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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, hex(node), str(linkrev))
|
|
|
|
)
|
2017-04-07 21:05:00 +03:00
|
|
|
finally:
|
|
|
|
abort.set()
|