Making the get_latest_touch function (useful to make archives) public in libpijul

[?]
Jan 11, 2021, 4:34 PM
27PYHR6LO4M4RMSMLVMUKSYNQ72V6RRMRXLYQI3JA3LBHJO747YAC

Dependencies

  • [2] BONBSXAU Archive mtimes: optimal complexity in all cases
  • [3] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [4] I3OVP3NH Archive: set the accurate and deterministic mtime
  • [5] GHO6DWPI Refactoring iterators
  • [6] VO5OQW4W Removing anyhow in libpijul
  • [7] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump

Change contents

  • replacement in libpijul/src/output/archive.rs at line 191
    [3.694891][2.0:95]()
    let latest_touch = get_latest_touch(changes, txn, &channel, output_item.pos)?;
    [3.694891]
    [3.694891]
    let (_, latest_touch) =
    crate::fs::get_latest_touch(txn, &channel, output_item.pos)?;
    let latest_touch = {
    let ext = txn.get_external(latest_touch)?.unwrap();
    let c = changes.get_header(&ext).map_err(ArchiveError::P)?;
    c.timestamp.timestamp() as u64
    };
  • edit in libpijul/src/output/archive.rs at line 241
    [3.696436][3.696436:696438](),[3.696438][2.96:2007]()
    }
    fn get_latest_touch<
    'a,
    T: ChannelTxnT + DepsTxnT<DepsError = <T as GraphTxnT>::GraphError>,
    P: ChangeStore,
    A: std::error::Error + 'static,
    >(
    changes: &P,
    txn: &T,
    channel: &T::Channel,
    pos: Position<ChangeId>,
    ) -> Result<u64, ArchiveError<P::Error, T::GraphError, A>> {
    let mut latest_touch = 0;
    let mut latest_change = 0;
    let mut touch_iter = Some(txn.iter_touched(pos)?);
    let mut log_iter = changeid_rev_log(txn, &channel, None)?;
    let mut continue_ = true;
    while continue_ {
    continue_ = false;
    if let Some(ref mut it) = touch_iter {
    if let Some(c) = it.next() {
    debug!("inode, change = {:?}", c);
    let (inode, change) = c?;
    if inode > pos {
    touch_iter = None;
    } else if inode == pos {
    if let Some(t) = txn.get_changeset(T::changes(&channel), change)? {
    if t > latest_change || latest_touch == 0 {
    latest_change = t;
    let ext = txn.get_external(change)?.unwrap();
    let c = changes.get_header(&ext).map_err(ArchiveError::P)?;
    latest_touch = c.timestamp.timestamp() as u64
    }
    }
    continue_ = true;
    }
    }
    }
    if let Some(l) = log_iter.next() {
    debug!("int = {:?}", l);
    let (_, (int, _)) = l?;
    if txn.get_touched_files(pos, Some(int))?.is_some() {
    let ext = txn.get_external(int)?.unwrap();
    let c = changes.get_header(&ext).map_err(ArchiveError::P)?;
    latest_touch = c.timestamp.timestamp() as u64;
    break;
    }
    continue_ = true;
    }
    }
    Ok(latest_touch)
  • replacement in libpijul/src/fs.rs at line 570
    [3.752701][3.109396:109480]()
    type Item = Result<(Position<ChangeId>, InodeMetadata, String), T::GraphError>;
    [3.752701]
    [3.752762]
    type Item = Result<(Position<ChangeId>, ChangeId, InodeMetadata, String), T::GraphError>;
  • replacement in libpijul/src/fs.rs at line 600
    [3.110553][3.110553:110618]()
    Some(Ok((grandchild.dest, perms, basename.to_string())))
    [3.110553]
    [3.753751]
    Some(Ok((
    grandchild.dest,
    grandchild.introduced_by,
    perms,
    basename.to_string(),
    )))
  • edit in libpijul/src/fs.rs at line 886
    [3.763287]
    [3.763287]
    }
    pub fn get_latest_touch<'a, T: ChannelTxnT + DepsTxnT<DepsError = <T as GraphTxnT>::GraphError>>(
    txn: &T,
    channel: &T::Channel,
    pos: Position<ChangeId>,
    ) -> Result<(u64, ChangeId), TxnErr<T::GraphError>> {
    let mut latest_change = 0;
    let mut id = ChangeId::ROOT;
    let mut touch_iter = Some(txn.iter_touched(pos)?);
    let mut log_iter = changeid_rev_log(txn, &channel, None)?;
    let mut continue_ = true;
    while continue_ {
    continue_ = false;
    if let Some(ref mut it) = touch_iter {
    if let Some(c) = it.next() {
    debug!("inode, change = {:?}", c);
    let (inode, change) = c?;
    if inode > pos {
    touch_iter = None;
    } else if inode == pos {
    if let Some(t) = txn.get_changeset(T::changes(&channel), change)? {
    if t >= latest_change {
    latest_change = t;
    id = change;
    }
    }
    continue_ = true;
    }
    }
    }
    if let Some(l) = log_iter.next() {
    debug!("int = {:?}", l);
    let (n, (int, _)) = l?;
    if txn.get_touched_files(pos, Some(int))?.is_some() {
    id = int;
    latest_change = n;
    break;
    }
    continue_ = true;
    }
    }
    Ok((latest_change, id))