Show More
@@ -380,6 +380,9 b' Node components are:' | |||
|
380 | 380 | P2_INFO = 1 << 2 |
|
381 | 381 | HAS_MODE_AND_SIZE = 1 << 3 |
|
382 | 382 | HAS_MTIME = 1 << 4 |
|
383 | MODE_EXEC_PERM = 1 << 5 | |
|
384 | MODE_IS_SYMLINK = 1 << 7 | |
|
385 | ||
|
383 | 386 | |
|
384 | 387 | Other bits are unset. The meaning of these bits are: |
|
385 | 388 | |
@@ -414,14 +417,17 b' Node components are:' | |||
|
414 | 417 | in order to optimize `hg status` |
|
415 | 418 | by enabling it to skip `readdir` in more cases. |
|
416 | 419 | |
|
417 |
When a node is for a file tracked anywhere |
|
|
418 | the rest of the node data is three fields: | |
|
420 | When a node is for a file tracked anywhere: | |
|
421 | - If `HAS_MODE_AND_SIZE` is set, the file is expected | |
|
422 | to be a symbolic link or a normal file based on `MODE_IS_SYMLINK`. | |
|
423 | - If `HAS_MODE_AND_SIZE` is set, the file’s owner is expected | |
|
424 | to have execute permission or not based on `MODE_EXEC_PERM`. | |
|
425 | - If `HAS_MODE_AND_SIZE` is unset, | |
|
426 | the expected type of file and permission are unknown. | |
|
427 | The rest of the node data is three fields: | |
|
419 | 428 | |
|
420 | 429 | * Offset 31: |
|
421 | If `HAS_MODE_AND_SIZE` is unset, four zero bytes. | |
|
422 | Otherwise, a 32-bit integer for the Unix mode (as in `stat_result.st_mode`) | |
|
423 | expected for this file to be considered clean. | |
|
424 | Only the `S_IXUSR` bit (owner has execute permission) is considered. | |
|
430 | 4 unused bytes, set to zero | |
|
425 | 431 | |
|
426 | 432 | * Offset 35: |
|
427 | 433 | If `HAS_MODE_AND_SIZE` is unset, four zero bytes. |
@@ -1,5 +1,7 b'' | |||
|
1 | 1 | # This file is automatically @generated by Cargo. |
|
2 | 2 | # It is not intended for manual editing. |
|
3 | version = 3 | |
|
4 | ||
|
3 | 5 | [[package]] |
|
4 | 6 | name = "adler" |
|
5 | 7 | version = "0.2.3" |
@@ -386,6 +388,7 b' dependencies = [' | |||
|
386 | 388 | "im-rc", |
|
387 | 389 | "itertools", |
|
388 | 390 | "lazy_static", |
|
391 | "libc", | |
|
389 | 392 | "log", |
|
390 | 393 | "memmap2", |
|
391 | 394 | "micro-timer", |
@@ -17,6 +17,7 b' home = "0.5"' | |||
|
17 | 17 | im-rc = "15.0.*" |
|
18 | 18 | itertools = "0.9" |
|
19 | 19 | lazy_static = "1.4.0" |
|
20 | libc = "0.2" | |
|
20 | 21 | rand = "0.7.3" |
|
21 | 22 | rand_pcg = "0.2.1" |
|
22 | 23 | rand_distr = "0.2.2" |
@@ -107,13 +107,15 b' bitflags! {' | |||
|
107 | 107 | const P2_INFO = 1 << 2; |
|
108 | 108 | const HAS_MODE_AND_SIZE = 1 << 3; |
|
109 | 109 | const HAS_MTIME = 1 << 4; |
|
110 | const MODE_EXEC_PERM = 1 << 5; | |
|
111 | const MODE_IS_SYMLINK = 1 << 7; | |
|
110 | 112 | } |
|
111 | 113 | } |
|
112 | 114 | |
|
113 | 115 | #[derive(BytesCast, Copy, Clone, Debug)] |
|
114 | 116 | #[repr(C)] |
|
115 | 117 | struct Entry { |
|
116 |
|
|
|
118 | _padding: U32Be, | |
|
117 | 119 | size: U32Be, |
|
118 | 120 | mtime: U32Be, |
|
119 | 121 | } |
@@ -332,13 +334,27 b' impl Node {' | |||
|
332 | 334 | ) |
|
333 | 335 | } |
|
334 | 336 | |
|
337 | fn synthesize_unix_mode(&self) -> u32 { | |
|
338 | let file_type = if self.flags.contains(Flags::MODE_IS_SYMLINK) { | |
|
339 | libc::S_IFLNK | |
|
340 | } else { | |
|
341 | libc::S_IFREG | |
|
342 | }; | |
|
343 | let permisions = if self.flags.contains(Flags::MODE_EXEC_PERM) { | |
|
344 | 0o755 | |
|
345 | } else { | |
|
346 | 0o644 | |
|
347 | }; | |
|
348 | file_type | permisions | |
|
349 | } | |
|
350 | ||
|
335 | 351 | fn assume_entry(&self) -> DirstateEntry { |
|
336 | 352 | // TODO: convert through raw bits instead? |
|
337 | 353 | let wdir_tracked = self.flags.contains(Flags::WDIR_TRACKED); |
|
338 | 354 | let p1_tracked = self.flags.contains(Flags::P1_TRACKED); |
|
339 | 355 | let p2_info = self.flags.contains(Flags::P2_INFO); |
|
340 | 356 | let mode_size = if self.flags.contains(Flags::HAS_MODE_AND_SIZE) { |
|
341 |
Some((self. |
|
|
357 | Some((self.synthesize_unix_mode(), self.data.size.into())) | |
|
342 | 358 | } else { |
|
343 | 359 | None |
|
344 | 360 | }; |
@@ -400,13 +416,15 b' impl Entry {' | |||
|
400 | 416 | flags.set(Flags::WDIR_TRACKED, wdir_tracked); |
|
401 | 417 | flags.set(Flags::P1_TRACKED, p1_tracked); |
|
402 | 418 | flags.set(Flags::P2_INFO, p2_info); |
|
403 |
let ( |
|
|
419 | let (size, mtime); | |
|
404 | 420 | if let Some((m, s)) = mode_size_opt { |
|
405 | mode = m; | |
|
421 | let exec_perm = m & libc::S_IXUSR != 0; | |
|
422 | let is_symlink = m & libc::S_IFMT == libc::S_IFLNK; | |
|
423 | flags.set(Flags::MODE_EXEC_PERM, exec_perm); | |
|
424 | flags.set(Flags::MODE_IS_SYMLINK, is_symlink); | |
|
406 | 425 | size = s; |
|
407 | 426 | flags.insert(Flags::HAS_MODE_AND_SIZE) |
|
408 | 427 | } else { |
|
409 | mode = 0; | |
|
410 | 428 | size = 0; |
|
411 | 429 | } |
|
412 | 430 | if let Some(m) = mtime_opt { |
@@ -416,7 +434,7 b' impl Entry {' | |||
|
416 | 434 | mtime = 0; |
|
417 | 435 | } |
|
418 | 436 | let raw_entry = Entry { |
|
419 |
|
|
|
437 | _padding: 0.into(), | |
|
420 | 438 | size: size.into(), |
|
421 | 439 | mtime: mtime.into(), |
|
422 | 440 | }; |
@@ -600,7 +618,7 b" impl Writer<'_, '_> {" | |||
|
600 | 618 | dirstate_map::NodeData::None => ( |
|
601 | 619 | Flags::empty(), |
|
602 | 620 | Entry { |
|
603 |
|
|
|
621 | _padding: 0.into(), | |
|
604 | 622 | size: 0.into(), |
|
605 | 623 | mtime: 0.into(), |
|
606 | 624 | }, |
General Comments 0
You need to be logged in to leave comments.
Login now