Checking that `pijul apply` does not destroy unrecorded changes

pmeunier
Feb 24, 2023, 3:58 PM
ISZ65SPQXSDGK6T6VQJJTD54KD3R5GOQ3GIMRALPJU6JPUSHUXMQC

Dependencies

  • [2] C4MJ7D7Q Verbose printing of conflicts to stderr
  • [3] 5NHRJ5PY Cleaner handling of binary changes in the text format
  • [4] YDTN6BGI Touch the channel if no file was changed
  • [5] I24UEJQL Various post-fire fixes
  • [6] I2D35LLF More accurate recording of modification time
  • [7] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [*] F6V27C3M Fixing the "old file optimisation" in record, after the move to parallelisable records
  • [*] 2D7P2VKJ Change completions (where the whole progress bar story started)

Change contents

  • edit in pijul/src/commands/record.rs at line 360
    [9.2840]
    [4.107607]
    }
    if rec.has_binary_files {
    bail!("Cannot record a binary change interactively. Please use -a.")
  • edit in pijul/src/commands/record.rs at line 365
    [4.107617]
    [4.14616]
  • replacement in pijul/src/commands/record.rs at line 419
    [4.109215][3.0:223]()
    if rec.has_binary_files {
    bail!("Cannot record a binary change interactively. Please use -a.")
    } else {
    bail!("Cannot parse change")
    }
    [4.109215]
    [4.109248]
    bail!("Cannot parse change")
  • edit in pijul/src/commands/apply.rs at line 133
    [10.5339]
    [2.3127]
    {
    let mut state = libpijul::RecordBuilder::new();
    if touched_files.is_empty() {
    state.record(
    txn.clone(),
    libpijul::Algorithm::default(),
    false,
    &libpijul::DEFAULT_SEPARATOR,
    channel.clone(),
    &repo.working_copy,
    &repo.changes,
    "",
    num_cpus::get(),
    )?
    } else {
    use canonical_path::CanonicalPathBuf;
    fill_relative_prefixes(&mut touched_files)?;
    repo.working_copy.record_prefixes(
    txn.clone(),
    channel.clone(),
    &repo.changes,
    &mut state,
    CanonicalPathBuf::canonicalize(&repo.path)?,
    &touched_files,
    false,
    num_cpus::get(),
    0,
    )?;
    }
    let rec = state.finish();
    if !rec.actions.is_empty() {
    bail!("Applying this patch would delete unrecorded changes, aborting")
    }
    }
  • edit in pijul/src/commands/apply.rs at line 208
    [4.196352]
    [4.196352]
    }
    }
    fn fill_relative_prefixes(prefixes: &mut [String]) -> Result<Vec<PathBuf>, anyhow::Error> {
    let cwd = std::env::current_dir()?;
    let mut pref = Vec::new();
    for p in prefixes.iter_mut() {
    if std::path::Path::new(p).is_relative() {
    pref.push(cwd.join(&p));
    }
  • edit in pijul/src/commands/apply.rs at line 219
    [4.196358]
    [4.196358]
    Ok(pref)