Fork to a *state*

pmeunier
Feb 7, 2024, 8:21 PM
E3DD265TSU5HFAAUYOIYFK5D3GYSPIJSWDVSQX5Q226WPCH43EFQC

Dependencies

  • [2] PRH6LZFX Return an error when trying to fork from a missing channel
  • [3] Y2Y4OOIE Move `pijul::DEFAULT_CHANNEL` to `libpijul`
  • [4] YN63NUZO Sanakirja 1.0
  • [5] 5OGOE4VW Store the current channel in the pristine
  • [6] AEPEFS7O Write help for each argument
  • [7] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [8] Y6EVFMTA Don't output files if they aren't in the current channel
  • [9] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [10] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [11] I7VL7VPZ Minor cleanup
  • [12] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [13] 4H2XTVJ2 Fix some mistakes in the docs
  • [14] KWAMD2KR A few fixes in the documentation comments
  • [15] I52XSRUH Massive cleanup, and simplification
  • [16] EUZFFJSO Updating Pijul with the latest changes in Libpijul

Change contents

  • replacement in pijul/src/commands/fork.rs at line 4
    [4.1111][4.4083:4126](),[4.2350][4.4083:4126]()
    use libpijul::{MutTxnT, MutTxnTExt, TxnT};
    [4.1111]
    [4.2351]
    use libpijul::{Base32, ChannelTxnT, MutTxnT, MutTxnTExt, TxnT, TxnTExt};
  • edit in pijul/src/commands/fork.rs at line 14
    [4.168107]
    [4.3329]
    /// Make the new channel from this state instead of the current channel
    #[clap(long = "state", conflicts_with = "change", conflicts_with = "channel")]
    state: Option<String>,
  • replacement in pijul/src/commands/fork.rs at line 18
    [4.3407][4.168107:168164](),[4.168107][4.168107:168164]()
    #[clap(long = "channel", conflicts_with = "change")]
    [4.3407]
    [4.168164]
    #[clap(long = "channel", conflicts_with = "change", conflicts_with = "state")]
  • replacement in pijul/src/commands/fork.rs at line 21
    [4.2431][4.168193:168250](),[4.3476][4.168193:168250](),[4.168193][4.168193:168250]()
    #[clap(long = "change", conflicts_with = "channel")]
    [4.2431]
    [4.168250]
    #[clap(long = "change", conflicts_with = "channel", conflicts_with = "state")]
  • replacement in pijul/src/commands/fork.rs at line 38
    [4.168764][4.15692:15753](),[4.15753][3.860:914](),[3.914][4.15804:15834](),[4.15804][4.15804:15834](),[4.15834][4.2740:2825](),[4.168764][4.2740:2825]()
    let cur = txn
    .current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string();
    let channel_name = if let Some(ref c) = self.channel {
    c
    [4.168764]
    [4.2825]
    let mut fork = if let Some(ref channel_name) = self.channel {
    if let Some(channel) = txn.load_channel(channel_name)? {
    txn.fork(&channel, &self.to)?
    } else {
    anyhow::bail!("Channel not found: {:?}", channel_name);
    }
  • replacement in pijul/src/commands/fork.rs at line 45
    [4.2846][4.15835:15864]()
    cur.as_str()
    [4.2846]
    [4.15864]
    let cur = txn
    .current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string();
    if let Some(channel) = txn.load_channel(&cur)? {
    txn.fork(&channel, &self.to)?
    } else {
    anyhow::bail!("Channel not found: {:?}", cur);
    }
  • replacement in pijul/src/commands/fork.rs at line 55
    [4.15879][4.2958:3028](),[4.2958][4.2958:3028](),[4.3028][4.168919:168966](),[4.17354][4.168919:168966](),[4.168919][4.168919:168966](),[4.168966][2.0:93]()
    if let Some(channel) = txn.load_channel(&channel_name)? {
    txn.fork(&channel, &self.to)?;
    } else {
    anyhow::bail!("Channel not found: {:?}", channel_name);
    [4.15879]
    [4.168966]
    if let Some(ref state) = self.state {
    if let Some(state) = libpijul::Merkle::from_base32(state.as_bytes()) {
    let ch = fork.write();
    if let Some(n) = txn.channel_has_state(&ch.states, &state.into())? {
    let n: u64 = n.into();
    let mut v = Vec::new();
    for l in txn.reverse_log(&ch, None)? {
    let (n_, h) = l?;
    if n_ > n {
    v.push(h.0.into())
    } else {
    break;
    }
    }
    std::mem::drop(ch);
    for h in v {
    txn.unrecord(&repo.changes, &mut fork, &h, 0)?;
    }
    }
    }