Refactor fork command's handling of repo and channel

dblsaiko
Mar 29, 2024, 9:33 PM
K34KD3FTTP3GD7TBEMLPOA2ZCBDTAMSW53RDIN4WRGZD2AAMLEMAC

Dependencies

  • [2] MYB5C3FP Solving conflicts
  • [3] GKSVBEUW Refactor Repository constructors to take Option<&Path> instead of Option<PathBuf>
  • [4] KWAMD2KR A few fixes in the documentation comments
  • [5] QQS7LII4 Add value hints to arguments
  • [6] RUBBHYZ7 Removing unnecessary async/await
  • [7] I52XSRUH Massive cleanup, and simplification
  • [8] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [9] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [10] I7VL7VPZ Minor cleanup
  • [11] X243Z3Y5 Recording only the required metadata (can even be changed later!)
  • [12] YN63NUZO Sanakirja 1.0
  • [13] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [14] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [15] 4H2XTVJ2 Fix some mistakes in the docs
  • [16] AEPEFS7O Write help for each argument
  • [17] Y6EVFMTA Don't output files if they aren't in the current channel
  • [18] 5OGOE4VW Store the current channel in the pristine
  • [19] A3RM526Y Integrating identity malleability
  • [20] E3DD265T Fork to a *state*
  • [*] ABQDWHNG Migrate from `pijul::repository` to `pijul-repository`

Change contents

  • replacement in pijul/src/commands/fork.rs at line 1
    [4.167873][2.33:64]()
    use clap::{Parser, ValueHint};
    [4.167873]
    [4.0]
    use clap::Parser;
  • edit in pijul/src/commands/fork.rs at line 4
    [4.2367][2.65:89]()
    use std::path::PathBuf;
  • edit in pijul/src/commands/fork.rs at line 5
    [4.2368]
    [22.1810]
    use crate::commands::common_opts::RepoPath;
    use crate::commands::load_channel;
  • replacement in pijul/src/commands/fork.rs at line 11
    [4.168042][4.1960:2110](),[4.2110][4.1715:1781](),[4.1781][4.168075:168107](),[4.168075][4.168075:168107]()
    /// 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>,
    [4.168042]
    [4.74]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/fork.rs at line 28
    [4.1926][3.2112:2182]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [4.1926]
    [4.168420]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/fork.rs at line 37
    [4.168764][4.429:745](),[4.745][4.2825:2846](),[4.2825][4.2825:2846](),[4.2846][4.746:1132](),[4.1132][4.15864:15879](),[4.15864][4.15864:15879]()
    let mut fork = if let Some(ref channel_name) = self.channel {
    if let Some(channel) = txn.load_channel(channel_name)? {
    txn.fork(&channel, &self.to)?
    } else {
    anyhow::bail!("Channel not found: {:?}", channel_name);
    }
    } else {
    let cur = txn
    .current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string();
    if let Some(channel) = txn.load_channel(&cur)? {
    txn.fork(&channel, &self.to)?
    } else {
    anyhow::bail!("Channel not found: {:?}", cur);
    }
    };
    [4.168764]
    [4.1133]
    let (channel, _) = load_channel(self.channel.as_deref(), &txn)?;
    let mut fork = txn.fork(&channel, &self.to)?;