edit in pijul/src/commands/tag.rs at line 3
+ use crate::commands::common_opts::RepoPath;
+ use crate::commands::load_channel;
replacement in pijul/src/commands/tag.rs at line 7
− use clap::{Parser, ValueHint};
replacement in pijul/src/commands/tag.rs at line 9
[5.255]→[5.2342:2427](∅→∅) − use libpijul::{ArcTxn, Base32, ChannelMutTxnT, ChannelTxnT, MutTxnT, TxnT, TxnTExt};
+ use libpijul::{ArcTxn, Base32, ChannelMutTxnT, ChannelRef, ChannelTxnT, MutTxnT, TxnT, TxnTExt};
edit in pijul/src/commands/tag.rs at line 15
+ #[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>,
+ #[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>,
+ #[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>,
+ #[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>,
+ #[clap(flatten)]
+ base: RepoPath,
replacement in pijul/src/commands/tag.rs at line 79
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())?;
+ 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()
− {
+ 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
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)?;
+ 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
replacement in pijul/src/commands/tag.rs at line 131
[5.113]→[4.1197:1270](∅→∅) − let repo = Repository::find_root(repo_path.as_deref())?;
+ 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()
− };
+ 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())?;
+ 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())?;
+ 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)
− };
+ 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())?;
+ 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)
− };
+ 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: 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
− use std::path::PathBuf;
resolve order conflict in pijul/src/commands/tag.rs at line 297