Show More
@@ -17,7 +17,7 b' use crate::DirstateEntry;' | |||
|
17 | 17 | use crate::DirstateError; |
|
18 | 18 | use crate::DirstateParents; |
|
19 | 19 | use crate::EntryState; |
|
20 |
use bytes_cast::unaligned::{I32Be, I64Be, U32Be |
|
|
20 | use bytes_cast::unaligned::{I32Be, I64Be, U32Be}; | |
|
21 | 21 | use bytes_cast::BytesCast; |
|
22 | 22 | use std::borrow::Cow; |
|
23 | 23 | use std::convert::TryFrom; |
@@ -135,9 +135,8 b' pub(super) struct Timestamp {' | |||
|
135 | 135 | |
|
136 | 136 | /// Counted in bytes from the start of the file |
|
137 | 137 | /// |
|
138 |
/// NOTE: |
|
|
139 | /// we could save space by using `U32Be` instead. | |
|
140 | type Offset = U64Be; | |
|
138 | /// NOTE: not supporting `.hg/dirstate` files larger than 4 GiB. | |
|
139 | type Offset = U32Be; | |
|
141 | 140 | |
|
142 | 141 | /// Counted in number of items |
|
143 | 142 | /// |
@@ -172,8 +171,8 b' type OptPathSlice = Slice;' | |||
|
172 | 171 | |
|
173 | 172 | /// Make sure that size-affecting changes are made knowingly |
|
174 | 173 | fn _static_assert_size_of() { |
|
175 |
let _ = std::mem::transmute::<Header, [u8; |
|
|
176 |
let _ = std::mem::transmute::<Node, [u8; 5 |
|
|
174 | let _ = std::mem::transmute::<Header, [u8; 88]>; | |
|
175 | let _ = std::mem::transmute::<Node, [u8; 45]>; | |
|
177 | 176 | } |
|
178 | 177 | |
|
179 | 178 | /// Unexpected file format found in `.hg/dirstate` with the "v2" format. |
@@ -589,8 +588,8 b' fn write_slice<T>(slice: &[T], out: &mut' | |||
|
589 | 588 | where |
|
590 | 589 | T: BytesCast, |
|
591 | 590 | { |
|
592 |
let start = u |
|
|
593 |
// Could only panic |
|
|
591 | let start = u32::try_from(out.len()) | |
|
592 | // Could only panic for a dirstate file larger than 4 GiB | |
|
594 | 593 | .expect("dirstate-v2 offset overflow") |
|
595 | 594 | .into(); |
|
596 | 595 | let len = u32::try_from(slice.len()) |
@@ -406,19 +406,19 b' Windows paths are accepted on input' | |||
|
406 | 406 | #if dirstate-v2 |
|
407 | 407 | |
|
408 | 408 | Check the hash of ignore patterns written in the dirstate at offset |
|
409 |
12 + 20 + 20 + |
|
|
409 | 12 + 20 + 20 + 4 + 4 + 4 + 4 = 68 | |
|
410 | 410 | |
|
411 | 411 | $ hg status > /dev/null |
|
412 | 412 | $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1 |
|
413 | 413 | sha1=6e315b60f15fb5dfa02be00f3e2c8f923051f5ff |
|
414 |
>>> import binascii; print(binascii.hexlify(open(".hg/dirstate", "rb").read()[ |
|
|
414 | >>> import binascii; print(binascii.hexlify(open(".hg/dirstate", "rb").read()[68:][:20]).decode()) | |
|
415 | 415 | 6e315b60f15fb5dfa02be00f3e2c8f923051f5ff |
|
416 | 416 | |
|
417 | 417 | $ echo rel > .hg/testhgignorerel |
|
418 | 418 | $ hg status > /dev/null |
|
419 | 419 | $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1 |
|
420 | 420 | sha1=dea19cc7119213f24b6b582a4bae7b0cb063e34e |
|
421 |
>>> import binascii; print(binascii.hexlify(open(".hg/dirstate", "rb").read()[ |
|
|
421 | >>> import binascii; print(binascii.hexlify(open(".hg/dirstate", "rb").read()[68:][:20]).decode()) | |
|
422 | 422 | dea19cc7119213f24b6b582a4bae7b0cb063e34e |
|
423 | 423 | |
|
424 | 424 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now