graflo.plot.merge3¶
Draw a three-way merge: where two branches met, and the lineage they met on.
Two pictures, because a merge raises two questions.
:func:plot_merge3_preview answers where in the model did they collide — the
slot tree, with the contested slots carrying what each branch did and what the
ancestor had. Slots are paths that contain one another, so the tree is already
there in the data; drawing it puts a rename of a vertex above the field edits
that live inside it, which is the relationship a flat list of conflicts loses.
:func:plot_history answers which two commits, and from where — the commit
DAG, with the merge base marked. First-parent edges are solid because that is
the line a commit's ops are a diff along; every other parent is dashed.
Attributes¶
COMMIT_SHAPE = {'merge': 'doubleoctagon', 'merge3': 'doubleoctagon', 'revert': 'octagon', 'edit': 'box'}
module-attribute
¶
SIDE_COLOR = {'left': '#B7D1DF', 'right': '#BEDFC8'}
module-attribute
¶
SLOT_COLOR = {'contested': '#C0392B', 'clean': '#7F8C8D', 'base': '#5D6D7E'}
module-attribute
¶
__all__ = ['COMMIT_SHAPE', 'SIDE_COLOR', 'SLOT_COLOR', 'build_history_graph', 'build_merge3_graph', 'plot_history', 'plot_merge3_preview']
module-attribute
¶
Classes¶
Functions:¶
build_history_graph(history, *, heads=(), merge_base=None)
¶
The commit DAG as a networkx graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
Any
|
A :class: |
required |
heads
|
Collection[str]
|
Commit ids to mark as the sides being reconciled. |
()
|
merge_base
|
str | None
|
The common ancestor, marked as such. |
None
|
Returns:
| Type | Description |
|---|---|
DiGraph
|
A graph with one node per commit, edges pointing parent to child. |
Source code in graflo/plot/merge3.py
build_merge3_graph(preview)
¶
The slot tree as a networkx graph, styled but not drawn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preview
|
Merge3Preview
|
What
:func: |
required |
Returns:
| Type | Description |
|---|---|
DiGraph
|
A graph whose attributes are Graphviz attributes; every node carries |
DiGraph
|
its slot path as |
Source code in graflo/plot/merge3.py
plot_history(history, path, *, heads=(), merge_base=None, output_format=None, prog='dot', dpi=None)
¶
Draw the commit DAG of history to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
Any
|
A :class: |
required |
path
|
str | PathLike[str]
|
Where to write; the suffix picks the format. |
required |
heads
|
Collection[str]
|
Commit ids to mark as the sides being reconciled. |
()
|
merge_base
|
str | None
|
The common ancestor, marked as such. |
None
|
output_format
|
str | None
|
Override the format the suffix implies. |
None
|
prog
|
str
|
Graphviz layout program. |
'dot'
|
dpi
|
int | None
|
Raster resolution, for |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The path written. |
Source code in graflo/plot/merge3.py
plot_merge3_preview(preview, path, *, output_format=None, prog='dot', dpi=None)
¶
Draw the slot tree of preview to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preview
|
Merge3Preview
|
What |
required |
path
|
str | PathLike[str]
|
Where to write; the suffix picks the format (svg/pdf/png/dot). |
required |
output_format
|
str | None
|
Override the format the suffix implies. |
None
|
prog
|
str
|
Graphviz layout program. |
'dot'
|
dpi
|
int | None
|
Raster resolution, for |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The path written. |