##// END OF EJS Templates
tests: add more tests of copy tracing with removed and re-added files...
tests: add more tests of copy tracing with removed and re-added files We had a test where the destination of a copy was removed and then added back. This patch adds similar cases where the break in history instead happens to the source file. There are three versions of this: 1. The break happens before the rename. 2. The break happens on a branch parallel to the rename (where copy tracing is done via the merge base) 3. The source is added on each side of the merge base. The break in history is thus in the form of a deletion when going backwards to the merge base and the re-add happens on the other branch. I've also added calls to `hg graft` in these cases to show the breakage in issue 6163. Another factor in these cases is matching nodeid (checked in copies._tracefile()). I've made two copies each of the cases to show the impact of that. One of these is the same as a test in test-rename-merge1.t, so I also deleted that test from there. Some of these tests currently fail, where "fail" is based on my current thinking of how things should work. I had initially thought that we should be more strict about not tracing copies across commits where the file did not exist, but issue 6163 made me reconsider. The only test case here that behaved differently in 4.9 is the exact case reported in issue 6163. Differential Revision: https://phab.mercurial-scm.org/D6599

File last commit:

r35625:24b5106e default
r42793:ab416b5d default
Show More
build.rs
127 lines | 3.4 KiB | application/rls-services+xml | RustLexer
// build.rs -- Configure build environment for `hgcli` Rust package.
//
// Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
use std::collections::HashMap;
use std::env;
use std::path::Path;
use std::process::Command;
struct PythonConfig {
python: String,
config: HashMap<String, String>,
}
fn get_python_config() -> PythonConfig {
// The python27-sys crate exports a Cargo variable defining the full
// path to the interpreter being used.
let python = env::var("DEP_PYTHON27_PYTHON_INTERPRETER").expect(
"Missing DEP_PYTHON27_PYTHON_INTERPRETER; bad python27-sys crate?",
);
if !Path::new(&python).exists() {
panic!(
"Python interpreter {} does not exist; this should never happen",
python
);
}
// This is a bit hacky but it gets the job done.
let separator = "SEPARATOR STRING";
let script = "import sysconfig; \
c = sysconfig.get_config_vars(); \
print('SEPARATOR STRING'.join('%s=%s' % i for i in c.items()))";
let mut command = Command::new(&python);
command.arg("-c").arg(script);
let out = command.output().unwrap();
if !out.status.success() {
panic!(
"python script failed: {}",
String::from_utf8_lossy(&out.stderr)
);
}
let stdout = String::from_utf8_lossy(&out.stdout);
let mut m = HashMap::new();
for entry in stdout.split(separator) {
let mut parts = entry.splitn(2, "=");
let key = parts.next().unwrap();
let value = parts.next().unwrap();
m.insert(String::from(key), String::from(value));
}
PythonConfig {
python: python,
config: m,
}
}
#[cfg(not(target_os = "windows"))]
fn have_shared(config: &PythonConfig) -> bool {
match config.config.get("Py_ENABLE_SHARED") {
Some(value) => value == "1",
None => false,
}
}
#[cfg(target_os = "windows")]
fn have_shared(config: &PythonConfig) -> bool {
use std::path::PathBuf;
// python27.dll should exist next to python2.7.exe.
let mut dll = PathBuf::from(&config.python);
dll.pop();
dll.push("python27.dll");
return dll.exists();
}
const REQUIRED_CONFIG_FLAGS: [&str; 2] = ["Py_USING_UNICODE", "WITH_THREAD"];
fn main() {
let config = get_python_config();
println!("Using Python: {}", config.python);
println!("cargo:rustc-env=PYTHON_INTERPRETER={}", config.python);
let prefix = config.config.get("prefix").unwrap();
println!("Prefix: {}", prefix);
// TODO Windows builds don't expose these config flags. Figure out another
// way.
#[cfg(not(target_os = "windows"))]
for key in REQUIRED_CONFIG_FLAGS.iter() {
let result = match config.config.get(*key) {
Some(value) => value == "1",
None => false,
};
if !result {
panic!("Detected Python requires feature {}", key);
}
}
// We need a Python shared library.
if !have_shared(&config) {
panic!("Detected Python lacks a shared library, which is required");
}
let ucs4 = match config.config.get("Py_UNICODE_SIZE") {
Some(value) => value == "4",
None => false,
};
if !ucs4 {
#[cfg(not(target_os = "windows"))]
panic!("Detected Python doesn't support UCS-4 code points");
}
}