@@ -56,7 +56,7 @@ pub struct WorkspaceSession<'a> {
5656pub struct SessionOperation {
5757 pub repo : Arc < ReadonlyRepo > ,
5858 pub wc_id : CommitId ,
59- branches_index : OnceCell < Rc < BranchIndex > > ,
59+ ref_index : OnceCell < Rc < RefIndex > > ,
6060 prefix_context : OnceCell < Rc < IdPrefixContext > > ,
6161 immutable_revisions : OnceCell < Rc < RevsetExpression > >
6262}
@@ -318,9 +318,9 @@ impl WorkspaceSession<'_> {
318318 self . operation . immutable_revisions . get_or_init ( || build_immutable_revisions ( & self . operation . repo , & self . aliases_map , & self . parse_context ( ) ) . expect ( "init immutable heads" ) )
319319 }
320320
321- pub fn branches_index ( & self ) -> & Rc < BranchIndex > {
322- self . operation . branches_index
323- . get_or_init ( || Rc :: new ( build_branches_index ( self . operation . repo . as_ref ( ) ) ) )
321+ pub fn ref_index ( & self ) -> & Rc < RefIndex > {
322+ self . operation . ref_index
323+ . get_or_init ( || Rc :: new ( build_ref_index ( self . operation . repo . as_ref ( ) ) ) )
324324 }
325325
326326 /************************************
@@ -398,7 +398,7 @@ impl WorkspaceSession<'_> {
398398 }
399399
400400 pub fn format_header ( & self , commit : & Commit , known_immutable : Option < bool > ) -> Result < messages:: RevHeader > {
401- let index = self . branches_index ( ) ;
401+ let index = self . ref_index ( ) ;
402402 let branches = index. get ( commit. id ( ) ) . iter ( ) . cloned ( ) . collect ( ) ;
403403
404404 let is_immutable = known_immutable
@@ -412,7 +412,7 @@ impl WorkspaceSession<'_> {
412412 has_conflict : commit. has_conflict ( ) ?,
413413 is_working_copy : * commit. id ( ) == self . operation . wc_id ,
414414 is_immutable,
415- branches,
415+ refs : branches,
416416 parent_ids : commit. parent_ids ( ) . iter ( ) . map ( |commit_id| self . format_commit_id ( commit_id) ) . collect ( )
417417 } )
418418 }
@@ -748,7 +748,7 @@ impl SessionOperation {
748748 SessionOperation {
749749 repo,
750750 wc_id,
751- branches_index : OnceCell :: default ( ) ,
751+ ref_index : OnceCell :: default ( ) ,
752752 prefix_context : OnceCell :: default ( ) ,
753753 immutable_revisions : OnceCell :: default ( )
754754 }
@@ -892,19 +892,19 @@ fn parse_revset(
892892/*************************/
893893
894894#[ derive( Default ) ]
895- pub struct BranchIndex {
896- index : HashMap < CommitId , Vec < messages:: RefName > > ,
895+ pub struct RefIndex {
896+ index : HashMap < CommitId , Vec < messages:: StoreRef > > ,
897897}
898898
899- impl BranchIndex {
900- fn insert < ' a > ( & mut self , ids : impl IntoIterator < Item = & ' a CommitId > , name : messages:: RefName ) {
899+ impl RefIndex {
900+ fn insert < ' a > ( & mut self , ids : impl IntoIterator < Item = & ' a CommitId > , r#ref : messages:: StoreRef ) {
901901 for id in ids {
902902 let ref_names = self . index . entry ( id. clone ( ) ) . or_default ( ) ;
903- ref_names. push ( name . clone ( ) ) ;
903+ ref_names. push ( r#ref . clone ( ) ) ;
904904 }
905905 }
906906
907- fn get ( & self , id : & CommitId ) -> & [ messages:: RefName ] {
907+ fn get ( & self , id : & CommitId ) -> & [ messages:: StoreRef ] {
908908 if let Some ( names) = self . index . get ( id) {
909909 names
910910 } else {
@@ -913,13 +913,14 @@ impl BranchIndex {
913913 }
914914}
915915
916- fn build_branches_index ( repo : & ReadonlyRepo ) -> BranchIndex {
917- let mut index = BranchIndex :: default ( ) ;
916+ fn build_ref_index ( repo : & ReadonlyRepo ) -> RefIndex {
917+ let mut index = RefIndex :: default ( ) ;
918+
918919 for ( branch_name, branch_target) in repo. view ( ) . branches ( ) {
919920 let local_target = branch_target. local_target ;
920921 let remote_refs = branch_target. remote_refs ;
921922 if local_target. is_present ( ) {
922- index. insert ( local_target. added_ids ( ) , messages:: RefName :: LocalBranch {
923+ index. insert ( local_target. added_ids ( ) , messages:: StoreRef :: LocalBranch {
923924 branch_name : branch_name. to_owned ( ) ,
924925 has_conflict : local_target. has_conflict ( ) ,
925926 is_synced : remote_refs. iter ( ) . all ( |& ( _, remote_ref) | {
@@ -929,7 +930,7 @@ fn build_branches_index(repo: &ReadonlyRepo) -> BranchIndex {
929930 } ) ;
930931 }
931932 for & ( remote_name, remote_ref) in & remote_refs {
932- index. insert ( remote_ref. target . added_ids ( ) , messages:: RefName :: RemoteBranch {
933+ index. insert ( remote_ref. target . added_ids ( ) , messages:: StoreRef :: RemoteBranch {
933934 branch_name : branch_name. to_owned ( ) ,
934935 remote_name : remote_name. to_owned ( ) ,
935936 has_conflict : remote_ref. target . has_conflict ( ) ,
@@ -939,6 +940,11 @@ fn build_branches_index(repo: &ReadonlyRepo) -> BranchIndex {
939940 } ) ;
940941 }
941942 }
943+
944+ for ( tag_name, tag_target) in repo. view ( ) . tags ( ) {
945+ index. insert ( tag_target. added_ids ( ) , messages:: StoreRef :: Tag { tag_name : tag_name. clone ( ) } ) ;
946+ }
947+
942948 index
943949}
944950
0 commit comments