Summary: This would be handy to visualize a MemNameDag.
Reviewed By: sfilipco
Differential Revision: D21486522
fbshipit-source-id: c8d7147dc53a1a7c1b8b09ce055493c69cceba2f
Summary:
Use MemNameDag::from_ascii to simplify the tests. This removes the need of:
- using tempdir
- converting between Id and VertexName manually via an IdMap
- depending on drawdag directly
Reviewed By: sfilipco
Differential Revision: D21486519
fbshipit-source-id: f04061d8892f043de40e7e321273acc51e15308a
Summary: This will allow different IdMap implementations.
Reviewed By: sfilipco
Differential Revision: D21479016
fbshipit-source-id: 852501896fddcb82624338acd9dceee41150e302
Summary: The APIs are compatible so the switch is straightforward.
Reviewed By: DurhamG
Differential Revision: D19818713
fbshipit-source-id: 504e9149567c90eb661804e0dad20580a401aa76
Summary:
I wrote it to understand how renderdag draws the same graph with different
orders. It seems useful for future optimization that tries to reduce the number
of columns. So let's check it in.
Reviewed By: xavierd
Differential Revision: D19440713
fbshipit-source-id: 8bc580799f6b24c87886d5ac306020f50bb694e5
Summary:
This changes the pattern commonly seen in smartlog:
╷ o e7f5f529 ...
╭─╯
│ o a1b2773d ...
╭─╯
o ecbb4eaa
╷
to:
╷ o e7f5f529 ...
├─╯
│ o a1b2773da ...
├─╯
o ecbb4eaa
╷
The change only applies to commits with a single parent. Vertical lines from
merge commits stay disconnected intentionally. For example:
│ │ o I
│ │ │
│ o │ H
╭─┼─┬─┬─╮
│ │ │ │ o G
│ │ │ │ │
This makes it more obvious that `H` has 5 parents while `I` only has 1 parent -
`I` does not "borrow" `H`'s parents. This problem does not exist if `H` only
has 1 parent.
Reviewed By: quark-zju
Differential Revision: D19407687
fbshipit-source-id: 1046c8e2309f50e3f1620ed21f1b10573759a5f8
Summary:
Enhance the tests to test whether the width of the graph matches the width that
was given by the `width` method before `next_row` was called.
The width we are interested in is the number of cells the string would occupy,
not the string length, so use the `unicode-width` crate to determine this.
Reviewed By: quark-zju
Differential Revision: D19282571
fbshipit-source-id: d9852c4c9e0f76c78db047f0da5dd34723a62a2a
Summary: Switch from `:` to `.` for the ancestor lines. I think they look better.
Reviewed By: quark-zju
Differential Revision: D19371721
fbshipit-source-id: e18f1a62e23620a82007e2c377607a0a61623830
Summary:
Box-drawing characters with curves aren't reliably renderable on Windows. Add
a "square" glyph set that uses right-angle characters. These characters are
available in cp437 and cp850, so should be available on most Windows systems.
For completeness, add a "dec" glyph set that uses DEC line drawing characters,
for use in old terminals like xterm.
Reviewed By: quark-zju
Differential Revision: D19371722
fbshipit-source-id: 35887243cceab66c702e2b5278b572f77946805f
Summary:
Per discussion, we decided to use "VertexName" as the struct name for things
like commit hashes, or the string names in tests (or the Mozilla DAG in tests).
Therefore, introduce a dedicated VertexName type and repalce all callsites to
use it.
`bytes::Bytes` is used so copying the `VertexName` is somewhat considered cheap.
This adds some overhead copying slices (and `Bytes` has some overhead). It
regresses the "building segments" benchmark from 673ms to 773ms, which seems
okay given the cleaner interface.
Reviewed By: markbt
Differential Revision: D19154905
fbshipit-source-id: 4c6d4eca67c11c10ed5f21999ccdc3f1b01695e8
Summary:
Move the test fixtures into a common module, so that they don't need to be
repeated in each test. Since each fixtures is now a struct, this also makes it
clearer what each of the items are.
Reviewed By: quark-zju
Differential Revision: D19288290
fbshipit-source-id: 394805c652592177f11ccb096b8e5e95361456e4
Summary:
Generalize construction of output renderers (renderers that render to `String`)
to avoid duplication of options. At the moment there is only one, but later we
may add new options.
This also allows us to construct output renderers from any renderer that
renders to `GraphRow`, which means we can create adapters that modify or
re-order the rows of the graph.
Reviewed By: quark-zju
Differential Revision: D19286350
fbshipit-source-id: a5649ca2f48e263ee24584339179655fb612d3d1
Summary:
A new implementation for rendering DAGs.
This new crate implements a generic DAG renderer, that can convert a
topologically sorted sequence of DAG nodes into a sequence of strings suitable
for rendering to a terminal.
The new renderer differs from the old renderer in a few important ways:
* It prioritizes keeping commits linear, and will allow gaps to form if
that will allow the history of the commits to be kept in a straight
line. This makes it easier to track long parallel histories.
* It supports octopus merges (nodes with more than two parents). Even
though Mercurial doesn't support octopus merge commits, summary DAGs
with omitted nodes can still end up with logical octopus merges.
* It supports reservation of columns for specific nodes. This can be
used to support smartlog-style indentation of draft stacks without
needing to hack around it by creating fake nodes.
* It separates out forming the graph from generating the lines. This
allows multiple back-ends for generating different styles of graph.
There are three back-ends implemented:
`AsciiRenderer` renders similar to the old graph renderer, using ASCII
characters. For example:
```
o F
|
| o E
| |
| | o D
.-----'
o | | C
+---'
o | B
:/
o A
```
`AsciiLargeRenderer` uses larger ASCII blocks to give a clearer picture of
complex graphs. For example:
```
o F
|
|
| o E
| |
| |
| | o D
______/
/ | |
o | | C
| ___/
|/ |
o | B
: /
:/
o A
```
`BoxDrawingRenderer` uses Unicode box drawing characters to give a more
continuous rendering of the graph, however requires support for these
characters in the terminal font. For example:
```
o F
│
│ o E
│ │
│ │ o D
╭─────╯
o │ │ C
├───╯
o │ B
├─╯
o A
│
~
```
Reviewed By: quark-zju
Differential Revision: D19272579
fbshipit-source-id: bb6fa4685c965544cc3b6b9261df3a3ec161b41f