Skip to content

Commit 564a9d7

Browse files
committed
feat: add revision component behind a feature toggle.
1 parent 96e60d9 commit 564a9d7

File tree

21 files changed

+52
-27
lines changed

21 files changed

+52
-27
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ default = ["max-performance-safe", "comfort", "extras"]
5858
#! Bundles are for convenience only and bear no further meaning beyond the cargo manifest file.
5959

6060
## Various additional features and capabilities that are not necessarily part of what most users would need.
61-
extras = ["worktree-stream", "worktree-archive", "blob-diff"]
61+
extras = ["worktree-stream", "worktree-archive", "blob-diff", "revision"]
6262

6363
## Various progress-related features that improve the look of progress message units.
6464
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
@@ -68,6 +68,9 @@ comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human
6868
#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.
6969
#! Providers of libraries should only activate
7070

71+
## Make revspec parsing possile, as well describing revision.
72+
revision = ["gix-revision"]
73+
7174
## Make it possible to diff blobs line by line. Note that this feature is integral for implementing tree-diffs as well due to the handling of rename-tracking,
7275
## which relies on line-by-line diffs in some cases.
7376
blob-diff = ["gix-diff/blob"]
@@ -187,7 +190,8 @@ gix-hash = { version = "^0.12.0", path = "../gix-hash" }
187190
gix-object = { version = "^0.35.0", path = "../gix-object" }
188191
gix-actor = { version = "^0.25.0", path = "../gix-actor" }
189192
gix-pack = { version = "^0.41.0", path = "../gix-pack", default-features = false, features = ["object-cache-dynamic"] }
190-
gix-revision = { version = "^0.20.0", path = "../gix-revision" }
193+
gix-revision = { version = "^0.20.0", path = "../gix-revision", optional = true }
194+
gix-revwalk = { version = "^0.6.0", path = "../gix-revwalk" }
191195
gix-negotiate = { version = "^0.6.0", path = "../gix-negotiate" }
192196

193197
gix-path = { version = "^0.9.0", path = "../gix-path" }

gix/src/commit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub enum Error {
2222
}
2323

2424
///
25+
#[cfg(feature = "revision")]
2526
pub mod describe {
2627
use std::borrow::Cow;
2728

@@ -197,7 +198,7 @@ pub mod describe {
197198
/// to save ~40% of time.
198199
pub fn try_resolve(&self) -> Result<Option<Resolution<'repo>>, Error> {
199200
// TODO: dirty suffix with respective dirty-detection
200-
let mut graph = gix_revision::Graph::new(
201+
let mut graph = gix_revwalk::Graph::new(
201202
|id, buf| {
202203
self.repo
203204
.objects

gix/src/config/cache/init.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ impl Cache {
151151
true,
152152
lenient_config,
153153
)?;
154+
#[cfg(feature = "revision")]
154155
let object_kind_hint = util::disambiguate_hint(&config, lenient_config)?;
155156
let (static_pack_cache_limit_bytes, pack_cache_bytes, object_cache_bytes) =
156157
util::parse_object_caches(&config, lenient_config, filter_config_section)?;
@@ -159,6 +160,7 @@ impl Cache {
159160
resolved: config.into(),
160161
use_multi_pack_index,
161162
object_hash,
163+
#[cfg(feature = "revision")]
162164
object_kind_hint,
163165
static_pack_cache_limit_bytes,
164166
pack_cache_bytes,
@@ -213,12 +215,16 @@ impl Cache {
213215
false,
214216
self.lenient_config,
215217
)?;
216-
let object_kind_hint = util::disambiguate_hint(config, self.lenient_config)?;
218+
219+
#[cfg(feature = "revision")]
220+
{
221+
let object_kind_hint = util::disambiguate_hint(config, self.lenient_config)?;
222+
self.object_kind_hint = object_kind_hint;
223+
}
217224
let reflog = util::query_refupdates(config, self.lenient_config)?;
218225

219226
self.hex_len = hex_len;
220227
self.ignore_case = ignore_case;
221-
self.object_kind_hint = object_kind_hint;
222228
self.reflog = reflog;
223229

224230
self.user_agent = Default::default();

gix/src/config/cache/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use super::Error;
33
use crate::{
44
config,
55
config::tree::{gitoxide, Core},
6-
revision::spec::parse::ObjectKindHint,
76
};
87

98
pub(crate) fn interpolate_context<'a>(
@@ -103,10 +102,11 @@ pub(crate) fn parse_core_abbrev(
103102
.flatten())
104103
}
105104

105+
#[cfg(feature = "revision")]
106106
pub(crate) fn disambiguate_hint(
107107
config: &gix_config::File<'static>,
108108
lenient_config: bool,
109-
) -> Result<Option<ObjectKindHint>, config::key::GenericErrorWithValue> {
109+
) -> Result<Option<crate::revision::spec::parse::ObjectKindHint>, config::key::GenericErrorWithValue> {
110110
match config.string_by_key("core.disambiguate") {
111111
None => Ok(None),
112112
Some(value) => Core::DISAMBIGUATE

gix/src/config/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub use gix_config::*;
22
use gix_features::threading::OnceCell;
33

4-
use crate::{bstr::BString, repository::identity, revision::spec, Repository};
4+
use crate::{bstr::BString, repository::identity, Repository};
55

66
pub(crate) mod cache;
77
mod snapshot;
@@ -513,7 +513,8 @@ pub(crate) struct Cache {
513513
/// The config section filter from the options used to initialize this instance. Keep these in sync!
514514
filter_config_section: fn(&gix_config::file::Metadata) -> bool,
515515
/// The object kind to pick if a prefix is ambiguous.
516-
pub object_kind_hint: Option<spec::parse::ObjectKindHint>,
516+
#[cfg(feature = "revision")]
517+
pub object_kind_hint: Option<crate::revision::spec::parse::ObjectKindHint>,
517518
/// If true, we are on a case-insensitive file system.
518519
pub ignore_case: bool,
519520
/// If true, we should default what's possible if something is misconfigured, on case by case basis, to be more resilient.

gix/src/config/tree/sections/core.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ mod autocrlf {
270270
}
271271
}
272272

273+
#[cfg(feature = "revision")]
273274
mod disambiguate {
274275
use std::borrow::Cow;
275276

@@ -425,7 +426,9 @@ mod validate {
425426

426427
pub struct Disambiguate;
427428
impl keys::Validate for Disambiguate {
429+
#[cfg_attr(not(feature = "revision"), allow(unused_variables))]
428430
fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
431+
#[cfg(feature = "revision")]
429432
super::Core::DISAMBIGUATE.try_into_object_kind_hint(value.into())?;
430433
Ok(())
431434
}

gix/src/ext/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
pub use object_id::ObjectIdExt;
22
pub use reference::ReferenceExt;
3+
#[cfg(feature = "revision")]
34
pub use rev_spec::RevSpecExt;
45
pub use tree::{TreeEntryExt, TreeEntryRefExt, TreeIterExt};
56

67
mod object_id;
78
mod reference;
9+
#[cfg(feature = "revision")]
810
mod rev_spec;
911
mod tree;

gix/src/id.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ops::Deref;
33

44
use gix_hash::{oid, ObjectId};
55

6-
use crate::{object::find, revision, Id, Object};
6+
use crate::{object::find, Id, Object};
77

88
/// An [object id][ObjectId] infused with a [`Repository`][crate::Repository].
99
impl<'repo> Id<'repo> {
@@ -103,9 +103,8 @@ impl<'repo> Id<'repo> {
103103

104104
impl<'repo> Id<'repo> {
105105
/// Obtain a platform for traversing ancestors of this commit.
106-
///
107-
pub fn ancestors(&self) -> revision::walk::Platform<'repo> {
108-
revision::walk::Platform::new(Some(self.inner), self.repo)
106+
pub fn ancestors(&self) -> crate::revision::walk::Platform<'repo> {
107+
crate::revision::walk::Platform::new(Some(self.inner), self.repo)
109108
}
110109
}
111110

gix/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ pub use gix_prompt as prompt;
105105
pub use gix_protocol as protocol;
106106
pub use gix_ref as refs;
107107
pub use gix_refspec as refspec;
108+
pub use gix_revwalk as revwalk;
108109
pub use gix_sec as sec;
109110
pub use gix_tempfile as tempfile;
110111
pub use gix_trace as trace;

gix/src/object/commit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{bstr, bstr::BStr, revision, Commit, ObjectDetached, Tree};
1+
use crate::{bstr, bstr::BStr, Commit, ObjectDetached, Tree};
22

33
mod error {
44
use crate::object;
@@ -131,12 +131,13 @@ impl<'repo> Commit<'repo> {
131131
}
132132

133133
/// Obtain a platform for traversing ancestors of this commit.
134-
pub fn ancestors(&self) -> revision::walk::Platform<'repo> {
134+
pub fn ancestors(&self) -> crate::revision::walk::Platform<'repo> {
135135
self.id().ancestors()
136136
}
137137

138138
/// Create a platform to further configure a `git describe` operation to find a name for this commit by looking
139139
/// at the closest annotated tags (by default) in its past.
140+
#[cfg(feature = "revision")]
140141
pub fn describe(&self) -> crate::commit::describe::Platform<'repo> {
141142
crate::commit::describe::Platform {
142143
id: self.id,

gix/src/remote/connection/fetch/negotiate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gix_pack::Find;
77

88
use crate::remote::{fetch, fetch::Shallow};
99

10-
type Queue = gix_revision::PriorityQueue<SecondsSinceUnixEpoch, gix_hash::ObjectId>;
10+
type Queue = gix_revwalk::PriorityQueue<SecondsSinceUnixEpoch, gix_hash::ObjectId>;
1111

1212
/// The error returned during negotiation.
1313
#[derive(Debug, thiserror::Error)]
@@ -16,7 +16,7 @@ pub enum Error {
1616
#[error("We were unable to figure out what objects the server should send after {rounds} round(s)")]
1717
NegotiationFailed { rounds: usize },
1818
#[error(transparent)]
19-
LookupCommitInGraph(#[from] gix_revision::graph::lookup::commit::Error),
19+
LookupCommitInGraph(#[from] gix_revwalk::graph::lookup::commit::Error),
2020
#[error(transparent)]
2121
InitRefsIterator(#[from] crate::reference::iter::init::Error),
2222
#[error(transparent)]

gix/src/repository/graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ impl crate::Repository {
1212
///
1313
/// ### Performance
1414
///
15-
/// Note that the [Graph][gix_revision::Graph] can be sensitive to various object database settings that may affect the performance
15+
/// Note that the [Graph][gix_revwalk::Graph] can be sensitive to various object database settings that may affect the performance
1616
/// of the commit walk.
17-
pub fn revision_graph<T>(&self) -> gix_revision::Graph<'_, T> {
18-
gix_revision::Graph::new(
17+
pub fn revision_graph<T>(&self) -> gix_revwalk::Graph<'_, T> {
18+
gix_revwalk::Graph::new(
1919
|id, buf| {
2020
self.objects
2121
.try_find(id, buf)

gix/src/repository/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ mod object;
5252
mod pathspec;
5353
mod reference;
5454
mod remote;
55+
#[cfg(feature = "revision")]
5556
mod revision;
5657
mod shallow;
5758
mod state;

gix/src/revision/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
//!
33
//! This module provides utilities to walk graphs of revisions and specify revisions and ranges of revisions.
44
5+
#[cfg(feature = "revision")]
56
pub use gix_revision as plumbing;
67

78
///
89
pub mod walk;
910
pub use walk::iter::Walk;
1011

1112
///
13+
#[cfg(feature = "revision")]
1214
pub mod spec;
1315

1416
/// The specification of a revision as parsed from a revision specification like `HEAD@{1}` or `v1.2.3...main`.
@@ -17,6 +19,7 @@ pub mod spec;
1719
/// See the [official git documentation](https://git-scm.com/docs/git-rev-parse#_specifying_revisions) for reference on how
1820
/// to specify revisions and revision ranges.
1921
#[derive(Clone, Debug)]
22+
#[cfg(feature = "revision")]
2023
pub struct Spec<'repo> {
2124
pub(crate) inner: gix_revision::Spec,
2225
/// The first name of a reference as seen while parsing a `RevSpec`, for completeness.

gix/tests/commit/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(feature = "revision")]
12
mod describe {
23
use gix::commit::describe::SelectRef::{AllRefs, AllTags, AnnotatedTags};
34

gix/tests/config/tree.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,7 @@ mod diff {
272272
mod core {
273273
use std::time::Duration;
274274

275-
use gix::{
276-
config::tree::{Core, Key},
277-
revision::spec::parse::ObjectKindHint,
278-
};
275+
use gix::config::tree::{Core, Key};
279276
use gix_lock::acquire::Fail;
280277

281278
use crate::config::tree::bcow;
@@ -313,7 +310,9 @@ mod core {
313310
}
314311

315312
#[test]
313+
#[cfg(feature = "revision")]
316314
fn disambiguate() -> crate::Result {
315+
use gix::revision::spec::parse::ObjectKindHint;
317316
for (value, expected) in [
318317
("none", None),
319318
("commit", Some(ObjectKindHint::Commit)),

gix/tests/gix-with-regex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ mod object;
1111
mod reference;
1212
mod remote;
1313
mod repository;
14+
#[cfg(feature = "revision")]
1415
mod revision;
1516
mod submodule;

gix/tests/gix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod remote;
2424
#[cfg(not(feature = "regex"))]
2525
mod repository;
2626
#[cfg(not(feature = "regex"))]
27+
#[cfg(feature = "revision")]
2728
mod revision;
2829
#[cfg(not(feature = "regex"))]
2930
mod submodule;

gix/tests/object/tree/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::util::{named_repo, named_subrepo_opts};
22

3-
#[cfg(feature = "blob-diff")]
3+
#[cfg(all(feature = "blob-diff", feature = "revision"))]
44
mod diff;
55

66
#[test]

gix/tests/reference/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use crate::repo_rw;
2-
31
mod log {
42

53
#[test]
@@ -86,7 +84,9 @@ mod find {
8684
}
8785

8886
#[test]
87+
#[cfg(feature = "revision")]
8988
fn set_target_id() {
89+
use crate::repo_rw;
9090
let (repo, _tmp) = repo_rw("make_basic_repo.sh").unwrap();
9191
let mut head_ref = repo.head_ref().unwrap().expect("present");
9292
let target_id = repo.rev_parse_single(":/c1").unwrap();

0 commit comments

Comments
 (0)