1
+ /// How to interpret a revision specification, or `revspec`.
2
+ #[ derive( Debug , Copy , Clone , PartialOrd , PartialEq , Ord , Eq , Hash ) ]
3
+ #[ cfg_attr( feature = "serde1" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
4
+ pub enum Kind {
5
+ /// A single revision specification, pointing at one reference.
6
+ Single ,
7
+ /// Two revision specifications `a` and `b` where we want all commits from `b` that are not also in `a`.
8
+ Range ,
9
+ /// Everything in `a` and `b` but no commit from any of their merge bases.
10
+ MergeBase ,
11
+ }
12
+
13
+ impl Default for Kind {
14
+ fn default ( ) -> Self {
15
+ Kind :: Single
16
+ }
17
+ }
18
+
1
19
pub mod parse {
2
20
#![ allow( missing_docs) ]
3
21
use git_object:: bstr:: BStr ;
@@ -8,12 +26,25 @@ pub mod parse {
8
26
Delegate ,
9
27
}
10
28
29
+ /// A delegate to be informed about parse events, with methods split into three categories.
30
+ ///
31
+ /// - **Revisions** - which revision to use as starting point for…
32
+ /// - **Navigation** - where to go once from the initial revision.
33
+ /// - **range** - to learn if the specification is for a single or multiple references.
11
34
pub trait Delegate {
12
35
fn resolve_ref ( & mut self , input : & BStr ) -> Option < ( ) > ;
13
36
fn find_by_prefix ( & mut self , input : & BStr ) -> Option < ( ) > ;
14
37
15
38
fn nth_ancestor ( & mut self , n : usize ) -> Option < ( ) > ;
16
39
fn nth_parent ( & mut self , n : usize ) -> Option < ( ) > ;
40
+
41
+ /// Set the kind of the specification, which happens only once if it happens at all.
42
+ /// In case this method isn't called, assume `Single`.
43
+ ///
44
+ /// Note that ranges don't necessarily assure that a second specification will be parsed.
45
+ /// If `^rev` is given, this method is called with [`spec::Kind::Range`][crate::spec::Kind::Range]
46
+ /// and no second specification is provided.
47
+ fn kind ( & mut self , kind : crate :: spec:: Kind ) ;
17
48
}
18
49
19
50
pub ( crate ) mod function {
0 commit comments