@@ -16,10 +16,9 @@ use crate::{
1616 commit:: { CommitMessage , CommitOptions , RepositoryCommitExtended } ,
1717 patchname:: PatchName ,
1818 signature:: { SignatureExtended , TimeExtended } ,
19- stack:: serde:: RawStackState ,
2019} ;
2120
22- use super :: iter:: { AllPatches , BothPatches } ;
21+ use super :: { access :: StackStateAccess , iter:: AllPatches , serde :: RawStackState } ;
2322
2423/// Stack state as recorded in the git repository.
2524///
@@ -59,83 +58,6 @@ pub(crate) struct PatchState<'repo> {
5958 pub commit : Commit < ' repo > ,
6059}
6160
62- /// Trait for accessing stack state.
63- ///
64- /// Both `Stack` and `StackTransaction` implement this interface.
65- pub ( crate ) trait StackStateAccess < ' repo > {
66- /// Get slice of applied patch names.
67- fn applied ( & self ) -> & [ PatchName ] ;
68-
69- /// Get slice of unapplied patch names.
70- fn unapplied ( & self ) -> & [ PatchName ] ;
71-
72- /// Get slice of hidden patch names.
73- fn hidden ( & self ) -> & [ PatchName ] ;
74-
75- /// Get patch state for given patch name.
76- fn get_patch ( & self , patchname : & PatchName ) -> & PatchState < ' repo > ;
77-
78- /// Test whether given patch name exists in the stack.
79- ///
80- /// N.B. use [`StackStateAccess::collides()`] to test for potential patch name
81- /// collisions.
82- fn has_patch ( & self , patchname : & PatchName ) -> bool ;
83-
84- /// Test whether given patch name collides with an existing patch name.
85- ///
86- /// A patch name collides if it is different from only by case from a patch in the
87- /// stack.
88- fn collides ( & self , patchname : & PatchName ) -> Option < & PatchName > {
89- self . all_patches ( ) . find ( |pn| patchname. collides ( pn) )
90- }
91-
92- /// Get stack's top commit, or base if no applied patches.
93- fn top ( & self ) -> & Commit < ' repo > ;
94-
95- /// Get recorded head of the stack.
96- ///
97- /// N.B. this is probably not what you want. See also [`crate::stack::Stack::branch_head`].
98- fn head ( & self ) -> & Commit < ' repo > ;
99-
100- /// Get stack's base commit.
101- fn base ( & self ) -> & Commit < ' repo > ;
102-
103- /// Get the commit for the given patch name.
104- fn get_patch_commit ( & self , patchname : & PatchName ) -> & Commit < ' repo > {
105- & self . get_patch ( patchname) . commit
106- }
107-
108- /// Test whether given patch name is applied.
109- fn is_applied ( & self , patchname : & PatchName ) -> bool {
110- self . applied ( ) . contains ( patchname)
111- }
112-
113- /// Test whether given patch name is unapplied.
114- fn is_unapplied ( & self , patchname : & PatchName ) -> bool {
115- self . unapplied ( ) . contains ( patchname)
116- }
117-
118- /// Test whether given patch name is hidden.
119- fn is_hidden ( & self , patchname : & PatchName ) -> bool {
120- self . hidden ( ) . contains ( patchname)
121- }
122-
123- /// Iterator over all patch names: applied, unapplied, and hidden.
124- fn all_patches ( & self ) -> AllPatches < ' _ > {
125- AllPatches :: new ( self . applied ( ) , self . unapplied ( ) , self . hidden ( ) )
126- }
127-
128- /// Iterator over applied and unapplied patch names.
129- fn applied_and_unapplied ( & self ) -> BothPatches < ' _ > {
130- BothPatches :: new ( self . applied ( ) , self . unapplied ( ) )
131- }
132-
133- /// Iterator over unapplied and hidden patch names.
134- fn unapplied_and_hidden ( & self ) -> BothPatches < ' _ > {
135- BothPatches :: new ( self . unapplied ( ) , self . hidden ( ) )
136- }
137- }
138-
13961impl < ' repo > StackStateAccess < ' repo > for StackState < ' repo > {
14062 fn applied ( & self ) -> & [ PatchName ] {
14163 & self . applied
0 commit comments