@@ -4,7 +4,7 @@ use std::collections::HashSet;
44use anyhow:: { Context , Result } ;
55use but_graph:: Graph ;
66use but_rebase:: graph_rebase:: { Editor , Step , mutate} ;
7- use but_testsupport:: { git_status, visualize_commit_graph_all} ;
7+ use but_testsupport:: { git_status, graph_tree , visualize_commit_graph_all} ;
88use gix:: prelude:: ObjectIdExt ;
99
1010use crate :: utils:: { fixture_writable, standard_options} ;
@@ -44,7 +44,16 @@ fn disconnect_and_remove_middle_commit_in_linear_history() -> Result<()> {
4444 editor. replace ( b_selector, Step :: None ) ?;
4545
4646 let outcome = editor. rebase ( ) ?;
47- outcome. materialize ( ) ?;
47+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
48+ insta:: assert_snapshot!( overlayed, @"
49+
50+ └── 👉►:0[0]:main[🌳]
51+ ├── ·4de0144 (⌂|1)
52+ ├── ·d591dfe (⌂|1)
53+ └── ·35b8235 (⌂|1)
54+ " ) ;
55+ let outcome = outcome. materialize ( ) ?;
56+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
4857
4958 insta:: assert_snapshot!( visualize_commit_graph_all( & repo) ?, @r"
5059 * 4de0144 (HEAD -> main) c
@@ -96,7 +105,15 @@ fn disconnect_and_remove_two_middle_commits_in_linear_history() -> Result<()> {
96105 editor. replace ( a_selector, Step :: None ) ?;
97106
98107 let outcome = editor. rebase ( ) ?;
99- outcome. materialize ( ) ?;
108+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
109+ insta:: assert_snapshot!( overlayed, @"
110+
111+ └── 👉►:0[0]:main[🌳]
112+ ├── ·f55e07c (⌂|1)
113+ └── ·35b8235 (⌂|1)
114+ " ) ;
115+ let outcome = outcome. materialize ( ) ?;
116+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
100117
101118 insta:: assert_snapshot!( visualize_commit_graph_all( & repo) ?, @"
102119 * f55e07c (HEAD -> main) c
@@ -145,7 +162,21 @@ fn disconnect_and_remove_commit_in_merge_history_rewires_children() -> Result<()
145162 editor. replace ( a_selector, Step :: None ) ?;
146163
147164 let outcome = editor. rebase ( ) ?;
148- outcome. materialize ( ) ?;
165+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
166+ insta:: assert_snapshot!( overlayed, @"
167+
168+ └── 👉►:0[0]:with-inner-merge[🌳]
169+ └── ·dde6cc8 (⌂|1)
170+ └── ►:1[1]:anon:
171+ └── ·5f962e2 (⌂|1)
172+ ├── ►:2[3]:anon:
173+ │ └── ·8f0d338 (⌂|1) ►A, ►main, ►tags/base
174+ └── ►:3[2]:B
175+ └── ·984fd1c (⌂|1)
176+ └── →:2:
177+ " ) ;
178+ let outcome = outcome. materialize ( ) ?;
179+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
149180
150181 let a_now = repo. rev_parse_single ( "A" ) ?. detach ( ) ;
151182 let base = repo. rev_parse_single ( "base" ) ?. detach ( ) ;
@@ -206,7 +237,27 @@ fn disconnect_and_remove_merge_with_two_parents_and_two_children() -> Result<()>
206237 editor. replace ( merge_selector, Step :: None ) ?;
207238
208239 let outcome = editor. rebase ( ) ?;
209- outcome. materialize ( ) ?;
240+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
241+ insta:: assert_snapshot!( overlayed, @"
242+
243+ └── 👉►:0[0]:with-two-children[🌳]
244+ └── ·f914957 (⌂|1)
245+ ├── ►:1[1]:C1
246+ │ └── ·d8cc9ec (⌂|1)
247+ │ ├── ►:3[2]:anon:
248+ │ │ └── ·bc0e772 (⌂|1) ►M, ►P1
249+ │ │ └── ►:5[3]:main
250+ │ │ └── ·7674a5e (⌂|1) ►tags/base
251+ │ └── ►:4[2]:P2
252+ │ └── ·392a8f8 (⌂|1)
253+ │ └── →:5: (main)
254+ └── ►:2[1]:C2
255+ └── ·72b8072 (⌂|1)
256+ ├── →:3:
257+ └── →:4: (P2)
258+ " ) ;
259+ let outcome = outcome. materialize ( ) ?;
260+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
210261
211262 let p1 = repo. rev_parse_single ( "P1" ) ?. detach ( ) ;
212263 let p2 = repo. rev_parse_single ( "P2" ) ?. detach ( ) ;
@@ -311,7 +362,27 @@ fn disconnect_and_remove_merge_with_two_parents_and_two_children_from_one_side()
311362 ) ?;
312363
313364 let outcome = editor. rebase ( ) ?;
314- outcome. materialize ( ) ?;
365+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
366+ insta:: assert_snapshot!( overlayed, @"
367+
368+ └── 👉►:0[0]:with-two-children[🌳]
369+ └── ·3305e26 (⌂|1)
370+ ├── ►:1[1]:C1
371+ │ └── ·f928700 (⌂|1)
372+ │ └── ►:3[2]:P1
373+ │ └── ·bc0e772 (⌂|1)
374+ │ └── ►:5[4]:main
375+ │ └── ·7674a5e (⌂|1) ►tags/base
376+ └── ►:2[1]:C2
377+ └── ·0e87cd3 (⌂|1)
378+ └── ►:4[2]:M
379+ └── ·3089592 (⌂|1)
380+ └── ►:6[3]:P2
381+ └── ·392a8f8 (⌂|1)
382+ └── →:5: (main)
383+ " ) ;
384+ let outcome = outcome. materialize ( ) ?;
385+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
315386
316387 let p1 = repo. rev_parse_single ( "P1" ) ?. detach ( ) ;
317388 let m = repo. rev_parse_single ( "M" ) ?. detach ( ) ;
@@ -408,7 +479,25 @@ fn disconnect_remove_merge_with_two_parents_and_two_children_children_only() ->
408479 ) ?;
409480
410481 let outcome = editor. rebase ( ) ?;
411- outcome. materialize ( ) ?;
482+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
483+ insta:: assert_snapshot!( overlayed, @"
484+
485+ └── 👉►:0[0]:with-two-children[🌳]
486+ └── ·2eac185 (⌂|1)
487+ ├── ►:1[1]:C1
488+ │ └── ·76e6d3c (⌂|1)
489+ │ └── ►:3[2]:M
490+ │ └── ·3089592 (⌂|1)
491+ │ └── ►:4[3]:P2
492+ │ └── ·392a8f8 (⌂|1)
493+ │ └── ►:5[4]:main
494+ │ └── ·7674a5e (⌂|1) ►tags/base
495+ └── ►:2[1]:C2
496+ └── ·0e87cd3 (⌂|1)
497+ └── →:3: (M)
498+ " ) ;
499+ let outcome = outcome. materialize ( ) ?;
500+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
412501
413502 let p1 = repo. rev_parse_single ( "P1" ) ?. detach ( ) ;
414503 let p2 = repo. rev_parse_single ( "P2" ) ?. detach ( ) ;
@@ -525,7 +614,28 @@ fn disconnect_fails_when_parents_to_disconnect_is_none() -> Result<()> {
525614 ) ;
526615
527616 let outcome = editor. rebase ( ) ?;
528- outcome. materialize ( ) ?;
617+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
618+ insta:: assert_snapshot!( overlayed, @"
619+
620+ └── 👉►:0[0]:with-two-children[🌳]
621+ └── ·d1cc4c7 (⌂|1)
622+ ├── ►:1[1]:C1
623+ │ └── ·f94f259 (⌂|1)
624+ │ └── ►:3[2]:M
625+ │ └── ·c5d1178 (⌂|1)
626+ │ ├── ►:4[3]:P1
627+ │ │ └── ·bc0e772 (⌂|1)
628+ │ │ └── ►:6[4]:main
629+ │ │ └── ·7674a5e (⌂|1) ►tags/base
630+ │ └── ►:5[3]:P2
631+ │ └── ·392a8f8 (⌂|1)
632+ │ └── →:6: (main)
633+ └── ►:2[1]:C2
634+ └── ·ce6aca9 (⌂|1)
635+ └── →:3: (M)
636+ " ) ;
637+ let outcome = outcome. materialize ( ) ?;
638+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
529639
530640 let after = visualize_commit_graph_all ( & repo) ?;
531641 assert_eq ! ( before, after, "graph should remain unchanged on failure" ) ;
@@ -576,7 +686,28 @@ fn disconnect_fails_fast_if_parent_to_disconnect_is_not_direct_parent() -> Resul
576686 ) ;
577687
578688 let outcome = editor. rebase ( ) ?;
579- outcome. materialize ( ) ?;
689+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
690+ insta:: assert_snapshot!( overlayed, @"
691+
692+ └── 👉►:0[0]:with-two-children[🌳]
693+ └── ·d1cc4c7 (⌂|1)
694+ ├── ►:1[1]:C1
695+ │ └── ·f94f259 (⌂|1)
696+ │ └── ►:3[2]:M
697+ │ └── ·c5d1178 (⌂|1)
698+ │ ├── ►:4[3]:P1
699+ │ │ └── ·bc0e772 (⌂|1)
700+ │ │ └── ►:6[4]:main
701+ │ │ └── ·7674a5e (⌂|1) ►tags/base
702+ │ └── ►:5[3]:P2
703+ │ └── ·392a8f8 (⌂|1)
704+ │ └── →:6: (main)
705+ └── ►:2[1]:C2
706+ └── ·ce6aca9 (⌂|1)
707+ └── →:3: (M)
708+ " ) ;
709+ let outcome = outcome. materialize ( ) ?;
710+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
580711
581712 let after = visualize_commit_graph_all ( & repo) ?;
582713 assert_eq ! ( before, after, "graph should remain unchanged on failure" ) ;
@@ -627,7 +758,28 @@ fn disconnect_fails_fast_if_child_to_disconnect_is_not_direct_child() -> Result<
627758 ) ;
628759
629760 let outcome = editor. rebase ( ) ?;
630- outcome. materialize ( ) ?;
761+ let overlayed = graph_tree ( & outcome. overlayed_graph ( ) ?) . to_string ( ) ;
762+ insta:: assert_snapshot!( overlayed, @"
763+
764+ └── 👉►:0[0]:with-two-children[🌳]
765+ └── ·d1cc4c7 (⌂|1)
766+ ├── ►:1[1]:C1
767+ │ └── ·f94f259 (⌂|1)
768+ │ └── ►:3[2]:M
769+ │ └── ·c5d1178 (⌂|1)
770+ │ ├── ►:4[3]:P1
771+ │ │ └── ·bc0e772 (⌂|1)
772+ │ │ └── ►:6[4]:main
773+ │ │ └── ·7674a5e (⌂|1) ►tags/base
774+ │ └── ►:5[3]:P2
775+ │ └── ·392a8f8 (⌂|1)
776+ │ └── →:6: (main)
777+ └── ►:2[1]:C2
778+ └── ·ce6aca9 (⌂|1)
779+ └── →:3: (M)
780+ " ) ;
781+ let outcome = outcome. materialize ( ) ?;
782+ assert_eq ! ( overlayed, graph_tree( & outcome. workspace. graph) . to_string( ) ) ;
631783
632784 let after = visualize_commit_graph_all ( & repo) ?;
633785 assert_eq ! ( before, after, "graph should remain unchanged on failure" ) ;
0 commit comments