Refactor apply command's handling of repo and channel

dblsaiko
Mar 29, 2024, 9:17 PM
YV5PVUXVFHZVG5D4R4IHYBXUL4GV3YSXST4JO23PJRGBLFKOGR7AC

Dependencies

  • [2] 4H6GNDAI Prevent `pijul apply` from creating empty channels
  • [3] ZDQB72IK When running `pijul apply` with stdin, immediately quit if the channel does not exist
  • [4] Y2Y4OOIE Move `pijul::DEFAULT_CHANNEL` to `libpijul`
  • [5] G7HJHNFD Migrate from `pijul_interaction::progress` to `pijul_interaction`
  • [6] QQS7LII4 Add value hints to arguments
  • [7] GKSVBEUW Refactor Repository constructors to take Option<&Path> instead of Option<PathBuf>
  • [8] AEPEFS7O Write help for each argument
  • [9] Y6EVFMTA Don't output files if they aren't in the current channel
  • [10] R3H7D42U Debugging `pijul git`: proper error reporting
  • [11] I7VL7VPZ Minor cleanup
  • [12] A3RM526Y Integrating identity malleability
  • [13] KWAMD2KR A few fixes in the documentation comments
  • [14] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [15] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [16] RUBBHYZ7 Removing unnecessary async/await
  • [17] ZBNKSYA6 Fixing a bus error when starting a transaction on a full disk
  • [18] 5SLOJYHG Fixing the Git feature
  • [19] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [20] RFLKHQ2Y First read all stdin when applying a patch, in order to avoid blocking
  • [21] 4H2XTVJ2 Fix some mistakes in the docs
  • [22] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [23] 26VQKD25 A more accurate safeguard for apply, to check if the output is nondestructive
  • [24] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [25] 5OGOE4VW Store the current channel in the pristine

Change contents

  • replacement in pijul/src/commands/apply.rs at line 4
    [8.584][6.2874:2905]()
    use clap::{Parser, ValueHint};
    [8.584]
    [8.194343]
    use clap::Parser;
  • edit in pijul/src/commands/apply.rs at line 10
    [8.3380]
    [5.532]
    use crate::commands::common_opts::RepoAndChannel;
    use crate::commands::load_channel;
  • replacement in pijul/src/commands/apply.rs at line 17
    [8.194540][8.3856:4006](),[8.4006][6.2906:2972](),[6.2972][8.194573:194605](),[8.194573][8.194573:194605](),[8.194605][8.4166:4203](),[8.4203][8.194605:194664](),[8.5984][8.194605:194664](),[8.194605][8.194605:194664]()
    /// 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>,
    /// Apply change to this channel
    #[clap(long = "channel")]
    channel: Option<String>,
    [8.194540]
    [8.585]
    #[clap(flatten)]
    base: RepoAndChannel,
  • replacement in pijul/src/commands/apply.rs at line 28
    [8.2548][7.3091:3161]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [8.2548]
    [8.407]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/apply.rs at line 31
    [8.17554][8.17554:17627](),[8.17627][4.1579:1629](),[4.1629][8.17674:17700](),[8.17674][8.17674:17700](),[8.17700][8.4895:4958](),[8.4895][8.4895:4958](),[8.4958][8.4958:4989](),[8.4989][8.17701:17726](),[8.17726][8.5005:5070](),[8.5005][8.5005:5070](),[8.5070][8.17727:17814](),[8.5653][8.195133:195153](),[8.17814][8.195133:195153](),[8.19457][8.195133:195153](),[8.195133][8.195133:195153](),[8.195250][8.195250:195267](),[8.195267][2.0:58](),[2.58][8.195402:195413](),[8.778][8.195402:195413](),[8.195402][8.195402:195413]()
    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()
    };
    let is_current_channel = channel_name == cur;
    let channel = if let Some(channel) = txn.read().load_channel(&channel_name)? {
    channel
    } else {
    bail!("Channel {:?} not found", channel_name)
    };
    [8.17554]
    [3.0]
    let (channel, is_current_channel) = load_channel(self.base.channel(), &*txn.read())?;