rust/hg-cpython/src/dirstate/dirstate_map.rs
changeset 48022 f2a9db29cb2d
parent 48020 1194394510ba
child 48023 357307feaf61
equal deleted inserted replaced
48021:627cd8f33db0 48022:f2a9db29cb2d
   133     def set_v1(&self, path: PyObject, item: PyObject) -> PyResult<PyObject> {
   133     def set_v1(&self, path: PyObject, item: PyObject) -> PyResult<PyObject> {
   134         let f = path.extract::<PyBytes>(py)?;
   134         let f = path.extract::<PyBytes>(py)?;
   135         let filename = HgPath::new(f.data(py));
   135         let filename = HgPath::new(f.data(py));
   136         let state = item.getattr(py, "state")?.extract::<PyBytes>(py)?;
   136         let state = item.getattr(py, "state")?.extract::<PyBytes>(py)?;
   137         let state = state.data(py)[0];
   137         let state = state.data(py)[0];
   138         let entry = DirstateEntry {
   138         let entry = DirstateEntry::from_v1_data(
   139             state: state.try_into().expect("state is always valid"),
   139             state.try_into().expect("state is always valid"),
   140             mtime: item.getattr(py, "mtime")?.extract(py)?,
   140             item.getattr(py, "mode")?.extract(py)?,
   141             size: item.getattr(py, "size")?.extract(py)?,
   141             item.getattr(py, "size")?.extract(py)?,
   142             mode: item.getattr(py, "mode")?.extract(py)?,
   142             item.getattr(py, "mtime")?.extract(py)?,
   143         };
   143         );
   144         self.inner(py).borrow_mut().set_v1(filename, entry);
   144         self.inner(py).borrow_mut().set_v1(filename, entry);
   145         Ok(py.None())
   145         Ok(py.None())
   146     }
   146     }
   147 
   147 
   148     def addfile(
   148     def addfile(
   174             // fallback default value
   174             // fallback default value
   175             MTIME_UNSET
   175             MTIME_UNSET
   176         } else {
   176         } else {
   177             mtime.extract(py)?
   177             mtime.extract(py)?
   178         };
   178         };
   179         let entry = DirstateEntry {
   179         let entry = DirstateEntry::new_for_add_file(mode, size, mtime);
   180             // XXX Arbitrary default value since the value is determined later
       
   181             state: EntryState::Normal,
       
   182             mode: mode,
       
   183             size: size,
       
   184             mtime: mtime,
       
   185         };
       
   186         let added = added.extract::<PyBool>(py)?.is_true();
   180         let added = added.extract::<PyBool>(py)?.is_true();
   187         let merged = merged.extract::<PyBool>(py)?.is_true();
   181         let merged = merged.extract::<PyBool>(py)?.is_true();
   188         let from_p2 = from_p2.extract::<PyBool>(py)?.is_true();
   182         let from_p2 = from_p2.extract::<PyBool>(py)?.is_true();
   189         let possibly_dirty = possibly_dirty.extract::<PyBool>(py)?.is_true();
   183         let possibly_dirty = possibly_dirty.extract::<PyBool>(py)?.is_true();
   190         self.inner(py).borrow_mut().add_file(
   184         self.inner(py).borrow_mut().add_file(
   420 
   414 
   421     def filefoldmapasdict(&self) -> PyResult<PyDict> {
   415     def filefoldmapasdict(&self) -> PyResult<PyDict> {
   422         let dict = PyDict::new(py);
   416         let dict = PyDict::new(py);
   423         for item in self.inner(py).borrow_mut().iter() {
   417         for item in self.inner(py).borrow_mut().iter() {
   424             let (path, entry) = item.map_err(|e| v2_error(py, e))?;
   418             let (path, entry) = item.map_err(|e| v2_error(py, e))?;
   425             if entry.state != EntryState::Removed {
   419             if entry.state() != EntryState::Removed {
   426                 let key = normalize_case(path);
   420                 let key = normalize_case(path);
   427                 let value = path;
   421                 let value = path;
   428                 dict.set_item(
   422                 dict.set_item(
   429                     py,
   423                     py,
   430                     PyBytes::new(py, key.as_bytes()).into_object(),
   424                     PyBytes::new(py, key.as_bytes()).into_object(),