-
Notifications
You must be signed in to change notification settings - Fork 693
[move-package] Support dependency overrides #964
base: sui-move
Are you sure you want to change the base?
Changes from 2 commits
98570d0
eb54a5c
bd139e9
8f938e1
2bcfc51
2f0f791
e1b18b5
8c71fe4
b5f59d6
4a80f06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ pub type NamedAddress = Symbol; | |
| pub type PackageName = Symbol; | ||
| pub type FileName = Symbol; | ||
| pub type PackageDigest = Symbol; | ||
| pub type DepOverride = bool; | ||
|
|
||
| pub type AddressDeclarations = BTreeMap<NamedAddress, Option<AccountAddress>>; | ||
| pub type DevAddressDeclarations = BTreeMap<NamedAddress, AccountAddress>; | ||
|
|
@@ -55,15 +56,31 @@ pub struct InternalDependency { | |
| pub subst: Option<Substitution>, | ||
| pub version: Option<Version>, | ||
| pub digest: Option<PackageDigest>, | ||
| pub dep_override: Option<DepOverride>, | ||
|
awelc marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||
| #[derive(Debug, Clone, Eq)] | ||
| pub enum DependencyKind { | ||
| Local(PathBuf), | ||
| Git(GitInfo), | ||
| Custom(CustomDepInfo), | ||
| } | ||
|
|
||
| /// Custom implementation to normalize local paths | ||
| impl PartialEq for DependencyKind { | ||
| fn eq(&self, other: &Self) -> bool { | ||
| match (self, other) { | ||
| (&DependencyKind::Local(ref p), &DependencyKind::Local(ref op)) => { | ||
| normalize_path(p, true).unwrap() == normalize_path(op, true).unwrap() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to ensure local paths are stored normalized? No worries if not, but I remember some other occasions where I ran into this, and that's how I solved it (by calling
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That was my first thought, but this I believe would require changing the code parsing the manifest file and I wasn't sure we wanted to go there. The comparison change seemed less invasive, but I am happy to go the other route if it looks better.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's settle on normalizing local paths. |
||
| } | ||
|
|
||
| (&DependencyKind::Git(ref i), &DependencyKind::Git(ref iv)) => i == iv, | ||
| (&DependencyKind::Custom(ref i), &DependencyKind::Custom(ref iv)) => i == iv, | ||
| _ => false, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Eq, PartialEq)] | ||
| pub struct GitInfo { | ||
| /// The git clone url to download from | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Failed to resolve dependencies for package 'Root': Resolving dependencies for package 'B': Conflicting dependencies found: | ||
| C = { local = "deps_only/C", version = "2.0.0" } | ||
| C = { local = "deps_only/C", version = "1.0.0" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [package] | ||
| name = "Root" | ||
| version = "0.0.0" | ||
|
|
||
| [dependencies] | ||
| A = { local = "./deps_only/A" } | ||
| B = { local = "./deps_only/B" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "A" | ||
| version = "0.0.0" | ||
|
|
||
| [dependencies] | ||
| C = { local = "../C", version = "2.0.0" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "B" | ||
| version = "0.0.0" | ||
|
|
||
| [dependencies] | ||
| C = { local = "../C", version = "1.0.0" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [package] | ||
| name = "C" | ||
| version = "0.0.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Failed to resolve dependencies for package 'Root': Adding dependencies from ../resolvers/successful.sh for dependency 'A' in 'Root': Conflicting dependencies found: | ||
| ADep = { local = "deps_only/ADep", version = "1.0.0" } | ||
| ADep = { local = "./deps_only/ADep" } # Resolved by ../resolvers/successful.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [package] | ||
| name = "Root" | ||
| version = "0.0.0" | ||
|
|
||
| [dependencies] | ||
| B = { local = "./deps_only/B" } | ||
|
|
||
| [dependencies.A] | ||
| resolver = "../resolvers/successful.sh" | ||
|
|
||
| [dependencies.A.packages] | ||
| Contains = "Anything" | ||
| Has = { No = "Schema" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "A" | ||
| version = "0.0.0" | ||
|
|
||
| [dependencies] | ||
| ADep = { local = "../ADep" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [package] | ||
| name = "ADep" | ||
| version = "0.0.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "B" | ||
| version = "0.0.0" | ||
|
|
||
| [dependencies] | ||
| ADep = { local = "../ADep", version = "1.0.0" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # @generated by Move, please check-in and do not edit manually. | ||
|
|
||
| [move] | ||
| version = 0 | ||
|
|
||
| dependencies = [ | ||
| { name = "A" }, | ||
| { name = "B" }, | ||
| ] | ||
|
|
||
| [[move.package]] | ||
| name = "A" | ||
| source = { local = "./deps_only/A" } | ||
|
|
||
| dependencies = [ | ||
| { name = "ADep" }, | ||
| ] | ||
|
|
||
| [[move.package]] | ||
| name = "ADep" | ||
| source = { local = "deps_only/ADep" } | ||
|
|
||
| [[move.package]] | ||
| name = "B" | ||
| source = { local = "deps_only/B" } | ||
|
|
||
| dependencies = [ | ||
| { name = "ADep" }, | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think dep overrides should be necessary in the lock file -- i.e. the lock file should only contain one package for each package name.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thought here (though not fully implemented yet) was that there may be an override encoded in the dependency graph coming from an external resolver. In particular, for the following manifest for a package involving a diamond problem down the line (e.g., https://github.com/move-language/move/pull/964/files#diff-8c1d4a846826c7a3c78ecd708834e6d958c922a948298f9279e402ab3b30ea37) , instead of overriding
Ban external resolver could conceivably contain an override forA:If we don't worry about this case (I think the external override would only make sense at the level of external root package) then we indeed don't need overrides in Move.lock files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not worry about external resolvers specifying overrides (for now).