Skip to content

Commit 908798b

Browse files
update to cargo 0.63/git2 0.14
the main change seems to be that registries no longer have an explicit update() call, but instead return `Poll` on queries with a helper to block until the Poll is ready. upstream change for reference: rust-lang/cargo#10064 Signed-off-by: Fabian Grünbichler <[email protected]>
1 parent 991fc70 commit 908798b

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2021"
1313
[dependencies]
1414
ansi_term = "0.12"
1515
anyhow = "1.0"
16-
cargo = "0.57"
16+
cargo = "0.63"
1717
chrono = "0.4"
1818
env_logger = "0.9"
1919
filetime = "0.2"
@@ -22,7 +22,7 @@ flate2 = "1"
2222
# libgit2 is too old - 1.1.0 vs 1.3.0 needed by newer git2 crates.
2323
#git2 = "= 0.13.21"
2424
#libgit2-sys = "= 0.12.22+1.1.0"
25-
git2 = "0.13.23"
25+
git2 = "0.14"
2626
glob = "0.3"
2727
itertools = "0.10"
2828
log = "0.4"

src/bin/debcargo.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ use structopt::{
44
StructOpt,
55
};
66

7-
use debcargo::build_order::{build_order, BuildOrderArgs};
8-
use debcargo::crates::{update_crates_io, CrateInfo};
7+
use debcargo::crates::CrateInfo;
98
use debcargo::debian::DebInfo;
109
use debcargo::errors::Result;
1110
use debcargo::package::*;
11+
use debcargo::{
12+
build_order::{build_order, BuildOrderArgs},
13+
crates::invalidate_crates_io_cache,
14+
};
1215

1316
#[derive(Debug, Clone, StructOpt)]
1417
#[structopt(name = "debcargo", about = "Package Rust crates for Debian.")]
@@ -54,7 +57,7 @@ fn real_main() -> Result<()> {
5457
.get_matches();
5558
use Opt::*;
5659
match Opt::from_clap(&m) {
57-
Update => update_crates_io(),
60+
Update => invalidate_crates_io_cache(),
5861
DebSrcName {
5962
crate_name,
6063
version,

src/crates.rs

+24-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use cargo::{
99
},
1010
ops,
1111
ops::{PackageOpts, Packages},
12-
sources::registry::RegistrySource,
12+
sources::RegistrySource,
1313
util::{interning::InternedString, toml::read_manifest, FileLock},
1414
Config,
1515
};
@@ -60,18 +60,25 @@ fn hash<H: Hash>(hashable: &H) -> u64 {
6060
}
6161

6262
fn fetch_candidates(registry: &mut PackageRegistry, dep: &Dependency) -> Result<Vec<Summary>> {
63-
let mut summaries = registry.query_vec(dep, false)?;
63+
let mut summaries = match registry.query_vec(dep, false) {
64+
std::task::Poll::Ready(res) => res?,
65+
std::task::Poll::Pending => {
66+
registry.block_until_ready()?;
67+
return fetch_candidates(registry, dep);
68+
}
69+
};
6470
summaries.sort_by(|a, b| b.package_id().partial_cmp(&a.package_id()).unwrap());
6571
Ok(summaries)
6672
}
6773

68-
pub fn update_crates_io() -> Result<()> {
74+
pub fn invalidate_crates_io_cache() -> Result<()> {
6975
let config = Config::default()?;
7076
let _lock = config.acquire_package_cache_lock()?;
7177
let source_id = SourceId::crates_io(&config)?;
7278
let yanked_whitelist = HashSet::new();
73-
let mut r = RegistrySource::remote(source_id, &yanked_whitelist, &config);
74-
r.update()
79+
let mut r = RegistrySource::remote(source_id, &yanked_whitelist, &config)?;
80+
r.invalidate_cache();
81+
Ok(())
7582
}
7683

7784
pub fn crate_name_ver_to_dep(crate_name: &str, version: Option<&str>) -> Result<Dependency> {
@@ -112,13 +119,22 @@ impl CrateInfo {
112119
let yanked_whitelist = HashSet::new();
113120

114121
let mut source = source_id.load(&config, &yanked_whitelist)?;
115-
source.update()?;
116122

117123
let package_id = match version {
118124
None | Some("") => {
119125
let dep = Dependency::parse(crate_name, None, source_id)?;
120126
let mut package_id: Option<PackageId> = None;
121-
source.query(&dep, &mut |p| package_id = Some(p.package_id()))?;
127+
loop {
128+
match source.query(&dep, &mut |p| package_id = Some(p.package_id())) {
129+
std::task::Poll::Ready(res) => {
130+
res?;
131+
break;
132+
}
133+
std::task::Poll::Pending => {
134+
source.block_until_ready()?;
135+
}
136+
}
137+
}
122138
package_id.unwrap()
123139
}
124140
Some(version) => PackageId::new(crate_name, version, source_id)?,
@@ -147,6 +163,7 @@ impl CrateInfo {
147163
jobs: None,
148164
targets: Vec::new(),
149165
to_package: Packages::Default,
166+
keep_going: false,
150167
};
151168

152169
// as of cargo 0.41 this returns a FileLock with a temp path, instead of the one

0 commit comments

Comments
 (0)