Skip to content

Commit 0f53b3c

Browse files
committed
[no ci] review progress
1 parent 0c8147f commit 0f53b3c

File tree

5 files changed

+63
-14
lines changed

5 files changed

+63
-14
lines changed

external-crates/move/crates/move-package-alt/TODO.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
- [ ] tests/test_runner.rs
2-
- [ ] dependency/dependency_set.rs
3-
- [ ] dependency/mod.rs
4-
- [ ] dependency/local.rs
1+
TODO
2+
====
3+
- in many instances we've wanted to do some amount of tranformation when converting from serialized
4+
stuff into our data structures. I've been thinking for a while that we may want to just have a
5+
separate parsing module that contains only the parsing data structures and
6+
serialization/deserialization code. We've been avoiding this for a while and I think it's
7+
causing us headaches
8+
9+
-
10+
11+
Needs review
12+
============
13+
- [X] dependency/dependency_set.rs
14+
- [X] dependency/mod.rs
15+
- [X] dependency/local.rs
516
- [ ] dependency/git.rs
617

718
- [ ] dependency/external.rs
@@ -33,6 +44,7 @@
3344
- [ ] package/lockfile.rs
3445
- [ ] package/manifest.rs
3546

47+
- [ ] tests/test_runner.rs
3648
- [ ] tests/data/flavor_sui/Move@parsed.snap
3749
- [ ] tests/data/flavor_sui/Move.parsed
3850
- [ ] tests/data/flavor_sui/Move.toml

external-crates/move/crates/move-package-alt/src/dependency/dependency_set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ use serde::{Deserialize, Serialize};
1414

1515
use crate::package::{EnvironmentName, PackageName};
1616

17+
// TODO (potential refactor): using [Option] here and representing the default environment as
18+
// [None] has led to some confusion, it might be better to make a specific enumeration, so that
19+
// [DependencySet] becomes closer to a vanilla map. In fact, in the dependency graph we'll have
20+
// `Option<EnvironmentName>, PackageName` edges - this might be a good type to encapsulate; then
21+
// DependencySet just becomes a map from edges to T. A little curry can go a long way
22+
1723
/// A set of default dependencies and dep overrides. Within each environment, package names are
1824
/// unique.
1925
///
@@ -262,6 +268,7 @@ impl<T> FromIterator<(Option<EnvironmentName>, PackageName, T)> for DependencySe
262268
}
263269
}
264270

271+
// TODO: maybe this can be derived with our fancy derive macros?
265272
// Note: can't be derived because that adds a spurious T: Default bound
266273
impl<T> Default for DependencySet<T> {
267274
/// The empty dependency set

external-crates/move/crates/move-package-alt/src/dependency/git.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//!
77
//! Git dependencies are cached in `~/.move`, which has the following structure:
88
//!
9+
//! TODO: this doesn't match the implementation below:
910
//! ```ignore
1011
//! .move/
1112
//! git/
@@ -34,6 +35,13 @@ use crate::errors::{GitError, GitErrorKind, Located, PackageError, PackageResult
3435

3536
use super::{DependencySet, Pinned, Unpinned};
3637

38+
// TODO: (potential refactor): it might be good to separate out a separate module that is just git
39+
// stuff and another that uses that git stuff to implement the dependency operations (like
40+
// the jsonrpc / dependency::external split).
41+
42+
// TODO: curious about the benefit of using String instead of wrapping it. The advantage of
43+
// wrapping it is that we have invariants (with the type alias, nothing prevents us from
44+
// writing `let x : Sha = ""`
3745
type Sha = String;
3846

3947
/// A git dependency that is unpinned. The `rev` field can be either empty, a branch, or a sha. To
@@ -60,7 +68,6 @@ pub struct PinnedGitDependency {
6068
repo: String,
6169

6270
/// The exact sha for the revision
63-
// rev: Sha,
6471
#[serde(deserialize_with = "deserialize_sha")]
6572
rev: Sha,
6673

@@ -81,7 +88,8 @@ pub struct GitRepo {
8188
path: PathBuf,
8289
}
8390

84-
// Custom error type for SHA validation
91+
/// Custom error type for SHA validation
92+
// TODO: derive(Error)?
8593
#[derive(Debug)]
8694
pub enum ShaError {
8795
InvalidLength(usize),

external-crates/move/crates/move-package-alt/src/dependency/local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct LocalDependency {
1616
local: PathBuf,
1717
}
1818

19+
// TODO: dead code
1920
impl TryFrom<(&Path, toml_edit::Value)> for LocalDependency {
2021
type Error = anyhow::Error; // TODO
2122

external-crates/move/crates/move-package-alt/src/dependency/mod.rs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,22 @@
22
// Copyright (c) The Move Contributors
33
// SPDX-License-Identifier: Apache-2.0
44

5-
mod dependency_set;
6-
// TODO: this shouldn't be pub; need to move resolver error into resolver module
7-
pub mod external;
8-
mod git;
9-
mod local;
10-
11-
pub use dependency_set::DependencySet;
125
use std::{
136
collections::BTreeMap,
147
fmt::{self, Debug},
158
marker::PhantomData,
169
path::PathBuf,
1710
process::{Command, Stdio},
1811
};
19-
use tracing::debug;
2012

2113
use derive_where::derive_where;
2214
use serde::{
2315
Deserialize, Deserializer, Serialize,
2416
de::{self, MapAccess, SeqAccess, Visitor},
2517
};
2618

19+
use tracing::debug;
20+
2721
use crate::{
2822
errors::{GitError, PackageError, PackageResult, ResolverError},
2923
flavor::MoveFlavor,
@@ -34,6 +28,24 @@ use external::ExternalDependency;
3428
use git::{GitRepo, PinnedGitDependency, UnpinnedGitDependency};
3529
use local::LocalDependency;
3630

31+
mod dependency_set;
32+
// TODO: this shouldn't be pub; need to move resolver error into resolver module
33+
pub mod external;
34+
mod git;
35+
mod local;
36+
37+
pub use dependency_set::DependencySet;
38+
39+
// TODO (potential refactor): consider using objects for manifest dependencies (i.e. `Box<dyn UnpinnedDependency>`).
40+
// part of the complexity here would be deserialization - probably need a flavor-specific
41+
// function that converts a toml value to a Box<dyn UnpinnedDependency>
42+
//
43+
// resolution would also be interesting because of batch resolution. Would probably need a
44+
// trait method to return a resolver object, and then a method on the resolver object to
45+
// resolve a bunch of dependencies (resolvers could implement Eq)
46+
//
47+
// TODO: maybe rename ManifestDependencyInfo to UnpinnedDependency
48+
3749
/// Phantom type to represent pinned dependencies (see [PinnedDependency])
3850
#[derive(Debug, PartialEq, Eq)]
3951
pub struct Pinned;
@@ -45,6 +57,7 @@ pub struct Unpinned;
4557
/// [ManifestDependencyInfo]s contain the dependency-type-specific things that users write in their
4658
/// Move.toml files in the `dependencies` section.
4759
///
60+
/// TODO: this paragraph will change with upcoming design changes:
4861
/// There are additional general fields in the manifest format (like `override` or `rename-from`)
4962
/// that are not part of the ManifestDependencyInfo. We separate these partly because these things
5063
/// are not serialized to the Lock file. See [crate::package::manifest] for the full representation
@@ -80,6 +93,8 @@ pub enum PinnedDependencyInfo<F: MoveFlavor + ?Sized> {
8093
FlavorSpecific(F::FlavorDependency<Pinned>),
8194
}
8295

96+
// TODO: these should be moved down.
97+
8398
// UNPINNED
8499
impl<'de, F> Deserialize<'de> for ManifestDependencyInfo<F>
85100
where
@@ -184,6 +199,7 @@ fn split<F: MoveFlavor>(
184199
(gits, exts, locs, flav)
185200
}
186201

202+
// TODO: this will change with upcoming design changes:
187203
/// Replace all dependencies with their pinned versions. The returned set may have a different set
188204
/// of keys than the input, for example if new implicit dependencies are added or if external
189205
/// resolvers resolve default deps to dep-overrides, or if dep-overrides are identical to the
@@ -231,6 +247,7 @@ pub async fn pin<F: MoveFlavor>(
231247
]))
232248
}
233249

250+
// TODO: this will change with the upcoming design changes:
234251
/// For each environment, if none of the implicit dependencies are present in [deps] (or the
235252
/// default environment), then they are all added.
236253
// TODO: what's the notion of identity used here?
@@ -250,3 +267,7 @@ fn fetch<F: MoveFlavor>(
250267

251268
todo!()
252269
}
270+
271+
// TODO: unit tests
272+
#[cfg(test)]
273+
mod tests {}

0 commit comments

Comments
 (0)