sapling/eden/scm/edenscm/graphmod.py

205 lines
6.7 KiB
Python
Raw Normal View History

# Portions Copyright (c) Meta Platforms, Inc. and affiliates.
#
# 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>
#
# 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
"""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
from . import dagop, smartset, util
2015-08-09 05:18:23 +03:00
from .node import nullrev
CHANGESET = "C"
PARENT = "P"
GRANDPARENT = "G"
MISSINGPARENT = "M"
graphmod: allow edges to end early Rather than draw an edge all the way to the bottom of the graph, make it possible to end an edge to parents that are not part of the graph early on. This results in a far cleaner graph. Any edge type can be set to end early; set the ui.graphstyle.<edgetype> parameter to the empty string to enable this. For example, setting the following configuration: [ui] graphstyle.grandparent = : graphstyle.missing = would result in a graph like this: o changeset: 32:d06dffa21a31 |\ parent: 27:886ed638191b | : parent: 31:621d83e11f67 | : o : changeset: 31:621d83e11f67 |\: parent: 21:d42a756af44d | : parent: 30:6e11cd4b648f | : o : changeset: 30:6e11cd4b648f |\ \ parent: 28:44ecd0b9ae99 | ~ : parent: 29:cd9bb2be7593 | / o : changeset: 28:44ecd0b9ae99 |\ \ parent: 1:6db2ef61d156 | ~ : parent: 26:7f25b6c2f0b9 | / o : changeset: 26:7f25b6c2f0b9 |\ \ parent: 18:1aa84d96232a | | : parent: 25:91da8ed57247 | | : | o : changeset: 25:91da8ed57247 | |\: parent: 21:d42a756af44d | | : parent: 24:a9c19a3d96b7 | | : | o : changeset: 24:a9c19a3d96b7 | |\ \ parent: 0:e6eb3150255d | | ~ : parent: 23:a01cddf0766d | | / | o : changeset: 23:a01cddf0766d | |\ \ parent: 1:6db2ef61d156 | | ~ : parent: 22:e0d9cccacb5d | | / | o : changeset: 22:e0d9cccacb5d |/:/ parent: 18:1aa84d96232a | : parent: 21:d42a756af44d | : | o changeset: 21:d42a756af44d | |\ parent: 19:31ddc2c1573b | | | parent: 20:d30ed6450e32 | | | +---o changeset: 20:d30ed6450e32 | | | parent: 0:e6eb3150255d | | ~ parent: 18:1aa84d96232a | | | o changeset: 19:31ddc2c1573b | |\ parent: 15:1dda3f72782d | ~ ~ parent: 17:44765d7c06e0 | o changeset: 18:1aa84d96232a parent: 1:6db2ef61d156 parent: 15:1dda3f72782d The default configuration leaves all 3 types set to |. This is part of the work towards moving smartlog upstream; currently smartlog injects extra nodes into the graph to indicate grandparent relationships (nodes elided).
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.
EDGES = {PARENT: "|", GRANDPARENT: ":", MISSINGPARENT: None}
2008-06-18 09:06:41 +04:00
def dagwalker(repo, revs, template):
"""cset DAG generator yielding (id, CHANGESET, ctx, [parentinfo]) tuples
This generator function walks through revisions (which should be ordered
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
returned.
"""
if not revs:
return
log: add a config to simplify graphs Summary: This could help simplify the graph a lot for repos with lots of merges. For example, logging tags on linux.git looks like: o fb893de3 Yesterday at 17:28 master ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o bcf87687 Aug 02 at 14:21 v5.8 ╷ ╷ ╷ ╭─────┬─┬───┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 92ed3019 Jul 26 at 14:14 v5.8-rc7 ╷ ╷ ╷ ╭─────┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ba47d845 Jul 19 at 15:41 v5.8-rc6 ╷ ╷ ╷ ╭─┬─┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 11ba4688 Jul 12 at 16:34 v5.8-rc5 ╷ ╷ ╷ ╭─┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ o dcb7fd82 Jul 05 at 16:20 v5.8-rc4 ╷ ╷ ╷ ╭─┬─┬─┤ ╷ ╷ ╷ ╷ ╷ o ╷ 9ebcfadb Jun 28 at 15:00 v5.8-rc3 ╷ ╷ ╭─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ o ╷ 48778464 Jun 21 at 15:45 v5.8-rc2 ╷ ╷ ╷ ╭─╯ ╷ ╷ ╷ ╷ o ╷ b3a9e3b9 Jun 14 at 12:45 v5.8-rc1 ╭─┬─┬─┼─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 3d77e6a8 May 31 at 16:49 v5.7 ╭─┬─┴───────┬───────────┬─┬───┬─╮ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 9cb1fd0e May 24 at 15:32 v5.7-rc7 ╷ ╰─────────┬─────────────┬─┬─┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o b9bbe6ed May 17 at 16:48 v5.7-rc6 ╭───────────┬─────────────┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 2ef96a5b May 10 at 15:16 v5.7-rc5 ╭───────────┬─────────────┬─┬─╯ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 0e698dfa May 03 at 14:56 v5.7-rc4 ╭───────────┴───────────┬─┬─╮ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 6a8b55ed Apr 26 at 13:51 v5.7-rc3 ╰─────────────────┬───────┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ae83d0b4 Apr 19 at 14:35 v5.7-rc2 ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╭─┤ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ 8f3d9f35 Apr 12 at 12:35 v5.7-rc1 ╭─┬─┬───────┬─────┬─┬─┬─┬─┼─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ 7111951b Mar 29 at 15:25 v5.6 ╷ ╭─────────┬─────┬─┬─┬─┴───╮ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ 16fbf79b Mar 22 at 18:31 v5.6-rc7 ╷ ╷ ╭───────┴─────┬─┬─┬─────╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o fb33c651 Mar 15 at 15:01 v5.6-rc6 ╷ ╭─┬─────────────┬─┬─┬─────╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ 2c523b34 Mar 08 at 17:44 v5.6-rc5 ╷ ╭─┬─────────────┬─┬─╯ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 98d54f81 Mar 01 at 14:38 v5.6-rc4 ╷ ╭─┴─────────────┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ f8788d86 Feb 23 at 16:17 v5.6-rc3 .... And with simplification turned on, it looks like: o fb893de3 Yesterday at 17:28 master ├─╮ o ╷ bcf87687 Aug 02 at 14:21 v5.8 ╷ ╷ o ╷ 92ed3019 Jul 26 at 14:14 v5.8-rc7 ╷ ╷ o ╷ ba47d845 Jul 19 at 15:41 v5.8-rc6 ╷ ╷ o ╷ 11ba4688 Jul 12 at 16:34 v5.8-rc5 ╷ ╷ o ╷ dcb7fd82 Jul 05 at 16:20 v5.8-rc4 ╷ ╷ o ╷ 9ebcfadb Jun 28 at 15:00 v5.8-rc3 ╷ ╷ o ╷ 48778464 Jun 21 at 15:45 v5.8-rc2 ├─╯ o b3a9e3b9 Jun 14 at 12:45 v5.8-rc1 ╷ o 3d77e6a8 May 31 at 16:49 v5.7 ╷ o 9cb1fd0e May 24 at 15:32 v5.7-rc7 ╷ o b9bbe6ed May 17 at 16:48 v5.7-rc6 ╷ o 2ef96a5b May 10 at 15:16 v5.7-rc5 ╷ o 0e698dfa May 03 at 14:56 v5.7-rc4 ╷ o 6a8b55ed Apr 26 at 13:51 v5.7-rc3 ╷ o ae83d0b4 Apr 19 at 14:35 v5.7-rc2 ╷ o 8f3d9f35 Apr 12 at 12:35 v5.7-rc1 ╷ o 7111951b Mar 29 at 15:25 v5.6 ╷ o 16fbf79b Mar 22 at 18:31 v5.6-rc7 ╷ o fb33c651 Mar 15 at 15:01 v5.6-rc6 ╷ o 2c523b34 Mar 08 at 17:44 v5.6-rc5 ╷ o 98d54f81 Mar 01 at 14:38 v5.6-rc4 ╷ o f8788d86 Feb 23 at 16:17 v5.6-rc3 .... Under the hood, the difference is how `reachableroots` gets calculated. See also D22657197 (https://github.com/facebookexperimental/eden/commit/a5c36fd0b1e3590e04fc274ff7fc02898fcee798) and D22368827 (https://github.com/facebookexperimental/eden/commit/da42f2c17ee27725e9523affcc56877c4b74813b). Since the old behavior almost always seems confusing to human. The new config is turned on by default (but only takes effect if the "segments" backend is used). Reviewed By: sfilipco Differential Revision: D23095468 fbshipit-source-id: f0fc631d2d9a00e3b36744e4236b43d230d10687
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)
gpcache = {}
ctxstream = revs.prefetchbytemplate(repo, template).iterctx()
for ctx in ctxstream:
# 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)
mpars = [
p.rev() for p in ctx.parents() if p.rev() != nullrev and p.rev() not in pset
]
parents = [(PARENT, p) for p in sorted(pset)]
for mpar in mpars:
gp = gpcache.get(mpar)
if gp is None:
log: add a config to simplify graphs Summary: This could help simplify the graph a lot for repos with lots of merges. For example, logging tags on linux.git looks like: o fb893de3 Yesterday at 17:28 master ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o bcf87687 Aug 02 at 14:21 v5.8 ╷ ╷ ╷ ╭─────┬─┬───┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 92ed3019 Jul 26 at 14:14 v5.8-rc7 ╷ ╷ ╷ ╭─────┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ba47d845 Jul 19 at 15:41 v5.8-rc6 ╷ ╷ ╷ ╭─┬─┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 11ba4688 Jul 12 at 16:34 v5.8-rc5 ╷ ╷ ╷ ╭─┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ o dcb7fd82 Jul 05 at 16:20 v5.8-rc4 ╷ ╷ ╷ ╭─┬─┬─┤ ╷ ╷ ╷ ╷ ╷ o ╷ 9ebcfadb Jun 28 at 15:00 v5.8-rc3 ╷ ╷ ╭─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ o ╷ 48778464 Jun 21 at 15:45 v5.8-rc2 ╷ ╷ ╷ ╭─╯ ╷ ╷ ╷ ╷ o ╷ b3a9e3b9 Jun 14 at 12:45 v5.8-rc1 ╭─┬─┬─┼─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 3d77e6a8 May 31 at 16:49 v5.7 ╭─┬─┴───────┬───────────┬─┬───┬─╮ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 9cb1fd0e May 24 at 15:32 v5.7-rc7 ╷ ╰─────────┬─────────────┬─┬─┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o b9bbe6ed May 17 at 16:48 v5.7-rc6 ╭───────────┬─────────────┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 2ef96a5b May 10 at 15:16 v5.7-rc5 ╭───────────┬─────────────┬─┬─╯ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 0e698dfa May 03 at 14:56 v5.7-rc4 ╭───────────┴───────────┬─┬─╮ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 6a8b55ed Apr 26 at 13:51 v5.7-rc3 ╰─────────────────┬───────┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ae83d0b4 Apr 19 at 14:35 v5.7-rc2 ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╭─┤ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ 8f3d9f35 Apr 12 at 12:35 v5.7-rc1 ╭─┬─┬───────┬─────┬─┬─┬─┬─┼─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ 7111951b Mar 29 at 15:25 v5.6 ╷ ╭─────────┬─────┬─┬─┬─┴───╮ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ 16fbf79b Mar 22 at 18:31 v5.6-rc7 ╷ ╷ ╭───────┴─────┬─┬─┬─────╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o fb33c651 Mar 15 at 15:01 v5.6-rc6 ╷ ╭─┬─────────────┬─┬─┬─────╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ 2c523b34 Mar 08 at 17:44 v5.6-rc5 ╷ ╭─┬─────────────┬─┬─╯ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 98d54f81 Mar 01 at 14:38 v5.6-rc4 ╷ ╭─┴─────────────┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ f8788d86 Feb 23 at 16:17 v5.6-rc3 .... And with simplification turned on, it looks like: o fb893de3 Yesterday at 17:28 master ├─╮ o ╷ bcf87687 Aug 02 at 14:21 v5.8 ╷ ╷ o ╷ 92ed3019 Jul 26 at 14:14 v5.8-rc7 ╷ ╷ o ╷ ba47d845 Jul 19 at 15:41 v5.8-rc6 ╷ ╷ o ╷ 11ba4688 Jul 12 at 16:34 v5.8-rc5 ╷ ╷ o ╷ dcb7fd82 Jul 05 at 16:20 v5.8-rc4 ╷ ╷ o ╷ 9ebcfadb Jun 28 at 15:00 v5.8-rc3 ╷ ╷ o ╷ 48778464 Jun 21 at 15:45 v5.8-rc2 ├─╯ o b3a9e3b9 Jun 14 at 12:45 v5.8-rc1 ╷ o 3d77e6a8 May 31 at 16:49 v5.7 ╷ o 9cb1fd0e May 24 at 15:32 v5.7-rc7 ╷ o b9bbe6ed May 17 at 16:48 v5.7-rc6 ╷ o 2ef96a5b May 10 at 15:16 v5.7-rc5 ╷ o 0e698dfa May 03 at 14:56 v5.7-rc4 ╷ o 6a8b55ed Apr 26 at 13:51 v5.7-rc3 ╷ o ae83d0b4 Apr 19 at 14:35 v5.7-rc2 ╷ o 8f3d9f35 Apr 12 at 12:35 v5.7-rc1 ╷ o 7111951b Mar 29 at 15:25 v5.6 ╷ o 16fbf79b Mar 22 at 18:31 v5.6-rc7 ╷ o fb33c651 Mar 15 at 15:01 v5.6-rc6 ╷ o 2c523b34 Mar 08 at 17:44 v5.6-rc5 ╷ o 98d54f81 Mar 01 at 14:38 v5.6-rc4 ╷ o f8788d86 Feb 23 at 16:17 v5.6-rc3 .... Under the hood, the difference is how `reachableroots` gets calculated. See also D22657197 (https://github.com/facebookexperimental/eden/commit/a5c36fd0b1e3590e04fc274ff7fc02898fcee798) and D22368827 (https://github.com/facebookexperimental/eden/commit/da42f2c17ee27725e9523affcc56877c4b74813b). Since the old behavior almost always seems confusing to human. The new config is turned on by default (but only takes effect if the "segments" backend is used). Reviewed By: sfilipco Differential Revision: D23095468 fbshipit-source-id: f0fc631d2d9a00e3b36744e4236b43d230d10687
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):
revs = smartset.baseset(revs, repo=repo)
log: add a config to simplify graphs Summary: This could help simplify the graph a lot for repos with lots of merges. For example, logging tags on linux.git looks like: o fb893de3 Yesterday at 17:28 master ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o bcf87687 Aug 02 at 14:21 v5.8 ╷ ╷ ╷ ╭─────┬─┬───┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 92ed3019 Jul 26 at 14:14 v5.8-rc7 ╷ ╷ ╷ ╭─────┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ba47d845 Jul 19 at 15:41 v5.8-rc6 ╷ ╷ ╷ ╭─┬─┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 11ba4688 Jul 12 at 16:34 v5.8-rc5 ╷ ╷ ╷ ╭─┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ o dcb7fd82 Jul 05 at 16:20 v5.8-rc4 ╷ ╷ ╷ ╭─┬─┬─┤ ╷ ╷ ╷ ╷ ╷ o ╷ 9ebcfadb Jun 28 at 15:00 v5.8-rc3 ╷ ╷ ╭─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ o ╷ 48778464 Jun 21 at 15:45 v5.8-rc2 ╷ ╷ ╷ ╭─╯ ╷ ╷ ╷ ╷ o ╷ b3a9e3b9 Jun 14 at 12:45 v5.8-rc1 ╭─┬─┬─┼─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 3d77e6a8 May 31 at 16:49 v5.7 ╭─┬─┴───────┬───────────┬─┬───┬─╮ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 9cb1fd0e May 24 at 15:32 v5.7-rc7 ╷ ╰─────────┬─────────────┬─┬─┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o b9bbe6ed May 17 at 16:48 v5.7-rc6 ╭───────────┬─────────────┬─┬─┬─╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o 2ef96a5b May 10 at 15:16 v5.7-rc5 ╭───────────┬─────────────┬─┬─╯ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 0e698dfa May 03 at 14:56 v5.7-rc4 ╭───────────┴───────────┬─┬─╮ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 6a8b55ed Apr 26 at 13:51 v5.7-rc3 ╰─────────────────┬───────┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ae83d0b4 Apr 19 at 14:35 v5.7-rc2 ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╭─┤ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ 8f3d9f35 Apr 12 at 12:35 v5.7-rc1 ╭─┬─┬───────┬─────┬─┬─┬─┬─┼─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ 7111951b Mar 29 at 15:25 v5.6 ╷ ╭─────────┬─────┬─┬─┬─┴───╮ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ 16fbf79b Mar 22 at 18:31 v5.6-rc7 ╷ ╷ ╭───────┴─────┬─┬─┬─────╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o fb33c651 Mar 15 at 15:01 v5.6-rc6 ╷ ╭─┬─────────────┬─┬─┬─────╯ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ 2c523b34 Mar 08 at 17:44 v5.6-rc5 ╷ ╭─┬─────────────┬─┬─╯ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ 98d54f81 Mar 01 at 14:38 v5.6-rc4 ╷ ╭─┴─────────────┬─╮ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ f8788d86 Feb 23 at 16:17 v5.6-rc3 .... And with simplification turned on, it looks like: o fb893de3 Yesterday at 17:28 master ├─╮ o ╷ bcf87687 Aug 02 at 14:21 v5.8 ╷ ╷ o ╷ 92ed3019 Jul 26 at 14:14 v5.8-rc7 ╷ ╷ o ╷ ba47d845 Jul 19 at 15:41 v5.8-rc6 ╷ ╷ o ╷ 11ba4688 Jul 12 at 16:34 v5.8-rc5 ╷ ╷ o ╷ dcb7fd82 Jul 05 at 16:20 v5.8-rc4 ╷ ╷ o ╷ 9ebcfadb Jun 28 at 15:00 v5.8-rc3 ╷ ╷ o ╷ 48778464 Jun 21 at 15:45 v5.8-rc2 ├─╯ o b3a9e3b9 Jun 14 at 12:45 v5.8-rc1 ╷ o 3d77e6a8 May 31 at 16:49 v5.7 ╷ o 9cb1fd0e May 24 at 15:32 v5.7-rc7 ╷ o b9bbe6ed May 17 at 16:48 v5.7-rc6 ╷ o 2ef96a5b May 10 at 15:16 v5.7-rc5 ╷ o 0e698dfa May 03 at 14:56 v5.7-rc4 ╷ o 6a8b55ed Apr 26 at 13:51 v5.7-rc3 ╷ o ae83d0b4 Apr 19 at 14:35 v5.7-rc2 ╷ o 8f3d9f35 Apr 12 at 12:35 v5.7-rc1 ╷ o 7111951b Mar 29 at 15:25 v5.6 ╷ o 16fbf79b Mar 22 at 18:31 v5.6-rc7 ╷ o fb33c651 Mar 15 at 15:01 v5.6-rc6 ╷ o 2c523b34 Mar 08 at 17:44 v5.6-rc5 ╷ o 98d54f81 Mar 01 at 14:38 v5.6-rc4 ╷ o f8788d86 Feb 23 at 16:17 v5.6-rc3 .... Under the hood, the difference is how `reachableroots` gets calculated. See also D22657197 (https://github.com/facebookexperimental/eden/commit/a5c36fd0b1e3590e04fc274ff7fc02898fcee798) and D22368827 (https://github.com/facebookexperimental/eden/commit/da42f2c17ee27725e9523affcc56877c4b74813b). Since the old behavior almost always seems confusing to human. The new config is turned on by default (but only takes effect if the "segments" backend is used). Reviewed By: sfilipco Differential Revision: D23095468 fbshipit-source-id: f0fc631d2d9a00e3b36744e4236b43d230d10687
2020-08-22 03:08:57 +03:00
gp = gpcache[mpar] = sorted(
set(dagop.reachableroots(repo, revs, [mpar]))
)
if not gp:
parents.append((MISSINGPARENT, mpar))
pset.add(mpar)
else:
parents.extend((GRANDPARENT, g) for g in gp if g not in pset)
pset.update(gp)
yield (ctx.rev(), CHANGESET, ctx, parents)
def nodes(repo, nodes):
"""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.
"""
include = set(nodes)
for node in nodes:
ctx = repo[node]
parents = set((PARENT, p.rev()) for p in ctx.parents() if p.node() in include)
yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
def colored(dag, repo):
"""annotates a DAG with colored edge information
2008-06-18 09:06:41 +04:00
For each DAG node this function emits tuples::
2008-06-18 09:06:41 +04:00
(id, type, data, (col, color), [(col, nextcol, color)])
2008-06-18 09:06:41 +04:00
with the following new elements:
- 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.
"""
seen = []
2008-06-18 09:06:41 +04:00
colors = {}
newcolor = 1
config = {}
for key, val in repo.ui.configitems("graph"):
if "." in key:
branch, setting = key.rsplit(".", 1)
# Validation
if setting == "width" and val.isdigit():
config.setdefault(branch, {})[setting] = int(val)
elif setting == "color" and val.isalnum():
config.setdefault(branch, {})[setting] = val
if config:
getconf = util.lrucachefunc(lambda rev: config.get(repo[rev].branch(), {}))
else:
getconf = lambda rev: {}
for (cur, type, data, parents) in dag:
2008-06-18 09:06:41 +04:00
# Compute seen and next
if cur not in seen:
seen.append(cur) # new head
colors[cur] = newcolor
newcolor += 1
2008-06-18 09:06:41 +04:00
col = seen.index(cur)
color = colors.pop(cur)
next = seen[:]
2008-06-18 09:06:41 +04:00
# Add parents to next
addparents = [p for pt, p in parents if p not in next]
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:
colors[p] = newcolor
newcolor += 1
2008-06-18 09:06:41 +04:00
# Add edges to the graph
edges = []
for ecol, eid in enumerate(seen):
if eid in next:
bconf = getconf(eid)
edges.append(
(
ecol,
next.index(eid),
colors[eid],
bconf.get("width", -1),
bconf.get("color", ""),
)
)
elif eid == cur:
for ptype, p in parents:
bconf = getconf(p)
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
yield (cur, type, data, (col, color), edges)
seen = next