reset: Require --force to reset unspecified unrecorded changes

spacefrogg
Jun 16, 2022, 9:07 PM
IP4CUEBEHNVTHTLRBXH27TDN6H5GA34GMR6LWY2GGHWGF6LW24CQC

Dependencies

  • [2] OY3CGEHQ Early stop in the diff algorithms for diff --short
  • [3] VNBLGT6G Do not output unmodified files when resetting (fix)
  • [4] 5OGOE4VW Store the current channel in the pristine
  • [5] QYY37T6Y Fixing a panic with reset --dry-run and no input
  • [6] QV66H4YA Prevent --channel from being used with a single file in `pijul reset`
  • [7] I52XSRUH Massive cleanup, and simplification
  • [8] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [9] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [10] QMTANHVN Reset: only output changed files
  • [11] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [12] I24UEJQL Various post-fire fixes
  • [13] Y7YAFMFF Fix path prefix striping on Windows.
  • [14] L4JXJHWX pijul/*: reorganize imports and remove extern crate

Change contents

  • replacement in pijul/src/commands/reset.rs at line 7
    [3.303][3.0:62](),[3.1330][3.0:62](),[3.62][3.6290:6353]()
    use libpijul::pristine::{ChangeId, ChannelMutTxnT, Position};
    use libpijul::{ChannelTxnT, DepsTxnT, MutTxnT, TxnT, TxnTExt};
    [3.303]
    [3.6353]
    use libpijul::pristine::{sanakirja::MutTxn, ChangeId, ChannelMutTxnT, Position};
    use libpijul::{ArcTxn, ChannelRef, ChannelTxnT, DepsTxnT, MutTxnT, TxnT, TxnTExt};
  • replacement in pijul/src/commands/reset.rs at line 112
    [3.7517][3.7517:7696](),[3.7696][2.16:43](),[2.43][3.330:380](),[3.7696][3.330:380](),[3.380][3.7696:7733](),[3.7696][3.7696:7733](),[3.7733][3.3955:3995](),[3.3995][3.7780:8038](),[3.7780][3.7780:8038]()
    let mut state = libpijul::RecordBuilder::new();
    state.record(
    txn.clone(),
    libpijul::Algorithm::default(),
    false,
    &libpijul::DEFAULT_SEPARATOR,
    channel.clone(),
    &repo.working_copy,
    &repo.changes,
    "",
    num_cpus::get(),
    )?;
    let rec = state.finish();
    debug!("actions = {:?}", rec.actions);
    if !rec.actions.is_empty() {
    [3.7517]
    [3.8038]
    if has_unrecorded_changes(txn.clone(), channel.clone(), &repo).unwrap() {
  • edit in pijul/src/commands/reset.rs at line 123
    [3.4079]
    [3.8400]
    if !self.force && has_unrecorded_changes(txn.clone(), channel.clone(), &repo).unwrap() {
    bail!("Refusing to reset, as there are unrecorded changes. Use --force")
    }
  • edit in pijul/src/commands/reset.rs at line 283
    [3.101746]
    fn has_unrecorded_changes(txn: ArcTxn<MutTxn<()>>,
    channel: ChannelRef<MutTxn<()>>,
    repo: &Repository) -> Result<bool, anyhow::Error> {
    let mut state = libpijul::RecordBuilder::new();
    state.record(
    txn,
    libpijul::Algorithm::default(),
    false,
    &libpijul::DEFAULT_SEPARATOR,
    channel,
    &repo.working_copy,
    &repo.changes,
    "",
    num_cpus::get(),
    )?;
    let rec = state.finish();
    debug!("actions = {:?}", rec.actions);
    Ok(!rec.actions.is_empty())
    }