Adding a "Sink" working copy and avoid outputting ignored files

pmeunier
Oct 12, 2022, 11:40 AM
4UY2WBBPAJUJRRI2S2OGO3R4NQRF6AIXKKAYPMPFYAU274JQYSEQC

Dependencies

  • [2] G55Y75FU Avoiding deadlocks when using output.rs with a non-filesystem output
  • [3] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [4] 2VXTRPO4 Custom diff separators
  • [5] G7VOM2IM Returning an error when recording non-existent paths
  • [*] 7KNPYIDU Splitting the WorkingCopy trait into a read-only record and a read/write output
  • [*] LPM4PBYJ More precise API for working copy in record and output
  • [*] ZDK3GNDB Tag transactions (including a massive refactoring of errors)

Change contents

  • edit in libpijul/src/working_copy/mod.rs at line 40
    [7.71]
    [7.71]
    fn is_writable(&self, _path: &str) -> Result<bool, Self::Error> {
    Ok(true)
    }
  • edit in libpijul/src/working_copy/mod.rs at line 50
    [8.135]
    [7.488]
    }
    #[derive(Clone)]
    pub struct Sink {}
    pub fn sink() -> Sink {
    Sink {}
    }
    impl WorkingCopyRead for Sink {
    type Error = std::io::Error;
    fn file_metadata(&self, _file: &str) -> Result<InodeMetadata, Self::Error> {
    panic!("file_metadata not implemented: {:?}", _file)
    }
    fn read_file(&self, _file: &str, _buffer: &mut Vec<u8>) -> Result<(), Self::Error> {
    panic!("read_file not implemented: {:?}", _file)
    }
    fn modified_time(&self, _file: &str) -> Result<std::time::SystemTime, Self::Error> {
    panic!("modified_time not implemented: {:?}", _file)
    }
  • edit in libpijul/src/working_copy/mod.rs at line 71
    [7.490]
    impl WorkingCopy for Sink {
    fn is_writable(&self, _path: &str) -> Result<bool, Self::Error> {
    Ok(false)
    }
    fn create_dir_all(&self, _path: &str) -> Result<(), Self::Error> {
    Ok(())
    }
    fn remove_path(&self, _name: &str, _rec: bool) -> Result<(), Self::Error> {
    Ok(())
    }
    fn rename(&self, _former: &str, _new: &str) -> Result<(), Self::Error> {
    Ok(())
    }
    fn set_permissions(&self, _name: &str, _permissions: u16) -> Result<(), Self::Error> {
    Ok(())
    }
    type Writer = std::io::Sink;
    fn write_file(&self, _file: &str, _inode: Inode) -> Result<Self::Writer, Self::Error> {
    Ok(std::io::sink())
    }
    }
  • replacement in libpijul/src/working_copy/filesystem.rs at line 347
    [3.682][3.682:697]()
    1,
    [3.682]
    [3.697]
    threads,
  • edit in libpijul/src/output/output.rs at line 729
    [9.26099]
    [2.0]
    if !repo.is_writable(path).map_err(OutputError::WorkingCopy)? {
    return Ok(());
    }