Mercurial > hg
comparison rust/hg-core/src/revset.rs @ 48078:ddde80830aea
rust-revset: add separate match logic for shortcuts
The next change will add a shortcut for the `.` revision.
One day we might start matching `tip` and others, so this is an easy refactor.
Differential Revision: https://phab.mercurial-scm.org/D11401
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Sat, 11 Sep 2021 00:05:08 +0200 |
parents | 6f579618ea7b |
children | 3da7bf75fdb2 |
comparison
equal
deleted
inserted
replaced
48077:ba773bd99203 | 48078:ddde80830aea |
---|---|
16 input: &str, | 16 input: &str, |
17 repo: &Repo, | 17 repo: &Repo, |
18 ) -> Result<Revision, RevlogError> { | 18 ) -> Result<Revision, RevlogError> { |
19 let changelog = repo.changelog()?; | 19 let changelog = repo.changelog()?; |
20 | 20 |
21 match input { | |
22 "null" => return Ok(NULL_REVISION), | |
23 _ => {} | |
24 } | |
25 | |
21 match resolve_rev_number_or_hex_prefix(input, &changelog.revlog) { | 26 match resolve_rev_number_or_hex_prefix(input, &changelog.revlog) { |
22 Err(RevlogError::InvalidRevision) => {} // Try other syntax | 27 Err(RevlogError::InvalidRevision) => { |
28 // TODO: support for the rest of the language here. | |
29 let msg = format!("cannot parse revset '{}'", input); | |
30 Err(HgError::unsupported(msg).into()) | |
31 } | |
23 result => return result, | 32 result => return result, |
24 } | 33 } |
25 | |
26 if input == "null" { | |
27 return Ok(NULL_REVISION); | |
28 } | |
29 | |
30 // TODO: support for the rest of the language here. | |
31 | |
32 Err( | |
33 HgError::unsupported(format!("cannot parse revset '{}'", input)) | |
34 .into(), | |
35 ) | |
36 } | 34 } |
37 | 35 |
38 /// Resolve the small subset of the language suitable for revlogs other than | 36 /// Resolve the small subset of the language suitable for revlogs other than |
39 /// the changelog, such as in `hg debugdata --manifest` CLI argument. | 37 /// the changelog, such as in `hg debugdata --manifest` CLI argument. |
40 /// | 38 /// |