Refactor tag command's handling of repo and channel

dblsaiko
Mar 30, 2024, 8:44 PM
Q7LEDPIWGV5LJE3LYXLT74RBKOHEHLL4EJY6N4FDR3B6ZPX3V2UAC

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] QL6K2ZM3 Tags
  • [6] L3RCAPPK Add --repository to tag commands
  • [7] DWSAYGVE Update codebase to use new identity management
  • [8] DO2Y5TY5 Tag synchronisation
  • [9] DX2FO4HZ Tag CLI cleanup
  • [10] GUL4M5FI Cleanup and formatting
  • [11] E7UUQQCC Apply changes with prefixes in .pijul/changes
  • [12] ZDK3GNDB Tag transactions (including a massive refactoring of errors)
  • [13] E6IKUIPD Command to delete a tag
  • [14] J7YVFL4A Improving the help of tags
  • [15] BPCAJCLT Use RFC2822 date formatting in `log`, `tag`, and `record --timestamp`
  • [16] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [17] 3FTEGCMR add timestamp_validator to tag --timestamp option
  • [18] FZ7MXL3B Allow to use short tag hashes
  • [19] C267PHOH Tags: dropping useless Hashes in favour of Merkles
  • [20] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [21] FDEVV5NG Tag check
  • [22] 5OGOE4VW Store the current channel in the pristine
  • [23] AAXP2534 Tags: completing the subcommand

Change contents

  • edit in pijul/src/commands/tag.rs at line 3
    [5.150]
    [5.0]
    use crate::commands::common_opts::RepoPath;
    use crate::commands::load_channel;
  • replacement in pijul/src/commands/tag.rs at line 7
    [5.203][3.99:130]()
    use clap::{Parser, ValueHint};
    [5.203]
    [5.219]
    use clap::Parser;
  • replacement in pijul/src/commands/tag.rs at line 9
    [5.255][5.2342:2427]()
    use libpijul::{ArcTxn, Base32, ChannelMutTxnT, ChannelTxnT, MutTxnT, TxnT, TxnTExt};
    [5.255]
    [5.0]
    use libpijul::{ArcTxn, Base32, ChannelMutTxnT, ChannelRef, ChannelTxnT, MutTxnT, TxnT, TxnTExt};
  • edit in pijul/src/commands/tag.rs at line 15
    [5.373]
    [5.604]
    #[clap(flatten)]
    base: RepoPath,
  • edit in pijul/src/commands/tag.rs at line 19
    [5.32][3.131:197](),[3.197][5.26452:26484](),[5.26452][5.26452:26484]()
    #[clap(long = "repository", value_hint = ValueHint::DirPath)]
    repo_path: Option<PathBuf>,
  • replacement in pijul/src/commands/tag.rs at line 29
    [5.764][5.0:178](),[5.178][3.198:268](),[3.268][5.215:251](),[5.215][5.215:251]()
    /// 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>,
    [5.764]
    [5.764]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/tag.rs at line 46
    [5.1249][5.252:430](),[5.430][3.269:339](),[3.339][5.467:503](),[5.467][5.467:503]()
    /// 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>,
    [5.1249]
    [5.1249]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/tag.rs at line 57
    [5.5312][5.95:273](),[5.273][3.340:410](),[3.410][5.310:346](),[5.310][5.310:346]()
    /// 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>,
    [5.5312]
    [5.346]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/tag.rs at line 65
    [5.532][5.5312:5490](),[5.5312][5.5312:5490](),[5.5490][3.411:481](),[3.481][5.5527:5563](),[5.5527][5.5527:5563]()
    /// 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>,
    [5.532]
    [5.533]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/tag.rs at line 79
    [5.71][5.504:531]()
    repo_path,
    [5.71]
    [5.1712]
    base,
  • replacement in pijul/src/commands/tag.rs at line 85
    [5.92][4.1119:1196]()
    let mut repo = Repository::find_root(repo_path.as_deref())?;
    [5.92]
    [5.2428]
    let mut repo = Repository::find_root(base.repo_path())?;
  • replacement in pijul/src/commands/tag.rs at line 87
    [5.2486][5.71:133](),[5.71][5.71:133](),[5.133][5.459:506](),[5.459][5.459:506](),[5.506][5.2487:2561](),[5.2561][2.139:201](),[2.201][5.235:272](),[5.235][5.235:272](),[5.272][5.582:601](),[5.582][5.582:601](),[5.601][5.273:334](),[5.388][5.388:456](),[5.456][5.2562:2761]()
    let channel_name = if let Some(c) = channel {
    c
    } else {
    txn.read()
    .current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string()
    };
    debug!("channel_name = {:?}", channel_name);
    try_record(&mut repo, txn.clone(), &channel_name)?;
    let channel = txn.read().load_channel(&channel_name)?.unwrap();
    let last_t = if let Some(n) = txn.read().reverse_log(&*channel.read(), None)?.next()
    {
    [5.2486]
    [5.2305]
    let (channel, _) = load_channel(channel.as_deref(), &*txn.read())?;
    debug!("channel_name = {:?}", channel.read().name);
    try_record(&mut repo, txn.clone(), channel.clone())?;
    let last_t = {
    let txn = txn.read();
    let Some(n) = txn.reverse_log(&*channel.read(), None)?.next() else {
    bail!("Channel {} is empty", channel.read().name.as_str());
    };
  • edit in pijul/src/commands/tag.rs at line 97
    [5.2337][5.2337:2426]()
    } else {
    bail!("Channel {} is empty", channel_name);
  • edit in pijul/src/commands/tag.rs at line 98
    [5.2445]
    [5.2445]
  • replacement in pijul/src/commands/tag.rs at line 111
    [5.142][5.74:212](),[5.3053][5.74:212]()
    let h: libpijul::Merkle =
    libpijul::tag::from_channel(&*txn.read(), &channel_name, &header, &mut w)?;
    [5.142]
    [5.212]
    let h: libpijul::Merkle = libpijul::tag::from_channel(
    &*txn.read(),
    channel.read().name.as_str(),
    &header,
    &mut w,
    )?;
  • replacement in pijul/src/commands/tag.rs at line 127
    [5.40][5.599:626]()
    repo_path,
    [5.40]
    [5.40]
    base,
  • replacement in pijul/src/commands/tag.rs at line 131
    [5.113][4.1197:1270]()
    let repo = Repository::find_root(repo_path.as_deref())?;
    [5.113]
    [5.150]
    let repo = Repository::find_root(base.repo_path())?;
  • replacement in pijul/src/commands/tag.rs at line 142
    [5.586][5.3795:3984](),[5.3795][5.3795:3984]()
    let channel_name = if let Some(ref channel) = to_channel {
    channel.as_str()
    } else {
    tag.as_str()
    };
    [5.586]
    [5.4046]
    let channel_name = to_channel.as_deref().unwrap_or(&tag);
  • replacement in pijul/src/commands/tag.rs at line 151
    [5.5599][5.5599:5659](),[5.5659][4.1271:1344]()
    Some(SubCommand::Reset { repo_path, tag }) => {
    let repo = Repository::find_root(repo_path.as_deref())?;
    [5.5599]
    [5.369]
    Some(SubCommand::Reset { base, tag }) => {
    let repo = Repository::find_root(base.repo_path())?;
  • replacement in pijul/src/commands/tag.rs at line 185
    [5.689][5.689:820](),[5.820][4.1345:1418]()
    Some(SubCommand::Delete {
    repo_path,
    channel,
    tag,
    }) => {
    let repo = Repository::find_root(repo_path.as_deref())?;
    [5.689]
    [5.882]
    Some(SubCommand::Delete { base, channel, tag }) => {
    let repo = Repository::find_root(base.repo_path())?;
  • replacement in pijul/src/commands/tag.rs at line 196
    [5.1313][5.1313:1418](),[5.1418][2.202:264](),[2.264][5.1477:1748](),[5.1477][5.1477:1748]()
    let channel_name = channel.unwrap_or_else(|| {
    txn.current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string()
    });
    let channel = if let Some(c) = txn.load_channel(&channel_name)? {
    c
    } else {
    bail!("Channel {:?} not found", channel_name)
    };
    [5.1313]
    [5.1748]
    let (channel, _) = load_channel(channel.as_deref(), &txn)?;
  • replacement in pijul/src/commands/tag.rs at line 209
    [5.268][4.1419:1497]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [5.268]
    [5.440]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/tag.rs at line 211
    [5.494][5.26612:26722](),[5.26722][2.265:327](),[2.327][5.26781:26838](),[5.26781][5.26781:26838](),[5.769][5.494:708](),[5.26838][5.494:708](),[5.494][5.494:708]()
    let channel_name = self.channel.unwrap_or_else(|| {
    txn.current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string()
    });
    let channel = if let Some(c) = txn.load_channel(&channel_name)? {
    c
    } else {
    bail!("Channel {:?} not found", channel_name)
    };
    [5.494]
    [5.559]
    let (channel, _) = load_channel(self.channel.as_deref(), &txn)?;
  • replacement in pijul/src/commands/tag.rs at line 277
    [5.3230][5.769:788](),[5.769][5.769:788]()
    channel: &str,
    [5.3230]
    [5.788]
    channel: ChannelRef<T>,
  • edit in pijul/src/commands/tag.rs at line 279
    [5.821][5.3231:3308](),[5.3308][5.907:923](),[5.907][5.907:923](),[5.923][5.6281:6342](),[5.6281][5.6281:6342](),[5.6342][5.924:931]()
    let channel = if let Some(channel) = txn.read().load_channel(channel)? {
    channel
    } else {
    bail!("Channel not found: {}", channel)
    };
  • edit in pijul/src/commands/tag.rs at line 297
    [5.95][5.95:119]()
    use std::path::PathBuf;
  • resolve order conflict in pijul/src/commands/tag.rs at line 297
    [5.1459]