diff options
| author | Cadence Marseille <cadencemarseille@gmail.com> | 2013-12-12 09:07:43 -0500 |
|---|---|---|
| committer | Cadence Marseille <cadencemarseille@gmail.com> | 2013-12-14 12:50:04 -0500 |
| commit | 5de42701a87cb0e517921cce7bc3a512e513301c (patch) | |
| tree | bf480894ad4ee3df5932a3d8e174eaba04f3320f /src/librustpkg/source_control.rs | |
| parent | 00b1adf93cab0ed11fbbace11f1c57c5f8017467 (diff) | |
| download | rust-5de42701a87cb0e517921cce7bc3a512e513301c.tar.gz rust-5de42701a87cb0e517921cce7bc3a512e513301c.zip | |
Fix #10754 - `std::run` functions fail after io_error
The problem was that std::run::Process::new() was unwrap()ing the result of std::io::process::Process::new(), which returns None in the case where the io_error condition is raised to signal failure to start the process. Have std::run::Process::new() similarly return an Option<run::Process> to reflect the fact that a subprocess might have failed to start. Update utility functions run::process_status() and run::process_output() to return Option<ProcessExit> and Option<ProcessOutput>, respectively. Various parts of librustc and librustpkg needed to be updated to reflect these API changes. closes #10754
Diffstat (limited to 'src/librustpkg/source_control.rs')
| -rw-r--r-- | src/librustpkg/source_control.rs | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/librustpkg/source_control.rs b/src/librustpkg/source_control.rs index 702a849e4ad..cbb55030231 100644 --- a/src/librustpkg/source_control.rs +++ b/src/librustpkg/source_control.rs @@ -33,15 +33,16 @@ pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult if !target.exists() { debug!("Running: git clone {} {}", source.display(), target.display()); // FIXME (#9639): This needs to handle non-utf8 paths - let outp = run::process_output("git", [~"clone", - source.as_str().unwrap().to_owned(), - target.as_str().unwrap().to_owned()]); + let opt_outp = run::process_output("git", [~"clone", + source.as_str().unwrap().to_owned(), + target.as_str().unwrap().to_owned()]); + let outp = opt_outp.expect("Failed to exec `git`"); if !outp.status.success() { println(str::from_utf8_owned(outp.output.clone())); println(str::from_utf8_owned(outp.error)); return DirToUse(target.clone()); } - else { + else { match v { &ExactRevision(ref s) => { let git_dir = target.join(".git"); @@ -51,7 +52,7 @@ pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult let outp = run::process_output("git", [format!("--work-tree={}", target.as_str().unwrap().to_owned()), format!("--git-dir={}", git_dir.as_str().unwrap().to_owned()), - ~"checkout", format!("{}", *s)]); + ~"checkout", format!("{}", *s)]).expect("Failed to exec `git`"); if !outp.status.success() { println(str::from_utf8_owned(outp.output.clone())); println(str::from_utf8_owned(outp.error)); @@ -72,7 +73,8 @@ pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult let args = [format!("--work-tree={}", target.as_str().unwrap().to_owned()), format!("--git-dir={}", git_dir.as_str().unwrap().to_owned()), ~"pull", ~"--no-edit", source.as_str().unwrap().to_owned()]; - let outp = run::process_output("git", args); + let opt_outp = run::process_output("git", args); + let outp = opt_outp.expect("Failed to exec `git`"); assert!(outp.status.success()); } CheckedOutSources @@ -108,8 +110,9 @@ pub fn git_clone_url(source: &str, target: &Path, v: &Version) { use conditions::git_checkout_failed::cond; // FIXME (#9639): This needs to handle non-utf8 paths - let outp = run::process_output("git", [~"clone", source.to_owned(), - target.as_str().unwrap().to_owned()]); + let opt_outp = run::process_output("git", [~"clone", source.to_owned(), + target.as_str().unwrap().to_owned()]); + let outp = opt_outp.expect("Failed to exec `git`"); if !outp.status.success() { debug!("{}", str::from_utf8_owned(outp.output.clone())); debug!("{}", str::from_utf8_owned(outp.error)); @@ -118,8 +121,9 @@ pub fn git_clone_url(source: &str, target: &Path, v: &Version) { else { match v { &ExactRevision(ref s) | &Tagged(ref s) => { - let outp = process_output_in_cwd("git", [~"checkout", s.to_owned()], + let opt_outp = process_output_in_cwd("git", [~"checkout", s.to_owned()], target); + let outp = opt_outp.expect("Failed to exec `git`"); if !outp.status.success() { debug!("{}", str::from_utf8_owned(outp.output.clone())); debug!("{}", str::from_utf8_owned(outp.error)); @@ -131,10 +135,13 @@ pub fn git_clone_url(source: &str, target: &Path, v: &Version) { } } -fn process_output_in_cwd(prog: &str, args: &[~str], cwd: &Path) -> ProcessOutput { - let mut prog = Process::new(prog, args, ProcessOptions{ dir: Some(cwd) - ,..ProcessOptions::new()}); - prog.finish_with_output() +fn process_output_in_cwd(prog: &str, args: &[~str], cwd: &Path) -> Option<ProcessOutput> { + let mut opt_prog = Process::new(prog, args, ProcessOptions{ dir: Some(cwd) + ,..ProcessOptions::new()}); + match opt_prog { + Some(ref mut prog) => Some(prog.finish_with_output()), + None => None + } } pub fn is_git_dir(p: &Path) -> bool { |
