rust/hg-core/src/dirstate/entry.rs
changeset 48051 98c0408324e6
parent 48043 3e69bef2031a
child 48061 060cd909439f
--- a/rust/hg-core/src/dirstate/entry.rs	Thu Sep 23 15:36:43 2021 +0200
+++ b/rust/hg-core/src/dirstate/entry.rs	Thu Sep 23 18:29:40 2021 +0200
@@ -83,12 +83,7 @@
                         mtime: 0,
                     }
                 } else {
-                    Self {
-                        flags: Flags::WDIR_TRACKED | Flags::P1_TRACKED,
-                        mode,
-                        size,
-                        mtime,
-                    }
+                    Self::new_normal(mode, size, mtime)
                 }
             }
             EntryState::Added => Self::new_added(),
@@ -111,7 +106,7 @@
         }
     }
 
-    fn new_from_p2() -> Self {
+    pub fn new_from_p2() -> Self {
         Self {
             // might be missing P1_TRACKED
             flags: Flags::WDIR_TRACKED | Flags::P2_TRACKED | Flags::CLEAN_P2,
@@ -121,7 +116,7 @@
         }
     }
 
-    fn new_possibly_dirty() -> Self {
+    pub fn new_possibly_dirty() -> Self {
         Self {
             flags: Flags::WDIR_TRACKED
                 | Flags::P1_TRACKED
@@ -132,7 +127,7 @@
         }
     }
 
-    fn new_added() -> Self {
+    pub fn new_added() -> Self {
         Self {
             flags: Flags::WDIR_TRACKED,
             mode: 0,
@@ -141,7 +136,7 @@
         }
     }
 
-    fn new_merged() -> Self {
+    pub fn new_merged() -> Self {
         Self {
             flags: Flags::WDIR_TRACKED
                 | Flags::P1_TRACKED // might not be true because of rename ?
@@ -153,6 +148,15 @@
         }
     }
 
+    pub fn new_normal(mode: i32, size: i32, mtime: i32) -> Self {
+        Self {
+            flags: Flags::WDIR_TRACKED | Flags::P1_TRACKED,
+            mode,
+            size,
+            mtime,
+        }
+    }
+
     /// Creates a new entry in "removed" state.
     ///
     /// `size` is expected to be zero, `SIZE_NON_NORMAL`, or
@@ -161,14 +165,6 @@
         Self::from_v1_data(EntryState::Removed, 0, size, 0)
     }
 
-    /// TODO: refactor `DirstateMap::add_file` to not take a `DirstateEntry`
-    /// parameter and remove this constructor
-    pub fn new_for_add_file(mode: i32, size: i32, mtime: i32) -> Self {
-        // XXX Arbitrary default value since the value is determined later
-        let state = EntryState::Normal;
-        Self::from_v1_data(state, mode, size, mtime)
-    }
-
     pub fn tracked(&self) -> bool {
         self.flags.contains(Flags::WDIR_TRACKED)
     }