From 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:41:41 +0200 Subject: Merging upstream version 1.70.0+dfsg2. Signed-off-by: Daniel Baumann --- vendor/gix-revision/src/spec/parse/mod.rs | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 vendor/gix-revision/src/spec/parse/mod.rs (limited to 'vendor/gix-revision/src/spec/parse/mod.rs') diff --git a/vendor/gix-revision/src/spec/parse/mod.rs b/vendor/gix-revision/src/spec/parse/mod.rs new file mode 100644 index 000000000..5a64012c6 --- /dev/null +++ b/vendor/gix-revision/src/spec/parse/mod.rs @@ -0,0 +1,64 @@ +use bstr::BString; + +use crate::spec; + +/// The error returned by [`spec::parse()`][crate::spec::parse()]. +#[derive(Debug, thiserror::Error)] +#[allow(missing_docs)] +pub enum Error { + #[error("'~' needs to follow an anchor, like '@~'.")] + MissingTildeAnchor, + #[error("':' needs to be followed by either '/' and regex or the path to lookup in the HEAD tree.")] + MissingColonSuffix, + #[error("':/' must be followed by a regular expression.")] + EmptyTopLevelRegex, + #[error("Need one character after '/!', typically '-', but got {:?}", .regex)] + UnspecifiedRegexModifier { regex: BString }, + #[error("Cannot peel to {:?} - unknown target.", .input)] + InvalidObject { input: BString }, + #[error("Could not parse time {:?} for revlog lookup.", .input)] + Time { + input: BString, + source: Option, + }, + #[error("Sibling branches like 'upstream' or 'push' require a branch name with remote configuration, got {:?}", .name)] + SiblingBranchNeedsBranchName { name: BString }, + #[error("Reflog entries require a ref name, got {:?}", .name)] + ReflogLookupNeedsRefName { name: BString }, + #[error("A reference name must be followed by positive numbers in '@{{n}}', got {:?}", .nav)] + RefnameNeedsPositiveReflogEntries { nav: BString }, + #[error("Negative or explicitly positive numbers are invalid here: {:?}", .input)] + SignedNumber { input: BString }, + #[error("Could not parse number from {input:?}")] + InvalidNumber { input: BString }, + #[error("Negative zeroes are invalid: {:?} - remove the '-'", .input)] + NegativeZero { input: BString }, + #[error("The opening brace in {:?} was not matched", .input)] + UnclosedBracePair { input: BString }, + #[error("Cannot set spec kind more than once. Previous value was {:?}, now it is {:?}", .prev_kind, .kind)] + KindSetTwice { prev_kind: spec::Kind, kind: spec::Kind }, + #[error("The @ character is either standing alone or followed by `{{}}`, got {:?}", .input)] + AtNeedsCurlyBrackets { input: BString }, + #[error("A portion of the input could not be parsed: {:?}", .input)] + UnconsumedInput { input: BString }, + #[error("The delegate didn't indicate success - check delegate for more information")] + Delegate, +} + +/// +pub mod delegate; + +/// A delegate to be informed about parse events, with methods split into categories. +/// +/// - **Anchors** - which revision to use as starting point for… +/// - **Navigation** - where to go once from the initial revision +/// - **Range** - to learn if the specification is for a single or multiple references, and how to combine them. +pub trait Delegate: delegate::Revision + delegate::Navigate + delegate::Kind { + /// Called at the end of a successful parsing operation. + /// It can be used as a marker to finalize internal data structures. + /// + /// Note that it will not be called if there is unconsumed input. + fn done(&mut self); +} + +pub(crate) mod function; -- cgit v1.2.3