Refactor record command's handling of repo and channel
Dependencies
- [2]
Y2Y4OOIEMove `pijul::DEFAULT_CHANNEL` to `libpijul` - [3]
QQS7LII4Add value hints to arguments - [4]
GKSVBEUWRefactor Repository constructors to take Option<&Path> instead of Option<PathBuf> - [5]
EEBKW7VTKeys and identities - [6]
AEPEFS7OWrite help for each argument - [7]
ZHABNS3SCanonicalize all paths - [8]
OU243LABSupport for staging - [9]
5OGOE4VWStore the current channel in the pristine - [10]
A3RM526YIntegrating identity malleability - [11]
PGERZ3KJChannel renaming (also do not create a new channel when recording on a channel that doesn't exist) - [12]
DWSAYGVEUpdate codebase to use new identity management - [13]
EUZFFJSOUpdating Pijul with the latest changes in Libpijul - [14]
3MHUNYERChanging --amend flag to respect -m flag - [15]
YN63NUZOSanakirja 1.0 - [16]
PIQCNEEBUpgrading to Clap 3.0.0-alpha.5 - [17]
L4JXJHWXpijul/*: reorganize imports and remove extern crate - [18]
KWAMD2KRA few fixes in the documentation comments - [19]
I24UEJQLVarious post-fire fixes - [20]
MF3WAHBIcommands/record: amend current change if unspecified - [21]
KWAGWB73Adding extra dependencies from the config file - [22]
ZBNKSYA6Fixing a bus error when starting a transaction on a full disk - [23]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [24]
4H2XTVJ2Fix some mistakes in the docs - [25]
CCLLB7OIUpgrading to Sanakirja 0.15 + version bump - [26]
NS36CJCOValidating timestamps in record - [*]
ABQDWHNGMigrate from `pijul::repository` to `pijul-repository`
Change contents
- replacement in pijul/src/commands/record.rs at line 8
use clap::{Parser, ValueHint};use clap::Parser; - edit in pijul/src/commands/record.rs at line 17[5.102093][28.1027]
use crate::commands::common_opts::RepoAndChannel;use crate::commands::load_channel; - edit in pijul/src/commands/record.rs at line 23
#[clap(flatten)]base: RepoAndChannel, - edit in pijul/src/commands/record.rs at line 37[5.102331]→[5.983:1056](∅→∅),[5.1056]→[5.102331:102394](∅→∅),[5.102331]→[5.102331:102394](∅→∅),[5.102394]→[5.664:814](∅→∅),[5.814]→[3.660:726](∅→∅),[3.726]→[5.102427:102463](∅→∅),[5.102427]→[5.102427:102463](∅→∅)
/// Record the change in this channel instead of the current channel#[clap(long = "channel")]pub channel: Option<String>,/// Set the repository where this command should run. Defaults to the first ancestor of the current directory that contains a `.pijul` directory.#[clap(long = "repository", value_hint = ValueHint::DirPath)]pub repo_path: Option<PathBuf>, - replacement in pijul/src/commands/record.rs at line 71
let repo = Repository::find_root(self.repo_path.as_deref())?;let repo = Repository::find_root(self.base.repo_path())?; - edit in pijul/src/commands/record.rs at line 79[5.5158]→[5.5158:5231](∅→∅),[5.5231]→[2.430:480](∅→∅),[2.480]→[5.5278:5304](∅→∅),[5.5278]→[5.5278:5304](∅→∅),[5.5304]→[5.1549:1638](∅→∅),[5.283]→[5.1549:1638](∅→∅),[5.1638]→[5.5305:5330](∅→∅),[5.5330]→[5.1706:1717](∅→∅),[5.1706]→[5.1706:1717](∅→∅),[5.1717]→[5.5331:5417](∅→∅),[5.5417]→[5.160:262](∅→∅),[5.160]→[5.160:262](∅→∅)
let cur = txn.read().current_channel().unwrap_or(libpijul::DEFAULT_CHANNEL).to_string();let channel = if let Some(ref c) = self.channel {c} else {cur.as_str()};let mut channel = if let Some(channel) = txn.read().load_channel(&channel)? {channel} else {bail!("Channel {:?} not found", channel);}; - replacement in pijul/src/commands/record.rs at line 80[5.194]→[5.194:287](∅→∅),[5.287]→[5.5418:5476](∅→∅),[5.5476]→[5.338:357](∅→∅),[5.338]→[5.338:357](∅→∅),[5.357]→[5.5477:5575](∅→∅),[5.5575]→[5.424:590](∅→∅),[5.10133]→[5.424:590](∅→∅),[5.12800]→[5.424:590](∅→∅),[5.424]→[5.424:590](∅→∅),[5.590]→[5.5576:5616](∅→∅),[5.5616]→[5.632:650](∅→∅),[5.12850]→[5.632:650](∅→∅),[5.632]→[5.632:650](∅→∅)
let mut extra = Vec::new();for h in repo.config.extra_dependencies.iter() {let (h, c) = txn.read().hash_from_prefix(h)?;if txn.read().get_changeset(txn.read().changes(&*channel.read()), &c)?.is_none(){bail!("Change {:?} (from .pijul/config) is not on channel {:?}",h,channel.read().name)let (mut channel, extra) = {let txn = txn.read();let (channel, _) = load_channel(self.base.channel(), &*txn)?;let mut extra = Vec::new();for h in repo.config.extra_dependencies.iter() {let (h, c) = txn.hash_from_prefix(h)?;if txn.get_changeset(txn.changes(&*channel.read()), &c)?.is_none(){bail!("Change {:?} (from .pijul/config) is not on channel {:?}",h,channel.read().name)}extra.push(h) - replacement in pijul/src/commands/record.rs at line 100
extra.push(h)}(channel, extra)}; - replacement in pijul/src/commands/record.rs at line 105[5.103811]→[5.76:128](∅→∅),[5.128]→[5.5617:5763](∅→∅),[5.5763]→[5.10134:10166](∅→∅),[5.12938]→[5.10134:10166](∅→∅),[5.12559]→[5.10134:10166](∅→∅),[5.10166]→[5.288:340](∅→∅),[5.12584]→[5.288:340](∅→∅),[5.288]→[5.288:340](∅→∅)
let h = if let Some(ref hash) = amend {txn.read().hash_from_prefix(hash)?.0} else if let Some(h) = txn.read().reverse_log(&*channel.read(), None)?.next() {(h?.1).0.into()} else {return Ok(());let h = {let txn = txn.read();if let Some(ref hash) = amend {txn.hash_from_prefix(hash)?.0} else if let Some(h) = txn.reverse_log(&*channel.read(), None)?.next() {h?.1 .0.into()} else {return Ok(());}