Show More
@@ -5,6 +5,7 | |||
|
5 | 5 | // This software may be used and distributed according to the terms of the |
|
6 | 6 | // GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | use crate::dirstate::parsers::Timestamp; | |
|
8 | 9 | use crate::errors::HgError; |
|
9 | 10 | use crate::revlog::node::NULL_NODE; |
|
10 | 11 | use crate::{ |
@@ -22,7 +23,6 use std::collections::HashSet; | |||
|
22 | 23 | use std::convert::TryInto; |
|
23 | 24 | use std::iter::FromIterator; |
|
24 | 25 | use std::ops::Deref; |
|
25 | use std::time::Duration; | |
|
26 | 26 | |
|
27 | 27 | pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; |
|
28 | 28 | |
@@ -389,7 +389,7 impl DirstateMap { | |||
|
389 | 389 | pub fn pack( |
|
390 | 390 | &mut self, |
|
391 | 391 | parents: DirstateParents, |
|
392 |
now: |
|
|
392 | now: Timestamp, | |
|
393 | 393 | ) -> Result<Vec<u8>, DirstateError> { |
|
394 | 394 | let packed = |
|
395 | 395 | pack_dirstate(&mut self.state_map, &self.copy_map, parents, now)?; |
@@ -13,7 +13,6 use byteorder::{BigEndian, WriteBytesExt | |||
|
13 | 13 | use bytes_cast::BytesCast; |
|
14 | 14 | use micro_timer::timed; |
|
15 | 15 | use std::convert::{TryFrom, TryInto}; |
|
16 | use std::time::Duration; | |
|
17 | 16 | |
|
18 | 17 | /// Parents are stored in the dirstate as byte hashes. |
|
19 | 18 | pub const PARENT_SIZE: usize = 20; |
@@ -83,15 +82,17 pub fn parse_dirstate_entries<'a>( | |||
|
83 | 82 | Ok(parents) |
|
84 | 83 | } |
|
85 | 84 | |
|
86 |
/// |
|
|
85 | /// Seconds since the Unix epoch | |
|
86 | pub struct Timestamp(pub u64); | |
|
87 | ||
|
87 | 88 | pub fn pack_dirstate( |
|
88 | 89 | state_map: &mut StateMap, |
|
89 | 90 | copy_map: &CopyMap, |
|
90 | 91 | parents: DirstateParents, |
|
91 | now: Duration, | |
|
92 | now: Timestamp, | |
|
92 | 93 | ) -> Result<Vec<u8>, HgError> { |
|
93 | 94 | // TODO move away from i32 before 2038. |
|
94 |
let now: i32 = now. |
|
|
95 | let now: i32 = now.0.try_into().expect("time overflow"); | |
|
95 | 96 | |
|
96 | 97 | let expected_size: usize = state_map |
|
97 | 98 | .iter() |
@@ -171,7 +172,7 mod tests { | |||
|
171 | 172 | p1: b"12345678910111213141".into(), |
|
172 | 173 | p2: b"00000000000000000000".into(), |
|
173 | 174 | }; |
|
174 |
let now = |
|
|
175 | let now = Timestamp(15000000); | |
|
175 | 176 | let expected = b"1234567891011121314100000000000000000000".to_vec(); |
|
176 | 177 | |
|
177 | 178 | assert_eq!( |
@@ -202,7 +203,7 mod tests { | |||
|
202 | 203 | p1: b"12345678910111213141".into(), |
|
203 | 204 | p2: b"00000000000000000000".into(), |
|
204 | 205 | }; |
|
205 |
let now = |
|
|
206 | let now = Timestamp(15000000); | |
|
206 | 207 | let expected = [ |
|
207 | 208 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 49, 48, 49, 49, 49, 50, 49, |
|
208 | 209 | 51, 49, 52, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, |
@@ -242,7 +243,7 mod tests { | |||
|
242 | 243 | p1: b"12345678910111213141".into(), |
|
243 | 244 | p2: b"00000000000000000000".into(), |
|
244 | 245 | }; |
|
245 |
let now = |
|
|
246 | let now = Timestamp(15000000); | |
|
246 | 247 | let expected = [ |
|
247 | 248 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 49, 48, 49, 49, 49, 50, 49, |
|
248 | 249 | 51, 49, 52, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, |
@@ -282,7 +283,7 mod tests { | |||
|
282 | 283 | p1: b"12345678910111213141".into(), |
|
283 | 284 | p2: b"00000000000000000000".into(), |
|
284 | 285 | }; |
|
285 |
let now = |
|
|
286 | let now = Timestamp(15000000); | |
|
286 | 287 | let result = |
|
287 | 288 | pack_dirstate(&mut state_map, ©map, parents.clone(), now) |
|
288 | 289 | .unwrap(); |
@@ -360,7 +361,7 mod tests { | |||
|
360 | 361 | p1: b"12345678910111213141".into(), |
|
361 | 362 | p2: b"00000000000000000000".into(), |
|
362 | 363 | }; |
|
363 |
let now = |
|
|
364 | let now = Timestamp(15000000); | |
|
364 | 365 | let result = |
|
365 | 366 | pack_dirstate(&mut state_map, ©map, parents.clone(), now) |
|
366 | 367 | .unwrap(); |
@@ -406,7 +407,7 mod tests { | |||
|
406 | 407 | p1: b"12345678910111213141".into(), |
|
407 | 408 | p2: b"00000000000000000000".into(), |
|
408 | 409 | }; |
|
409 |
let now = |
|
|
410 | let now = Timestamp(15000000); | |
|
410 | 411 | let result = |
|
411 | 412 | pack_dirstate(&mut state_map, ©map, parents.clone(), now) |
|
412 | 413 | .unwrap(); |
@@ -1,10 +1,10 | |||
|
1 | 1 | use std::collections::BTreeMap; |
|
2 | 2 | use std::path::PathBuf; |
|
3 | use std::time::Duration; | |
|
4 | 3 | |
|
5 | 4 | use super::path_with_basename::WithBasename; |
|
6 | 5 | use crate::dirstate::parsers::parse_dirstate_entries; |
|
7 | 6 | use crate::dirstate::parsers::parse_dirstate_parents; |
|
7 | use crate::dirstate::parsers::Timestamp; | |
|
8 | 8 | |
|
9 | 9 | use crate::matchers::Matcher; |
|
10 | 10 | use crate::revlog::node::NULL_NODE; |
@@ -328,7 +328,7 impl super::dispatch::DirstateMapMethods | |||
|
328 | 328 | fn pack( |
|
329 | 329 | &mut self, |
|
330 | 330 | _parents: DirstateParents, |
|
331 |
_now: |
|
|
331 | _now: Timestamp, | |
|
332 | 332 | ) -> Result<Vec<u8>, DirstateError> { |
|
333 | 333 | let _ = self.iter_node_data_mut(); |
|
334 | 334 | todo!() |
@@ -1,6 +1,6 | |||
|
1 | 1 | use std::path::PathBuf; |
|
2 | use std::time::Duration; | |
|
3 | 2 | |
|
3 | use crate::dirstate::parsers::Timestamp; | |
|
4 | 4 | use crate::matchers::Matcher; |
|
5 | 5 | use crate::utils::hg_path::{HgPath, HgPathBuf}; |
|
6 | 6 | use crate::CopyMapIter; |
@@ -90,7 +90,7 pub trait DirstateMapMethods { | |||
|
90 | 90 | fn pack( |
|
91 | 91 | &mut self, |
|
92 | 92 | parents: DirstateParents, |
|
93 |
now: |
|
|
93 | now: Timestamp, | |
|
94 | 94 | ) -> Result<Vec<u8>, DirstateError>; |
|
95 | 95 | |
|
96 | 96 | fn build_file_fold_map(&mut self) -> &FastHashMap<HgPathBuf, HgPathBuf>; |
@@ -254,7 +254,7 impl DirstateMapMethods for DirstateMap | |||
|
254 | 254 | fn pack( |
|
255 | 255 | &mut self, |
|
256 | 256 | parents: DirstateParents, |
|
257 |
now: |
|
|
257 | now: Timestamp, | |
|
258 | 258 | ) -> Result<Vec<u8>, DirstateError> { |
|
259 | 259 | self.pack(parents, now) |
|
260 | 260 | } |
@@ -8,7 +8,7 mod ancestors; | |||
|
8 | 8 | pub mod dagops; |
|
9 | 9 | pub mod errors; |
|
10 | 10 | pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors}; |
|
11 | mod dirstate; | |
|
11 | pub mod dirstate; | |
|
12 | 12 | pub mod dirstate_tree; |
|
13 | 13 | pub mod discovery; |
|
14 | 14 | pub mod requirements; |
@@ -10,7 +10,6 | |||
|
10 | 10 | |
|
11 | 11 | use std::cell::{Ref, RefCell}; |
|
12 | 12 | use std::convert::TryInto; |
|
13 | use std::time::Duration; | |
|
14 | 13 | |
|
15 | 14 | use cpython::{ |
|
16 | 15 | exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, |
@@ -27,6 +26,7 use crate::{ | |||
|
27 | 26 | parsers::dirstate_parents_to_pytuple, |
|
28 | 27 | }; |
|
29 | 28 | use hg::{ |
|
29 | dirstate::parsers::Timestamp, | |
|
30 | 30 | dirstate_tree::dispatch::DirstateMapMethods, |
|
31 | 31 | errors::HgError, |
|
32 | 32 | revlog::Node, |
@@ -312,7 +312,7 py_class!(pub class DirstateMap |py| { | |||
|
312 | 312 | p2: PyObject, |
|
313 | 313 | now: PyObject |
|
314 | 314 | ) -> PyResult<PyBytes> { |
|
315 |
let now = |
|
|
315 | let now = Timestamp(now.extract(py)?); | |
|
316 | 316 | let parents = DirstateParents { |
|
317 | 317 | p1: extract_node_id(py, &p1)?, |
|
318 | 318 | p2: extract_node_id(py, &p2)?, |
@@ -14,13 +14,13 use cpython::{ | |||
|
14 | 14 | PythonObject, ToPyObject, |
|
15 | 15 | }; |
|
16 | 16 | use hg::{ |
|
17 | pack_dirstate, parse_dirstate, utils::hg_path::HgPathBuf, DirstateEntry, | |
|
18 | DirstateParents, FastHashMap, PARENT_SIZE, | |
|
17 | dirstate::parsers::Timestamp, pack_dirstate, parse_dirstate, | |
|
18 | utils::hg_path::HgPathBuf, DirstateEntry, DirstateParents, FastHashMap, | |
|
19 | PARENT_SIZE, | |
|
19 | 20 | }; |
|
20 | 21 | use std::convert::TryInto; |
|
21 | 22 | |
|
22 | 23 | use crate::dirstate::{extract_dirstate, make_dirstate_tuple}; |
|
23 | use std::time::Duration; | |
|
24 | 24 | |
|
25 | 25 | fn parse_dirstate_wrapper( |
|
26 | 26 | py: Python, |
@@ -98,7 +98,7 fn pack_dirstate_wrapper( | |||
|
98 | 98 | p1: p1.try_into().unwrap(), |
|
99 | 99 | p2: p2.try_into().unwrap(), |
|
100 | 100 | }, |
|
101 |
|
|
|
101 | Timestamp(now.as_object().extract::<u64>(py)?), | |
|
102 | 102 | ) { |
|
103 | 103 | Ok(packed) => { |
|
104 | 104 | for (filename, entry) in dirstate_map.iter() { |
General Comments 0
You need to be logged in to leave comments.
Login now