##// END OF EJS Templates
ci: add a runner for Windows 10...
ci: add a runner for Windows 10 This is currently only manually invoked, and allows for failure because we only have a single runner that takes over 2h for a full run, and there are a handful of flakey tests, plus 3 known failing tests. The system being used here is running MSYS, Python, Visual Studio, etc, as installed by `install-windows-dependencies.ps1`. This script installs everything to a specific directory instead of using the defaults, so we adjust the MinGW shell path to compensate. Additionally, the script doesn't install the launcher `py.exe`. It is possible to adjust the script to install it, but it's an option to an existing python install (instead of a standalone installer), and I've had the whole python install fail and rollback when requested to install the launcher if it detects a newer one is already installed. In short, it is a point of failure for a feature we don't (yet?) need. Unlike other systems where the intepreter name includes the version, everything here is `python.exe`, so they can't all exist on `PATH` and let the script choose the desired one. (The `py.exe` launcher would accomplish, using the registry instead of `PATH`, but that wouldn't allow for venv installs.) Because of this, switch to the absolute path of the python interpreter to be used (in this case a venv created from the py39 install, which is old, but what both pyoxidizer and TortoiseHg currently use). The `RUNTEST_ARGS` hardcodes `-j8` because this system has 4 cores, and therefore runs 4 parallel tests by default. However on Windows, using more parallel tests than cores results in better performance for whatever reason. I don't have an optimal value yet (ideally the runner itself can make the adjustment on Windows), but this results in saving ~15m on a full run that otherwise takes ~2.5h. I'm also not concerned about how it would affect other Windows machines, because we don't have any at this point, and I have no idea when we can get more. As far as system setup goes, the CI is run by a dedicated user that lacks admin rights. The install script was run by an admin user, and then the standard user was configured to use it. If I set this up again, I'd probably give the dedicated user admin rights to run the install script, and reset to standard user rights when done. The python intepreter failed in weird ways when run by the standard user until it was manually reinstalled by the standard user: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Additionally, changing the environment through the Windows UI prompts to escalate to an admin user, and then setting the user level environment variables like `TEMP` and `PATH` (to try to avoid exceeding the 260 character path limit) didn't actually change the user's environment. (Likely it changed the admin user's environment, but I didn't confirm that.) I ended up having to use the registry editor for the standard user to make those changes.

File last commit:

r51870:1928b770 default
r53049:8766d47e stable
Show More
cat.rs
115 lines | 3.3 KiB | application/rls-services+xml | RustLexer
Antoine Cezar
hg-core: add a `CatRev` operation...
r46112 // list_tracked_files.rs
//
// Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 use crate::repo::Repo;
Simon Sapin
rust: use NodePrefix::from_hex instead of hex::decode directly...
r46647 use crate::revlog::Node;
Raphaël Gomès
rust-clippy: merge "revlog" module definition and struct implementation...
r50832 use crate::revlog::RevlogError;
Simon Sapin
rust: Add a Filelog struct that wraps Revlog...
r48775
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 use crate::utils::hg_path::HgPath;
Antoine Cezar
hg-core: add a `CatRev` operation...
r46112
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 use crate::errors::HgError;
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 use crate::manifest::Manifest;
use crate::manifest::ManifestEntry;
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 use itertools::put_back;
use itertools::PutBack;
use std::cmp::Ordering;
Arseniy Alekseyev
rhg: faster hg cat when many files are requested...
r49038
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 pub struct CatOutput<'a> {
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 /// Whether any file in the manifest matched the paths given as CLI
/// arguments
pub found_any: bool,
/// The contents of matching files, in manifest order
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 pub results: Vec<(&'a HgPath, Vec<u8>)>,
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 /// Which of the CLI arguments did not match any manifest file
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 pub missing: Vec<&'a HgPath>,
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 /// The node ID that the given revset was resolved to
pub node: Node,
}
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 // Find an item in an iterator over a sorted collection.
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 fn find_item<'a>(
i: &mut PutBack<impl Iterator<Item = Result<ManifestEntry<'a>, HgError>>>,
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 needle: &HgPath,
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 ) -> Result<Option<Node>, HgError> {
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 loop {
match i.next() {
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 None => return Ok(None),
Some(result) => {
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 let entry = result?;
match needle.as_bytes().cmp(entry.path.as_bytes()) {
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 Ordering::Less => {
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 i.put_back(Ok(entry));
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 return Ok(None);
}
Ordering::Greater => continue,
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 Ordering::Equal => return Ok(Some(entry.node_id()?)),
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 }
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 }
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 }
}
}
Raphaël Gomès
rust-clippy: refactor complex type...
r50820 // Tuple of (missing, found) paths in the manifest
type ManifestQueryResponse<'a> = (Vec<(&'a HgPath, Node)>, Vec<&'a HgPath>);
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 fn find_files_in_manifest<'query>(
manifest: &Manifest,
query: impl Iterator<Item = &'query HgPath>,
Raphaël Gomès
rust-clippy: refactor complex type...
r50820 ) -> Result<ManifestQueryResponse<'query>, HgError> {
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 let mut manifest = put_back(manifest.iter());
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 let mut res = vec![];
let mut missing = vec![];
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 for file in query {
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 match find_item(&mut manifest, file)? {
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 None => missing.push(file),
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 Some(item) => res.push((file, item)),
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 }
}
Raphaël Gomès
rust-clippy: fix most warnings in `hg-core`...
r50825 Ok((res, missing))
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 }
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 /// Output the given revision of files
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 ///
/// * `root`: Repository root
/// * `rev`: The revision to cat the files from.
/// * `files`: The files to output.
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 pub fn cat<'a>(
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 repo: &Repo,
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 revset: &str,
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 mut files: Vec<&'a HgPath>,
) -> Result<CatOutput<'a>, RevlogError> {
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 let rev = crate::revset::resolve_single(revset, repo)?;
Raphaël Gomès
rust: use the new `UncheckedRevision` everywhere applicable...
r51870 let manifest = repo.manifest_for_rev(rev.into())?;
Simon Sapin
rust: Add Repo::manifest(revision)...
r48774 let node = *repo
.changelog()?
Raphaël Gomès
rust: use the new `UncheckedRevision` everywhere applicable...
r51870 .node_from_rev(rev.into())
Simon Sapin
rust: Add Repo::manifest(revision)...
r48774 .expect("should succeed when repo.manifest did");
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 let mut results: Vec<(&'a HgPath, Vec<u8>)> = vec![];
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 let mut found_any = false;
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039
Arseniy Alekseyev
rhg: faster hg cat when many files are requested...
r49038 files.sort_unstable();
Raphaël Gomès
rust-clippy: fix most warnings in `hg-core`...
r50825 let (found, missing) =
find_files_in_manifest(&manifest, files.into_iter())?;
Antoine Cezar
hg-core: add a `CatRev` operation...
r46112
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 for (file_path, file_node) in found {
Arseniy Alekseyev
rhg: stop manifest traversal when no more files are needed...
r49039 found_any = true;
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 let file_log = repo.filelog(file_path)?;
results.push((
file_path,
Simon Sapin
rhg: Rename some revlog-related types and methods...
r49372 file_log.data_for_node(file_node)?.into_file_data()?,
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 ));
Antoine Cezar
hg-core: add a `CatRev` operation...
r46112 }
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 Ok(CatOutput {
found_any,
Arseniy Alekseyev
rhg: internally, return a structured representation from hg cat...
r49051 results,
Simon Sapin
rhg: `cat` command: print error messages for missing files...
r47478 missing,
node,
})
Antoine Cezar
hg-core: add a `CatRev` operation...
r46112 }