1- use std:: collections:: HashMap ;
1+ use std:: collections:: BTreeMap ;
22
33#[ derive( Clone , Debug , PartialEq , Eq ) ]
44pub struct Node {
55 pub local_commit : std:: rc:: Rc < crate :: git:: Commit > ,
66 pub branches : Vec < crate :: git:: Branch > ,
77 pub action : crate :: graph:: Action ,
88 pub pushable : bool ,
9- pub children : HashMap < git2:: Oid , Node > ,
9+ pub children : BTreeMap < git2:: Oid , Node > ,
1010}
1111
1212impl Node {
@@ -17,7 +17,7 @@ impl Node {
1717 let branches = possible_branches
1818 . remove ( local_commit. id )
1919 . unwrap_or_else ( Vec :: new) ;
20- let children = HashMap :: new ( ) ;
20+ let children = BTreeMap :: new ( ) ;
2121 Self {
2222 local_commit,
2323 branches,
@@ -59,8 +59,13 @@ impl Node {
5959 . ok_or_else ( || eyre:: eyre!( "Could not find merge base" ) ) ?;
6060
6161 if merge_base_id != self . local_commit . id {
62- let prefix =
63- Node :: populate ( repo, merge_base_id, self . local_commit . id , possible_branches) ?;
62+ let prefix = Node :: populate (
63+ repo,
64+ merge_base_id,
65+ self . local_commit . id ,
66+ possible_branches,
67+ self . action ,
68+ ) ?;
6469 self = prefix. extend ( repo, self ) ?;
6570 }
6671
@@ -69,6 +74,7 @@ impl Node {
6974 self . local_commit . id ,
7075 local_commit. id ,
7176 possible_branches,
77+ crate :: graph:: Action :: Pick ,
7278 ) ?;
7379 self . merge ( other) ;
7480
@@ -106,6 +112,7 @@ impl Node {
106112 merge_base_id,
107113 self . local_commit . id ,
108114 & mut possible_branches,
115+ self . action ,
109116 ) ?;
110117 self = prefix. extend ( repo, self ) ?;
111118 }
@@ -115,6 +122,7 @@ impl Node {
115122 merge_base_id,
116123 other. local_commit . id ,
117124 & mut possible_branches,
125+ other. action ,
118126 ) ?;
119127 other = prefix. extend ( repo, other) ?;
120128 }
@@ -129,6 +137,7 @@ impl Node {
129137 base_oid : git2:: Oid ,
130138 head_oid : git2:: Oid ,
131139 branches : & mut crate :: git:: Branches ,
140+ default_action : crate :: graph:: Action ,
132141 ) -> Result < Self , git2:: Error > {
133142 if let Some ( head_branches) = branches. get ( head_oid) {
134143 let head_name = head_branches. first ( ) . unwrap ( ) . name . as_str ( ) ;
@@ -153,6 +162,7 @@ impl Node {
153162
154163 let head_commit = repo. find_commit ( head_oid) . unwrap ( ) ;
155164 let mut root = Node :: new ( head_commit, branches) ;
165+ root. action = default_action;
156166
157167 let mut commits = repo. commits_from ( head_oid) ;
158168 // Already added head_oid
@@ -163,6 +173,7 @@ impl Node {
163173 for commit in commits {
164174 let child = root;
165175 root = Node :: new ( commit, branches) ;
176+ root. action = default_action;
166177 root. children . insert ( child. local_commit . id , child) ;
167178 if root. local_commit . id == base_oid {
168179 break ;
0 commit comments