Refactor record command's handling of repo and channel

dblsaiko
Mar 29, 2024, 9:39 PM
DDEUZMXQRYVBGTJWKZY6W4UFSDCLB6JV7VX32AOTY3ZPD7OS6P6QC

Dependencies

  • [2] Y2Y4OOIE Move `pijul::DEFAULT_CHANNEL` to `libpijul`
  • [3] QQS7LII4 Add value hints to arguments
  • [4] GKSVBEUW Refactor Repository constructors to take Option<&Path> instead of Option<PathBuf>
  • [5] EEBKW7VT Keys and identities
  • [6] AEPEFS7O Write help for each argument
  • [7] ZHABNS3S Canonicalize all paths
  • [8] OU243LAB Support for staging
  • [9] 5OGOE4VW Store the current channel in the pristine
  • [10] A3RM526Y Integrating identity malleability
  • [11] PGERZ3KJ Channel renaming (also do not create a new channel when recording on a channel that doesn't exist)
  • [12] DWSAYGVE Update codebase to use new identity management
  • [13] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [14] 3MHUNYER Changing --amend flag to respect -m flag
  • [15] YN63NUZO Sanakirja 1.0
  • [16] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [17] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [18] KWAMD2KR A few fixes in the documentation comments
  • [19] I24UEJQL Various post-fire fixes
  • [20] MF3WAHBI commands/record: amend current change if unspecified
  • [21] KWAGWB73 Adding extra dependencies from the config file
  • [22] ZBNKSYA6 Fixing a bus error when starting a transaction on a full disk
  • [23] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [24] 4H2XTVJ2 Fix some mistakes in the docs
  • [25] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [26] NS36CJCO Validating timestamps in record
  • [*] ABQDWHNG Migrate from `pijul::repository` to `pijul-repository`

Change contents

  • replacement in pijul/src/commands/record.rs at line 8
    [5.101821][3.628:659]()
    use clap::{Parser, ValueHint};
    [5.101821]
    [5.101821]
    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
    [5.102136]
    [5.849]
    #[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
    [5.536][4.1569:1639]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [5.536]
    [5.102903]
    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
    )
    [5.194]
    [5.650]
    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
    [5.664][5.664:700]()
    extra.push(h)
    }
    [5.664]
    [5.103751]
    (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(());
    [5.103811]
    [5.340]
    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(());
    }