Skip to content

Check whether to load databases after sync mode check #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion example_projects/project-upgrade/rproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
name = "project-upgrade"
r_version = "4.4"
repositories = [
{alias = "PPM", url = "https://packagemanager.posit.co/cran/2024-12-22"}
{alias = "PPM", url = "https://packagemanager.posit.co/cran/2025-04-12"},
{alias = "PPM-old", url = "https://packagemanager.posit.co/cran/2025-04-01"}
]

dependencies = [
Expand Down
118 changes: 34 additions & 84 deletions example_projects/project-upgrade/rv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,59 @@
version = 1
r_version = "4.4"

[[packages]]
name = "MASS"
version = "7.3-60.2"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
path = "4.4.0/Recommended"
force_source = false
dependencies = []

[[packages]]
name = "Matrix"
version = "1.6-5"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
path = "4.4.0/Recommended"
force_source = false
dependencies = [
"lattice",
]

[[packages]]
name = "R6"
version = "2.5.1"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "2.6.1"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "RColorBrewer"
version = "1.1-3"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "cli"
version = "3.6.2"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "3.6.4"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "colorspace"
version = "2.1-0"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "2.1-1"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "fansi"
version = "1.0.6"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "farver"
version = "2.1.1"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "2.1.2"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "ggplot2"
version = "3.4.4"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "3.5.1"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"cli",
"glue",
"gtable",
"isoband",
"lifecycle",
"MASS",
"mgcv",
"rlang",
"scales",
"tibble",
Expand All @@ -85,15 +65,15 @@ dependencies = [

[[packages]]
name = "glue"
version = "1.7.0"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "1.8.0"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "gtable"
version = "0.3.4"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "0.3.6"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"cli",
Expand All @@ -105,29 +85,21 @@ dependencies = [
[[packages]]
name = "isoband"
version = "0.2.7"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "labeling"
version = "0.4.3"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
force_source = false
dependencies = []

[[packages]]
name = "lattice"
version = "0.22-5"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
path = "4.4.0/Recommended"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "lifecycle"
version = "1.0.4"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"cli",
Expand All @@ -138,48 +110,26 @@ dependencies = [
[[packages]]
name = "magrittr"
version = "2.0.3"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "mgcv"
version = "1.9-1"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
path = "4.4.0/Recommended"
force_source = false
dependencies = [
"nlme",
"Matrix",
]

[[packages]]
name = "munsell"
version = "0.5.0"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "0.5.1"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"colorspace",
]

[[packages]]
name = "nlme"
version = "3.1-164"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
path = "4.4.0/Recommended"
force_source = false
dependencies = [
"lattice",
]

[[packages]]
name = "pillar"
version = "1.9.0"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "1.10.1"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"cli",
"fansi",
"glue",
"lifecycle",
"rlang",
Expand All @@ -190,21 +140,21 @@ dependencies = [
[[packages]]
name = "pkgconfig"
version = "2.0.3"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "rlang"
version = "1.1.3"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "1.1.5"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "scales"
version = "1.3.0"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"cli",
Expand All @@ -222,7 +172,7 @@ dependencies = [
[[packages]]
name = "tibble"
version = "3.2.1"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"fansi",
Expand All @@ -237,14 +187,14 @@ dependencies = [
[[packages]]
name = "utf8"
version = "1.2.4"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "vctrs"
version = "0.6.5"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = [
"cli",
Expand All @@ -256,13 +206,13 @@ dependencies = [
[[packages]]
name = "viridisLite"
version = "0.4.2"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []

[[packages]]
name = "withr"
version = "3.0.0"
source = { repository = "https://packagemanager.posit.co/cran/2024-02-22" }
version = "3.0.2"
source = { repository = "https://packagemanager.posit.co/cran/2025-04-01" }
force_source = false
dependencies = []
14 changes: 14 additions & 0 deletions src/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ impl LockedPackage {

true
}

// check if a resolved_dep has the same name and version
#[inline]
fn is_matching_resolved_dep(&self, dep: &ResolvedDependency) -> bool {
self.name == dep.name.as_ref() && self.version == dep.version.as_ref().original
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do

fn is_matching_resolved_dep(&self, dep: &ResolvedDependency) -> bool {
    self.name == dep.name.as_ref() && self.version == dep.version
}

It can also be inlined since it's only used once

}

#[derive(Debug, Deserialize, Clone, PartialEq)]
Expand Down Expand Up @@ -481,6 +487,14 @@ impl Lockfile {
true
}

pub fn contains_resolved_dep(&self, dep: &ResolvedDependency) -> bool {
self
.packages
.iter()
.find(|x| x.is_matching_resolved_dep(dep))
.is_some()
}

/// Gets a set of all the package names listed in the lockfile
pub fn package_names(&self) -> HashSet<&str> {
let mut out = HashSet::new();
Expand Down
Loading