Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
647 changes: 94 additions & 553 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "q"
version = "0.1.0"
edition = "2024"
license = "GPL-3.0-or-later"
rust-version = "1.99"

[[bin]]
name = "quilt"
Expand All @@ -14,15 +15,21 @@ path = "src/bin/guards.rs"

[dependencies]
anyhow = "1.0.102"
chrono = "0.4.44"
filetime = "0.2.27"
jiff = "1.0.1"
lexopt = "0.3.2"
libc = "0.2.186"
p2 = { path = "p2" }
shlex = "1.3.0"
tempfile = "3.27.0"
walkdir = "2.5.0"

[target.'cfg(unix)'.dependencies]
libc = "0.2.186"

[dev-dependencies]
assert_cmd = "2.2.1"
predicates = "3.1.4"

[profile.release]
panic = "abort"
codegen-units = 1
lto = "fat"
162 changes: 140 additions & 22 deletions p2/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion p2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ version = "0.1.0"
edition = "2024"
description = "A Rust implementation of GNU patch-compatible patch application"
license = "GPL-3.0-or-later"
rust-version = "1.99"

[dependencies]
filetime = "0.2"
jiff = "1.0.1"
libc = "0.2"
rayon = "1.10"
8 changes: 5 additions & 3 deletions p2/src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::time::SystemTime;

use filetime::set_file_mtime;
use rayon::prelude::*;

use crate::fs_util::{
Expand All @@ -29,7 +29,7 @@ use crate::timestamp::{
use crate::{
ApplyOptions, ApplyReport, FilePatch, FileReport, GitOperation, Hunk, HunkLine, HunkReport,
HunkStatus, MergeMode, PatchFormat, PatchSet, ReadOnlyBehavior, ReportOperation, Result,
io_error,
io_error, io_error_other,
};

/// Patch sets touching at least this many distinct files apply files in parallel.
Expand Down Expand Up @@ -500,7 +500,9 @@ fn apply_file_patch(
&& !time_mismatch
&& let Some(timestamp) = target_timestamp
{
set_file_mtime(&full_path, timestamp).map_err(io_error(&full_path))?;
let mtime: SystemTime = timestamp.try_into().map_err(io_error_other(&full_path))?;
fs::set_times(&full_path, fs::FileTimes::new().set_modified(mtime))
.map_err(io_error(&full_path))?;
}
}

Expand Down
11 changes: 11 additions & 0 deletions p2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ pub(crate) fn io_error(path: &Path) -> impl FnOnce(std::io::Error) -> Error + '_
}
}

/// Builds an `Error::Io` mapper for `path` and an arbitrary error (flagged as "Other" IO error), for use with `map_err`.
pub(crate) fn io_error_other<E>(path: &Path) -> impl FnOnce(E) -> Error + '_
where
E: Into<Box<dyn std::error::Error + Send + Sync>>,
{
move |source| Error::Io {
path: path.to_path_buf(),
source: std::io::Error::new(std::io::ErrorKind::Other, source),
}
}

/// The paths `apply_patch` would write to, in patch order.
pub fn affected_paths(
root: impl AsRef<Path>,
Expand Down
Loading