Mercurial > hg
annotate rust/hg-core/src/dirstate/entry.rs @ 48087:79bc60ca5946
dirstate-item: introduce a `any_tracked` property
This property is True is the file is tracked anywhere, either the working copy,
or any of the parent.
Differential Revision: https://phab.mercurial-scm.org/D11524
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 29 Sep 2021 14:51:31 +0200 |
parents | 80783e553bd5 |
children | 3c7db97ce541 |
rev | line source |
---|---|
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
1 use crate::errors::HgError; |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
2 use bitflags::bitflags; |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
3 use std::convert::TryFrom; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
4 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
5 #[derive(Copy, Clone, Debug, Eq, PartialEq)] |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
6 pub enum EntryState { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
7 Normal, |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
8 Added, |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
9 Removed, |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
10 Merged, |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
11 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
12 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
13 /// The C implementation uses all signed types. This will be an issue |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
14 /// either when 4GB+ source files are commonplace or in 2038, whichever |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
15 /// comes first. |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
16 #[derive(Debug, PartialEq, Copy, Clone)] |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
17 pub struct DirstateEntry { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
18 flags: Flags, |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
19 mode: i32, |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
20 size: i32, |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
21 mtime: i32, |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
22 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
23 |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
24 bitflags! { |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
25 pub struct Flags: u8 { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
26 const WDIR_TRACKED = 1 << 0; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
27 const P1_TRACKED = 1 << 1; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
28 const P2_TRACKED = 1 << 2; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
29 const POSSIBLY_DIRTY = 1 << 3; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
30 const MERGED = 1 << 4; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
31 const CLEAN_P1 = 1 << 5; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
32 const CLEAN_P2 = 1 << 6; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
33 const ENTRYLESS_TREE_NODE = 1 << 7; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
34 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
35 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
36 |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
37 pub const V1_RANGEMASK: i32 = 0x7FFFFFFF; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
38 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
39 pub const MTIME_UNSET: i32 = -1; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
40 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
41 /// A `DirstateEntry` with a size of `-2` means that it was merged from the |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
42 /// other parent. This allows revert to pick the right status back during a |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
43 /// merge. |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
44 pub const SIZE_FROM_OTHER_PARENT: i32 = -2; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
45 /// A special value used for internal representation of special case in |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
46 /// dirstate v1 format. |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
47 pub const SIZE_NON_NORMAL: i32 = -1; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
48 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
49 impl DirstateEntry { |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
50 pub fn new( |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
51 flags: Flags, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
52 mode_size_mtime: Option<(i32, i32, i32)>, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
53 ) -> Self { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
54 let (mode, size, mtime) = |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
55 mode_size_mtime.unwrap_or((0, SIZE_NON_NORMAL, MTIME_UNSET)); |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
56 Self { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
57 flags, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
58 mode, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
59 size, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
60 mtime, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
61 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
62 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
63 |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
64 pub fn from_v1_data( |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
65 state: EntryState, |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
66 mode: i32, |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
67 size: i32, |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
68 mtime: i32, |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
69 ) -> Self { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
70 match state { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
71 EntryState::Normal => { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
72 if size == SIZE_FROM_OTHER_PARENT { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
73 Self::new_from_p2() |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
74 } else if size == SIZE_NON_NORMAL { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
75 Self::new_possibly_dirty() |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
76 } else if mtime == MTIME_UNSET { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
77 Self { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
78 flags: Flags::WDIR_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
79 | Flags::P1_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
80 | Flags::POSSIBLY_DIRTY, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
81 mode, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
82 size, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
83 mtime: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
84 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
85 } else { |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
86 Self::new_normal(mode, size, mtime) |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
87 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
88 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
89 EntryState::Added => Self::new_added(), |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
90 EntryState::Removed => Self { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
91 flags: if size == SIZE_NON_NORMAL { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
92 Flags::P1_TRACKED // might not be true because of rename ? |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
93 | Flags::P2_TRACKED // might not be true because of rename ? |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
94 | Flags::MERGED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
95 } else if size == SIZE_FROM_OTHER_PARENT { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
96 // We don’t know if P1_TRACKED should be set (file history) |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
97 Flags::P2_TRACKED | Flags::CLEAN_P2 |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
98 } else { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
99 Flags::P1_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
100 }, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
101 mode: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
102 size: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
103 mtime: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
104 }, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
105 EntryState::Merged => Self::new_merged(), |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
106 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
107 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
108 |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
109 pub fn new_from_p2() -> Self { |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
110 Self { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
111 // might be missing P1_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
112 flags: Flags::WDIR_TRACKED | Flags::P2_TRACKED | Flags::CLEAN_P2, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
113 mode: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
114 size: SIZE_FROM_OTHER_PARENT, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
115 mtime: MTIME_UNSET, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
116 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
117 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
118 |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
119 pub fn new_possibly_dirty() -> Self { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
120 Self { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
121 flags: Flags::WDIR_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
122 | Flags::P1_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
123 | Flags::POSSIBLY_DIRTY, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
124 mode: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
125 size: SIZE_NON_NORMAL, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
126 mtime: MTIME_UNSET, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
127 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
128 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
129 |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
130 pub fn new_added() -> Self { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
131 Self { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
132 flags: Flags::WDIR_TRACKED, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
133 mode: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
134 size: SIZE_NON_NORMAL, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
135 mtime: MTIME_UNSET, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
136 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
137 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
138 |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
139 pub fn new_merged() -> Self { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
140 Self { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
141 flags: Flags::WDIR_TRACKED |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
142 | Flags::P1_TRACKED // might not be true because of rename ? |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
143 | Flags::P2_TRACKED // might not be true because of rename ? |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
144 | Flags::MERGED, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
145 mode: 0, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
146 size: SIZE_NON_NORMAL, |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
147 mtime: MTIME_UNSET, |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
148 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
149 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
150 |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
151 pub fn new_normal(mode: i32, size: i32, mtime: i32) -> Self { |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
152 Self { |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
153 flags: Flags::WDIR_TRACKED | Flags::P1_TRACKED, |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
154 mode, |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
155 size, |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
156 mtime, |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
157 } |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
158 } |
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48043
diff
changeset
|
159 |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
160 /// Creates a new entry in "removed" state. |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
161 /// |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
162 /// `size` is expected to be zero, `SIZE_NON_NORMAL`, or |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
163 /// `SIZE_FROM_OTHER_PARENT` |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
164 pub fn new_removed(size: i32) -> Self { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
165 Self::from_v1_data(EntryState::Removed, 0, size, 0) |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
166 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
167 |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
168 pub fn tracked(&self) -> bool { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
169 self.flags.contains(Flags::WDIR_TRACKED) |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
170 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
171 |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
172 fn tracked_in_any_parent(&self) -> bool { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
173 self.flags.intersects(Flags::P1_TRACKED | Flags::P2_TRACKED) |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
174 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
175 |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
176 pub fn removed(&self) -> bool { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
177 self.tracked_in_any_parent() |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
178 && !self.flags.contains(Flags::WDIR_TRACKED) |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
179 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
180 |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
181 pub fn merged(&self) -> bool { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
182 self.flags.contains(Flags::WDIR_TRACKED | Flags::MERGED) |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
183 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
184 |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
185 pub fn added(&self) -> bool { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
186 self.flags.contains(Flags::WDIR_TRACKED) |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
187 && !self.tracked_in_any_parent() |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
188 } |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
189 |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
190 pub fn from_p2(&self) -> bool { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
191 self.flags.contains(Flags::WDIR_TRACKED | Flags::CLEAN_P2) |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
192 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
193 |
48086
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
194 pub fn maybe_clean(&self) -> bool { |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
195 if !self.flags.contains(Flags::WDIR_TRACKED) { |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
196 false |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
197 } else if self.added() { |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
198 false |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
199 } else if self.flags.contains(Flags::MERGED) { |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
200 false |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
201 } else if self.flags.contains(Flags::CLEAN_P2) { |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
202 false |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
203 } else { |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
204 true |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
205 } |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
206 } |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48067
diff
changeset
|
207 |
48087
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48086
diff
changeset
|
208 pub fn any_tracked(&self) -> bool { |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48086
diff
changeset
|
209 self.flags.intersects( |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48086
diff
changeset
|
210 Flags::WDIR_TRACKED | Flags::P1_TRACKED | Flags::P2_TRACKED, |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48086
diff
changeset
|
211 ) |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48086
diff
changeset
|
212 } |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48086
diff
changeset
|
213 |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
214 pub fn state(&self) -> EntryState { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
215 if self.removed() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
216 EntryState::Removed |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
217 } else if self.merged() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
218 EntryState::Merged |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
219 } else if self.added() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
220 EntryState::Added |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
221 } else { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
222 EntryState::Normal |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
223 } |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
224 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
225 |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
226 pub fn mode(&self) -> i32 { |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
227 self.mode |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
228 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
229 |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
230 pub fn size(&self) -> i32 { |
48064
2943955304b3
dirstate: inline the merged_removed logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48061
diff
changeset
|
231 if self.removed() && self.flags.contains(Flags::MERGED) { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
232 SIZE_NON_NORMAL |
48066
7a2de2bd9fcd
dirstate: inline the `from_p2_removed` logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48065
diff
changeset
|
233 } else if self.removed() && self.flags.contains(Flags::CLEAN_P2) { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
234 SIZE_FROM_OTHER_PARENT |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
235 } else if self.removed() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
236 0 |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
237 } else if self.merged() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
238 SIZE_FROM_OTHER_PARENT |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
239 } else if self.added() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
240 SIZE_NON_NORMAL |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
241 } else if self.from_p2() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
242 SIZE_FROM_OTHER_PARENT |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
243 } else if self.flags.contains(Flags::POSSIBLY_DIRTY) { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
244 self.size // TODO: SIZE_NON_NORMAL ? |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
245 } else { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
246 self.size |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
247 } |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
248 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
249 |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
250 pub fn mtime(&self) -> i32 { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
251 if self.removed() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
252 0 |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
253 } else if self.flags.contains(Flags::POSSIBLY_DIRTY) { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
254 MTIME_UNSET |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
255 } else if self.merged() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
256 MTIME_UNSET |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
257 } else if self.added() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
258 MTIME_UNSET |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
259 } else if self.from_p2() { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
260 MTIME_UNSET |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
261 } else { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
262 self.mtime |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
263 } |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
264 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
265 |
48043
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
266 pub fn set_possibly_dirty(&mut self) { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
267 self.flags.insert(Flags::POSSIBLY_DIRTY) |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
268 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
269 |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
270 pub fn set_clean(&mut self, mode: i32, size: i32, mtime: i32) { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
271 self.flags.insert(Flags::WDIR_TRACKED | Flags::P1_TRACKED); |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
272 self.flags.remove( |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
273 Flags::P2_TRACKED // This might be wrong |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
274 | Flags::MERGED |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
275 | Flags::CLEAN_P2 |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
276 | Flags::POSSIBLY_DIRTY, |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
277 ); |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
278 self.mode = mode; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
279 self.size = size; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
280 self.mtime = mtime; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
281 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
282 |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
283 pub fn set_tracked(&mut self) { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
284 self.flags |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
285 .insert(Flags::WDIR_TRACKED | Flags::POSSIBLY_DIRTY); |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
286 // size = None on the python size turn into size = NON_NORMAL when |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
287 // accessed. So the next line is currently required, but a some future |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
288 // clean up would be welcome. |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
289 self.size = SIZE_NON_NORMAL; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
290 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
291 |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
292 pub fn set_untracked(&mut self) { |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
293 self.flags.remove(Flags::WDIR_TRACKED); |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
294 self.mode = 0; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
295 self.size = 0; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
296 self.mtime = 0; |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
297 } |
3e69bef2031a
rust: Add Python bindings for DirstateEntry as rustext.dirstate.DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48042
diff
changeset
|
298 |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
299 /// Returns `(state, mode, size, mtime)` for the puprose of serialization |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
300 /// in the dirstate-v1 format. |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
301 /// |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
302 /// This includes marker values such as `mtime == -1`. In the future we may |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
303 /// want to not represent these cases that way in memory, but serialization |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
304 /// will need to keep the same format. |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
305 pub fn v1_data(&self) -> (u8, i32, i32, i32) { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
306 (self.state().into(), self.mode(), self.size(), self.mtime()) |
48022
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
307 } |
f2a9db29cb2d
rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents:
48018
diff
changeset
|
308 |
48061
060cd909439f
dirstate: drop all logic around the "non-normal" sets
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48051
diff
changeset
|
309 pub(crate) fn is_from_other_parent(&self) -> bool { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
310 self.state() == EntryState::Normal |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
311 && self.size() == SIZE_FROM_OTHER_PARENT |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
312 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
313 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
314 // TODO: other platforms |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
315 #[cfg(unix)] |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
316 pub fn mode_changed( |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
317 &self, |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
318 filesystem_metadata: &std::fs::Metadata, |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
319 ) -> bool { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
320 use std::os::unix::fs::MetadataExt; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
321 const EXEC_BIT_MASK: u32 = 0o100; |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
322 let dirstate_exec_bit = (self.mode() as u32) & EXEC_BIT_MASK; |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
323 let fs_exec_bit = filesystem_metadata.mode() & EXEC_BIT_MASK; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
324 dirstate_exec_bit != fs_exec_bit |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
325 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
326 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
327 /// Returns a `(state, mode, size, mtime)` tuple as for |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
328 /// `DirstateMapMethods::debug_iter`. |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
329 pub fn debug_tuple(&self) -> (u8, i32, i32, i32) { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
330 let state = if self.flags.contains(Flags::ENTRYLESS_TREE_NODE) { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
331 b' ' |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
332 } else { |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
333 self.state().into() |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
334 }; |
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
335 (state, self.mode(), self.size(), self.mtime()) |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
336 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
337 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
338 pub fn mtime_is_ambiguous(&self, now: i32) -> bool { |
48042
008959fcbfb2
rust: Align DirstateEntry internals with Python/C DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48026
diff
changeset
|
339 self.state() == EntryState::Normal && self.mtime() == now |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
340 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
341 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
342 pub fn clear_ambiguous_mtime(&mut self, now: i32) -> bool { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
343 let ambiguous = self.mtime_is_ambiguous(now); |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
344 if ambiguous { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
345 // The file was last modified "simultaneously" with the current |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
346 // write to dirstate (i.e. within the same second for file- |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
347 // systems with a granularity of 1 sec). This commonly happens |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
348 // for at least a couple of files on 'update'. |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
349 // The user could change the file without changing its size |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
350 // within the same second. Invalidate the file's mtime in |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
351 // dirstate, forcing future 'status' calls to compare the |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
352 // contents of the file if the size is the same. This prevents |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
353 // mistakenly treating such files as clean. |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
354 self.clear_mtime() |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
355 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
356 ambiguous |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
357 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
358 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
359 pub fn clear_mtime(&mut self) { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
360 self.mtime = -1; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
361 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
362 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
363 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
364 impl EntryState { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
365 pub fn is_tracked(self) -> bool { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
366 use EntryState::*; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
367 match self { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
368 Normal | Added | Merged => true, |
48026
1b2ee68e85f9
rust: Remove EntryState::Unknown
Simon Sapin <simon.sapin@octobus.net>
parents:
48022
diff
changeset
|
369 Removed => false, |
48018
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
370 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
371 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
372 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
373 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
374 impl TryFrom<u8> for EntryState { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
375 type Error = HgError; |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
376 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
377 fn try_from(value: u8) -> Result<Self, Self::Error> { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
378 match value { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
379 b'n' => Ok(EntryState::Normal), |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
380 b'a' => Ok(EntryState::Added), |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
381 b'r' => Ok(EntryState::Removed), |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
382 b'm' => Ok(EntryState::Merged), |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
383 _ => Err(HgError::CorruptedRepository(format!( |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
384 "Incorrect dirstate entry state {}", |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
385 value |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
386 ))), |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
387 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
388 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
389 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
390 |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
391 impl Into<u8> for EntryState { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
392 fn into(self) -> u8 { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
393 match self { |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
394 EntryState::Normal => b'n', |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
395 EntryState::Added => b'a', |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
396 EntryState::Removed => b'r', |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
397 EntryState::Merged => b'm', |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
398 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
399 } |
08efe5945d2b
rust: Move DirstateEntry to its own module
Simon Sapin <simon.sapin@octobus.net>
parents:
diff
changeset
|
400 } |