Recording a prefix we just deleted (mostly useful in `pijul git`, regular records returned NotFound)

pmeunier
Dec 6, 2021, 9:05 PM
LOJL4HMYG7EOVZ5MSMCORDLDSRHWO2JPHMOTLMLQA7GPJNSVDXOQC

Dependencies

  • [2] Z7J55B4P Fix the concatenation of repository root and file when recording
  • [3] HSEYMLO2 Adding an untracked change iterator
  • [4] I24UEJQL Various post-fire fixes
  • [5] 4OCC6D42 Recursive add
  • [6] G7VOM2IM Returning an error when recording non-existent paths
  • [7] 2RXOCWUW Making libpijul deterministic (and getting rid of `rand`)
  • [8] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [9] VO5OQW4W Removing anyhow in libpijul
  • [10] ZHABNS3S Canonicalize all paths
  • [*] A3DMBJJA Upgrading the `git` subcommand to the latest Sanakirja and Libpijul

Change contents

  • edit in pijul/src/commands/git.rs at line 506
    [4.153092]
    [4.153092]
    } else {
    *reset_was_useful_.borrow_mut() = true
  • edit in pijul/src/commands/git.rs at line 737
    [12.1006]
    [4.160829]
    debug!("record_apply {:?}", prefixes);
  • edit in pijul/src/commands/file_operations.rs at line 143
    [4.87]
    [4.87]
    let full = CanonicalPathBuf::new(&full)?;
  • replacement in libpijul/src/working_copy/filesystem.rs at line 45
    [4.209129][4.1270:1309]()
    repo_path: Option<&CanonicalPath>,
    [4.209129]
    [4.209159]
    repo_path: Option<&Path>,
  • replacement in libpijul/src/working_copy/filesystem.rs at line 47
    [4.209178][4.1310:1384]()
    ) -> Result<(canonical_path::CanonicalPathBuf, String), std::io::Error> {
    [4.209178]
    [4.209226]
    ) -> Result<(PathBuf, String), std::io::Error> {
  • replacement in libpijul/src/working_copy/filesystem.rs at line 50
    [4.209304][4.1385:1413]()
    Cow::Borrowed(repo)
    [4.209304]
    [4.209341]
    Cow::Borrowed(repo.into())
  • replacement in libpijul/src/working_copy/filesystem.rs at line 52
    [4.209354][4.1414:1531]()
    Cow::Owned(canonical_path::CanonicalPathBuf::canonicalize(
    std::env::current_dir()?,
    )?)
    [4.209354]
    [4.209387]
    Cow::Owned(std::env::current_dir()?)
  • replacement in libpijul/src/working_copy/filesystem.rs at line 55
    [2.50][2.50:132]()
    let prefix_ = CanonicalPathBuf::canonicalize(&repo.as_path().join(&prefix))?;
    [2.50]
    [4.209577]
    let repo_prefix = &repo.join(&prefix);
    let prefix_ = if let Ok(x) = repo_prefix.canonicalize() {
    x
    } else {
    let mut p = PathBuf::new();
    for c in repo_prefix.components() {
    use std::path::Component;
    match c {
    Component::Prefix(_) => p.push(c.as_os_str()),
    Component::RootDir => p.push(c.as_os_str()),
    Component::CurDir => {},
    Component::ParentDir => { p.pop(); },
    Component::Normal(x) => p.push(x),
    }
    }
    p
    };
  • replacement in libpijul/src/working_copy/filesystem.rs at line 73
    [4.209617][4.1572:1645]()
    if let Ok(prefix) = prefix_.as_path().strip_prefix(repo.as_path()) {
    [4.209617]
    [4.209670]
    if let Ok(prefix) = prefix_.as_path().strip_prefix(repo) {
  • replacement in libpijul/src/working_copy/filesystem.rs at line 295
    [4.390][3.4612:5018]()
    {
    let path = if let Ok(path) = full.as_path().strip_prefix(&repo_path.as_path()) {
    path
    } else {
    return Ok(());
    };
    use path_slash::PathExt;
    let path_str = path.to_slash_lossy();
    if !txn.read().is_tracked(&path_str)? {
    self.add_prefix_rec(&txn, repo_path, full, threads, salt)?;
    [4.390]
    [3.5018]
    if let Ok(full) = CanonicalPathBuf::canonicalize(&full) {
    if let Ok(path) = full.as_path().strip_prefix(&repo_path.as_path()) {
    use path_slash::PathExt;
    let path_str = path.to_slash_lossy();
    if !txn.read().is_tracked(&path_str)? {
    self.add_prefix_rec(&txn, repo_path, full, threads, salt)?;
    }