Refactor channel command's handling of repo and channel

dblsaiko
Mar 29, 2024, 9:20 PM
JA4POQALQZSM4U6XII4VE56J3LNM57MCFMAKFKYJCBNY6OCYRZ7AC

Dependencies

  • [2] QQS7LII4 Add value hints to arguments
  • [3] GKSVBEUW Refactor Repository constructors to take Option<&Path> instead of Option<PathBuf>
  • [4] 5OGOE4VW Store the current channel in the pristine
  • [5] GHO6DWPI Refactoring iterators
  • [6] YN63NUZO Sanakirja 1.0
  • [7] JL4WKA5P Implement the Sanakirja concurrency model in a cross-process way
  • [8] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [9] A7NTQINQ pijul channel delete: error if channel doesn't exist
  • [10] I52XSRUH Massive cleanup, and simplification
  • [11] AEPEFS7O Write help for each argument
  • [12] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [13] FMKKWCFV Better clap attributes
  • [14] ABQDWHNG Migrate from `pijul::repository` to `pijul-repository`
  • [15] 4H2XTVJ2 Fix some mistakes in the docs
  • [16] 3AMEP2Y5 More convenient interface for channels
  • [17] PGERZ3KJ Channel renaming (also do not create a new channel when recording on a channel that doesn't exist)
  • [18] KWAMD2KR A few fixes in the documentation comments
  • [19] 53SC53QW Adding --force to reset/switch, to ignore name conflicts
  • [20] VQPAUKBQ channel switch as an alias to reset
  • [21] I24UEJQL Various post-fire fixes
  • [22] A3RM526Y Integrating identity malleability
  • [23] Q4SVMHAE Removing --channel from the changes command
  • [24] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [25] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [26] TFK7CYFQ `pijul channel new` to create new, empty channels
  • [27] ZBNKSYA6 Fixing a bus error when starting a transaction on a full disk
  • [28] YK7EBTF6 Safeguarding `pijul channel new`: it was too easy to create a new, independent root

Change contents

  • edit in pijul/src/commands/channel.rs at line 2
    [4.186989][4.186989:187013]()
    use std::path::PathBuf;
  • edit in pijul/src/commands/channel.rs at line 3
    [4.187014]
    [4.0]
    use crate::commands::common_opts::RepoPath;
    use crate::commands::{load_channel, load_channel_exact};
  • replacement in pijul/src/commands/channel.rs at line 7
    [4.18687][2.2496:2527]()
    use clap::{Parser, ValueHint};
    [4.18687]
    [4.943]
    use clap::Parser;
  • replacement in pijul/src/commands/channel.rs at line 14
    [4.187058][4.3554:3704](),[4.3704][2.2528:2594](),[2.2594][4.187091:187123](),[4.187091][4.187091:187123]()
    /// 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.187058]
    [4.187123]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/channel.rs at line 53
    [4.187735][3.2626:2704]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [4.187735]
    [4.187735]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/channel.rs at line 67
    [4.188244][3.2705:2783]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [4.188244]
    [4.3917]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/channel.rs at line 74
    [4.69][4.69:142]()
    return Err(anyhow!("Channel {} not found", delete));
    [4.69]
    [4.142]
    return Err(anyhow!("No such channel: {}", delete));
  • replacement in pijul/src/commands/channel.rs at line 80
    [4.1508][4.1508:1555]()
    repo_path: self.repo_path,
    [4.1508]
    [4.1555]
    base: self.base,
  • replacement in pijul/src/commands/channel.rs at line 89
    [4.188456][3.2784:2862]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [4.188456]
    [4.960]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/channel.rs at line 99
    [4.188838][4.18898:18981](),[4.18981][4.188920:188973](),[4.188920][4.188920:188973](),[4.188973][4.18982:19039](),[4.19039][4.189141:189160](),[4.189141][4.189141:189160]()
    let mut channel = if let Some(channel) = txn.load_channel(from)? {
    channel
    } else {
    bail!("No such channel: {:?}", from)
    };
    [4.188838]
    [4.189160]
    let mut channel = load_channel_exact(from, &txn)?;
  • replacement in pijul/src/commands/channel.rs at line 110
    [4.391][3.2863:2941]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [4.391]
    [4.228]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/channel.rs at line 118
    [4.570][4.570:862]()
    let current = txn.current_channel()?;
    let channel = if let Some(channel) = txn.load_channel(current)? {
    channel
    } else {
    bail!("No such channel: {:?}", current)
    };
    [4.570]
    [4.862]
    let (channel, _) = load_channel(None, &txn)?;