author | Augie Fackler <augie@google.com> |
Wed, 02 Mar 2022 10:06:37 -0500 | |
changeset 48825 | 726b3601a534 |
parent 48393 | 1a8a70b4b0ad |
child 48875 | 6000f5b25c9b |
permissions | -rw-r--r-- |
47501
8b7e47802deb
dirstate: split dirstatemap in its own file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47489
diff
changeset
|
1 |
# dirstatemap.py |
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
2 |
# |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
3 |
# This software may be used and distributed according to the terms of the |
10263 | 4 |
# GNU General Public License version 2 or any later version. |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
5 |
|
27503
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
6 |
from __future__ import absolute_import |
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
7 |
|
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
8 |
import errno |
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
9 |
|
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
10 |
from .i18n import _ |
43239
6fcdcea2b03a
dirstate: add some traces on listdir calls
Augie Fackler <augie@google.com>
parents:
43117
diff
changeset
|
11 |
|
27503
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
12 |
from . import ( |
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
13 |
error, |
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
14 |
pathutil, |
32372
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32352
diff
changeset
|
15 |
policy, |
30304
ba2c04059317
py3: use pycompat.ossep at certain places
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30224
diff
changeset
|
16 |
pycompat, |
31050
206532700213
txnutil: factor out the logic to read file in according to HG_PENDING
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30634
diff
changeset
|
17 |
txnutil, |
27503
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
18 |
util, |
0f4596622273
dirstate: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27399
diff
changeset
|
19 |
) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
20 |
|
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47672
diff
changeset
|
21 |
from .dirstateutils import ( |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47672
diff
changeset
|
22 |
docket as docketmod, |
48221
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48220
diff
changeset
|
23 |
v2, |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47672
diff
changeset
|
24 |
) |
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47672
diff
changeset
|
25 |
|
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43505
diff
changeset
|
26 |
parsers = policy.importmod('parsers') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43505
diff
changeset
|
27 |
rustmod = policy.importrust('dirstate') |
32372
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32352
diff
changeset
|
28 |
|
8261
0fe1f57ac2bd
dirstate: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8226
diff
changeset
|
29 |
propertycache = util.propertycache |
16201
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16200
diff
changeset
|
30 |
|
48044
d5528ac9b4f2
dirstate: Use the Rust implementation of DirstateItem when Rust is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48024
diff
changeset
|
31 |
if rustmod is None: |
d5528ac9b4f2
dirstate: Use the Rust implementation of DirstateItem when Rust is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48024
diff
changeset
|
32 |
DirstateItem = parsers.DirstateItem |
d5528ac9b4f2
dirstate: Use the Rust implementation of DirstateItem when Rust is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48024
diff
changeset
|
33 |
else: |
d5528ac9b4f2
dirstate: Use the Rust implementation of DirstateItem when Rust is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48024
diff
changeset
|
34 |
DirstateItem = rustmod.DirstateItem |
21808
7537e57f5dbd
dirstate: add dirstatetuple to create dirstate values
Siddharth Agarwal <sid0@fb.com>
parents:
21116
diff
changeset
|
35 |
|
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
36 |
rangemask = 0x7FFFFFFF |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
37 |
|
47482
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47481
diff
changeset
|
38 |
|
48119
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
39 |
class _dirstatemapcommon(object): |
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
40 |
""" |
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
41 |
Methods that are identical for both implementations of the dirstatemap |
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
42 |
class, with and without Rust extensions enabled. |
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
43 |
""" |
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
44 |
|
48122
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
45 |
# please pytype |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
46 |
|
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
47 |
_map = None |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
48 |
copymap = None |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
49 |
|
48120
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
50 |
def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2): |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
51 |
self._use_dirstate_v2 = use_dirstate_v2 |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
52 |
self._nodeconstants = nodeconstants |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
53 |
self._ui = ui |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
54 |
self._opener = opener |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
55 |
self._root = root |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
56 |
self._filename = b'dirstate' |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
57 |
self._nodelen = 20 # Also update Rust code when changing this! |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
58 |
self._parents = None |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
59 |
self._dirtyparents = False |
48220
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
60 |
self._docket = None |
48120
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
61 |
|
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
62 |
# for consistent view between _pl() and _read() invocations |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
63 |
self._pendingmode = None |
fe6617715464
dirstatemap: use a common __init__ for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48119
diff
changeset
|
64 |
|
48122
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
65 |
def preload(self): |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
66 |
"""Loads the underlying data, if it's not already loaded""" |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
67 |
self._map |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
68 |
|
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
69 |
def get(self, key, default=None): |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
70 |
return self._map.get(key, default) |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
71 |
|
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
72 |
def __len__(self): |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
73 |
return len(self._map) |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
74 |
|
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
75 |
def __iter__(self): |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
76 |
return iter(self._map) |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
77 |
|
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
78 |
def __contains__(self, key): |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
79 |
return key in self._map |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
80 |
|
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
81 |
def __getitem__(self, item): |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
82 |
return self._map[item] |
bbd924a36a6e
dirstatemap: move a multiple simple functions in the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48121
diff
changeset
|
83 |
|
48125
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
84 |
### sub-class utility method |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
85 |
# |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
86 |
# Use to allow for generic implementation of some method while still coping |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
87 |
# with minor difference between implementation. |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
88 |
|
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
89 |
def _dirs_incr(self, filename, old_entry=None): |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
90 |
"""incremente the dirstate counter if applicable |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
91 |
|
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
92 |
This might be a no-op for some subclass who deal with directory |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
93 |
tracking in a different way. |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
94 |
""" |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
95 |
|
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
96 |
def _dirs_decr(self, filename, old_entry=None, remove_variant=False): |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
97 |
"""decremente the dirstate counter if applicable |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
98 |
|
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
99 |
This might be a no-op for some subclass who deal with directory |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
100 |
tracking in a different way. |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
101 |
""" |
de793f249852
dirstatemap: create `_dirs_incr/_dirs_decr` methods on the common class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48124
diff
changeset
|
102 |
|
48126
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
103 |
def _refresh_entry(self, f, entry): |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
104 |
"""record updated state of an entry""" |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
105 |
|
48128
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
106 |
def _insert_entry(self, f, entry): |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
107 |
"""add a new dirstate entry (or replace an unrelated one) |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
108 |
|
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
109 |
The fact it is actually new is the responsability of the caller |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
110 |
""" |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
111 |
|
48132
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
112 |
def _drop_entry(self, f): |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
113 |
"""remove any entry for file f |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
114 |
|
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
115 |
This should also drop associated copy information |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
116 |
|
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
117 |
The fact we actually need to drop it is the responsability of the caller""" |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
118 |
|
48127
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
119 |
### method to manipulate the entries |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
120 |
|
48130
743808de0c03
dirstatemap: use common code for set_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48129
diff
changeset
|
121 |
def set_possibly_dirty(self, filename): |
743808de0c03
dirstatemap: use common code for set_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48129
diff
changeset
|
122 |
"""record that the current state of the file on disk is unknown""" |
743808de0c03
dirstatemap: use common code for set_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48129
diff
changeset
|
123 |
entry = self[filename] |
743808de0c03
dirstatemap: use common code for set_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48129
diff
changeset
|
124 |
entry.set_possibly_dirty() |
743808de0c03
dirstatemap: use common code for set_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48129
diff
changeset
|
125 |
self._refresh_entry(filename, entry) |
743808de0c03
dirstatemap: use common code for set_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48129
diff
changeset
|
126 |
|
48131
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
127 |
def set_clean(self, filename, mode, size, mtime): |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
128 |
"""mark a file as back to a clean state""" |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
129 |
entry = self[filename] |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
130 |
size = size & rangemask |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
131 |
entry.set_clean(mode, size, mtime) |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
132 |
self._refresh_entry(filename, entry) |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
133 |
self.copymap.pop(filename, None) |
f903a357ba72
dirstatemap: use common code for set_clean
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48130
diff
changeset
|
134 |
|
48129
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
135 |
def set_tracked(self, filename): |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
136 |
new = False |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
137 |
entry = self.get(filename) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
138 |
if entry is None: |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
139 |
self._dirs_incr(filename) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
140 |
entry = DirstateItem( |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
141 |
wc_tracked=True, |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
142 |
) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
143 |
|
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
144 |
self._insert_entry(filename, entry) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
145 |
new = True |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
146 |
elif not entry.tracked: |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
147 |
self._dirs_incr(filename, entry) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
148 |
entry.set_tracked() |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
149 |
self._refresh_entry(filename, entry) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
150 |
new = True |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
151 |
else: |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
152 |
# XXX This is probably overkill for more case, but we need this to |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
153 |
# fully replace the `normallookup` call with `set_tracked` one. |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
154 |
# Consider smoothing this in the future. |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
155 |
entry.set_possibly_dirty() |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
156 |
self._refresh_entry(filename, entry) |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
157 |
return new |
a39192fc7c56
dirstatemap: use a common implement for set_tracked
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48128
diff
changeset
|
158 |
|
48127
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
159 |
def set_untracked(self, f): |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
160 |
"""Mark a file as no longer tracked in the dirstate map""" |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
161 |
entry = self.get(f) |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
162 |
if entry is None: |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
163 |
return False |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
164 |
else: |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
165 |
self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added) |
48151
e0b4e4f80fff
dirstate-item: replace a `merged` usage with `p2_info`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48148
diff
changeset
|
166 |
if not entry.p2_info: |
48127
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
167 |
self.copymap.pop(f, None) |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
168 |
entry.set_untracked() |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
169 |
self._refresh_entry(f, entry) |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
170 |
return True |
ced8cf9c4905
dirstatemap: use a common implementation for `dirstatemap.set_untracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48126
diff
changeset
|
171 |
|
48133
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
172 |
def reset_state( |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
173 |
self, |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
174 |
filename, |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
175 |
wc_tracked=False, |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
176 |
p1_tracked=False, |
48140
98b3eb6c1479
dirstate: align the dirstatemap's API to the data change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48138
diff
changeset
|
177 |
p2_info=False, |
98b3eb6c1479
dirstate: align the dirstatemap's API to the data change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48138
diff
changeset
|
178 |
has_meaningful_mtime=True, |
98b3eb6c1479
dirstate: align the dirstatemap's API to the data change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48138
diff
changeset
|
179 |
has_meaningful_data=True, |
48133
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
180 |
parentfiledata=None, |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
181 |
): |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
182 |
"""Set a entry to a given state, diregarding all previous state |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
183 |
|
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
184 |
This is to be used by the part of the dirstate API dedicated to |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
185 |
adjusting the dirstate after a update/merge. |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
186 |
|
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
187 |
note: calling this might result to no entry existing at all if the |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
188 |
dirstate map does not see any point at having one for this file |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
189 |
anymore. |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
190 |
""" |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
191 |
# copy information are now outdated |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
192 |
# (maybe new information should be in directly passed to this function) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
193 |
self.copymap.pop(filename, None) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
194 |
|
48140
98b3eb6c1479
dirstate: align the dirstatemap's API to the data change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48138
diff
changeset
|
195 |
if not (p1_tracked or p2_info or wc_tracked): |
48133
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
196 |
old_entry = self._map.get(filename) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
197 |
self._drop_entry(filename) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
198 |
self._dirs_decr(filename, old_entry=old_entry) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
199 |
return |
48138
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48137
diff
changeset
|
200 |
|
48133
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
201 |
old_entry = self._map.get(filename) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
202 |
self._dirs_incr(filename, old_entry) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
203 |
entry = DirstateItem( |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
204 |
wc_tracked=wc_tracked, |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
205 |
p1_tracked=p1_tracked, |
48138
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48137
diff
changeset
|
206 |
p2_info=p2_info, |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48137
diff
changeset
|
207 |
has_meaningful_mtime=has_meaningful_mtime, |
48133
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
208 |
parentfiledata=parentfiledata, |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
209 |
) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
210 |
self._insert_entry(filename, entry) |
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
211 |
|
48220
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
212 |
### disk interaction |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
213 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
214 |
def _opendirstatefile(self): |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
215 |
fp, mode = txnutil.trypending(self._root, self._opener, self._filename) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
216 |
if self._pendingmode is not None and self._pendingmode != mode: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
217 |
fp.close() |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
218 |
raise error.Abort( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
219 |
_(b'working directory state may be changed parallelly') |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
220 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
221 |
self._pendingmode = mode |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
222 |
return fp |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
223 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
224 |
def _readdirstatefile(self, size=-1): |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
225 |
try: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
226 |
with self._opendirstatefile() as fp: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
227 |
return fp.read(size) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
228 |
except IOError as err: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
229 |
if err.errno != errno.ENOENT: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
230 |
raise |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
231 |
# File doesn't exist, so the current state is empty |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
232 |
return b'' |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
233 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
234 |
@property |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
235 |
def docket(self): |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
236 |
if not self._docket: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
237 |
if not self._use_dirstate_v2: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
238 |
raise error.ProgrammingError( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
239 |
b'dirstate only has a docket in v2 format' |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
240 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
241 |
self._docket = docketmod.DirstateDocket.parse( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
242 |
self._readdirstatefile(), self._nodeconstants |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
243 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
244 |
return self._docket |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
245 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
246 |
def write_v2_no_append(self, tr, st, meta, packed): |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
247 |
old_docket = self.docket |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
248 |
new_docket = docketmod.DirstateDocket.with_new_uuid( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
249 |
self.parents(), len(packed), meta |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
250 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
251 |
data_filename = new_docket.data_filename() |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
252 |
if tr: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
253 |
tr.add(data_filename, 0) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
254 |
self._opener.write(data_filename, packed) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
255 |
# Write the new docket after the new data file has been |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
256 |
# written. Because `st` was opened with `atomictemp=True`, |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
257 |
# the actual `.hg/dirstate` file is only affected on close. |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
258 |
st.write(new_docket.serialize()) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
259 |
st.close() |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
260 |
# Remove the old data file after the new docket pointing to |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
261 |
# the new data file was written. |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
262 |
if old_docket.uuid: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
263 |
data_filename = old_docket.data_filename() |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
264 |
unlink = lambda _tr=None: self._opener.unlink(data_filename) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
265 |
if tr: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
266 |
category = b"dirstate-v2-clean-" + old_docket.uuid |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
267 |
tr.addpostclose(category, unlink) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
268 |
else: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
269 |
unlink() |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
270 |
self._docket = new_docket |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
271 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
272 |
### reading/setting parents |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
273 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
274 |
def parents(self): |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
275 |
if not self._parents: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
276 |
if self._use_dirstate_v2: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
277 |
self._parents = self.docket.parents |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
278 |
else: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
279 |
read_len = self._nodelen * 2 |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
280 |
st = self._readdirstatefile(read_len) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
281 |
l = len(st) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
282 |
if l == read_len: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
283 |
self._parents = ( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
284 |
st[: self._nodelen], |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
285 |
st[self._nodelen : 2 * self._nodelen], |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
286 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
287 |
elif l == 0: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
288 |
self._parents = ( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
289 |
self._nodeconstants.nullid, |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
290 |
self._nodeconstants.nullid, |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
291 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
292 |
else: |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
293 |
raise error.Abort( |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
294 |
_(b'working directory state appears damaged!') |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
295 |
) |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
296 |
|
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
297 |
return self._parents |
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
298 |
|
48119
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
299 |
|
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
300 |
class dirstatemap(_dirstatemapcommon): |
35078
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
301 |
"""Map encapsulating the dirstate's contents. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
302 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
303 |
The dirstate contains the following state: |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
304 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
305 |
- `identity` is the identity of the dirstate file, which can be used to |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
306 |
detect when changes have occurred to the dirstate file. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
307 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
308 |
- `parents` is a pair containing the parents of the working copy. The |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
309 |
parents are updated by calling `setparents`. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
310 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
311 |
- the state map maps filenames to tuples of (state, mode, size, mtime), |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
312 |
where state is a single character representing 'normal', 'added', |
35079
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35078
diff
changeset
|
313 |
'removed', or 'merged'. It is read by treating the dirstate as a |
47996
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
314 |
dict. File state is updated by calling various methods (see each |
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
315 |
documentation for details): |
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
316 |
|
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
317 |
- `reset_state`, |
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
318 |
- `set_tracked` |
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
319 |
- `set_untracked` |
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
320 |
- `set_clean` |
aa442fde0ea5
dirstate: update the documentation of the dirstatemap API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47990
diff
changeset
|
321 |
- `set_possibly_dirty` |
35078
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
322 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
323 |
- `copymap` maps destination filenames to their source filename. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
324 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
325 |
The dirstate also provides the following views onto the state: |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
326 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
327 |
- `filefoldmap` is a dict mapping normalized filenames to the denormalized |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
328 |
form that they appear as in the dirstate. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
329 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
330 |
- `dirfoldmap` is a dict mapping normalized directory names to the |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
331 |
denormalized form that they appear as in the dirstate. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
332 |
""" |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35016
diff
changeset
|
333 |
|
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
334 |
### Core data storage and access |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
335 |
|
34934
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
336 |
@propertycache |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
337 |
def _map(self): |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
338 |
self._map = {} |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
339 |
self.read() |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
340 |
return self._map |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
341 |
|
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
342 |
@propertycache |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
343 |
def copymap(self): |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
344 |
self.copymap = {} |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
345 |
self._map |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
346 |
return self.copymap |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
347 |
|
34933
0217f75b6e59
dirstate: move clear onto dirstatemap class
Durham Goode <durham@fb.com>
parents:
34678
diff
changeset
|
348 |
def clear(self): |
34935
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
349 |
self._map.clear() |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
350 |
self.copymap.clear() |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
351 |
self.setparents(self._nodeconstants.nullid, self._nodeconstants.nullid) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
352 |
util.clearcachedproperty(self, b"_dirs") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
353 |
util.clearcachedproperty(self, b"_alldirs") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
354 |
util.clearcachedproperty(self, b"filefoldmap") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
355 |
util.clearcachedproperty(self, b"dirfoldmap") |
34933
0217f75b6e59
dirstate: move clear onto dirstatemap class
Durham Goode <durham@fb.com>
parents:
34678
diff
changeset
|
356 |
|
35878
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35835
diff
changeset
|
357 |
def items(self): |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43090
diff
changeset
|
358 |
return pycompat.iteritems(self._map) |
34332
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34188
diff
changeset
|
359 |
|
35878
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35835
diff
changeset
|
360 |
# forward for python2,3 compat |
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35835
diff
changeset
|
361 |
iteritems = items |
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35835
diff
changeset
|
362 |
|
48023
357307feaf61
debugstate: Always call dirstatemap.debug_iter()
Simon Sapin <simon.sapin@octobus.net>
parents:
48019
diff
changeset
|
363 |
def debug_iter(self, all): |
357307feaf61
debugstate: Always call dirstatemap.debug_iter()
Simon Sapin <simon.sapin@octobus.net>
parents:
48019
diff
changeset
|
364 |
""" |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
365 |
Return an iterator of (filename, state, mode, size, mtime) tuples |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
366 |
|
48023
357307feaf61
debugstate: Always call dirstatemap.debug_iter()
Simon Sapin <simon.sapin@octobus.net>
parents:
48019
diff
changeset
|
367 |
`all` is unused when Rust is not enabled |
357307feaf61
debugstate: Always call dirstatemap.debug_iter()
Simon Sapin <simon.sapin@octobus.net>
parents:
48019
diff
changeset
|
368 |
""" |
48024
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
369 |
for (filename, item) in self.items(): |
cedfe2606adf
debugsate: Change debug_iter() to yield tuples instead of DirstateItem
Simon Sapin <simon.sapin@octobus.net>
parents:
48023
diff
changeset
|
370 |
yield (filename, item.state, item.mode, item.size, item.mtime) |
47683
284a20269a97
dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
371 |
|
34332
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34188
diff
changeset
|
372 |
def keys(self): |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34188
diff
changeset
|
373 |
return self._map.keys() |
34333
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34332
diff
changeset
|
374 |
|
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
375 |
### reading/setting parents |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
376 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
377 |
def setparents(self, p1, p2, fold_p2=False): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
378 |
self._parents = (p1, p2) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
379 |
self._dirtyparents = True |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
380 |
copies = {} |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
381 |
if fold_p2: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
382 |
for f, s in pycompat.iteritems(self._map): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
383 |
# Discard "merged" markers when moving away from a merge state |
48148
e2753a7acfa7
dirstate-item: use the `p2_info` property to replace more verbose call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48140
diff
changeset
|
384 |
if s.p2_info: |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
385 |
source = self.copymap.pop(f, None) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
386 |
if source: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
387 |
copies[f] = source |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
388 |
s.drop_merge_data() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
389 |
return copies |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
390 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
391 |
### disk interaction |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
392 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
393 |
def read(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
394 |
# ignore HG_PENDING because identity is used only for writing |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
395 |
self.identity = util.filestat.frompath( |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
396 |
self._opener.join(self._filename) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
397 |
) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
398 |
|
48223
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
399 |
if self._use_dirstate_v2: |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
400 |
if not self.docket.uuid: |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
401 |
return |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
402 |
st = self._opener.read(self.docket.data_filename()) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
403 |
else: |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
404 |
st = self._readdirstatefile() |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
405 |
|
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
406 |
if not st: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
407 |
return |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
408 |
|
48223
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
409 |
# TODO: adjust this estimate for dirstate-v2 |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
410 |
if util.safehasattr(parsers, b'dict_new_presized'): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
411 |
# Make an estimate of the number of files in the dirstate based on |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
412 |
# its size. This trades wasting some memory for avoiding costly |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
413 |
# resizes. Each entry have a prefix of 17 bytes followed by one or |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
414 |
# two path names. Studies on various large-scale real-world repositories |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
415 |
# found 54 bytes a reasonable upper limit for the average path names. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
416 |
# Copy entries are ignored for the sake of this estimate. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
417 |
self._map = parsers.dict_new_presized(len(st) // 71) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
418 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
419 |
# Python's garbage collector triggers a GC each time a certain number |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
420 |
# of container objects (the number being defined by |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
421 |
# gc.get_threshold()) are allocated. parse_dirstate creates a tuple |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
422 |
# for each file in the dirstate. The C version then immediately marks |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
423 |
# them as not to be tracked by the collector. However, this has no |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
424 |
# effect on when GCs are triggered, only on what objects the GC looks |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
425 |
# into. This means that O(number of files) GCs are unavoidable. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
426 |
# Depending on when in the process's lifetime the dirstate is parsed, |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
427 |
# this can get very expensive. As a workaround, disable GC while |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
428 |
# parsing the dirstate. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
429 |
# |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
430 |
# (we cannot decorate the function directly since it is in a C module) |
48223
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
431 |
if self._use_dirstate_v2: |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
432 |
p = self.docket.parents |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
433 |
meta = self.docket.tree_metadata |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
434 |
parse_dirstate = util.nogc(v2.parse_dirstate) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
435 |
parse_dirstate(self._map, self.copymap, st, meta) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
436 |
else: |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
437 |
parse_dirstate = util.nogc(parsers.parse_dirstate) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
438 |
p = parse_dirstate(self._map, self.copymap, st) |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
439 |
if not self._dirtyparents: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
440 |
self.setparents(*p) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
441 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
442 |
# Avoid excess attribute lookups by fast pathing certain checks |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
443 |
self.__contains__ = self._map.__contains__ |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
444 |
self.__getitem__ = self._map.__getitem__ |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
445 |
self.get = self._map.get |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
446 |
|
48393
1a8a70b4b0ad
dirstate: cleanup remaining of "now" during write
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48392
diff
changeset
|
447 |
def write(self, tr, st): |
48223
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
448 |
if self._use_dirstate_v2: |
48392
434de12918fd
dirstate: remove need_delay logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48260
diff
changeset
|
449 |
packed, meta = v2.pack_dirstate(self._map, self.copymap) |
48223
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
450 |
self.write_v2_no_append(tr, st, meta, packed) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
451 |
else: |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
452 |
packed = parsers.pack_dirstate( |
48392
434de12918fd
dirstate: remove need_delay logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48260
diff
changeset
|
453 |
self._map, self.copymap, self.parents() |
48223
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
454 |
) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
455 |
st.write(packed) |
b4f83c9e7905
dirstate-v2: Add support when Rust is not enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
48221
diff
changeset
|
456 |
st.close() |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
457 |
self._dirtyparents = False |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
458 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
459 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
460 |
def identity(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
461 |
self._map |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
462 |
return self.identity |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
463 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
464 |
### code related to maintaining and accessing "extra" property |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
465 |
# (e.g. "has_dir") |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
466 |
|
47687
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
467 |
def _dirs_incr(self, filename, old_entry=None): |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
468 |
"""incremente the dirstate counter if applicable""" |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
469 |
if ( |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
470 |
old_entry is None or old_entry.removed |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
471 |
) and "_dirs" in self.__dict__: |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
472 |
self._dirs.addpath(filename) |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
473 |
if old_entry is None and "_alldirs" in self.__dict__: |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
474 |
self._alldirs.addpath(filename) |
e59bd6723f2f
dirstate-map: factor out the change to _dirs and _alldirs on adding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
475 |
|
47689
f2aef39abc14
dirstate-map: factor out the change to _dirs and _alldirs on removing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47688
diff
changeset
|
476 |
def _dirs_decr(self, filename, old_entry=None, remove_variant=False): |
47688
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
477 |
"""decremente the dirstate counter if applicable""" |
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
478 |
if old_entry is not None: |
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
479 |
if "_dirs" in self.__dict__ and not old_entry.removed: |
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
480 |
self._dirs.delpath(filename) |
47689
f2aef39abc14
dirstate-map: factor out the change to _dirs and _alldirs on removing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47688
diff
changeset
|
481 |
if "_alldirs" in self.__dict__ and not remove_variant: |
47688
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
482 |
self._alldirs.delpath(filename) |
47689
f2aef39abc14
dirstate-map: factor out the change to _dirs and _alldirs on removing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47688
diff
changeset
|
483 |
elif remove_variant and "_alldirs" in self.__dict__: |
f2aef39abc14
dirstate-map: factor out the change to _dirs and _alldirs on removing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47688
diff
changeset
|
484 |
self._alldirs.addpath(filename) |
47688
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
485 |
if "filefoldmap" in self.__dict__: |
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
486 |
normed = util.normcase(filename) |
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
487 |
self.filefoldmap.pop(normed, None) |
b37ab6b5c438
dirstate-map: factor out the change to _dirs and _alldirs on dropping
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47687
diff
changeset
|
488 |
|
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
489 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
490 |
def filefoldmap(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
491 |
"""Returns a dictionary mapping normalized case paths to their |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
492 |
non-normalized versions. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
493 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
494 |
try: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
495 |
makefilefoldmap = parsers.make_file_foldmap |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
496 |
except AttributeError: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
497 |
pass |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
498 |
else: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
499 |
return makefilefoldmap( |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
500 |
self._map, util.normcasespec, util.normcasefallback |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
501 |
) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
502 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
503 |
f = {} |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
504 |
normcase = util.normcase |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
505 |
for name, s in pycompat.iteritems(self._map): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
506 |
if not s.removed: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
507 |
f[normcase(name)] = name |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
508 |
f[b'.'] = b'.' # prevents useless util.fspath() invocation |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
509 |
return f |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
510 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
511 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
512 |
def dirfoldmap(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
513 |
f = {} |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
514 |
normcase = util.normcase |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
515 |
for name in self._dirs: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
516 |
f[normcase(name)] = name |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
517 |
return f |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
518 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
519 |
def hastrackeddir(self, d): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
520 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
521 |
Returns True if the dirstate contains a tracked (not removed) file |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
522 |
in this directory. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
523 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
524 |
return d in self._dirs |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
525 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
526 |
def hasdir(self, d): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
527 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
528 |
Returns True if the dirstate contains a file (tracked or removed) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
529 |
in this directory. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
530 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
531 |
return d in self._alldirs |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
532 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
533 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
534 |
def _dirs(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
535 |
return pathutil.dirs(self._map, only_tracked=True) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
536 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
537 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
538 |
def _alldirs(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
539 |
return pathutil.dirs(self._map) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
540 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
541 |
### code related to manipulation of entries and copy-sources |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
542 |
|
48126
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
543 |
def _refresh_entry(self, f, entry): |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
544 |
if not entry.any_tracked: |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
545 |
self._map.pop(f, None) |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
546 |
|
48128
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
547 |
def _insert_entry(self, f, entry): |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
548 |
self._map[f] = entry |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
549 |
|
48132
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
550 |
def _drop_entry(self, f): |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
551 |
self._map.pop(f, None) |
48133
55293938b843
dirstatemap: use a common implement for reset_state
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48132
diff
changeset
|
552 |
self.copymap.pop(f, None) |
48132
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
553 |
|
42755
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42747
diff
changeset
|
554 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42747
diff
changeset
|
555 |
if rustmod is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42927
diff
changeset
|
556 |
|
48119
aec5b0981c26
dirstatemap: introduce a common base for the dirstatemap class
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48109
diff
changeset
|
557 |
class dirstatemap(_dirstatemapcommon): |
42755
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42747
diff
changeset
|
558 |
|
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
559 |
### Core data storage and access |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
560 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
561 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
562 |
def _map(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
563 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
564 |
Fills the Dirstatemap when called. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
565 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
566 |
# ignore HG_PENDING because identity is used only for writing |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
567 |
self.identity = util.filestat.frompath( |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
568 |
self._opener.join(self._filename) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
569 |
) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
570 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
571 |
if self._use_dirstate_v2: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
572 |
if self.docket.uuid: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
573 |
# TODO: use mmap when possible |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
574 |
data = self._opener.read(self.docket.data_filename()) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
575 |
else: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
576 |
data = b'' |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
577 |
self._map = rustmod.DirstateMap.new_v2( |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
578 |
data, self.docket.data_size, self.docket.tree_metadata |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
579 |
) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
580 |
parents = self.docket.parents |
48051
98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Simon Sapin <simon.sapin@octobus.net>
parents:
48050
diff
changeset
|
581 |
else: |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
582 |
self._map, parents = rustmod.DirstateMap.new_v1( |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
583 |
self._readdirstatefile() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
584 |
) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
585 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
586 |
if parents and not self._dirtyparents: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
587 |
self.setparents(*parents) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
588 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
589 |
self.__contains__ = self._map.__contains__ |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
590 |
self.__getitem__ = self._map.__getitem__ |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
591 |
self.get = self._map.get |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
592 |
return self._map |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
593 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
594 |
@property |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
595 |
def copymap(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
596 |
return self._map.copymap() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
597 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
598 |
def debug_iter(self, all): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
599 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
600 |
Return an iterator of (filename, state, mode, size, mtime) tuples |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
601 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
602 |
`all`: also include with `state == b' '` dirstate tree nodes that |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
603 |
don't have an associated `DirstateItem`. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
604 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
605 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
606 |
return self._map.debug_iter(all) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
607 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
608 |
def clear(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
609 |
self._map.clear() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
610 |
self.setparents( |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
611 |
self._nodeconstants.nullid, self._nodeconstants.nullid |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
612 |
) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
613 |
util.clearcachedproperty(self, b"_dirs") |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
614 |
util.clearcachedproperty(self, b"_alldirs") |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
615 |
util.clearcachedproperty(self, b"dirfoldmap") |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
616 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
617 |
def items(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
618 |
return self._map.items() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
619 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
620 |
# forward for python2,3 compat |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
621 |
iteritems = items |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
622 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
623 |
def keys(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
624 |
return iter(self._map) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
625 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
626 |
### reading/setting parents |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
627 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
628 |
def setparents(self, p1, p2, fold_p2=False): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
629 |
self._parents = (p1, p2) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
630 |
self._dirtyparents = True |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
631 |
copies = {} |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
632 |
if fold_p2: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
633 |
# Collect into an intermediate list to avoid a `RuntimeError` |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
634 |
# exception due to mutation during iteration. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
635 |
# TODO: move this the whole loop to Rust where `iter_mut` |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
636 |
# enables in-place mutation of elements of a collection while |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
637 |
# iterating it, without mutating the collection itself. |
48136
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
638 |
files_with_p2_info = [ |
48148
e2753a7acfa7
dirstate-item: use the `p2_info` property to replace more verbose call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48140
diff
changeset
|
639 |
f for f, s in self._map.items() if s.p2_info |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
640 |
] |
48136
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
641 |
rust_map = self._map |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
642 |
for f in files_with_p2_info: |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
643 |
e = rust_map.get(f) |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
644 |
source = self.copymap.pop(f, None) |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
645 |
if source: |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
646 |
copies[f] = source |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
647 |
e.drop_merge_data() |
bda85920de6b
dirstatemap: align the Rust wrapper implementation of `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48133
diff
changeset
|
648 |
rust_map.set_dirstate_item(f, e) |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
649 |
return copies |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
650 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
651 |
### disk interaction |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
652 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
653 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
654 |
def identity(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
655 |
self._map |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
656 |
return self.identity |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
657 |
|
48393
1a8a70b4b0ad
dirstate: cleanup remaining of "now" during write
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48392
diff
changeset
|
658 |
def write(self, tr, st): |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
659 |
if not self._use_dirstate_v2: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
660 |
p1, p2 = self.parents() |
48392
434de12918fd
dirstate: remove need_delay logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48260
diff
changeset
|
661 |
packed = self._map.write_v1(p1, p2) |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
662 |
st.write(packed) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
663 |
st.close() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
664 |
self._dirtyparents = False |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
665 |
return |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
666 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
667 |
# We can only append to an existing data file if there is one |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
668 |
can_append = self.docket.uuid is not None |
48392
434de12918fd
dirstate: remove need_delay logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48260
diff
changeset
|
669 |
packed, meta, append = self._map.write_v2(can_append) |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
670 |
if append: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
671 |
docket = self.docket |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
672 |
data_filename = docket.data_filename() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
673 |
if tr: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
674 |
tr.add(data_filename, docket.data_size) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
675 |
with self._opener(data_filename, b'r+b') as fp: |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
676 |
fp.seek(docket.data_size) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
677 |
assert fp.tell() == docket.data_size |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
678 |
written = fp.write(packed) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
679 |
if written is not None: # py2 may return None |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
680 |
assert written == len(packed), (written, len(packed)) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
681 |
docket.data_size += len(packed) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
682 |
docket.parents = self.parents() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
683 |
docket.tree_metadata = meta |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
684 |
st.write(docket.serialize()) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
685 |
st.close() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
686 |
else: |
48220
e7b5e8ba7cab
dirstate: Move more methods to the _dirstatemapcommon base class
Simon Sapin <simon.sapin@octobus.net>
parents:
48151
diff
changeset
|
687 |
self.write_v2_no_append(tr, st, meta, packed) |
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
688 |
# Reload from the newly-written file |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
689 |
util.clearcachedproperty(self, b"_map") |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
690 |
self._dirtyparents = False |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
691 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
692 |
### code related to maintaining and accessing "extra" property |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
693 |
# (e.g. "has_dir") |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
694 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
695 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
696 |
def filefoldmap(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
697 |
"""Returns a dictionary mapping normalized case paths to their |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
698 |
non-normalized versions. |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
699 |
""" |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
700 |
return self._map.filefoldmapasdict() |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
701 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
702 |
def hastrackeddir(self, d): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
703 |
return self._map.hastrackeddir(d) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
704 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
705 |
def hasdir(self, d): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
706 |
return self._map.hasdir(d) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
707 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
708 |
@propertycache |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
709 |
def dirfoldmap(self): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
710 |
f = {} |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
711 |
normcase = util.normcase |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
712 |
for name in self._map.tracked_dirs(): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
713 |
f[normcase(name)] = name |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
714 |
return f |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
715 |
|
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
716 |
### code related to manipulation of entries and copy-sources |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
717 |
|
48126
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
718 |
def _refresh_entry(self, f, entry): |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
719 |
if not entry.any_tracked: |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
720 |
self._map.drop_item_and_copy_source(f) |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
721 |
else: |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
722 |
self._map.addfile(f, entry) |
a1a6569b9283
dirstatemap: add a common `_refresh_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
723 |
|
48128
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
724 |
def _insert_entry(self, f, entry): |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
725 |
self._map.addfile(f, entry) |
a8ff00ad290b
dirstatemap: add a common `_insert_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48127
diff
changeset
|
726 |
|
48132
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
727 |
def _drop_entry(self, f): |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
728 |
self._map.drop_item_and_copy_source(f) |
c057d7c97b72
dirstatemap: add a common `_drop_entry` method for dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48131
diff
changeset
|
729 |
|
48123
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
730 |
def __setitem__(self, key, value): |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
731 |
assert isinstance(value, DirstateItem) |
771c90807a2b
dirstatemap: arrange methods by category
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
732 |
self._map.set_dirstate_item(key, value) |