Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-cpython/src/parsers.rs @ 47115: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 | 98a455a62699 |
children | 3b9914b28133 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/parsers.rs Tue Apr 06 21:07:12 2021 +0200 +++ b/rust/hg-cpython/src/parsers.rs Mon Apr 12 14:43:45 2021 +0200 @@ -14,13 +14,13 @@ PythonObject, ToPyObject, }; use hg::{ - pack_dirstate, parse_dirstate, utils::hg_path::HgPathBuf, DirstateEntry, - DirstateParents, FastHashMap, PARENT_SIZE, + dirstate::parsers::Timestamp, pack_dirstate, parse_dirstate, + utils::hg_path::HgPathBuf, DirstateEntry, DirstateParents, FastHashMap, + PARENT_SIZE, }; use std::convert::TryInto; use crate::dirstate::{extract_dirstate, make_dirstate_tuple}; -use std::time::Duration; fn parse_dirstate_wrapper( py: Python, @@ -98,7 +98,7 @@ p1: p1.try_into().unwrap(), p2: p2.try_into().unwrap(), }, - Duration::from_secs(now.as_object().extract::<u64>(py)?), + Timestamp(now.as_object().extract::<u64>(py)?), ) { Ok(packed) => { for (filename, entry) in dirstate_map.iter() {