Awesome!
I was able to make a one-line fix (in read_key) to PrettyPatch to allow it to correctly translate back into an UnsignedPatch.
My current (ugly) “pretty printing” of PrettyPatch is as follows:
PrettyPatch { header: PatchHeader { authors: ["Florent Becker <florent.becker@ens-lyon.org>"], name: "Fixes in the test suite", description: None, timestamp: 2018-04-08T14:59:53.077354432Z, flag: (empty) }, dependencies: ["69FSXS1UWZwqQ5AdmiBQeBtYK2B6UtZALQfnzsVdRaMCaQEpEaiqoBwBao6PeL2GphzwTCxYEiz71h7rg75L3w6P"], changes: [NewEdges { previous: 8, flag: 24, edges: [PrettyNewEdge { from: "1.MF1Bc9zzEzB", to: "1.M5JWbMBVdif", introduced_by: 1 }], inode: "1.foh4EGyS55" }, NewNodes { up_context: ["1.M5JWbMBVdif"], down_context: ["1.MQhrcxpUrFh"], flag: 0, line_num: 3, nodes: [String(" REMOTE_PIJUL=\"$PIJUL_EXE\" pijul key upload $USER@localhost\n")], inode: "1.foh4EGyS55" }, NewEdges { previous: 8, flag: 24, edges: [PrettyNewEdge { from: "1.GjNc5KjH9zP", to: "1.GZfw4WunYis", introduced_by: 1 }], inode: "1.LQM2cdzDY3" }, NewNodes { up_context: ["1.GZfw4WunYis"], down_context: ["1.Gu5H68YmmFu"], flag: 0, line_num: 4, nodes: [String(" export PIJUL_SRC_DIR=\"$BATS_TEST_DIRNAME/../..\"\n")], inode: "1.LQM2cdzDY3" }, NewEdges { previous: 8, flag: 24, edges: [PrettyNewEdge { from: "1.HEUd7kBkynw", to: "1.H4mx6wNGNXR", introduced_by: 1 }], inode: "1.LQM2cdzDY3" }, NewNodes { up_context: ["1.H4mx6wNGNXR"], down_context: ["1.HQBJ8Z1Fb4T"], flag: 0, line_num: 5, nodes: [String(" export PIJUL_EXE=\"$PIJUL_SRC_DIR/../target/debug/pijul\"\n")], inode: "1.LQM2cdzDY3" }] }
Turns into:
PIJUL PATCH 2018-04-08 14:59:53.077354432 UTC
Florent Becker <florent.becker@ens-lyon.org>
Fixes in the test suite
69FSXS1UWZwqQ5AdmiBQeBtYK2B6UtZALQfnzsVdRaMCaQEpEaiqoBwBao6PeL2GphzwTCxYEiz71h7rg75L3w6P
EDGES 8 24
1.foh4EGyS55
1: 1.MF1Bc9zzEzB -> 1.M5JWbMBVdif
NODES 3
0 1.foh4EGyS55 1.M5JWbMBVdif 1.MQhrcxpUrFh
+ REMOTE_PIJUL="$PIJUL_EXE" pijul key upload $USER@localhost
EDGES 8 24
1.LQM2cdzDY3
1: 1.GjNc5KjH9zP -> 1.GZfw4WunYis
NODES 4
0 1.LQM2cdzDY3 1.GZfw4WunYis 1.Gu5H68YmmFu
+ export PIJUL_SRC_DIR="$BATS_TEST_DIRNAME/../.."
EDGES 8 24
1.LQM2cdzDY3
1: 1.HEUd7kBkynw -> 1.H4mx6wNGNXR
NODES 5
0 1.LQM2cdzDY3 1.H4mx6wNGNXR 1.HQBJ8Z1Fb4T
+ export PIJUL_EXE="$PIJUL_SRC_DIR/../target/debug/pijul"
I think I’ll have to read more about how Pijul works in order to devise a more logical encoding (I’m open to suggestions!). I also think some fields are redundant, such as flags seemingly the same for all nodes and up/down contexts seemingly always being arrays of length one.