Simplifying pijul::commands::log, and fixing Broken Pipe errors
Dependencies
- [2]
6O43WXDAVersion bump - [3]
TYAKEAJLA better estimate of the maximum number of open patches we can keep (Unix-only at the moment) - [4]
F2S6XETOFixing log --hash-only - [5]
5OGOE4VWStore the current channel in the pristine - [6]
YN63NUZOSanakirja 1.0 - [7]
I52XSRUHMassive cleanup, and simplification - [8]
TNN56XYKlibpijul alpha.43 - [9]
XF3FRWJ6Version bump (including clap 3.0.0-beta.4) - [10]
SMMBFECLConverting to the new patch format "online" - [11]
Y6EVFMTADon't output files if they aren't in the current channel - [12]
CCLLB7OIUpgrading to Sanakirja 0.15 + version bump - [13]
JL4WKA5PImplement the Sanakirja concurrency model in a cross-process way - [14]
NWYJJHDFVersion bump - [15]
RUBBHYZ7Removing unnecessary async/await - [16]
YMWMWFA5Version bumps - [17]
BECIRKR2Avoid a double formatting - [18]
6XDVUSBMVersion bump - [19]
FYUDBQ3CFormatting changes + version bump - [20]
A3RM526YIntegrating identity malleability - [21]
2K7JLB4ZNo pager on Windows - [22]
VIHXB7SGcommands: set up pager for diff, change, and credit - [23]
L4JXJHWXpijul/*: reorganize imports and remove extern crate - [24]
V4T4SC7OTesting binary diff - [25]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [26]
OU6JOR3CAdd path filtering for log, add json output for log - [27]
I7VL7VPZMinor cleanup - [28]
QJXNUQFJSolving conflicts - [29]
23LVKATNUse pager crate for log output
Change contents
- replacement in "pijul/src/commands/log.rs" at line 11
use libpijul::pristine::{sanakirja::Txn, ChannelRef, DepsTxnT, GraphTxnT, TreeTxnT};use libpijul::pristine::{sanakirja::Txn, ChannelRef, DepsTxnT, GraphTxnT, TreeTxnT, TxnErr}; - edit in "pijul/src/commands/log.rs" at line 15
use thiserror::*; - edit in "pijul/src/commands/log.rs" at line 51
impl TryFrom<Log> for LogIterator {type Error = anyhow::Error;fn try_from(cmd: Log) -> Result<LogIterator, Self::Error> {let repo = Repository::find_root(cmd.repo_path.clone())?;let repo_path = repo.path.clone();let txn = repo.pristine.txn_begin()?;let channel_name = if let Some(ref c) = cmd.channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)};// The only situation that's disallowed is if the user's trying to apply// path filters AND get the logs for a channel other than the one they're// currently using (where using means the one that comprises the working copy)if !cmd.filters.is_empty()&& !(channel_name == txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)){bail!("Currently, log filters can only be applied to the channel currently in use.")}let channel_ref = if let Some(channel) = txn.load_channel(channel_name)? {channel} else {bail!("No such channel: {:?}", channel_name)};let changes = repo.changes;let limit = cmd.limit.unwrap_or(std::usize::MAX);let offset = cmd.offset.unwrap_or(0);let mut id_path = repo.path.join(libpijul::DOT_DIR);id_path.push("identities");Ok(Self {txn,cmd,changes,repo_path,id_path,channel_ref,limit,offset,})}}#[derive(Debug, Error)]pub enum Error<E: std::error::Error> {#[error("pijul log couldn't find a file or directory corresponding to `{}`", 0)]NotFound(String),#[error(transparent)]Txn(#[from] libpijul::pristine::sanakirja::SanakirjaError),#[error(transparent)]TxnErr(#[from] TxnErr<libpijul::pristine::sanakirja::SanakirjaError>),#[error(transparent)]Fs(#[from] libpijul::FsError<libpijul::pristine::sanakirja::SanakirjaError>),#[error(transparent)]Io(#[from] std::io::Error),#[error("pijul log couldn't assemble file prefix for pattern `{}`: {} was not a file in the repository at {}", pat, canon_path.display(), repo_path.display())]FilterPath {pat: String,canon_path: PathBuf,repo_path: PathBuf,},#[error("pijul log couldn't assemble file prefix for pattern `{}`: the path contained invalid UTF-8", 0)]InvalidUtf8(String),#[error(transparent)]E(E),#[error(transparent)]Filesystem(#[from] libpijul::changestore::filesystem::Error),} - replacement in "pijul/src/commands/log.rs" at line 124
fn get_inodes(txn: &impl libpijul::pristine::TreeTxnT,fn get_inodes<E: std::error::Error>(txn: &Txn, - replacement in "pijul/src/commands/log.rs" at line 128
) -> Result<Vec<libpijul::Inode>, anyhow::Error> {) -> Result<Vec<libpijul::Inode>, Error<E>> { - replacement in "pijul/src/commands/log.rs" at line 133
bail!("pijul log couldn't find a file or directory corresponding to `{}`",pat)return Err(Error::NotFound(pat.to_string())) - replacement in "pijul/src/commands/log.rs" at line 143
Err(_) => bail!("pijul log couldn't assemble file prefix for pattern `{}`; \{} was not a file in the repository at {}",pat,canon_path.display(),repo_path.display()),Err(_) => {return Err(Error::FilterPath {pat: pat.to_string(),canon_path,repo_path: repo_path.to_path_buf(),})} - replacement in "pijul/src/commands/log.rs" at line 151
Ok(None) => bail!("pijul log couldn't assemble file prefix for pattern `{}`; \the path contained invalid UTF-8",pat),Ok(Some(s)) => match libpijul::fs::find_inode(txn, s) {Err(e) => bail!("pijul log couldn't assemble file prefix for pattern `{}`; \no Inode found for the corresponding path. Internal error: {:?}",pat,e),Ok(inode) => {inodes.push(inode);}},Ok(None) => return Err(Error::InvalidUtf8(pat.to_string())),Ok(Some(s)) => inodes.push(libpijul::fs::find_inode(txn, s)?), - replacement in "pijul/src/commands/log.rs" at line 161
fn filtered_hashes<T: TreeTxnT + GraphTxnT + DepsTxnT>(txn: &T,fn filtered_hashes<E: std::error::Error>(txn: &Txn, - replacement in "pijul/src/commands/log.rs" at line 165
) -> Result<HashSet<libpijul::Hash>, anyhow::Error> {) -> Result<HashSet<libpijul::Hash>, Error<E>> { - replacement in "pijul/src/commands/log.rs" at line 171
None => bail!("Failed to get matching inode: {:?}", inode),None => continue, - replacement in "pijul/src/commands/log.rs" at line 178
match txn.get_external(touched_change_id)? {Some(ser_h) => {hashes.insert(libpijul::Hash::from(*ser_h));}_ => {log::error!("`get_external` failed to retrieve full hash for ChangeId {:?}",touched_change_id);bail!("Failed to retrieve full hash for {:?}", touched_change_id)}}let ser_h = txn.get_external(touched_change_id)?.unwrap();hashes.insert(libpijul::Hash::from(*ser_h)); - edit in "pijul/src/commands/log.rs" at line 317[5.8452]→[5.8452:8694](∅→∅),[5.7169]→[5.135006:135052](∅→∅),[5.8694]→[5.135006:135052](∅→∅),[5.12911]→[5.135006:135052](∅→∅),[5.21108]→[5.135006:135052](∅→∅),[5.135006]→[5.135006:135052](∅→∅),[5.135052]→[5.8695:8757](∅→∅),[5.8757]→[5.2523:2633](∅→∅),[5.2523]→[5.2523:2633](∅→∅),[5.2633]→[5.8758:9250](∅→∅)
impl TryFrom<Log> for LogIterator {type Error = anyhow::Error;fn try_from(cmd: Log) -> Result<LogIterator, Self::Error> {let repo = Repository::find_root(cmd.repo_path.clone())?;let repo_path = repo.path.clone();let txn = repo.pristine.txn_begin()?;let channel_name = if let Some(ref c) = cmd.channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)};// The only situation that's disallowed is if the user's trying to apply// path filters AND get the logs for a channel other than the one they're// currently using (where using means the one that comprises the working copy)if !cmd.filters.is_empty()&& !(channel_name == txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)){bail!("Currently, log filters can only be applied to the channel currently in use.")} - edit in "pijul/src/commands/log.rs" at line 318[5.9251]→[5.9251:9334](∅→∅),[5.9334]→[5.135251:135288](∅→∅),[5.17023]→[5.135251:135288](∅→∅),[5.135251]→[5.135251:135288](∅→∅),[5.135288]→[5.17024:17081](∅→∅),[5.17081]→[5.135423:135434](∅→∅),[5.135423]→[5.135423:135434](∅→∅),[5.46]→[5.135434:135470](∅→∅),[5.66]→[5.135434:135470](∅→∅),[5.187]→[5.135434:135470](∅→∅),[5.135434]→[5.135434:135470](∅→∅),[5.135470]→[5.9335:9737](∅→∅)
let channel_ref = if let Some(channel) = txn.load_channel(channel_name)? {channel} else {bail!("No such channel: {:?}", channel_name)};let changes = repo.changes;let limit = cmd.limit.unwrap_or(std::usize::MAX);let offset = cmd.offset.unwrap_or(0);let mut id_path = repo.path.join(libpijul::DOT_DIR);id_path.push("identities");Ok(Self {txn,cmd,changes,repo_path,id_path,channel_ref,limit,offset,})}} - replacement in "pijul/src/commands/log.rs" at line 324
fn for_each<A, E>(fn for_each<A, E: std::error::Error>( - replacement in "pijul/src/commands/log.rs" at line 327
) -> Result<(), anyhow::Error>whereE: std::fmt::Display,{) -> Result<(), Error<E>> { - replacement in "pijul/src/commands/log.rs" at line 359
if let Err(e) = f(entry) {return Err(anyhow::Error::msg(format!("{}", e)));}f(entry).map_err(Error::E)?; - replacement in "pijul/src/commands/log.rs" at line 378
fn mk_log_entry<'x>(fn mk_log_entry<'x, E: std::error::Error>( - replacement in "pijul/src/commands/log.rs" at line 384
) -> Result<LogEntry, anyhow::Error> {) -> Result<LogEntry, Error<E>> { - replacement in "pijul/src/commands/log.rs" at line 431
// In order to accommodate both pretty-printing and efficient serialization to a serde// target format, this now delegates mostly to [`LogIterator`].// In order to accommodate both pretty-printing and efficient// serialization to a serde target format, this now delegates// mostly to [`LogIterator`]. - replacement in "pijul/src/commands/log.rs" at line 442
LogIterator::try_from(self)?.for_each(|entry| write!(&mut stdout, "{}", entry))?LogIterator::try_from(self)?.for_each(|entry| {match write!(&mut stdout, "{}", entry) {Ok(_) => Ok(()),Err(e) if e.kind() == std::io::ErrorKind::BrokenPipe => Ok(()),Err(e) => Err(e),}})? - edit in "pijul/Cargo.toml" at line 93
thiserror = "1.0" - replacement in "Cargo.lock" at line 1063
version = "1.0.0-alpha.47"version = "1.0.0-alpha.48" - edit in "Cargo.lock" at line 1520
"thiserror", - edit in "Cargo.lock" at line 2109
name = "threadpool"version = "1.8.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"dependencies = ["num_cpus",][[package]] - edit in "Cargo.lock" at line 2599
name = "xxhash-rust"version = "0.8.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e575e15bedf6e57b5c2d763ffc6c3c760143466cbd09d762d539680ab5992ded"[[package]] - replacement in "Cargo.lock" at line 2637
version = "0.1.7"version = "0.2.0" - replacement in "Cargo.lock" at line 2639
checksum = "3e3b99cee88f0309ca765c6aa8c284a00394c35ef8ca012e2409485fc369bf2f"checksum = "62d9eace42d7bf64591d547cb727d89277e3de1c1b934e3d9d0af8c6687587ef" - edit in "Cargo.lock" at line 2641
"cc", - replacement in "Cargo.lock" at line 2644
"threadpool","xxhash-rust",