Refactor apply command's handling of repo and channel
Dependencies
- [2]
4H6GNDAIPrevent `pijul apply` from creating empty channels - [3]
ZDQB72IKWhen running `pijul apply` with stdin, immediately quit if the channel does not exist - [4]
Y2Y4OOIEMove `pijul::DEFAULT_CHANNEL` to `libpijul` - [5]
G7HJHNFDMigrate from `pijul_interaction::progress` to `pijul_interaction` - [6]
QQS7LII4Add value hints to arguments - [7]
GKSVBEUWRefactor Repository constructors to take Option<&Path> instead of Option<PathBuf> - [8]
AEPEFS7OWrite help for each argument - [9]
Y6EVFMTADon't output files if they aren't in the current channel - [10]
R3H7D42UDebugging `pijul git`: proper error reporting - [11]
I7VL7VPZMinor cleanup - [12]
A3RM526YIntegrating identity malleability - [13]
KWAMD2KRA few fixes in the documentation comments - [14]
CCLLB7OIUpgrading to Sanakirja 0.15 + version bump - [15]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [16]
RUBBHYZ7Removing unnecessary async/await - [17]
ZBNKSYA6Fixing a bus error when starting a transaction on a full disk - [18]
5SLOJYHGFixing the Git feature - [19]
PIQCNEEBUpgrading to Clap 3.0.0-alpha.5 - [20]
RFLKHQ2YFirst read all stdin when applying a patch, in order to avoid blocking - [21]
4H2XTVJ2Fix some mistakes in the docs - [22]
EUZFFJSOUpdating Pijul with the latest changes in Libpijul - [23]
26VQKD25A more accurate safeguard for apply, to check if the output is nondestructive - [24]
L4JXJHWXpijul/*: reorganize imports and remove extern crate - [25]
5OGOE4VWStore the current channel in the pristine
Change contents
- replacement in pijul/src/commands/apply.rs at line 4
use clap::{Parser, ValueHint};use clap::Parser; - edit in pijul/src/commands/apply.rs at line 10
use crate::commands::common_opts::RepoAndChannel;use crate::commands::load_channel; - replacement in pijul/src/commands/apply.rs at line 17[8.194540]→[8.3856:4006](∅→∅),[8.4006]→[6.2906:2972](∅→∅),[6.2972]→[8.194573:194605](∅→∅),[8.194573]→[8.194573:194605](∅→∅),[8.194605]→[8.4166:4203](∅→∅),[8.4203]→[8.194605:194664](∅→∅),[8.5984]→[8.194605:194664](∅→∅),[8.194605]→[8.194605:194664](∅→∅)
/// 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)]repo_path: Option<PathBuf>,/// Apply change to this channel#[clap(long = "channel")]channel: Option<String>,#[clap(flatten)]base: RepoAndChannel, - replacement in pijul/src/commands/apply.rs at line 28
let repo = Repository::find_root(self.repo_path.as_deref())?;let repo = Repository::find_root(self.base.repo_path())?; - replacement in pijul/src/commands/apply.rs at line 31[8.17554]→[8.17554:17627](∅→∅),[8.17627]→[4.1579:1629](∅→∅),[4.1629]→[8.17674:17700](∅→∅),[8.17674]→[8.17674:17700](∅→∅),[8.17700]→[8.4895:4958](∅→∅),[8.4895]→[8.4895:4958](∅→∅),[8.4958]→[8.4958:4989](∅→∅),[8.4989]→[8.17701:17726](∅→∅),[8.17726]→[8.5005:5070](∅→∅),[8.5005]→[8.5005:5070](∅→∅),[8.5070]→[8.17727:17814](∅→∅),[8.5653]→[8.195133:195153](∅→∅),[8.17814]→[8.195133:195153](∅→∅),[8.19457]→[8.195133:195153](∅→∅),[8.195133]→[8.195133:195153](∅→∅),[8.195250]→[8.195250:195267](∅→∅),[8.195267]→[2.0:58](∅→∅),[2.58]→[8.195402:195413](∅→∅),[8.778]→[8.195402:195413](∅→∅),[8.195402]→[8.195402:195413](∅→∅)
let cur = txn.read().current_channel().unwrap_or(libpijul::DEFAULT_CHANNEL).to_string();let channel_name = if let Some(ref c) = self.channel {c} else {cur.as_str()};let is_current_channel = channel_name == cur;let channel = if let Some(channel) = txn.read().load_channel(&channel_name)? {channel} else {bail!("Channel {:?} not found", channel_name)};let (channel, is_current_channel) = load_channel(self.base.channel(), &*txn.read())?;