summaryrefslogtreecommitdiffstats
path: root/vendor/gix-revision/src/spec/parse/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
commit10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch)
treebdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/gix-revision/src/spec/parse/mod.rs
parentReleasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff)
downloadrustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz
rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-revision/src/spec/parse/mod.rs')
-rw-r--r--vendor/gix-revision/src/spec/parse/mod.rs64
1 files changed, 64 insertions, 0 deletions
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<gix_date::parse::Error>,
+ },
+ #[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 `{{<content>}}`, 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;