From: Carl Lerche Date: Tue, 24 Jun 2014 00:03:13 +0000 (-0700) Subject: GitSource delegates to PathSource for path ops X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~971 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=de6944798cf2940b91c742b8d6cd4294ea28f76a;p=cargo.git GitSource delegates to PathSource for path ops --- diff --git a/src/bin/cargo-read-manifest.rs b/src/bin/cargo-read-manifest.rs index b8125bf84..4e98f1850 100644 --- a/src/bin/cargo-read-manifest.rs +++ b/src/bin/cargo-read-manifest.rs @@ -8,7 +8,7 @@ extern crate serialize; extern crate hammer; use cargo::{execute_main_without_stdin}; -use cargo::core::{MultiShell, Package, Source, SourceId}; +use cargo::core::{MultiShell, Package, Source}; use cargo::util::{CliResult, CliError}; use cargo::sources::{PathSource}; diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 724be4f41..3894183b9 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -7,20 +7,20 @@ use serialize::hex::ToHex; use url; use url::Url; -use ops; use core::source::{Source,SourceId,GitKind}; use core::{Package,PackageId,Summary}; use util::{CargoResult,Config}; +use sources::PathSource; use sources::git::utils::{GitReference,GitRemote,Master,Other}; /* TODO: Refactor GitSource to delegate to a PathSource */ pub struct GitSource<'a, 'b> { - id: SourceId, remote: GitRemote, reference: GitReference, db_path: Path, checkout_path: Path, + path_source: PathSource, config: &'a mut Config<'b> } @@ -42,12 +42,14 @@ impl<'a, 'b> GitSource<'a, 'b> { let checkout_path = config.git_checkout_path() .join(ident.as_slice()).join(reference.as_slice()); + let path_source = PathSource::new(&checkout_path, source_id); + GitSource { - id: source_id.clone(), remote: remote, reference: GitReference::for_str(reference.as_slice()), db_path: db_path, checkout_path: checkout_path, + path_source: path_source, config: config } } @@ -55,10 +57,6 @@ impl<'a, 'b> GitSource<'a, 'b> { pub fn get_namespace<'a>(&'a self) -> &'a url::Url { self.remote.get_url() } - - fn packages(&self) -> CargoResult> { - ops::read_packages(&self.checkout_path, &self.id) - } } fn ident(url: &Url) -> String { @@ -101,30 +99,21 @@ impl<'a, 'b> Source for GitSource<'a, 'b> { let repo = try!(self.remote.checkout(&self.db_path)); try!(repo.copy_to(self.reference.as_slice(), &self.checkout_path)); - Ok(()) + self.path_source.update() } fn list(&self) -> CargoResult> { - log!(5, "listing summaries in git source `{}`", self.remote); - let pkgs = try!(self.packages()); - Ok(pkgs.iter().map(|p| p.get_summary().clone()).collect()) + self.path_source.list() } fn download(&self, _: &[PackageId]) -> CargoResult<()> { + // TODO: assert! that the PackageId is contained by the source Ok(()) } fn get(&self, ids: &[PackageId]) -> CargoResult> { - log!(5, "getting packages for package ids `{}` from `{}`", ids, - self.remote); - - // TODO: Support multiple manifests per repo - let pkgs = try!(self.packages()); - - Ok(pkgs.iter() - .filter(|pkg| ids.iter().any(|id| pkg.get_package_id() == id)) - .map(|pkg| pkg.clone()) - .collect()) + log!(5, "getting packages for package ids `{}` from `{}`", ids, self.remote); + self.path_source.get(ids) } fn fingerprint(&self) -> CargoResult { diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index c5dc5444c..225b35c02 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -27,7 +27,6 @@ impl PathSource { /// in the directory structure reachable by the root manifest. pub fn new(path: &Path, id: &SourceId) -> PathSource { log!(5, "new; id={}", id); - assert!(id.is_path(), "does not represent a path source; id={}", id); PathSource { id: id.clone(),