Refactor log command's handling of repo and channel

dblsaiko
Mar 29, 2024, 9:34 PM
3FNRS6MWYYKFO2IX5WVUFIXKPSTRKQEHMPCYZVMNXGN33KWV2XNAC

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] AEPEFS7O Write help for each argument
  • [6] U6TQX5Z2 pager function respects cli option and user config files, PAGER env var
  • [7] 4H2XTVJ2 Fix some mistakes in the docs
  • [8] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [9] ATUZBEPE Add hunk paths to log ouput
  • [10] 2K7JLB4Z No pager on Windows
  • [11] I52XSRUH Massive cleanup, and simplification
  • [12] GURIBVW6 Fixing the pager
  • [13] OU6JOR3C Add path filtering for log, add json output for log
  • [14] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [15] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [16] KWAMD2KR A few fixes in the documentation comments
  • [17] ZDK3GNDB Tag transactions (including a massive refactoring of errors)
  • [18] NAUECZW3 Fixing the map between keys and identities
  • [19] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [20] 6F6AAHK4 Simplifying pijul::commands::log, and fixing Broken Pipe errors

Change contents

  • edit in pijul/src/commands/log.rs at line 7
    [5.2088]
    [5.16925]
    use crate::commands::common_opts::RepoAndChannel;
    use crate::commands::load_channel;
  • replacement in pijul/src/commands/log.rs at line 10
    [5.16943][3.1082:1113]()
    use clap::{Parser, ValueHint};
    [5.16943]
    [5.134430]
    use clap::Parser;
  • replacement in pijul/src/commands/log.rs at line 15
    [5.93][5.3357:3396](),[5.224][5.3357:3396](),[5.7127][5.3357:3396](),[5.134460][5.3357:3396]()
    use libpijul::{Base32, TxnT, TxnTExt};
    [5.7127]
    [5.230]
    use libpijul::{Base32, TxnTExt};
  • replacement in pijul/src/commands/log.rs at line 25
    [5.134600][5.1268:1418](),[5.1418][3.1114:1180](),[3.1180][5.134633:134665](),[5.134633][5.134633:134665](),[5.134665][5.2884:2950](),[5.2950][5.134665:134724](),[5.134665][5.134665:134724]()
    /// 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>,
    /// Show logs for this channel instead of the current channel
    #[clap(long = "channel")]
    channel: Option<String>,
    [5.134600]
    [5.2951]
    #[clap(flatten)]
    base: RepoAndChannel,
  • replacement in pijul/src/commands/log.rs at line 58
    [5.245][4.1953:2022]()
    let repo = Repository::find_root(cmd.repo_path.as_deref())?;
    [5.245]
    [5.354]
    let repo = Repository::find_root(cmd.base.repo_path())?;
  • replacement in pijul/src/commands/log.rs at line 60
    [5.400][5.400:493](),[5.493][2.622:693](),[2.693][5.561:572](),[5.561][5.561:572]()
    let channel_name = if let Some(ref c) = cmd.channel {
    c
    } else {
    txn.current_channel().unwrap_or(libpijul::DEFAULT_CHANNEL)
    };
    [5.400]
    [5.572]
    let (channel_ref, is_current_channel) = load_channel(cmd.base.channel(), &txn)?;
  • replacement in pijul/src/commands/log.rs at line 65
    [5.822][5.822:857](),[5.857][2.694:787](),[2.787][5.947:957](),[5.947][5.947:957]()
    if !cmd.filters.is_empty()
    && !(channel_name == txn.current_channel().unwrap_or(libpijul::DEFAULT_CHANNEL))
    {
    [5.822]
    [5.957]
    if !cmd.filters.is_empty() && !is_current_channel {
  • replacement in pijul/src/commands/log.rs at line 69
    [5.1065][5.1065:1253](),[5.1289][5.1289:1347]()
    let channel_ref = if let Some(channel) = txn.load_channel(channel_name)? {
    channel
    } else {
    bail!("No such channel: {:?}", channel_name)
    };
    let limit = cmd.limit.unwrap_or(std::usize::MAX);
    [5.1065]
    [5.1347]
    let limit = cmd.limit.unwrap_or(usize::MAX);