diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 47101:5d62243c7732

rust: Add a Timestamp struct instead of abusing Duration `SystemTime` would be the standard library type semantically appropriate instead of `Duration`. But since the value is coming from Python as a plain integer and used in dirstate packing code as an integer, let’s make a type that contains a single integer instead of using one with sub-second precision. Differential Revision: https://phab.mercurial-scm.org/D10485
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 12 Apr 2021 14:43:45 +0200
parents 473abf4728bf
children 33e5511b571a
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Tue Apr 06 21:07:12 2021 +0200
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Mon Apr 12 14:43:45 2021 +0200
@@ -10,7 +10,6 @@
 
 use std::cell::{Ref, RefCell};
 use std::convert::TryInto;
-use std::time::Duration;
 
 use cpython::{
     exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList,
@@ -27,6 +26,7 @@
     parsers::dirstate_parents_to_pytuple,
 };
 use hg::{
+    dirstate::parsers::Timestamp,
     dirstate_tree::dispatch::DirstateMapMethods,
     errors::HgError,
     revlog::Node,
@@ -312,7 +312,7 @@
         p2: PyObject,
         now: PyObject
     ) -> PyResult<PyBytes> {
-        let now = Duration::new(now.extract(py)?, 0);
+        let now = Timestamp(now.extract(py)?);
         let parents = DirstateParents {
             p1: extract_node_id(py, &p1)?,
             p2: extract_node_id(py, &p2)?,