@@ -11,6 +11,7 @@ use anyhow::Result;
1111use blobstore:: Loadable ;
1212use bytes:: Bytes ;
1313use bytes:: BytesMut ;
14+ use cloned:: cloned;
1415use context:: CoreContext ;
1516use edenapi_service:: utils:: to_hg_path;
1617use edenapi_types:: commit:: BonsaiExtra ;
@@ -158,7 +159,7 @@ pub fn to_identical_changeset(
158159 . collect ( ) ,
159160 } ;
160161
161- let bonsai_parents = BonsaiParents :: from_iter ( parents. iter ( ) . map ( |p| ( * p) . into ( ) ) ) ;
162+ let bonsai_parents = BonsaiParents :: from_iter ( parents. clone ( ) . iter ( ) . map ( |p| ( * p) . into ( ) ) ) ;
162163
163164 // Ensure items are indeed equivalent between bonsai and hg changeset
164165 ensure ! ( author. as_bytes( ) == hg_cs. user( ) , "Author mismatch" ) ;
@@ -188,7 +189,7 @@ pub fn to_identical_changeset(
188189 value : value. to_vec ( ) ,
189190 } )
190191 . collect ( ) ,
191- file_changes : to_file_change ( & file_changes, bcs . parents ( ) ) ?,
192+ file_changes : to_file_change ( & file_changes, parents. iter ( ) . copied ( ) ) ?,
192193 message : message. to_string ( ) ,
193194 is_snapshot,
194195 hg_info,
@@ -197,7 +198,7 @@ pub fn to_identical_changeset(
197198
198199fn to_file_change (
199200 map : & SortedVectorMap < NonRootMPath , FileChange > ,
200- mut parents : impl Iterator < Item = ChangesetId > ,
201+ parents : impl Iterator < Item = ChangesetId > + Clone ,
201202) -> Result < Vec < ( RepoPathBuf , BonsaiFileChange ) > > {
202203 let res = map
203204 . into_iter ( )
@@ -216,9 +217,10 @@ fn to_file_change(
216217 file_type : tc. file_type ( ) . try_into ( ) ?,
217218 copy_info : match tc. copy_from ( ) {
218219 Some ( ( path, cs_id) ) => {
219- let index = parents. position ( |parent| parent == * cs_id) . ok_or (
220- anyhow:: anyhow!( "Error: Copy from info doesn't match parents" ) ,
221- ) ?;
220+ cloned ! ( mut parents) ;
221+ let index = parents
222+ . position ( |parent| parent == * cs_id)
223+ . ok_or ( anyhow:: anyhow!( "Copy from info doesn't match parents" ) ) ?;
222224 Some ( ( to_hg_path ( path) ?, index) )
223225 }
224226 None => None ,
0 commit comments