Splitting the WorkingCopy trait into a read-only record and a read/write output

pmeunier
Sep 9, 2021, 12:25 PM
7KNPYIDUXCBZ65NA74NL2DIFS6STJWN4XXHXLTIV5QXZSVLARJMAC

Dependencies

  • [2] SBSM3VZV Fixing a bug in deletions (the encoding was improperly set)
  • [3] QU6T6J6W Use the change time in addition to the modified time when detecting untouched files (at least on Unix)
  • [4] EAAJNZ3J Make recursive directory removal optional
  • [5] FXEDPLRI Resurrecting tests, and type cleanup (no need for Arc<RwLock<…>> anymore)
  • [6] MOPABMFW Fixing a deadlock in working_copy::memory (used only in tests for now)
  • [7] O4DNWMPD Cleaunp and proofreading of libpijul::record
  • [8] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [9] Q3GU26WD merge with changes from sanakirja v1.1.2
  • [10] 3S6LU2U5 abstract out FileMetadata (de)serialistion
  • [11] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [12] WKX5S4Z4 remove unneccesary explicit lifetimes
  • [13] VO5OQW4W Removing anyhow in libpijul
  • [14] GHO6DWPI Refactoring iterators
  • [15] X7OHUPL5 Fixing a bug in unrecord, and fixing the tests
  • [16] I24UEJQL Various post-fire fixes
  • [17] LERRJNFC Fixing the text change version of "FileMove" to include the former path
  • [18] 4NNR32V6 conflicts
  • [19] ZSF3YFZT encoded file deletion
  • [20] TVVW53HZ Conflict resolution
  • [21] RRCSHAYZ Formatting
  • [22] JP3BYVXX Fixing file paths on Windows
  • [23] FYUDBQ3C Formatting changes + version bump
  • [*] NYOF5766 track file encoding in the record, including change text for file adds

Change contents

  • replacement in ""libpijul/src/working_copy/mod.rs"" at line 14
    [4.198425][4.198425:198449]()
    pub trait WorkingCopy {
    [4.1193]
    [4.24589]
    pub trait WorkingCopyRead {
  • edit in ""libpijul/src/working_copy/mod.rs"" at line 16
    [4.24631][4.24631:24700]()
    fn create_dir_all(&self, path: &str) -> Result<(), Self::Error>;
  • edit in ""libpijul/src/working_copy/mod.rs"" at line 19
    [4.1728][4.0:77](),[4.77][4.24767:25038](),[4.24767][4.24767:25038]()
    fn remove_path(&self, name: &str, rec: bool) -> Result<(), Self::Error>;
    fn rename(&self, former: &str, new: &str) -> Result<(), Self::Error>;
    fn set_permissions(&self, name: &str, permissions: u16) -> Result<(), Self::Error>;
    type Writer: std::io::Write;
    fn write_file(&self, file: &str) -> Result<Self::Writer, Self::Error>;
  • edit in ""libpijul/src/working_copy/mod.rs"" at line 39
    [25.946]
    pub trait WorkingCopy: WorkingCopyRead {
    fn create_dir_all(&self, path: &str) -> Result<(), Self::Error>;
    fn remove_path(&self, name: &str, rec: bool) -> Result<(), Self::Error>;
    fn rename(&self, former: &str, new: &str) -> Result<(), Self::Error>;
    fn set_permissions(&self, name: &str, permissions: u16) -> Result<(), Self::Error>;
    type Writer: std::io::Write;
    fn write_file(&self, file: &str) -> Result<Self::Writer, Self::Error>;
    }
  • replacement in ""libpijul/src/working_copy/memory.rs"" at line 216
    [4.205404][4.205404:205434]()
    impl WorkingCopy for Memory {
    [4.205404]
    [4.2216]
    impl WorkingCopyRead for Memory {
  • edit in ""libpijul/src/working_copy/memory.rs"" at line 218
    [4.2240][4.25842:25912](),[4.25912][4.107:142](),[4.142][4.238:273](),[4.273][4.186:268](),[4.186][4.186:268](),[4.268][4.205553:205680](),[4.25992][4.205553:205680](),[4.205553][4.205553:205680](),[4.205680][4.177:236](),[4.236][4.205739:205780](),[4.205739][4.205739:205780](),[4.205780][4.25993:26047](),[4.26047][4.205830:205959](),[4.205830][4.205830:205959]()
    fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
    let not_already_exists = {
    let m = self.0.lock();
    m.get_file(file).is_none()
    };
    if not_already_exists {
    let last = SystemTime::now();
    self.add_inode(
    file,
    Inode::Directory {
    meta: InodeMetadata::new(0o100, true),
    children: FileTree {
    children: HashMap::default(),
    },
    last_modified: last,
    },
    );
    }
    Ok(())
    }
  • edit in ""libpijul/src/working_copy/memory.rs"" at line 245
    [4.207006]
    [4.207006]
    }
  • edit in ""libpijul/src/working_copy/memory.rs"" at line 247
    [4.207007]
    [4.78]
    impl WorkingCopy for Memory {
    fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
    let not_already_exists = {
    let m = self.0.lock();
    m.get_file(file).is_none()
    };
    if not_already_exists {
    let last = SystemTime::now();
    self.add_inode(
    file,
    Inode::Directory {
    meta: InodeMetadata::new(0o100, true),
    children: FileTree {
    children: HashMap::default(),
    },
    last_modified: last,
    },
    );
    }
    Ok(())
    }
  • replacement in ""libpijul/src/working_copy/filesystem.rs"" at line 311
    [4.213919][4.213919:213953]()
    impl WorkingCopy for FileSystem {
    [4.213919]
    [4.3918]
    impl WorkingCopyRead for FileSystem {
  • edit in ""libpijul/src/working_copy/filesystem.rs"" at line 313
    [4.3951][4.28617:28732](),[4.4025][4.159:214](),[4.28732][4.159:214](),[4.214029][4.159:214](),[4.214][4.214089:214095](),[4.214089][4.214089:214095]()
    fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
    debug!("create_dir_all {:?}", file);
    Ok(std::fs::create_dir_all(&self.path(file))?)
    }
  • edit in ""libpijul/src/working_copy/filesystem.rs"" at line 344
    [3.429]
    [3.429]
    }
  • edit in ""libpijul/src/working_copy/filesystem.rs"" at line 346
    [3.430]
    [4.158]
    impl WorkingCopy for FileSystem {
    fn create_dir_all(&self, file: &str) -> Result<(), Self::Error> {
    debug!("create_dir_all {:?}", file);
    Ok(std::fs::create_dir_all(&self.path(file))?)
    }
  • replacement in ""libpijul/src/record.rs"" at line 8
    [4.489161][4.489161:489199]()
    use crate::working_copy::WorkingCopy;
    [4.489161]
    [4.1477]
    use crate::working_copy::WorkingCopyRead;
  • replacement in ""libpijul/src/record.rs"" at line 276
    [4.44558][4.96492:96548]()
    W: WorkingCopy + Clone + Send + Sync + 'static,
    [4.44558]
    [4.44606]
    W: WorkingCopyRead + Clone + Send + Sync + 'static,
  • replacement in ""libpijul/src/record.rs"" at line 295
    [4.28265][4.32756:32800](),[4.44969][4.32756:32800](),[4.32756][4.32756:32800]()
    <W as WorkingCopy>::Error: 'static,
    [4.44969]
    [4.32800]
    <W as WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 472
    [4.50608][4.50608:50632]()
    W: WorkingCopy,
    [4.50608]
    [4.50632]
    W: WorkingCopyRead,
  • replacement in ""libpijul/src/record.rs"" at line 484
    [4.50908][4.50908:50952]()
    <W as WorkingCopy>::Error: 'static,
    [4.50908]
    [4.50952]
    <W as WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 544
    [4.53464][4.53464:53488]()
    W: WorkingCopy,
    [4.53464]
    [4.53488]
    W: WorkingCopyRead,
  • replacement in ""libpijul/src/record.rs"" at line 559
    [4.53882][4.53882:53947]()
    <W as crate::working_copy::WorkingCopy>::Error: 'static,
    [4.53882]
    [4.53947]
    <W as crate::working_copy::WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 623
    [4.56117][4.56117:56180]()
    fn modified_since_last_commit<T: ChannelTxnT, W: WorkingCopy>(
    [4.56117]
    [4.56180]
    fn modified_since_last_commit<T: ChannelTxnT, W: WorkingCopyRead>(
  • replacement in ""libpijul/src/record.rs"" at line 647
    [4.1][4.495618:495651](),[4.56806][4.495618:495651](),[4.495618][4.495618:495651]()
    fn add_file<W: WorkingCopy>(
    [4.56806]
    [4.495651]
    fn add_file<W: WorkingCopyRead>(
  • replacement in ""libpijul/src/record.rs"" at line 743
    [4.57987][4.98010:98042]()
    W: WorkingCopy + Clone,
    [4.57987]
    [4.33078]
    W: WorkingCopyRead + Clone,
  • replacement in ""libpijul/src/record.rs"" at line 757
    [4.33188][4.33188:33253]()
    <W as crate::working_copy::WorkingCopy>::Error: 'static,
    [4.33188]
    [4.33253]
    <W as crate::working_copy::WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 901
    [4.503333][4.571:645]()
    fn record_moved_file<T: ChannelTxnT, C: ChangeStore, W: WorkingCopy>(
    [4.503333]
    [4.507676]
    fn record_moved_file<T: ChannelTxnT, C: ChangeStore, W: WorkingCopyRead>(
  • replacement in ""libpijul/src/record.rs"" at line 912
    [4.35958][4.35958:36023]()
    <W as crate::working_copy::WorkingCopy>::Error: 'static,
    [4.35958]
    [4.36023]
    <W as crate::working_copy::WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 995
    [4.510763][4.36087:36157]()
    fn collect_moved_edges<T: GraphTxnT, C: ChangeStore, W: WorkingCopy>(
    [4.510763]
    [4.510812]
    fn collect_moved_edges<T: GraphTxnT, C: ChangeStore, W: WorkingCopyRead>(
  • replacement in ""libpijul/src/record.rs"" at line 1005
    [4.36261][4.36261:36322]()
    <W as crate::working_copy::WorkingCopy>::Error: 'static,
    [4.36261]
    [4.36322]
    <W as crate::working_copy::WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 1212
    [4.37258][4.37258:37282]()
    W: WorkingCopy,
    [4.37258]
    [4.2864]
    W: WorkingCopyRead,
  • replacement in ""libpijul/src/record.rs"" at line 1224
    [4.2988][4.2988:3032]()
    <W as WorkingCopy>::Error: 'static,
    [4.2988]
    [4.3032]
    <W as WorkingCopyRead>::Error: 'static,
  • replacement in ""libpijul/src/record.rs"" at line 1301
    [4.521266][2.293:367]()
    fn delete_inode_vertex<T: GraphTxnT, C: ChangeStore, W: WorkingCopy>(
    [4.521266]
    [4.521303]
    fn delete_inode_vertex<T: GraphTxnT, C: ChangeStore, W: WorkingCopyRead>(
  • replacement in ""libpijul/src/record.rs"" at line 1311
    [2.470][2.470:514]()
    <W as WorkingCopy>::Error: 'static,
    [2.470]
    [2.514]
    <W as WorkingCopyRead>::Error: 'static,