2022-01-06 01:42:23 +03:00
|
|
|
# Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
2019-11-01 22:33:28 +03:00
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
2008-06-18 09:06:41 +04:00
|
|
|
# Revision graph generator for Mercurial
|
|
|
|
#
|
|
|
|
# Copyright 2008 Dirkjan Ochtman <dirkjan@ochtman.nl>
|
|
|
|
# Copyright 2007 Joel Rosdahl <joel@rosdahl.net>
|
|
|
|
#
|
2009-04-26 03:08:54 +04:00
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-06-19 15:22:32 +04:00
|
|
|
"""supports walking the history as DAGs suitable for graphical output
|
|
|
|
|
|
|
|
The most basic format we use is that of::
|
|
|
|
|
|
|
|
(id, type, data, [parentids])
|
|
|
|
|
|
|
|
The node and parent ids are arbitrary integers which identify a node in the
|
|
|
|
context of the graph returned. Type is a constant specifying the node type.
|
|
|
|
Data depends on type.
|
|
|
|
"""
|
|
|
|
|
2015-08-09 05:18:23 +03:00
|
|
|
from __future__ import absolute_import
|
2009-06-19 15:22:32 +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
|
|
|
from . import dagop, smartset, util
|
2015-08-09 05:18:23 +03:00
|
|
|
from .node import 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
|
|
|
|
|
|
|
|
|
|
|
CHANGESET = "C"
|
|
|
|
PARENT = "P"
|
|
|
|
GRANDPARENT = "G"
|
|
|
|
MISSINGPARENT = "M"
|
2016-03-20 02:37:47 +03:00
|
|
|
# Style of line to draw. None signals a line that ends and is removed at this
|
graphmod: partial edge styling
Allow for a style to only apply to the last N lines (for positive N) or
everything but the first N lines (for negative N) of the section along the
current node. This allows for more subtle grandparent styling.
So from the default:
$ hg log -G ...
o Lorem ipsum dolor sit
:\ amet, consectetur
: : adipiscing elit, sed
: : do eiusmod tempor
: :
o : incididunt ut labore
| : et dolore magna
| : aliqua. Ut enim ad
| : minim veniam, quis
|/
o nostrud exercitation
: ullamco laboris nisi
: ut aliquip ex ea
: commodo consequat.
:
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
to
$ hg log -G --config "experimental.graphstyle.grandparent=2." ...
o Lorem ipsum dolor sit
|\ amet, consectetur
| | adipiscing elit, sed
. . do eiusmod tempor
. .
o | incididunt ut labore
| | et dolore magna
| | aliqua. Ut enim ad
| | minim veniam, quis
|/
o nostrud exercitation
| ullamco laboris nisi
| ut aliquip ex ea
. commodo consequat.
.
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
or
$ hg log -G --config "experimental.graphstyle.grandparent=1:" ...
o Lorem ipsum dolor sit
|\ amet, consectetur
| | adipiscing elit, sed
| | do eiusmod tempor
: :
o | incididunt ut labore
| | et dolore magna
| | aliqua. Ut enim ad
| | minim veniam, quis
|/
o nostrud exercitation
| ullamco laboris nisi
| ut aliquip ex ea
| commodo consequat.
:
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
or
$ hg log -G --config "experimental.graphstyle.grandparent=-2!" ...
o Lorem ipsum dolor sit
|\ amet, consectetur
! ! adipiscing elit, sed
! ! do eiusmod tempor
! !
o | incididunt ut labore
| | et dolore magna
| | aliqua. Ut enim ad
| | minim veniam, quis
|/
o nostrud exercitation
| ullamco laboris nisi
! ut aliquip ex ea
! commodo consequat.
!
o Duis aute irure dolor
| in reprehenderit in
~ voluptate velit esse
cillum dolore eu
2016-05-04 22:11:59 +03:00
|
|
|
# point. A number prefix means only the last N characters of the current block
|
|
|
|
# will use that style, the rest will use the PARENT style. Add a - sign
|
|
|
|
# (so making N negative) and all but the first N characters use that style.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
EDGES = {PARENT: "|", GRANDPARENT: ":", MISSINGPARENT: None}
|
2008-06-18 09:06:41 +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
|
|
|
|
2020-11-07 02:29:18 +03:00
|
|
|
def dagwalker(repo, revs, template):
|
2016-03-04 17:44:32 +03:00
|
|
|
"""cset DAG generator yielding (id, CHANGESET, ctx, [parentinfo]) tuples
|
2009-06-19 15:14:01 +04:00
|
|
|
|
2011-03-13 17:53:38 +03:00
|
|
|
This generator function walks through revisions (which should be ordered
|
2016-03-04 17:44:32 +03:00
|
|
|
from bigger to lower). It returns a tuple for each node.
|
|
|
|
|
|
|
|
Each parentinfo entry is a tuple with (edgetype, parentid), where edgetype
|
|
|
|
is one of PARENT, GRANDPARENT or MISSINGPARENT. The node and parent ids
|
|
|
|
are arbitrary integers which identify a node in the context of the graph
|
2011-03-13 17:53:38 +03:00
|
|
|
returned.
|
2016-03-04 17:44:32 +03:00
|
|
|
|
2009-06-19 15:14:01 +04:00
|
|
|
"""
|
2011-03-13 17:53:38 +03:00
|
|
|
if not revs:
|
2011-04-30 16:10:58 +04:00
|
|
|
return
|
2011-03-13 17:53:38 +03:00
|
|
|
|
2020-08-22 03:08:57 +03:00
|
|
|
simplifygrandparents = repo.ui.configbool("log", "simplify-grandparents")
|
|
|
|
cl = repo.changelog
|
|
|
|
if cl.algorithmbackend != "segments":
|
|
|
|
simplifygrandparents = False
|
|
|
|
if simplifygrandparents:
|
|
|
|
rootnodes = cl.tonodes(revs)
|
|
|
|
|
2011-03-13 17:53:38 +03:00
|
|
|
gpcache = {}
|
2020-12-15 00:10:41 +03:00
|
|
|
ctxstream = revs.prefetchbytemplate(repo, template).iterctx()
|
2020-11-07 02:29:18 +03:00
|
|
|
for ctx in ctxstream:
|
2016-03-04 17:44:32 +03:00
|
|
|
# partition into parents in the rev set and missing parents, then
|
|
|
|
# augment the lists with markers, to inform graph drawing code about
|
|
|
|
# what kind of edge to draw between nodes.
|
|
|
|
pset = set(p.rev() for p in ctx.parents() if p.rev() in 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
|
|
|
mpars = [
|
|
|
|
p.rev() for p in ctx.parents() if p.rev() != nullrev and p.rev() not in pset
|
|
|
|
]
|
2016-03-04 17:44:32 +03:00
|
|
|
parents = [(PARENT, p) for p in sorted(pset)]
|
2011-03-13 17:53:38 +03:00
|
|
|
|
|
|
|
for mpar in mpars:
|
2011-05-01 17:51:46 +04:00
|
|
|
gp = gpcache.get(mpar)
|
2011-03-13 17:53:38 +03:00
|
|
|
if gp is None:
|
2020-08-22 03:08:57 +03:00
|
|
|
if simplifygrandparents:
|
|
|
|
gp = gpcache[mpar] = cl.torevs(
|
|
|
|
cl.dageval(
|
|
|
|
lambda: headsancestors(
|
|
|
|
ancestors(cl.tonodes([mpar])) & rootnodes
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
# precompute slow query as we know reachableroots() goes
|
|
|
|
# through all revs (issue4782)
|
|
|
|
if not isinstance(revs, smartset.baseset):
|
2020-12-15 00:10:41 +03:00
|
|
|
revs = smartset.baseset(revs, repo=repo)
|
2020-08-22 03:08:57 +03:00
|
|
|
gp = gpcache[mpar] = sorted(
|
|
|
|
set(dagop.reachableroots(repo, revs, [mpar]))
|
|
|
|
)
|
2011-05-01 17:51:46 +04:00
|
|
|
if not gp:
|
2016-03-04 17:44:32 +03:00
|
|
|
parents.append((MISSINGPARENT, mpar))
|
|
|
|
pset.add(mpar)
|
2011-05-01 17:51:46 +04:00
|
|
|
else:
|
2016-03-04 17:44:32 +03:00
|
|
|
parents.extend((GRANDPARENT, g) for g in gp if g not in pset)
|
|
|
|
pset.update(gp)
|
2011-03-13 17:53:38 +03:00
|
|
|
|
2011-04-30 16:10:58 +04:00
|
|
|
yield (ctx.rev(), CHANGESET, ctx, parents)
|
2009-06-19 15:14:01 +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
|
|
|
|
2009-06-19 15:14:45 +04:00
|
|
|
def nodes(repo, nodes):
|
2009-06-19 15:22:32 +04:00
|
|
|
"""cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
|
|
|
|
|
|
|
|
This generator function walks the given nodes. It only returns parents
|
|
|
|
that are in nodes, too.
|
|
|
|
"""
|
2009-06-19 15:14:45 +04:00
|
|
|
include = set(nodes)
|
|
|
|
for node in nodes:
|
|
|
|
ctx = repo[node]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
parents = set((PARENT, p.rev()) for p in ctx.parents() if p.node() in include)
|
2009-06-19 15:22:32 +04:00
|
|
|
yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
|
2009-06-19 15:14:45 +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
|
|
|
|
2012-01-22 16:35:26 +04:00
|
|
|
def colored(dag, repo):
|
2009-06-19 15:44:23 +04:00
|
|
|
"""annotates a DAG with colored edge information
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-06-19 15:44:23 +04:00
|
|
|
For each DAG node this function emits tuples::
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-06-19 15:44:23 +04:00
|
|
|
(id, type, data, (col, color), [(col, nextcol, color)])
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-06-19 15:44:23 +04:00
|
|
|
with the following new elements:
|
2009-01-04 21:10:42 +03:00
|
|
|
|
2009-06-19 15:44:23 +04:00
|
|
|
- Tuple (col, color) with column and color index for the current node
|
|
|
|
- A list of tuples indicating the edges between the current node and its
|
|
|
|
parents.
|
|
|
|
"""
|
2009-05-16 09:12:12 +04:00
|
|
|
seen = []
|
2008-06-18 09:06:41 +04:00
|
|
|
colors = {}
|
2009-05-16 09:12:12 +04:00
|
|
|
newcolor = 1
|
2012-01-22 16:35:26 +04:00
|
|
|
config = {}
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
for key, val in repo.ui.configitems("graph"):
|
|
|
|
if "." in key:
|
|
|
|
branch, setting = key.rsplit(".", 1)
|
2012-02-17 23:53:19 +04:00
|
|
|
# Validation
|
|
|
|
if setting == "width" and val.isdigit():
|
2012-01-22 16:35:26 +04:00
|
|
|
config.setdefault(branch, {})[setting] = int(val)
|
2012-02-17 23:53:19 +04:00
|
|
|
elif setting == "color" and val.isalnum():
|
|
|
|
config.setdefault(branch, {})[setting] = val
|
|
|
|
|
2012-02-17 23:53:41 +04:00
|
|
|
if config:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
getconf = util.lrucachefunc(lambda rev: config.get(repo[rev].branch(), {}))
|
2012-02-17 23:53:41 +04:00
|
|
|
else:
|
2012-01-22 16:35:26 +04:00
|
|
|
getconf = lambda rev: {}
|
2012-01-22 16:35:26 +04:00
|
|
|
|
2009-06-19 15:44:23 +04:00
|
|
|
for (cur, type, data, parents) in dag:
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-05-16 09:12:12 +04:00
|
|
|
# Compute seen and next
|
|
|
|
if cur not in seen:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
seen.append(cur) # new head
|
2009-05-16 09:12:12 +04:00
|
|
|
colors[cur] = newcolor
|
|
|
|
newcolor += 1
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-05-16 09:12:12 +04:00
|
|
|
col = seen.index(cur)
|
|
|
|
color = colors.pop(cur)
|
|
|
|
next = seen[:]
|
2008-06-18 09:06:41 +04:00
|
|
|
|
2009-06-19 15:44:23 +04:00
|
|
|
# Add parents to next
|
2016-03-04 17:44:32 +03:00
|
|
|
addparents = [p for pt, p in parents if p not in next]
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
next[col : col + 1] = addparents
|
2008-06-18 09:06:41 +04:00
|
|
|
|
|
|
|
# Set colors for the parents
|
|
|
|
for i, p in enumerate(addparents):
|
|
|
|
if not i:
|
|
|
|
colors[p] = color
|
|
|
|
else:
|
2009-05-16 09:12:12 +04:00
|
|
|
colors[p] = newcolor
|
|
|
|
newcolor += 1
|
2008-06-18 09:06:41 +04:00
|
|
|
|
|
|
|
# Add edges to the graph
|
|
|
|
edges = []
|
2009-05-16 09:12:12 +04:00
|
|
|
for ecol, eid in enumerate(seen):
|
|
|
|
if eid in next:
|
2012-01-22 16:35:26 +04:00
|
|
|
bconf = getconf(eid)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
edges.append(
|
|
|
|
(
|
|
|
|
ecol,
|
|
|
|
next.index(eid),
|
|
|
|
colors[eid],
|
|
|
|
bconf.get("width", -1),
|
|
|
|
bconf.get("color", ""),
|
|
|
|
)
|
|
|
|
)
|
2009-06-19 15:44:23 +04:00
|
|
|
elif eid == cur:
|
2016-03-04 17:44:32 +03:00
|
|
|
for ptype, p in parents:
|
2012-01-22 16:35:26 +04:00
|
|
|
bconf = getconf(p)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
edges.append(
|
|
|
|
(
|
|
|
|
ecol,
|
|
|
|
next.index(p),
|
|
|
|
color,
|
|
|
|
bconf.get("width", -1),
|
|
|
|
bconf.get("color", ""),
|
|
|
|
)
|
|
|
|
)
|
2008-06-18 09:06:41 +04:00
|
|
|
|
|
|
|
# Yield and move on
|
2009-06-19 15:44:23 +04:00
|
|
|
yield (cur, type, data, (col, color), edges)
|
2009-05-16 09:12:12 +04:00
|
|
|
seen = next
|