2011-12-16 02:08:09 +04:00
|
|
|
""" Mercurial phases support code
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
|
|
|
|
Logilab SA <contact@logilab.fr>
|
|
|
|
Augie Fackler <durin42@gmail.com>
|
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
This software may be used and distributed according to the terms
|
|
|
|
of the GNU General Public License version 2 or any later version.
|
2011-12-16 02:08:09 +04:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
This module implements most phase logic in mercurial.
|
|
|
|
|
|
|
|
Basic Concept
|
|
|
|
=============
|
|
|
|
|
2012-05-13 14:06:12 +04:00
|
|
|
A 'changeset phase' is an indicator that tells us how a changeset is
|
2012-05-13 14:07:49 +04:00
|
|
|
manipulated and communicated. The details of each phase is described
|
|
|
|
below, here we describe the properties they have in common.
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
Like bookmarks, phases are not stored in history and thus are not
|
|
|
|
permanent and leave no audit trail.
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
First, no changeset can be in two phases at once. Phases are ordered,
|
|
|
|
so they can be considered from lowest to highest. The default, lowest
|
|
|
|
phase is 'public' - this is the normal phase of existing changesets. A
|
|
|
|
child changeset can not be in a lower phase than its parents.
|
2011-12-16 02:08:09 +04:00
|
|
|
|
|
|
|
These phases share a hierarchy of traits:
|
|
|
|
|
|
|
|
immutable shared
|
|
|
|
public: X X
|
|
|
|
draft: X
|
2011-12-20 04:34:12 +04:00
|
|
|
secret:
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:06:12 +04:00
|
|
|
Local commits are draft by default.
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:06:12 +04:00
|
|
|
Phase Movement and Exchange
|
|
|
|
===========================
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
Phase data is exchanged by pushkey on pull and push. Some servers have
|
|
|
|
a publish option set, we call such a server a "publishing server".
|
|
|
|
Pushing a draft changeset to a publishing server changes the phase to
|
|
|
|
public.
|
2011-12-16 02:08:09 +04:00
|
|
|
|
|
|
|
A small list of fact/rules define the exchange of phase:
|
|
|
|
|
|
|
|
* old client never changes server states
|
|
|
|
* pull never changes server states
|
2012-05-13 14:06:12 +04:00
|
|
|
* publish and old server changesets are seen as public by client
|
2012-05-13 14:07:49 +04:00
|
|
|
* any secret changeset seen in another repository is lowered to at
|
|
|
|
least draft
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
Here is the final table summing up the 49 possible use cases of phase
|
|
|
|
exchange:
|
2011-12-16 02:08:09 +04:00
|
|
|
|
|
|
|
server
|
|
|
|
old publish non-publish
|
|
|
|
N X N D P N D P
|
|
|
|
old client
|
|
|
|
pull
|
|
|
|
N - X/X - X/D X/P - X/D X/P
|
|
|
|
X - X/X - X/D X/P - X/D X/P
|
|
|
|
push
|
|
|
|
X X/X X/X X/P X/P X/P X/D X/D X/P
|
|
|
|
new client
|
|
|
|
pull
|
|
|
|
N - P/X - P/D P/P - D/D P/P
|
|
|
|
D - P/X - P/D P/P - D/D P/P
|
|
|
|
P - P/X - P/D P/P - P/D P/P
|
|
|
|
push
|
|
|
|
D P/X P/X P/P P/P P/P D/D D/D P/P
|
|
|
|
P P/X P/X P/P P/P P/P P/P P/P P/P
|
|
|
|
|
|
|
|
Legend:
|
|
|
|
|
|
|
|
A/B = final state on client / state on server
|
|
|
|
|
|
|
|
* N = new/not present,
|
|
|
|
* P = public,
|
|
|
|
* D = draft,
|
2012-05-13 14:07:49 +04:00
|
|
|
* X = not tracked (i.e., the old client or server has no internal
|
|
|
|
way of recording the phase.)
|
2011-12-16 02:08:09 +04:00
|
|
|
|
|
|
|
passive = only pushes
|
|
|
|
|
|
|
|
A cell here can be read like this:
|
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
"When a new client pushes a draft changeset (D) to a publishing
|
|
|
|
server where it's not present (N), it's marked public on both
|
|
|
|
sides (P/P)."
|
2011-12-16 02:08:09 +04:00
|
|
|
|
2012-05-13 14:06:12 +04:00
|
|
|
Note: old client behave as a publishing server with draft only content
|
2011-12-16 02:08:09 +04:00
|
|
|
- other people see it as public
|
|
|
|
- content is pushed as draft
|
|
|
|
|
|
|
|
"""
|
2011-11-04 02:49:14 +04:00
|
|
|
|
2015-08-09 05:46:33 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2011-11-06 21:57:24 +04:00
|
|
|
import errno
|
2017-09-19 23:01:31 +03:00
|
|
|
import struct
|
2015-08-09 05:46:33 +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
|
|
|
from . import error, pycompat, smartset, txnutil, util
|
2015-08-09 05:46:33 +03:00
|
|
|
from .i18n import _
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
from .node import bin, hex, nullid, nullrev, short
|
|
|
|
|
|
|
|
|
|
|
|
_fphasesentry = struct.Struct(">i20s")
|
2017-09-19 23:01:31 +03:00
|
|
|
|
2012-01-06 12:51:35 +04:00
|
|
|
allphases = public, draft, secret = range(3)
|
2011-11-04 02:49:14 +04:00
|
|
|
trackedphases = allphases[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
|
|
|
phasenames = ["public", "draft", "secret"]
|
2011-11-04 03:16:24 +04:00
|
|
|
|
flake8: enable F821 check
Summary:
This check is useful and detects real errors (ex. fbconduit). Unfortunately
`arc lint` will run it with both py2 and py3 so a lot of py2 builtins will
still be warned.
I didn't find a clean way to disable py3 check. So this diff tries to fix them.
For `xrange`, the change was done by a script:
```
import sys
import redbaron
headertypes = {'comment', 'endl', 'from_import', 'import', 'string',
'assignment', 'atomtrailers'}
xrangefix = '''try:
xrange(0)
except NameError:
xrange = range
'''
def isxrange(x):
try:
return x[0].value == 'xrange'
except Exception:
return False
def main(argv):
for i, path in enumerate(argv):
print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
content = open(path).read()
try:
red = redbaron.RedBaron(content)
except Exception:
print(' warning: failed to parse')
continue
hasxrange = red.find('atomtrailersnode', value=isxrange)
hasxrangefix = 'xrange = range' in content
if hasxrangefix or not hasxrange:
print(' no need to change')
continue
# find a place to insert the compatibility statement
changed = False
for node in red:
if node.type in headertypes:
continue
# node.insert_before is an easier API, but it has bugs changing
# other "finally" and "except" positions. So do the insert
# manually.
# # node.insert_before(xrangefix)
line = node.absolute_bounding_box.top_left.line - 1
lines = content.splitlines(1)
content = ''.join(lines[:line]) + xrangefix + ''.join(lines[line:])
changed = True
break
if changed:
# "content" is faster than "red.dumps()"
open(path, 'w').write(content)
print(' updated')
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
```
For other py2 builtins that do not have a py3 equivalent, some `# noqa`
were added as a workaround for now.
Reviewed By: DurhamG
Differential Revision: D6934535
fbshipit-source-id: 546b62830af144bc8b46788d2e0fd00496838939
2018-02-10 04:31:44 +03:00
|
|
|
try:
|
|
|
|
xrange(0)
|
|
|
|
except NameError:
|
|
|
|
xrange = 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
|
|
|
|
2012-05-12 02:24:07 +04:00
|
|
|
def _readroots(repo, phasedefaults=None):
|
2012-05-10 20:52:04 +04:00
|
|
|
"""Read phase roots from disk
|
|
|
|
|
|
|
|
phasedefaults is a list of fn(repo, roots) callable, which are
|
|
|
|
executed if the phase roots file does not exist. When phases are
|
|
|
|
being initialized on an existing repository, this could be used to
|
|
|
|
set selected changesets phase to something else than public.
|
|
|
|
|
|
|
|
Return (roots, dirty) where dirty is true if roots differ from
|
|
|
|
what is being stored.
|
|
|
|
"""
|
2012-11-21 03:53:45 +04:00
|
|
|
repo = repo.unfiltered()
|
2012-05-10 20:52:04 +04:00
|
|
|
dirty = False
|
2011-11-04 03:16:24 +04:00
|
|
|
roots = [set() for i in allphases]
|
|
|
|
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
|
|
|
f, pending = txnutil.trypending(repo.root, repo.svfs, "phaseroots")
|
2011-11-04 03:16:24 +04:00
|
|
|
try:
|
|
|
|
for line in f:
|
2012-05-04 17:24:00 +04:00
|
|
|
phase, nh = line.split()
|
2011-11-04 03:16:24 +04:00
|
|
|
roots[int(phase)].add(bin(nh))
|
|
|
|
finally:
|
|
|
|
f.close()
|
2015-06-24 08:20:08 +03:00
|
|
|
except IOError as inst:
|
2011-11-06 21:57:24 +04:00
|
|
|
if inst.errno != errno.ENOENT:
|
|
|
|
raise
|
2012-05-10 20:52:04 +04:00
|
|
|
if phasedefaults:
|
|
|
|
for f in phasedefaults:
|
|
|
|
roots = f(repo, roots)
|
|
|
|
dirty = True
|
|
|
|
return roots, dirty
|
2011-11-04 03:16:24 +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 23:01:31 +03:00
|
|
|
def binaryencode(phasemapping):
|
|
|
|
"""encode a 'phase -> nodes' mapping into a binary stream
|
|
|
|
|
|
|
|
Since phases are integer the mapping is actually a python list:
|
|
|
|
[[PUBLIC_HEADS], [DRAFTS_HEADS], [SECRET_HEADS]]
|
|
|
|
"""
|
|
|
|
binarydata = []
|
|
|
|
for phase, nodes in enumerate(phasemapping):
|
|
|
|
for head in nodes:
|
|
|
|
binarydata.append(_fphasesentry.pack(phase, head))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return "".join(binarydata)
|
|
|
|
|
2017-09-19 23:01:31 +03:00
|
|
|
|
2017-09-19 23:23:41 +03:00
|
|
|
def binarydecode(stream):
|
|
|
|
"""decode a binary stream into a 'phase -> nodes' mapping
|
|
|
|
|
|
|
|
Since phases are integer the mapping is actually a python list."""
|
|
|
|
headsbyphase = [[] for i in allphases]
|
|
|
|
entrysize = _fphasesentry.size
|
|
|
|
while True:
|
|
|
|
entry = stream.read(entrysize)
|
|
|
|
if len(entry) < entrysize:
|
|
|
|
if entry:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(_("bad phase-heads stream"))
|
2017-09-19 23:23:41 +03:00
|
|
|
break
|
|
|
|
phase, node = _fphasesentry.unpack(entry)
|
|
|
|
headsbyphase[phase].append(node)
|
|
|
|
return headsbyphase
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-07-11 03:39:52 +03:00
|
|
|
def _trackphasechange(data, rev, old, new):
|
|
|
|
"""add a phase move the <data> dictionnary
|
|
|
|
|
|
|
|
If data is None, nothing happens.
|
|
|
|
"""
|
|
|
|
if data is None:
|
|
|
|
return
|
|
|
|
existing = data.get(rev)
|
|
|
|
if existing is not None:
|
|
|
|
old = existing[0]
|
|
|
|
data[rev] = (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
|
|
|
|
2012-05-12 02:24:07 +04:00
|
|
|
class phasecache(object):
|
2012-05-12 02:24:07 +04:00
|
|
|
def __init__(self, repo, phasedefaults, _load=True):
|
|
|
|
if _load:
|
|
|
|
# Cheap trick to allow shallow-copy without copy module
|
|
|
|
self.phaseroots, self.dirty = _readroots(repo, phasedefaults)
|
2017-12-14 16:37:10 +03:00
|
|
|
self._loadedrevslen = 0
|
2015-04-01 21:17:17 +03:00
|
|
|
self._phasesets = None
|
2013-01-04 09:11:29 +04:00
|
|
|
self.filterunknown(repo)
|
2015-01-11 02:25:54 +03:00
|
|
|
self.opener = repo.svfs
|
2012-05-12 02:24:07 +04:00
|
|
|
|
2017-12-09 01:20:34 +03:00
|
|
|
def getrevset(self, repo, phases, subset=None):
|
2017-02-18 09:49:05 +03:00
|
|
|
"""return a smartset for the given phases"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.loadphaserevs(repo) # ensure phase's sets are loaded
|
2017-12-06 17:46:41 +03:00
|
|
|
phases = set(phases)
|
|
|
|
if public not in phases:
|
|
|
|
# fast path: _phasesets contains the interesting sets,
|
|
|
|
# might only need a union and post-filtering.
|
|
|
|
if len(phases) == 1:
|
|
|
|
[p] = phases
|
|
|
|
revs = self._phasesets[p]
|
|
|
|
else:
|
|
|
|
revs = set.union(*[self._phasesets[p] for p in phases])
|
2017-02-18 09:49:05 +03:00
|
|
|
if repo.changelog.filteredrevs:
|
|
|
|
revs = revs - repo.changelog.filteredrevs
|
2017-12-09 01:20:34 +03:00
|
|
|
if subset is None:
|
|
|
|
return smartset.baseset(revs)
|
|
|
|
else:
|
|
|
|
return subset & smartset.baseset(revs)
|
2017-02-18 09:49:05 +03:00
|
|
|
else:
|
2017-12-06 17:46:41 +03:00
|
|
|
phases = set(allphases).difference(phases)
|
|
|
|
if not phases:
|
|
|
|
return smartset.fullreposet(repo)
|
|
|
|
if len(phases) == 1:
|
|
|
|
[p] = phases
|
|
|
|
revs = self._phasesets[p]
|
|
|
|
else:
|
|
|
|
revs = set.union(*[self._phasesets[p] for p in phases])
|
2017-12-09 01:20:34 +03:00
|
|
|
if subset is None:
|
|
|
|
subset = smartset.fullreposet(repo)
|
2017-12-06 17:46:41 +03:00
|
|
|
if not revs:
|
2017-12-09 01:20:34 +03:00
|
|
|
return subset
|
|
|
|
return subset.filter(lambda r: r not in revs)
|
2017-02-18 09:49:05 +03:00
|
|
|
|
2012-05-12 02:24:07 +04:00
|
|
|
def copy(self):
|
|
|
|
# Shallow copy meant to ensure isolation in
|
|
|
|
# advance/retractboundary(), nothing more.
|
2014-12-18 22:38:48 +03:00
|
|
|
ph = self.__class__(None, None, _load=False)
|
2012-05-12 02:24:07 +04:00
|
|
|
ph.phaseroots = self.phaseroots[:]
|
|
|
|
ph.dirty = self.dirty
|
|
|
|
ph.opener = self.opener
|
2017-12-14 16:35:37 +03:00
|
|
|
ph._loadedrevslen = self._loadedrevslen
|
2015-06-16 01:52:52 +03:00
|
|
|
ph._phasesets = self._phasesets
|
2012-05-12 02:24:07 +04:00
|
|
|
return ph
|
|
|
|
|
|
|
|
def replace(self, phcache):
|
2015-06-16 02:06:24 +03:00
|
|
|
"""replace all values in 'self' with content of phcache"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 a in ("phaseroots", "dirty", "opener", "_loadedrevslen", "_phasesets"):
|
2012-05-12 02:24:07 +04:00
|
|
|
setattr(self, a, getattr(phcache, a))
|
2012-05-12 02:24:07 +04:00
|
|
|
|
2015-03-31 01:38:24 +03:00
|
|
|
def _getphaserevsnative(self, repo):
|
2015-03-20 21:14:27 +03:00
|
|
|
repo = repo.unfiltered()
|
|
|
|
nativeroots = []
|
|
|
|
for phase in trackedphases:
|
|
|
|
nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase]))
|
2015-06-11 05:26:16 +03:00
|
|
|
return repo.changelog.computephases(nativeroots)
|
2015-03-20 21:14:27 +03:00
|
|
|
|
2015-03-31 01:38:24 +03:00
|
|
|
def _computephaserevspure(self, repo):
|
2015-03-30 22:48:15 +03:00
|
|
|
repo = repo.unfiltered()
|
2017-12-06 17:46:41 +03:00
|
|
|
cl = repo.changelog
|
|
|
|
self._phasesets = [set() for phase in allphases]
|
|
|
|
roots = pycompat.maplist(cl.rev, self.phaseroots[secret])
|
|
|
|
if roots:
|
|
|
|
ps = set(cl.descendants(roots))
|
|
|
|
for root in roots:
|
|
|
|
ps.add(root)
|
|
|
|
self._phasesets[secret] = ps
|
|
|
|
roots = pycompat.maplist(cl.rev, self.phaseroots[draft])
|
|
|
|
if roots:
|
|
|
|
ps = set(cl.descendants(roots))
|
|
|
|
for root in roots:
|
|
|
|
ps.add(root)
|
|
|
|
ps.difference_update(self._phasesets[secret])
|
|
|
|
self._phasesets[draft] = ps
|
2017-12-14 16:35:37 +03:00
|
|
|
self._loadedrevslen = len(cl)
|
2015-03-30 22:48:15 +03:00
|
|
|
|
2015-06-16 02:04:14 +03:00
|
|
|
def loadphaserevs(self, repo):
|
|
|
|
"""ensure phase information is loaded in the object"""
|
2017-12-06 17:46:41 +03:00
|
|
|
if self._phasesets is None:
|
2015-03-20 21:14:27 +03:00
|
|
|
try:
|
2017-03-02 02:50:01 +03:00
|
|
|
res = self._getphaserevsnative(repo)
|
2017-12-14 16:35:37 +03:00
|
|
|
self._loadedrevslen, self._phasesets = res
|
2015-03-20 21:14:27 +03:00
|
|
|
except AttributeError:
|
2015-03-31 01:38:24 +03:00
|
|
|
self._computephaserevspure(repo)
|
2014-10-07 22:42:37 +04:00
|
|
|
|
2014-10-07 22:37:54 +04:00
|
|
|
def invalidate(self):
|
2017-12-14 16:37:10 +03:00
|
|
|
self._loadedrevslen = 0
|
2015-06-16 01:57:47 +03:00
|
|
|
self._phasesets = None
|
2012-05-12 02:24:07 +04:00
|
|
|
|
|
|
|
def phase(self, repo, rev):
|
2017-12-06 17:46:41 +03:00
|
|
|
# We need a repo argument here to be able to build _phasesets
|
2012-05-12 02:24:07 +04:00
|
|
|
# if necessary. The repository instance is not stored in
|
|
|
|
# phasecache to avoid reference cycles. The changelog instance
|
|
|
|
# is not stored because it is a filecache() property and can
|
|
|
|
# be replaced without us being notified.
|
|
|
|
if rev == nullrev:
|
|
|
|
return public
|
2013-11-05 07:59:00 +04:00
|
|
|
if rev < nullrev:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise ValueError(_("cannot lookup negative revision"))
|
2017-12-14 16:35:37 +03:00
|
|
|
if rev >= self._loadedrevslen:
|
2014-10-07 22:37:54 +04:00
|
|
|
self.invalidate()
|
2015-06-16 02:04:14 +03:00
|
|
|
self.loadphaserevs(repo)
|
2017-12-06 17:46:41 +03:00
|
|
|
for phase in trackedphases:
|
|
|
|
if rev in self._phasesets[phase]:
|
|
|
|
return phase
|
|
|
|
return public
|
2012-05-12 02:24:07 +04:00
|
|
|
|
|
|
|
def write(self):
|
|
|
|
if not self.dirty:
|
|
|
|
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
|
|
|
f = self.opener("phaseroots", "w", atomictemp=True, checkambig=True)
|
2012-05-12 02:24:07 +04:00
|
|
|
try:
|
2014-08-08 01:41:00 +04:00
|
|
|
self._write(f)
|
2012-05-12 02:24:07 +04:00
|
|
|
finally:
|
|
|
|
f.close()
|
2014-08-08 01:41:00 +04:00
|
|
|
|
|
|
|
def _write(self, fp):
|
|
|
|
for phase, roots in enumerate(self.phaseroots):
|
|
|
|
for h in roots:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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("%i %s\n" % (phase, hex(h)))
|
2012-05-12 02:24:07 +04:00
|
|
|
self.dirty = False
|
2011-11-07 17:11:01 +04:00
|
|
|
|
2014-08-08 01:11:36 +04:00
|
|
|
def _updateroots(self, phase, newroots, tr):
|
2012-05-12 02:24:07 +04:00
|
|
|
self.phaseroots[phase] = newroots
|
2014-10-07 22:37:54 +04:00
|
|
|
self.invalidate()
|
2012-05-12 02:24:07 +04:00
|
|
|
self.dirty = 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
|
|
|
tr.addfilegenerator("phase", ("phaseroots",), self._write)
|
|
|
|
tr.hookargs["phases_moved"] = "1"
|
2014-08-08 01:11:36 +04:00
|
|
|
|
2017-07-11 04:47:25 +03:00
|
|
|
def registernew(self, repo, tr, targetphase, nodes):
|
|
|
|
repo = repo.unfiltered()
|
|
|
|
self._retractboundary(repo, tr, targetphase, nodes)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 tr is not None and "phases" in tr.changes:
|
|
|
|
phasetracking = tr.changes["phases"]
|
2017-07-11 04:47:25 +03:00
|
|
|
torev = repo.changelog.rev
|
|
|
|
phase = self.phase
|
|
|
|
for n in nodes:
|
|
|
|
rev = torev(n)
|
|
|
|
revphase = phase(repo, rev)
|
|
|
|
_trackphasechange(phasetracking, rev, None, revphase)
|
|
|
|
repo.invalidatevolatilesets()
|
|
|
|
|
2014-08-06 12:54:19 +04:00
|
|
|
def advanceboundary(self, repo, tr, targetphase, nodes):
|
2017-07-10 23:18:41 +03:00
|
|
|
"""Set all 'nodes' to phase 'targetphase'
|
|
|
|
|
|
|
|
Nodes with a phase lower than 'targetphase' are not affected.
|
|
|
|
"""
|
2012-05-12 02:24:07 +04:00
|
|
|
# Be careful to preserve shallow-copied values: do not update
|
|
|
|
# phaseroots values, replace them.
|
2017-07-11 03:39:52 +03:00
|
|
|
if tr is None:
|
|
|
|
phasetracking = None
|
|
|
|
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
|
|
|
phasetracking = tr.changes.get("phases")
|
2012-05-12 02:24:07 +04:00
|
|
|
|
2012-11-21 03:53:45 +04:00
|
|
|
repo = repo.unfiltered()
|
2017-07-11 03:39:52 +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
|
|
|
delroots = [] # set of root deleted by this path
|
2012-05-12 02:24:07 +04:00
|
|
|
for phase in xrange(targetphase + 1, len(allphases)):
|
|
|
|
# filter nodes that are not in a compatible phase already
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
nodes = [n for n in nodes if self.phase(repo, repo[n].rev()) >= phase]
|
2012-05-12 02:24:07 +04:00
|
|
|
if not nodes:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
break # no roots to move anymore
|
2017-07-10 23:18:41 +03:00
|
|
|
|
2012-05-12 02:24:07 +04:00
|
|
|
olds = self.phaseroots[phase]
|
2017-07-11 03:39:52 +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
|
|
|
affected = repo.revs("%ln::%ln", olds, nodes)
|
2017-07-11 03:39:52 +03:00
|
|
|
for r in affected:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_trackphasechange(phasetracking, r, self.phase(repo, r), targetphase)
|
2017-07-10 23:18:41 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
roots = set(
|
|
|
|
ctx.node() for ctx in repo.set("roots((%ln::) - %ld)", olds, affected)
|
|
|
|
)
|
2012-05-12 02:24:07 +04:00
|
|
|
if olds != roots:
|
2014-08-08 01:11:36 +04:00
|
|
|
self._updateroots(phase, roots, tr)
|
2012-05-12 02:24:07 +04:00
|
|
|
# some roots may need to be declared for lower phases
|
|
|
|
delroots.extend(olds - roots)
|
2017-07-10 23:22:42 +03:00
|
|
|
# declare deleted root in the target phase
|
|
|
|
if targetphase != 0:
|
2017-07-11 00:50:16 +03:00
|
|
|
self._retractboundary(repo, tr, targetphase, delroots)
|
2012-12-18 05:04:37 +04:00
|
|
|
repo.invalidatevolatilesets()
|
2012-05-12 02:24:07 +04:00
|
|
|
|
2014-08-06 10:52:21 +04:00
|
|
|
def retractboundary(self, repo, tr, targetphase, nodes):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
oldroots = self.phaseroots[: targetphase + 1]
|
2017-07-12 21:11:00 +03:00
|
|
|
if tr is None:
|
|
|
|
phasetracking = None
|
|
|
|
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
|
|
|
phasetracking = tr.changes.get("phases")
|
2017-07-12 21:11:00 +03:00
|
|
|
repo = repo.unfiltered()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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._retractboundary(repo, tr, targetphase, nodes)
|
|
|
|
and phasetracking is not None
|
|
|
|
):
|
2017-07-12 21:11:00 +03:00
|
|
|
|
|
|
|
# find the affected revisions
|
|
|
|
new = self.phaseroots[targetphase]
|
|
|
|
old = oldroots[targetphase]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
affected = set(repo.revs("(%ln::) - (%ln::)", new, old))
|
2017-07-12 21:11:00 +03:00
|
|
|
|
|
|
|
# find the phase of the affected revision
|
|
|
|
for phase in xrange(targetphase, -1, -1):
|
|
|
|
if phase:
|
|
|
|
roots = oldroots[phase]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 = set(repo.revs("%ln::%ld", roots, affected))
|
2017-07-12 21:11:00 +03:00
|
|
|
affected -= revs
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
else: # public phase
|
2017-07-12 21:11:00 +03:00
|
|
|
revs = affected
|
|
|
|
for r in revs:
|
|
|
|
_trackphasechange(phasetracking, r, phase, targetphase)
|
2017-07-11 00:50:16 +03:00
|
|
|
repo.invalidatevolatilesets()
|
|
|
|
|
|
|
|
def _retractboundary(self, repo, tr, targetphase, nodes):
|
2012-05-12 02:24:07 +04:00
|
|
|
# Be careful to preserve shallow-copied values: do not update
|
|
|
|
# phaseroots values, replace them.
|
|
|
|
|
2012-11-21 03:53:45 +04:00
|
|
|
repo = repo.unfiltered()
|
2012-05-12 02:24:07 +04:00
|
|
|
currentroots = self.phaseroots[targetphase]
|
2017-07-13 00:15:09 +03:00
|
|
|
finalroots = oldroots = set(currentroots)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
newroots = [n for n in nodes if self.phase(repo, repo[n].rev()) < targetphase]
|
2012-05-12 02:24:07 +04:00
|
|
|
if newroots:
|
2017-07-11 00:50:16 +03:00
|
|
|
|
2012-05-12 02:24:07 +04:00
|
|
|
if nullid in newroots:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.Abort(_("cannot change null revision phase"))
|
2012-05-12 02:24:07 +04:00
|
|
|
currentroots = currentroots.copy()
|
|
|
|
currentroots.update(newroots)
|
phase: improve retractboundary perf
The existing retractboundary implementation computed the new boundary by walking
all descendants of all existing roots and computing the new roots. This is
O(commits since first root), which on long repos can be hundreds of thousands of
commits.
The new algorithm only updates roots that are greater than the new root
locations. For common operations like commit on a repo with the earliest root
several hundred thousand commits ago, this makes retractboundary go from
1 second to 0.008 seconds.
I tested it by running the test suite with both implementations and checking
that the root results were always the identical.
There was some discussion on IRC about the safety of this (i.e. what if the new
nodes are already part of the phase, etc). I've looked into it and believe this
patch is safe:
1) The old existing code already filters the input nodes to only contain nodes
that require retracting (i.e. we only make node X a new root if the old phase
is less than the target phase), so there's no chance of us adding a
unnecessary root to the phase (unless the input root is made unnecessary by
another root in the same input, but see point #3).
2) Another way of thinking about this is: the only way the new algorithm would
be different from the old algorithm is if it added a root that is a
descendant of an old root (since the old algorithm would've caught this in
the big "roots(%ln::)". At the beginning of the function, when we filter out
roots that already meet the phase criteria, the *definition* of meeting the
phase criteria is "not being a descendant of an existing root". Therefore,
by definition none of the new roots we are processing are descendants of an
existing root.
3) If two nodes are passed in as input, and one node is an ancestor of the other
(and therefore the later node should not be a root), this is still caught by
the 'roots(%ln::)' revset. So there's no chance of an extra root being
introduced that way either.
2015-11-08 03:11:49 +03:00
|
|
|
|
|
|
|
# Only compute new roots for revs above the roots that are being
|
|
|
|
# retracted.
|
|
|
|
minnewroot = min(repo[n].rev() for n in newroots)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
aboveroots = [n for n in currentroots if repo[n].rev() >= minnewroot]
|
|
|
|
updatedroots = repo.set("roots(%ln::)", aboveroots)
|
phase: improve retractboundary perf
The existing retractboundary implementation computed the new boundary by walking
all descendants of all existing roots and computing the new roots. This is
O(commits since first root), which on long repos can be hundreds of thousands of
commits.
The new algorithm only updates roots that are greater than the new root
locations. For common operations like commit on a repo with the earliest root
several hundred thousand commits ago, this makes retractboundary go from
1 second to 0.008 seconds.
I tested it by running the test suite with both implementations and checking
that the root results were always the identical.
There was some discussion on IRC about the safety of this (i.e. what if the new
nodes are already part of the phase, etc). I've looked into it and believe this
patch is safe:
1) The old existing code already filters the input nodes to only contain nodes
that require retracting (i.e. we only make node X a new root if the old phase
is less than the target phase), so there's no chance of us adding a
unnecessary root to the phase (unless the input root is made unnecessary by
another root in the same input, but see point #3).
2) Another way of thinking about this is: the only way the new algorithm would
be different from the old algorithm is if it added a root that is a
descendant of an old root (since the old algorithm would've caught this in
the big "roots(%ln::)". At the beginning of the function, when we filter out
roots that already meet the phase criteria, the *definition* of meeting the
phase criteria is "not being a descendant of an existing root". Therefore,
by definition none of the new roots we are processing are descendants of an
existing root.
3) If two nodes are passed in as input, and one node is an ancestor of the other
(and therefore the later node should not be a root), this is still caught by
the 'roots(%ln::)' revset. So there's no chance of an extra root being
introduced that way either.
2015-11-08 03:11:49 +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
|
|
|
finalroots = set(n for n in currentroots if repo[n].rev() < minnewroot)
|
phase: improve retractboundary perf
The existing retractboundary implementation computed the new boundary by walking
all descendants of all existing roots and computing the new roots. This is
O(commits since first root), which on long repos can be hundreds of thousands of
commits.
The new algorithm only updates roots that are greater than the new root
locations. For common operations like commit on a repo with the earliest root
several hundred thousand commits ago, this makes retractboundary go from
1 second to 0.008 seconds.
I tested it by running the test suite with both implementations and checking
that the root results were always the identical.
There was some discussion on IRC about the safety of this (i.e. what if the new
nodes are already part of the phase, etc). I've looked into it and believe this
patch is safe:
1) The old existing code already filters the input nodes to only contain nodes
that require retracting (i.e. we only make node X a new root if the old phase
is less than the target phase), so there's no chance of us adding a
unnecessary root to the phase (unless the input root is made unnecessary by
another root in the same input, but see point #3).
2) Another way of thinking about this is: the only way the new algorithm would
be different from the old algorithm is if it added a root that is a
descendant of an old root (since the old algorithm would've caught this in
the big "roots(%ln::)". At the beginning of the function, when we filter out
roots that already meet the phase criteria, the *definition* of meeting the
phase criteria is "not being a descendant of an existing root". Therefore,
by definition none of the new roots we are processing are descendants of an
existing root.
3) If two nodes are passed in as input, and one node is an ancestor of the other
(and therefore the later node should not be a root), this is still caught by
the 'roots(%ln::)' revset. So there's no chance of an extra root being
introduced that way either.
2015-11-08 03:11:49 +03:00
|
|
|
finalroots.update(ctx.node() for ctx in updatedroots)
|
2017-07-13 00:15:09 +03:00
|
|
|
if finalroots != oldroots:
|
phase: improve retractboundary perf
The existing retractboundary implementation computed the new boundary by walking
all descendants of all existing roots and computing the new roots. This is
O(commits since first root), which on long repos can be hundreds of thousands of
commits.
The new algorithm only updates roots that are greater than the new root
locations. For common operations like commit on a repo with the earliest root
several hundred thousand commits ago, this makes retractboundary go from
1 second to 0.008 seconds.
I tested it by running the test suite with both implementations and checking
that the root results were always the identical.
There was some discussion on IRC about the safety of this (i.e. what if the new
nodes are already part of the phase, etc). I've looked into it and believe this
patch is safe:
1) The old existing code already filters the input nodes to only contain nodes
that require retracting (i.e. we only make node X a new root if the old phase
is less than the target phase), so there's no chance of us adding a
unnecessary root to the phase (unless the input root is made unnecessary by
another root in the same input, but see point #3).
2) Another way of thinking about this is: the only way the new algorithm would
be different from the old algorithm is if it added a root that is a
descendant of an old root (since the old algorithm would've caught this in
the big "roots(%ln::)". At the beginning of the function, when we filter out
roots that already meet the phase criteria, the *definition* of meeting the
phase criteria is "not being a descendant of an existing root". Therefore,
by definition none of the new roots we are processing are descendants of an
existing root.
3) If two nodes are passed in as input, and one node is an ancestor of the other
(and therefore the later node should not be a root), this is still caught by
the 'roots(%ln::)' revset. So there's no chance of an extra root being
introduced that way either.
2015-11-08 03:11:49 +03:00
|
|
|
self._updateroots(targetphase, finalroots, tr)
|
2017-07-13 00:15:09 +03:00
|
|
|
return True
|
|
|
|
return False
|
2012-05-12 02:24:07 +04:00
|
|
|
|
2013-01-04 09:11:29 +04:00
|
|
|
def filterunknown(self, repo):
|
|
|
|
"""remove unknown nodes from the phase boundary
|
|
|
|
|
|
|
|
Nothing is lost as unknown nodes only hold data for their descendants.
|
|
|
|
"""
|
|
|
|
filtered = 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
|
|
|
nodemap = repo.changelog.nodemap # to filter unknown nodes
|
2013-01-04 09:11:29 +04:00
|
|
|
for phase, nodes in enumerate(self.phaseroots):
|
2014-02-20 05:43:17 +04:00
|
|
|
missing = sorted(node for node in nodes if node not in nodemap)
|
2013-01-04 09:11:29 +04:00
|
|
|
if missing:
|
|
|
|
for mnode in missing:
|
|
|
|
repo.ui.debug(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"removing unknown node %s from %i-phase boundary\n"
|
|
|
|
% (short(mnode), phase)
|
|
|
|
)
|
2013-01-04 09:11:29 +04:00
|
|
|
nodes.symmetric_difference_update(missing)
|
|
|
|
filtered = True
|
|
|
|
if filtered:
|
|
|
|
self.dirty = True
|
2013-04-15 19:10:58 +04:00
|
|
|
# filterunknown is called by repo.destroyed, we may have no changes in
|
2017-12-06 17:46:41 +03:00
|
|
|
# root but _phasesets contents is certainly invalid (or at least we
|
2013-10-23 21:49:56 +04:00
|
|
|
# have not proper way to check that). related to issue 3858.
|
2013-04-15 19:10:58 +04:00
|
|
|
#
|
2017-12-06 17:46:41 +03:00
|
|
|
# The other caller is __init__ that have no _phasesets initialized
|
2013-04-15 19:10:58 +04:00
|
|
|
# anyway. If this change we should consider adding a dedicated
|
2013-10-23 21:49:56 +04:00
|
|
|
# "destroyed" function to phasecache or a proper cache key mechanism
|
2013-04-15 19:10:58 +04:00
|
|
|
# (see branchmap one)
|
2014-10-07 22:37:54 +04:00
|
|
|
self.invalidate()
|
2013-01-04 09:11:29 +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-08-06 12:54:19 +04:00
|
|
|
def advanceboundary(repo, tr, targetphase, nodes):
|
2011-11-07 17:11:01 +04:00
|
|
|
"""Add nodes to a phase changing other nodes phases if necessary.
|
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
This function move boundary *forward* this means that all nodes
|
|
|
|
are set in the target phase or kept in a *lower* phase.
|
2011-11-07 17:11:01 +04:00
|
|
|
|
2011-11-11 03:16:53 +04:00
|
|
|
Simplify boundary to contains phase roots only."""
|
2012-05-12 02:24:07 +04:00
|
|
|
phcache = repo._phasecache.copy()
|
2014-08-06 12:54:19 +04:00
|
|
|
phcache.advanceboundary(repo, tr, targetphase, nodes)
|
2012-05-12 02:24:07 +04:00
|
|
|
repo._phasecache.replace(phcache)
|
2011-11-11 03:16:53 +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-08-06 10:52:21 +04:00
|
|
|
def retractboundary(repo, tr, targetphase, nodes):
|
2012-05-13 14:07:49 +04:00
|
|
|
"""Set nodes back to a phase changing other nodes phases if
|
|
|
|
necessary.
|
2011-11-11 03:16:53 +04:00
|
|
|
|
2012-05-13 14:07:49 +04:00
|
|
|
This function move boundary *backward* this means that all nodes
|
|
|
|
are set in the target phase or kept in a *higher* phase.
|
2011-11-11 03:16:53 +04:00
|
|
|
|
|
|
|
Simplify boundary to contains phase roots only."""
|
2012-05-12 02:24:07 +04:00
|
|
|
phcache = repo._phasecache.copy()
|
2014-08-06 10:52:21 +04:00
|
|
|
phcache.retractboundary(repo, tr, targetphase, nodes)
|
2012-05-12 02:24:07 +04:00
|
|
|
repo._phasecache.replace(phcache)
|
2011-12-15 14:24: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
|
|
|
|
2017-07-11 04:47:25 +03:00
|
|
|
def registernew(repo, tr, targetphase, nodes):
|
|
|
|
"""register a new revision and its phase
|
|
|
|
|
|
|
|
Code adding revisions to the repository should use this function to
|
|
|
|
set new changeset in their target phase (or higher).
|
|
|
|
"""
|
|
|
|
phcache = repo._phasecache.copy()
|
|
|
|
phcache.registernew(repo, tr, targetphase, nodes)
|
|
|
|
repo._phasecache.replace(phcache)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-12-15 14:24:26 +04:00
|
|
|
def listphases(repo):
|
2012-05-13 14:06:12 +04:00
|
|
|
"""List phases root for serialization over pushkey"""
|
2017-04-14 08:12:04 +03:00
|
|
|
# Use ordered dictionary so behavior is deterministic.
|
|
|
|
keys = util.sortdict()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
value = "%i" % draft
|
2017-10-11 21:08:02 +03:00
|
|
|
cl = repo.unfiltered().changelog
|
2012-05-12 02:24:07 +04:00
|
|
|
for root in repo._phasecache.phaseroots[draft]:
|
2017-10-11 21:08:02 +03:00
|
|
|
if repo._phasecache.phase(repo, cl.rev(root)) <= draft:
|
|
|
|
keys[hex(root)] = value
|
2012-01-13 05:04:16 +04:00
|
|
|
|
2015-06-18 23:34:22 +03:00
|
|
|
if repo.publishing():
|
2012-05-13 14:07:49 +04:00
|
|
|
# Add an extra data to let remote know we are a publishing
|
|
|
|
# repo. Publishing repo can't just pretend they are old repo.
|
|
|
|
# When pushing to a publishing repo, the client still need to
|
|
|
|
# push phase boundary
|
2011-12-15 14:24:26 +04:00
|
|
|
#
|
2012-05-13 14:07:49 +04:00
|
|
|
# Push do not only push changeset. It also push phase data.
|
|
|
|
# New phase data may apply to common changeset which won't be
|
|
|
|
# push (as they are common). Here is a very simple example:
|
2011-12-15 14:24:26 +04:00
|
|
|
#
|
|
|
|
# 1) repo A push changeset X as draft to repo B
|
|
|
|
# 2) repo B make changeset X public
|
2012-05-13 14:07:49 +04:00
|
|
|
# 3) repo B push to repo A. X is not pushed but the data that
|
|
|
|
# X as now public should
|
2011-12-15 14:24:26 +04:00
|
|
|
#
|
2012-05-13 14:07:49 +04:00
|
|
|
# The server can't handle it on it's own as it has no idea of
|
|
|
|
# client phase data.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
keys["publishing"] = "True"
|
2011-12-15 14:24:26 +04:00
|
|
|
return keys
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2011-12-15 14:24:26 +04:00
|
|
|
def pushphase(repo, nhex, oldphasestr, newphasestr):
|
2012-08-18 00:58:19 +04:00
|
|
|
"""List phases root for serialization over pushkey"""
|
2012-11-21 03:53:45 +04:00
|
|
|
repo = repo.unfiltered()
|
2016-01-16 00:14:49 +03:00
|
|
|
with repo.lock():
|
2011-12-15 14:24:26 +04:00
|
|
|
currentphase = repo[nhex].phase()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
newphase = abs(int(newphasestr)) # let's avoid negative index surprise
|
|
|
|
oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
|
2011-12-15 14:24:26 +04:00
|
|
|
if currentphase == oldphase and newphase < oldphase:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.transaction("pushkey-phase") as tr:
|
2016-01-16 00:14:49 +03:00
|
|
|
advanceboundary(repo, tr, newphase, [bin(nhex)])
|
2017-06-13 02:35:57 +03:00
|
|
|
return True
|
2012-02-02 00:17:26 +04:00
|
|
|
elif currentphase == newphase:
|
|
|
|
# raced, but got correct result
|
2017-06-13 02:35:57 +03:00
|
|
|
return True
|
2011-12-15 14:24:26 +04:00
|
|
|
else:
|
2017-06-13 02:35:57 +03:00
|
|
|
return False
|
2011-12-15 05:18:24 +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-06-22 20:10:02 +03:00
|
|
|
def subsetphaseheads(repo, subset):
|
|
|
|
"""Finds the phase heads for a subset of a history
|
|
|
|
|
|
|
|
Returns a list indexed by phase number where each item is a list of phase
|
|
|
|
head nodes.
|
|
|
|
"""
|
|
|
|
cl = repo.changelog
|
|
|
|
|
|
|
|
headsbyphase = [[] for i in allphases]
|
|
|
|
# No need to keep track of secret phase; any heads in the subset that
|
|
|
|
# are not mentioned are implicitly secret.
|
|
|
|
for phase in allphases[:-1]:
|
|
|
|
revset = "heads(%%ln & %s())" % phasenames[phase]
|
|
|
|
headsbyphase[phase] = [cl.node(r) for r in repo.revs(revset, subset)]
|
|
|
|
return headsbyphase
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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-20 19:29:10 +03:00
|
|
|
def updatephases(repo, trgetter, headsbyphase):
|
2017-06-22 20:10:02 +03:00
|
|
|
"""Updates the repo with the given phase heads"""
|
|
|
|
# Now advance phase boundaries of all but secret phase
|
2017-09-20 19:29:10 +03:00
|
|
|
#
|
|
|
|
# run the update (and fetch transaction) only if there are actually things
|
|
|
|
# to update. This avoid creating empty transaction during no-op operation.
|
|
|
|
|
2017-06-22 20:10:02 +03:00
|
|
|
for phase in allphases[:-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
|
|
|
revset = "%%ln - %s()" % phasenames[phase]
|
2017-09-20 19:29:10 +03:00
|
|
|
heads = [c.node() for c in repo.set(revset, headsbyphase[phase])]
|
|
|
|
if heads:
|
|
|
|
advanceboundary(repo, trgetter(), phase, heads)
|
2017-06-22 20:10:02 +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
|
|
|
|
2011-12-15 05:18:24 +04:00
|
|
|
def analyzeremotephases(repo, subset, roots):
|
|
|
|
"""Compute phases heads and root in a subset of node from root dict
|
|
|
|
|
|
|
|
* subset is heads of the subset
|
|
|
|
* roots is {<nodeid> => phase} mapping. key and value are string.
|
|
|
|
|
|
|
|
Accept unknown element input
|
|
|
|
"""
|
2012-11-21 03:53:45 +04:00
|
|
|
repo = repo.unfiltered()
|
2011-12-15 05:18:24 +04:00
|
|
|
# build list from dictionary
|
2012-01-13 05:04:16 +04:00
|
|
|
draftroots = []
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
nodemap = repo.changelog.nodemap # to filter unknown nodes
|
2011-12-15 05:18:24 +04:00
|
|
|
for nhex, phase in roots.iteritems():
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 nhex == "publishing": # ignore data related to publish option
|
2011-12-15 05:18:24 +04:00
|
|
|
continue
|
|
|
|
node = bin(nhex)
|
|
|
|
phase = int(phase)
|
2016-02-16 03:49:52 +03:00
|
|
|
if phase == public:
|
2012-01-13 05:04:16 +04:00
|
|
|
if node != nullid:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
repo.ui.warn(
|
|
|
|
_("ignoring inconsistent public root" " from remote: %s\n") % nhex
|
|
|
|
)
|
2016-02-16 03:49:52 +03:00
|
|
|
elif phase == draft:
|
2012-01-18 19:46:15 +04:00
|
|
|
if node in nodemap:
|
2012-01-13 05:04:16 +04:00
|
|
|
draftroots.append(node)
|
|
|
|
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
|
|
|
repo.ui.warn(
|
|
|
|
_("ignoring unexpected root from remote: %i %s\n") % (phase, nhex)
|
|
|
|
)
|
2011-12-15 05:18:24 +04:00
|
|
|
# compute heads
|
2012-01-20 22:23:53 +04:00
|
|
|
publicheads = newheads(repo, subset, draftroots)
|
2012-01-13 05:04:16 +04:00
|
|
|
return publicheads, draftroots
|
2011-12-15 05:18:24 +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-10-11 19:39:04 +03:00
|
|
|
class remotephasessummary(object):
|
|
|
|
"""summarize phase information on the remote side
|
|
|
|
|
|
|
|
:publishing: True is the remote is publishing
|
|
|
|
:publicheads: list of remote public phase heads (nodes)
|
|
|
|
:draftheads: list of remote draft phase heads (nodes)
|
|
|
|
:draftroots: list of remote draft phase root (nodes)
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, repo, remotesubset, remoteroots):
|
|
|
|
unfi = repo.unfiltered()
|
|
|
|
self._allremoteroots = remoteroots
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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.publishing = remoteroots.get("publishing", False)
|
2017-10-11 19:39:04 +03:00
|
|
|
|
|
|
|
ana = analyzeremotephases(repo, remotesubset, remoteroots)
|
|
|
|
self.publicheads, self.draftroots = ana
|
|
|
|
# Get the list of all "heads" revs draft on remote
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
dheads = unfi.set("heads(%ln::%ln)", self.draftroots, remotesubset)
|
2017-10-11 19:39:04 +03:00
|
|
|
self.draftheads = [c.node() for c in dheads]
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-01-20 22:23:53 +04:00
|
|
|
def newheads(repo, heads, roots):
|
|
|
|
"""compute new head of a subset minus another
|
|
|
|
|
|
|
|
* `heads`: define the first subset
|
2012-08-16 00:39:18 +04:00
|
|
|
* `roots`: define the second we subtract from the first"""
|
2012-11-21 03:53:45 +04:00
|
|
|
repo = repo.unfiltered()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
revset = repo.set(
|
|
|
|
"heads((%ln + parents(%ln)) - (%ln::%ln))", heads, roots, roots, heads
|
|
|
|
)
|
2012-01-20 22:23:53 +04:00
|
|
|
return [c.node() for c in revset]
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-01-30 20:46:15 +04:00
|
|
|
def newcommitphase(ui):
|
|
|
|
"""helper to get the target phase of new commit
|
|
|
|
|
|
|
|
Handle all possible values for the phases.new-commit options.
|
|
|
|
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
v = ui.config("phases", "new-commit")
|
2012-01-30 20:46:15 +04:00
|
|
|
try:
|
|
|
|
return phasenames.index(v)
|
|
|
|
except ValueError:
|
|
|
|
try:
|
|
|
|
return int(v)
|
|
|
|
except ValueError:
|
|
|
|
msg = _("phases.new-commit: not a valid phase name ('%s')")
|
|
|
|
raise error.ConfigError(msg % v)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2012-09-03 16:05:19 +04:00
|
|
|
def hassecret(repo):
|
|
|
|
"""utility function that check if a repo have any secret changeset."""
|
|
|
|
return bool(repo._phasecache.phaseroots[2])
|
2017-10-08 18:50:46 +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
|
|
|
|
2017-10-08 18:50:46 +03:00
|
|
|
def preparehookargs(node, old, new):
|
|
|
|
if old 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
|
|
|
old = ""
|
2017-10-08 18:50:46 +03:00
|
|
|
else:
|
2017-10-18 20:19:53 +03:00
|
|
|
old = phasenames[old]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` 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 {"node": node, "oldphase": old, "phase": phasenames[new]}
|