summaryrefslogtreecommitdiffstats
path: root/vendor/gix-revision/src/spec/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/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/mod.rs')
-rw-r--r--vendor/gix-revision/src/spec/mod.rs63
1 files changed, 63 insertions, 0 deletions
diff --git a/vendor/gix-revision/src/spec/mod.rs b/vendor/gix-revision/src/spec/mod.rs
new file mode 100644
index 000000000..ba24c75c0
--- /dev/null
+++ b/vendor/gix-revision/src/spec/mod.rs
@@ -0,0 +1,63 @@
+use crate::Spec;
+
+/// How to interpret a revision specification, or `revspec`.
+#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
+#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
+pub enum Kind {
+ /// Include commits reachable from this revision, the default when parsing revision `a` for example, i.e. `a` and its ancestors.
+ /// Example: `a`.
+ IncludeReachable,
+ /// Exclude commits reachable from this revision, i.e. `a` and its ancestors. Example: `^a`.
+ ExcludeReachable,
+ /// Every commit that is reachable from `b` but not from `a`. Example: `a..b`.
+ RangeBetween,
+ /// Every commit reachable through either `a` or `b` but no commit that is reachable by both. Example: `a...b`.
+ ReachableToMergeBase,
+ /// Include every commit of all parents of `a`, but not `a` itself. Example: `a^@`.
+ IncludeReachableFromParents,
+ /// Exclude every commit of all parents of `a`, but not `a` itself. Example: `a^!`.
+ ExcludeReachableFromParents,
+}
+
+impl Default for Kind {
+ fn default() -> Self {
+ Kind::IncludeReachable
+ }
+}
+
+impl Spec {
+ /// Return the kind of this specification.
+ pub fn kind(&self) -> Kind {
+ match self {
+ Spec::Include(_) => Kind::IncludeReachable,
+ Spec::Exclude(_) => Kind::ExcludeReachable,
+ Spec::Range { .. } => Kind::RangeBetween,
+ Spec::Merge { .. } => Kind::ReachableToMergeBase,
+ Spec::IncludeOnlyParents { .. } => Kind::IncludeReachableFromParents,
+ Spec::ExcludeParents { .. } => Kind::ExcludeReachableFromParents,
+ }
+ }
+}
+
+mod _impls {
+ use std::fmt::{Display, Formatter};
+
+ use crate::Spec;
+
+ impl Display for Spec {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Spec::Include(oid) => Display::fmt(oid, f),
+ Spec::Exclude(oid) => write!(f, "^{oid}"),
+ Spec::Range { from, to } => write!(f, "{from}..{to}"),
+ Spec::Merge { theirs, ours } => write!(f, "{theirs}...{ours}"),
+ Spec::IncludeOnlyParents(from_exclusive) => write!(f, "{from_exclusive}^@"),
+ Spec::ExcludeParents(oid) => write!(f, "{oid}^!"),
+ }
+ }
+ }
+}
+
+///
+pub mod parse;
+pub use parse::function::parse;