Reset: only output changed files

[?]
Jan 10, 2021, 4:27 PM
QMTANHVNRPQ5IX66FYQBFRBDCTN6YKMNCO6OHTQ6QCUASPWWXJKAC

Dependencies

  • [2] GHO6DWPI Refactoring iterators
  • [3] 3KRGVQFU Do not update the mtime of unmodified files
  • [4] QYY37T6Y Fixing a panic with reset --dry-run and no input
  • [5] MU5GSJAW Partial push and pull (WARNING: breaks the existing protocol)
  • [6] Y7YAFMFF Fix path prefix striping on Windows.
  • [7] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [8] WZVCLZKY address clippy lints
  • [9] 76PCXGML Pushing to, and pulling from the local repository
  • [10] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [11] VQPAUKBQ channel switch as an alias to reset
  • [12] WKX5S4Z4 remove unneccesary explicit lifetimes
  • [13] I52XSRUH Massive cleanup, and simplification
  • [14] L4JXJHWX pijul/*: reorganize imports and remove extern crate

Change contents

  • replacement in pijul/src/commands/reset.rs at line 1
    [4.97650][3.557:588]()
    use std::collections::HashMap;
    [4.97650]
    [4.1289]
    use std::collections::{HashMap, HashSet};
  • replacement in pijul/src/commands/reset.rs at line 7
    [4.1330][4.2048:2100]()
    use libpijul::{MutTxnT, MutTxnTExt, TxnT, TxnTExt};
    [4.1330]
    [4.1331]
    use libpijul::pristine::{ChangeId, Position};
    use libpijul::{ChannelTxnT, DepsTxnT, MutTxnT, MutTxnTExt, TxnT, TxnTExt};
  • replacement in pijul/src/commands/reset.rs at line 72
    [4.604][4.727:767](),[4.727][4.727:767](),[4.767][4.767:835](),[4.835][4.2101:2136]()
    if !overwrite_changes {
    // No need to change channel, no need to reset.
    return Ok(());
    [4.604]
    [4.869]
    if overwrite_changes {
    txn.output_repository_no_pending(
    &mut repo.working_copy,
    &repo.changes,
    &mut channel,
    &mut HashMap::new(),
    "",
    true,
    )?;
    txn.commit()?;
  • edit in pijul/src/commands/reset.rs at line 83
    [4.887]
    [4.887]
    return Ok(());
  • edit in pijul/src/commands/reset.rs at line 101
    [4.100549][4.100549:100701]()
    }
    if self.channel.is_some() {
    repo.config.current_channel = self.channel;
    repo.save_config()?;
  • replacement in pijul/src/commands/reset.rs at line 105
    [4.100946][4.100946:101109](),[4.101109][3.589:630](),[3.630][4.101109:101179](),[4.101109][4.101109:101179]()
    txn.output_repository_no_pending(
    &mut repo.working_copy,
    &repo.changes,
    &mut channel,
    &mut HashMap::new(),
    "",
    true,
    )?;
    [4.100946]
    [4.101179]
    let mut inodes = HashSet::new();
    if let Some(cur) = txn.load_channel(current_channel)? {
    let mut changediff = HashSet::new();
    let (a, b, s) = libpijul::pristine::last_common_state(
    &txn,
    &cur.borrow(),
    &channel.borrow(),
    )?;
    debug!("last common state {:?}", s);
    changes_after(&txn, &cur.borrow(), a, &mut changediff, &mut inodes)?;
    changes_after(&txn, &channel.borrow(), b, &mut changediff, &mut inodes)?;
    }
    if self.channel.is_some() {
    repo.config.current_channel = self.channel;
    repo.save_config()?;
    }
    for pos in inodes.iter() {
    let (path, _) = libpijul::fs::find_path(
    &repo.changes,
    &txn,
    &channel.borrow(),
    false,
    *pos,
    )?;
    debug!("resetting {:?}", path);
    txn.output_repository_no_pending(
    &mut repo.working_copy,
    &repo.changes,
    &mut channel,
    &mut HashMap::new(),
    &path,
    true,
    )?;
    }
  • edit in pijul/src/commands/reset.rs at line 165
    [4.101738]
    [4.101738]
    }
    }
    fn changes_after<T: ChannelTxnT + DepsTxnT>(
    txn: &T,
    chan: &T::Channel,
    from: u64,
    changediff: &mut HashSet<ChangeId>,
    inodes: &mut HashSet<Position<ChangeId>>,
    ) -> Result<(), anyhow::Error> {
    for x in libpijul::pristine::changeid_log(txn, chan, from)? {
    let (n, (u, _)) = x?;
    debug!("{:?} {:?} {:?}", n, u, from);
    if n <= from {
    continue;
    }
    if changediff.insert(u) {
    for y in txn.iter_rev_touched_files(u, None)? {
    let (uu, pos) = y?;
    if uu < u {
    continue;
    } else if uu > u {
    break;
    }
    inodes.insert(pos);
    }
    }
  • edit in pijul/src/commands/reset.rs at line 193
    [4.101744]
    [4.101744]
    Ok(())
  • replacement in pijul/src/commands/pushpull.rs at line 312
    [4.13929][4.13929:13990]()
    if txn.channel_has_state(&channel, m)? {
    [4.13929]
    [4.6416]
    if txn.channel_has_state(&channel.borrow(), m)?.is_some() {
  • replacement in pijul/src/commands/pushpull.rs at line 339
    [4.14545][4.14545:14610]()
    if txn.channel_has_state(&channel, m)? {
    [4.14545]
    [4.7403]
    if txn.channel_has_state(&channel.borrow(), m)?.is_some() {
  • edit in libpijul/src/pristine/sanakirja.rs at line 809
    [2.43985]
    [2.43985]
    }
    fn channel_has_state(
    &self,
    channel: &Self::Channel,
    m: Merkle,
    ) -> Result<Option<u64>, TxnErr<Self::GraphError>> {
    Ok(self.txn.get(&channel.states, m, None)?)
  • edit in libpijul/src/pristine/sanakirja.rs at line 1302
    [4.556904][4.49759:49976](),[4.49976][4.558202:558208](),[4.558202][4.558202:558208]()
    fn channel_has_state(
    &self,
    channel: &ChannelRef<Self>,
    m: Merkle,
    ) -> Result<bool, TxnErr<Self::GraphError>> {
    Ok(self.txn.get(&channel.borrow().states, m, None)?.is_some())
    }
  • edit in libpijul/src/pristine/mod.rs at line 222
    [2.51831]
    [2.51831]
    fn channel_has_state(
    &self,
    channel: &Self::Channel,
    hash: Merkle,
    ) -> Result<Option<u64>, TxnErr<Self::GraphError>>;
  • edit in libpijul/src/pristine/mod.rs at line 427
    [4.59897][4.59897:60045]()
    hash: Merkle,
    ) -> Result<bool, TxnErr<Self::GraphError>>;
    fn channel_has_state(
    &self,
    channel: &ChannelRef<Self>,
  • replacement in libpijul/src/pristine/mod.rs at line 555
    [4.39866][4.62378:62438]()
    pub(crate) fn changeid_log<'db, 'txn: 'db, T: ChannelTxnT>(
    [4.39578]
    [4.39919]
    pub fn changeid_log<'db, 'txn: 'db, T: ChannelTxnT>(
  • edit in libpijul/src/pristine/mod.rs at line 1634
    [4.55586]
    [4.55586]
    }
    fn first_state_after<T: ChannelTxnT>(txn: &T, c: &T::Channel, pos: u64) -> Result<Option<(u64, Merkle)>, TxnErr<T::GraphError>> {
    for x in T::cursor_revchangeset_ref(txn, T::rev_changes(&c), Some(pos))? {
    let (n, (_, m)) = x?;
    if n >= pos {
    return Ok(Some((n, m)))
    }
    }
    Ok(None)
    }
    fn last_state<T: ChannelTxnT>(txn: &T, c: &T::Channel) -> Result<Option<(u64, Merkle)>, TxnErr<T::GraphError>> {
    if let Some(e) = txn
    .rev_cursor_revchangeset(T::rev_changes(&c), None)?
    .next()
    {
    let (b, (_, state)) = e?;
    Ok(Some((b, state)))
    } else {
    Ok(None)
    }
    }
    /// Find the last state of c1 that is also in c0.
    pub fn last_common_state<T: ChannelTxnT>(txn: &T, c0: &T::Channel, c1: &T::Channel) -> Result<(u64, u64, Merkle), TxnErr<T::GraphError>> {
    let mut a = 0;
    let (mut b, mut state) = if let Some(x) = last_state(txn, c1)? {
    x
    } else {
    return Ok((0, 0, Merkle::zero()))
    };
    if let Some(aa) = txn.channel_has_state(c0, state)? {
    return Ok((aa, b, state))
    }
    let mut aa = 0;
    while a < b {
    let mid = (a+b) / 2;
    let (_, s) = first_state_after(txn, c1, mid)?.unwrap();
    state = s;
    if let Some(aa_) = txn.channel_has_state(c0, state)? {
    aa = aa_;
    a = mid
    } else {
    b = mid
    }
    }
    Ok((aa, a, state))