Refactor reset command's handling of repo and channel

dblsaiko
Mar 29, 2024, 9:41 PM
Q5PNWJ5WICBXCVODOZBNZLADNNCBPQPMN32SJKQUVEP4ZJIBPZ3QC

Dependencies

  • [2] Y2Y4OOIE Move `pijul::DEFAULT_CHANNEL` to `libpijul`
  • [3] G7HJHNFD Migrate from `pijul_interaction::progress` to `pijul_interaction`
  • [4] QQS7LII4 Add value hints to arguments
  • [5] GKSVBEUW Refactor Repository constructors to take Option<&Path> instead of Option<PathBuf>
  • [6] JL4WKA5P Implement the Sanakirja concurrency model in a cross-process way
  • [7] Y7YAFMFF Fix path prefix striping on Windows.
  • [8] I7VL7VPZ Minor cleanup
  • [9] KWAMD2KR A few fixes in the documentation comments
  • [10] M3VTIZCP Validate change before reset
  • [11] I24UEJQL Various post-fire fixes
  • [12] 5OGOE4VW Store the current channel in the pristine
  • [13] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [14] AEPEFS7O Write help for each argument
  • [15] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [16] VQPAUKBQ channel switch as an alias to reset
  • [17] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [18] Y6EVFMTA Don't output files if they aren't in the current channel
  • [19] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [20] UAXGGNAZ Improve command feedback
  • [21] 4H2XTVJ2 Fix some mistakes in the docs
  • [22] A3RM526Y Integrating identity malleability
  • [23] RUBBHYZ7 Removing unnecessary async/await
  • [*] L4JXJHWX pijul/*: reorganize imports and remove extern crate

Change contents

  • edit in pijul/src/commands/reset.rs at line 11
    [25.1348]
    [3.402]
    use crate::commands::common_opts::RepoPath;
    use crate::commands::load_channel;
  • replacement in pijul/src/commands/reset.rs at line 18
    [6.97841][6.302:452](),[6.452][4.514:580](),[4.580][6.290:326](),[6.97874][6.290:326]()
    /// 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>,
    [6.97841]
    [6.453]
    #[clap(flatten)]
    pub base: RepoPath,
  • replacement in pijul/src/commands/reset.rs at line 56
    [6.236][6.98164:98218](),[6.642][6.98164:98218](),[6.1369][6.98164:98218](),[6.6093][6.98164:98218](),[6.98164][6.98164:98218](),[6.98218][5.1498:1568]()
    let has_repo_path = self.repo_path.is_some();
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [6.236]
    [6.3338]
    let has_repo_path = self.base.repo_path().is_some();
    let repo = Repository::find_root(self.base.repo_path())?;
  • edit in pijul/src/commands/reset.rs at line 60
    [6.6482][6.3389:3462](),[6.3462][2.328:378](),[2.378][6.3509:3535](),[6.3509][6.3509:3535](),[6.3535][6.770:864](),[6.6482][6.770:864](),[6.864][6.3536:3561](),[6.3561][6.932:943](),[6.932][6.932:943]()
    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()
    };
  • replacement in pijul/src/commands/reset.rs at line 61
    [6.108][6.3562:3649](),[6.3649][6.98538:98558](),[6.6732][6.98538:98558](),[6.12223][6.98538:98558](),[6.98538][6.98538:98558](),[6.98655][6.98655:98672](),[6.98672][6.12224:12281](),[6.12281][6.98807:98818](),[6.98807][6.98807:98818]()
    let channel = if let Some(channel) = txn.read().load_channel(&channel_name)? {
    channel
    } else {
    bail!("No such channel: {:?}", channel_name)
    };
    [6.108]
    [6.6733]
    let (channel, _) = load_channel(self.channel.as_deref(), &*txn.read())?;