Skip to content

Commit

Permalink
Delete what I can.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Nov 10, 2023
1 parent 63bef10 commit 47e6bec
Show file tree
Hide file tree
Showing 211 changed files with 26 additions and 80,251 deletions.
14 changes: 7 additions & 7 deletions crates/resolver-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ use cargo::core::Resolve;
use cargo::core::{Dependency, PackageId, Registry, Summary};
use cargo::core::{GitReference, SourceId};
use cargo::sources::source::QueryKind;
use cargo::util::{CargoResult, Config, Graph, IntoUrl, RustVersion};
use cargo::util::{anyhow::Result, Config, Graph, IntoUrl, RustVersion};

use proptest::collection::{btree_map, vec};
use proptest::prelude::*;
use proptest::sample::Index;
use proptest::string::string_regex;
use varisat::{self, ExtendFormula};

pub fn resolve(deps: Vec<Dependency>, registry: &[Summary]) -> CargoResult<Vec<PackageId>> {
pub fn resolve(deps: Vec<Dependency>, registry: &[Summary]) -> anyhow::Result<Vec<PackageId>> {
resolve_with_config(deps, registry, &Config::default().unwrap())
}

pub fn resolve_and_validated(
deps: Vec<Dependency>,
registry: &[Summary],
sat_resolve: Option<SatResolve>,
) -> CargoResult<Vec<PackageId>> {
) -> anyhow::Result<Vec<PackageId>> {
let resolve = resolve_with_config_raw(deps.clone(), registry, &Config::default().unwrap());

match resolve {
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn resolve_with_config(
deps: Vec<Dependency>,
registry: &[Summary],
config: &Config,
) -> CargoResult<Vec<PackageId>> {
) -> anyhow::Result<Vec<PackageId>> {
let resolve = resolve_with_config_raw(deps, registry, config)?;
Ok(resolve.sort())
}
Expand All @@ -121,7 +121,7 @@ pub fn resolve_with_config_raw(
deps: Vec<Dependency>,
registry: &[Summary],
config: &Config,
) -> CargoResult<Resolve> {
) -> anyhow::Result<Resolve> {
struct MyRegistry<'a> {
list: &'a [Summary],
used: HashSet<PackageId>,
Expand All @@ -132,7 +132,7 @@ pub fn resolve_with_config_raw(
dep: &Dependency,
kind: QueryKind,
f: &mut dyn FnMut(Summary),
) -> Poll<CargoResult<()>> {
) -> Poll<anyhow::Result<()>> {
for summary in self.list.iter() {
let matched = match kind {
QueryKind::Exact => dep.matches(summary),
Expand All @@ -154,7 +154,7 @@ pub fn resolve_with_config_raw(
false
}

fn block_until_ready(&mut self) -> CargoResult<()> {
fn block_until_ready(&mut self) -> anyhow::Result<()> {
Ok(())
}
}
Expand Down
18 changes: 9 additions & 9 deletions crates/xtask-bump-check/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::fmt::Write;
use std::fs;
use std::task;

use cargo::anyhow::Result;
use cargo::core::dependency::Dependency;
use cargo::core::registry::PackageRegistry;
use cargo::core::Package;
Expand All @@ -24,7 +25,6 @@ use cargo::core::Workspace;
use cargo::sources::source::QueryKind;
use cargo::util::cache_lock::CacheLockMode;
use cargo::util::command_prelude::*;
use cargo::CargoResult;
use cargo_util::ProcessBuilder;

const UPSTREAM_BRANCH: &str = "master";
Expand Down Expand Up @@ -105,7 +105,7 @@ fn config_configure(config: &mut Config, args: &ArgMatches) -> CliResult {
/// Main entry of `xtask-bump-check`.
///
/// Assumption: version number are incremental. We never have point release for old versions.
fn bump_check(args: &clap::ArgMatches, config: &cargo::util::Config) -> CargoResult<()> {
fn bump_check(args: &clap::ArgMatches, config: &cargo::util::Config) -> anyhow::Result<()> {
let ws = args.workspace(config)?;
let repo = git2::Repository::open(ws.root())?;
let base_commit = get_base_commit(config, args, &repo)?;
Expand Down Expand Up @@ -178,7 +178,7 @@ fn get_base_commit<'a>(
config: &Config,
args: &clap::ArgMatches,
repo: &'a git2::Repository,
) -> CargoResult<git2::Commit<'a>> {
) -> anyhow::Result<git2::Commit<'a>> {
let base_commit = match args.get_one::<String>("base-rev") {
Some(sha) => {
let obj = repo.revparse_single(sha)?;
Expand Down Expand Up @@ -219,7 +219,7 @@ fn get_base_commit<'a>(
fn get_head_commit<'a>(
args: &clap::ArgMatches,
repo: &'a git2::Repository,
) -> CargoResult<git2::Commit<'a>> {
) -> anyhow::Result<git2::Commit<'a>> {
let head_commit = match args.get_one::<String>("head-rev") {
Some(sha) => {
let head_obj = repo.revparse_single(sha)?;
Expand All @@ -241,7 +241,7 @@ fn get_head_commit<'a>(
fn get_referenced_commit<'a>(
repo: &'a git2::Repository,
base: &git2::Commit<'a>,
) -> CargoResult<Option<git2::Commit<'a>>> {
) -> anyhow::Result<Option<git2::Commit<'a>>> {
let [beta, stable] = beta_and_stable_branch(repo)?;
let rev_id = base.id();
let stable_commit = stable.get().peel_to_commit()?;
Expand All @@ -267,7 +267,7 @@ fn get_referenced_commit<'a>(
/// * The repository contains the full history of `<remote>/rust-1.*.0` branches.
/// * The version part of `<remote>/rust-1.*.0` always ends with a zero.
/// * The maximum version is for beta channel, and the second one is for stable.
fn beta_and_stable_branch(repo: &git2::Repository) -> CargoResult<[git2::Branch<'_>; 2]> {
fn beta_and_stable_branch(repo: &git2::Repository) -> anyhow::Result<[git2::Branch<'_>; 2]> {
let mut release_branches = Vec::new();
for branch in repo.branches(Some(git2::BranchType::Remote))? {
let (branch, _) = branch?;
Expand Down Expand Up @@ -303,7 +303,7 @@ fn changed<'r, 'ws>(
repo: &'r git2::Repository,
base_commit: &git2::Commit<'r>,
head: &git2::Commit<'r>,
) -> CargoResult<HashMap<&'ws str, &'ws Package>> {
) -> anyhow::Result<HashMap<&'ws str, &'ws Package>> {
let root_pkg_name = ws.current()?.name(); // `cargo` crate.
let ws_members = ws
.members()
Expand Down Expand Up @@ -344,7 +344,7 @@ fn check_crates_io<'a>(
config: &Config,
changed_members: &HashMap<&'a str, &'a Package>,
needs_bump: &mut Vec<&'a Package>,
) -> CargoResult<()> {
) -> anyhow::Result<()> {
let source_id = SourceId::crates_io(config)?;
let mut registry = PackageRegistry::new(config)?;
let _lock = config.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?;
Expand Down Expand Up @@ -388,7 +388,7 @@ fn checkout_ws<'cfg, 'a>(
ws: &Workspace<'cfg>,
repo: &'a git2::Repository,
referenced_commit: &git2::Commit<'a>,
) -> CargoResult<Workspace<'cfg>> {
) -> anyhow::Result<Workspace<'cfg>> {
let repo_path = repo.path().as_os_str().to_str().unwrap();
// Put it under `target/cargo-<short-id>`
let short_id = &referenced_commit.id().to_string()[..7];
Expand Down
Loading

0 comments on commit 47e6bec

Please sign in to comment.