author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Sun, 04 Jul 2021 01:58:03 +0200 | |
changeset 47529 | d3cf20328abd |
parent 47528 | 80617f3c0f9a |
child 47530 | a1745a292885 |
permissions | -rw-r--r-- |
47506
8b7e47802deb
dirstate: split dirstatemap in its own file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47494
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, |
32411
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32391
diff
changeset
|
15 |
policy, |
30317
ba2c04059317
py3: use pycompat.ossep at certain places
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30224
diff
changeset
|
16 |
pycompat, |
31070
206532700213
txnutil: factor out the logic to read file in according to HG_PENDING
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30639
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 |
|
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43553
diff
changeset
|
21 |
parsers = policy.importmod('parsers') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43553
diff
changeset
|
22 |
rustmod = policy.importrust('dirstate') |
32411
df448de7cf3b
parsers: switch to policy importer
Yuya Nishihara <yuya@tcha.org>
parents:
32391
diff
changeset
|
23 |
|
8261
0fe1f57ac2bd
dirstate: use propertycache
Matt Mackall <mpm@selenic.com>
parents:
8226
diff
changeset
|
24 |
propertycache = util.propertycache |
16201
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16200
diff
changeset
|
25 |
|
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
26 |
dirstatetuple = parsers.dirstatetuple |
21808
7537e57f5dbd
dirstate: add dirstatetuple to create dirstate values
Siddharth Agarwal <sid0@fb.com>
parents:
21116
diff
changeset
|
27 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
28 |
|
47487
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47486
diff
changeset
|
29 |
# a special value used internally for `size` if the file come from the other parent |
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47486
diff
changeset
|
30 |
FROM_P2 = -2 |
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47486
diff
changeset
|
31 |
|
47488
4ac418b4a6af
dirstate: introduce a symbolic constant for the NONNORMAL marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47487
diff
changeset
|
32 |
# a special value used internally for `size` if the file is modified/merged/added |
4ac418b4a6af
dirstate: introduce a symbolic constant for the NONNORMAL marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47487
diff
changeset
|
33 |
NONNORMAL = -1 |
4ac418b4a6af
dirstate: introduce a symbolic constant for the NONNORMAL marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47487
diff
changeset
|
34 |
|
47489
3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47488
diff
changeset
|
35 |
# a special value used internally for `time` if the time is ambigeous |
3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47488
diff
changeset
|
36 |
AMBIGUOUS_TIME = -1 |
3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47488
diff
changeset
|
37 |
|
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
38 |
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
|
39 |
|
47487
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47486
diff
changeset
|
40 |
|
34339
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
41 |
class dirstatemap(object): |
35101
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
42 |
"""Map encapsulating the dirstate's contents. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
43 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
44 |
The dirstate contains the following state: |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
45 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
46 |
- `identity` is the identity of the dirstate file, which can be used to |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
47 |
detect when changes have occurred to the dirstate file. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
48 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
49 |
- `parents` is a pair containing the parents of the working copy. The |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
50 |
parents are updated by calling `setparents`. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
51 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
52 |
- the state map maps filenames to tuples of (state, mode, size, mtime), |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
53 |
where state is a single character representing 'normal', 'added', |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
54 |
'removed', or 'merged'. It is read by treating the dirstate as a |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
55 |
dict. File state is updated by calling the `addfile`, `removefile` and |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
56 |
`dropfile` methods. |
35101
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
57 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
58 |
- `copymap` maps destination filenames to their source filename. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
59 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
60 |
The dirstate also provides the following views onto the state: |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
61 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
62 |
- `nonnormalset` is a set of the filenames that have state other |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
63 |
than 'normal', or are normal but have an mtime of -1 ('normallookup'). |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
64 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
65 |
- `otherparentset` is a set of the filenames that are marked as coming |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
66 |
from the second parent when the dirstate is currently being merged. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
67 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
68 |
- `filefoldmap` is a dict mapping normalized filenames to the denormalized |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
69 |
form that they appear as in the dirstate. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
70 |
|
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
71 |
- `dirfoldmap` is a dict mapping normalized directory names to the |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
72 |
denormalized form that they appear as in the dirstate. |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
73 |
""" |
a052022639cc
dirstate: document dirstatemap interface
Mark Thomas <mbthomas@fb.com>
parents:
35055
diff
changeset
|
74 |
|
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
75 |
def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2): |
34344
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
76 |
self._ui = ui |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
77 |
self._opener = opener |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
78 |
self._root = root |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 |
self._filename = b'dirstate' |
45252
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
80 |
self._nodelen = 20 |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
45957
diff
changeset
|
81 |
self._nodeconstants = nodeconstants |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
82 |
assert ( |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
83 |
not use_dirstate_v2 |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
84 |
), "should have detected unsupported requirement" |
34344
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
85 |
|
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
86 |
self._parents = None |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
87 |
self._dirtyparents = False |
34339
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
88 |
|
34344
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
89 |
# for consistent view between _pl() and _read() invocations |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
90 |
self._pendingmode = None |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
91 |
|
34934
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
92 |
@propertycache |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
93 |
def _map(self): |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
94 |
self._map = {} |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
95 |
self.read() |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
96 |
return self._map |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
97 |
|
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
98 |
@propertycache |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
99 |
def copymap(self): |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
100 |
self.copymap = {} |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
101 |
self._map |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
102 |
return self.copymap |
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
103 |
|
47357
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
104 |
def directories(self): |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
105 |
# Rust / dirstate-v2 only |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
106 |
return [] |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
107 |
|
34933
0217f75b6e59
dirstate: move clear onto dirstatemap class
Durham Goode <durham@fb.com>
parents:
34678
diff
changeset
|
108 |
def clear(self): |
34935
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
109 |
self._map.clear() |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
110 |
self.copymap.clear() |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
111 |
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
|
112 |
util.clearcachedproperty(self, b"_dirs") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
113 |
util.clearcachedproperty(self, b"_alldirs") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 |
util.clearcachedproperty(self, b"filefoldmap") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
115 |
util.clearcachedproperty(self, b"dirfoldmap") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 |
util.clearcachedproperty(self, b"nonnormalset") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
117 |
util.clearcachedproperty(self, b"otherparentset") |
34933
0217f75b6e59
dirstate: move clear onto dirstatemap class
Durham Goode <durham@fb.com>
parents:
34678
diff
changeset
|
118 |
|
35918
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35875
diff
changeset
|
119 |
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
|
120 |
return pycompat.iteritems(self._map) |
34339
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
121 |
|
35918
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35875
diff
changeset
|
122 |
# forward for python2,3 compat |
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35875
diff
changeset
|
123 |
iteritems = items |
6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
Augie Fackler <augie@google.com>
parents:
35875
diff
changeset
|
124 |
|
34409
7d2f71b7bc31
dirstate: implement __len__ on dirstatemap (issue5695)
Simon Whitaker <swhitaker@fb.com>
parents:
34346
diff
changeset
|
125 |
def __len__(self): |
7d2f71b7bc31
dirstate: implement __len__ on dirstatemap (issue5695)
Simon Whitaker <swhitaker@fb.com>
parents:
34346
diff
changeset
|
126 |
return len(self._map) |
7d2f71b7bc31
dirstate: implement __len__ on dirstatemap (issue5695)
Simon Whitaker <swhitaker@fb.com>
parents:
34346
diff
changeset
|
127 |
|
34339
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
128 |
def __iter__(self): |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
129 |
return iter(self._map) |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
130 |
|
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
131 |
def get(self, key, default=None): |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
132 |
return self._map.get(key, default) |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
133 |
|
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
134 |
def __contains__(self, key): |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
135 |
return key in self._map |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
136 |
|
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
137 |
def __getitem__(self, key): |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
138 |
return self._map[key] |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
139 |
|
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
140 |
def keys(self): |
b36881c68569
dirstate: create new dirstatemap class
Durham Goode <durham@fb.com>
parents:
34200
diff
changeset
|
141 |
return self._map.keys() |
34340
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
142 |
|
34935
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
143 |
def preload(self): |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
144 |
"""Loads the underlying data, if it's not already loaded""" |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
145 |
self._map |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
146 |
|
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
147 |
def addfile( |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
148 |
self, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
149 |
f, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
150 |
state=None, |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
151 |
mode=0, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
152 |
size=None, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
153 |
mtime=None, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
154 |
added=False, |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
155 |
merged=False, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
156 |
from_p2=False, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
157 |
possibly_dirty=False, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
158 |
): |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
159 |
"""Add a tracked file to the dirstate.""" |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
160 |
if added: |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
161 |
assert not merged |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
162 |
assert not possibly_dirty |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
163 |
assert not from_p2 |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
164 |
state = b'a' |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
165 |
size = NONNORMAL |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
166 |
mtime = AMBIGUOUS_TIME |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
167 |
elif merged: |
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
168 |
assert not possibly_dirty |
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
169 |
assert not from_p2 |
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
170 |
state = b'm' |
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
171 |
size = FROM_P2 |
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
172 |
mtime = AMBIGUOUS_TIME |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
173 |
elif from_p2: |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
174 |
assert not possibly_dirty |
47529
d3cf20328abd
dirstate: infer the 'n' state from `from_p2`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47528
diff
changeset
|
175 |
state = b'n' |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
176 |
size = FROM_P2 |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
177 |
mtime = AMBIGUOUS_TIME |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
178 |
elif possibly_dirty: |
47528
80617f3c0f9a
dirstate: infer the 'n' state from `possibly_dirty`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47527
diff
changeset
|
179 |
state = b'n' |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
180 |
size = NONNORMAL |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
181 |
mtime = AMBIGUOUS_TIME |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
182 |
else: |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
183 |
assert state != b'a' |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
184 |
assert size != FROM_P2 |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
185 |
assert size != NONNORMAL |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
186 |
size = size & rangemask |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
187 |
mtime = mtime & rangemask |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
188 |
assert state is not None |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
189 |
assert size is not None |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
190 |
assert mtime is not None |
47524
69a463a4f193
dirstate: no longer pass the `oldstate` value to the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47521
diff
changeset
|
191 |
old_entry = self.get(f) |
69a463a4f193
dirstate: no longer pass the `oldstate` value to the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47521
diff
changeset
|
192 |
if ( |
69a463a4f193
dirstate: no longer pass the `oldstate` value to the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47521
diff
changeset
|
193 |
old_entry is None or old_entry.removed |
69a463a4f193
dirstate: no longer pass the `oldstate` value to the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47521
diff
changeset
|
194 |
) and "_dirs" in self.__dict__: |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
195 |
self._dirs.addpath(f) |
47524
69a463a4f193
dirstate: no longer pass the `oldstate` value to the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47521
diff
changeset
|
196 |
if old_entry is None and "_alldirs" in self.__dict__: |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
197 |
self._alldirs.addpath(f) |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
198 |
self._map[f] = dirstatetuple(state, mode, size, mtime) |
47489
3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47488
diff
changeset
|
199 |
if state != b'n' or mtime == AMBIGUOUS_TIME: |
35103
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
200 |
self.nonnormalset.add(f) |
47487
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47486
diff
changeset
|
201 |
if size == FROM_P2: |
35103
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
202 |
self.otherparentset.add(f) |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
203 |
|
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
204 |
def removefile(self, f, in_merge=False): |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
205 |
""" |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
206 |
Mark a file as removed in the dirstate. |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
207 |
|
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
208 |
The `size` parameter is used to store sentinel values that indicate |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
209 |
the file's previous state. In the future, we should refactor this |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
210 |
to be more explicit about what that state is. |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
211 |
""" |
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
212 |
entry = self.get(f) |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
213 |
size = 0 |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
214 |
if in_merge: |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
215 |
# XXX we should not be able to have 'm' state and 'FROM_P2' if not |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
216 |
# during a merge. So I (marmoute) am not sure we need the |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
217 |
# conditionnal at all. Adding double checking this with assert |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
218 |
# would be nice. |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
219 |
if entry is not None: |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
220 |
# backup the previous state |
47513
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47511
diff
changeset
|
221 |
if entry.merged: # merge |
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
222 |
size = NONNORMAL |
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
223 |
elif entry[0] == b'n' and entry.from_p2: |
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
224 |
size = FROM_P2 |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
225 |
self.otherparentset.add(f) |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
226 |
if size == 0: |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
227 |
self.copymap.pop(f, None) |
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
228 |
|
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
229 |
if entry is not None and entry[0] != b'r' and "_dirs" in self.__dict__: |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
230 |
self._dirs.delpath(f) |
47511
eaae39894312
dirstate: move most of the `remove` logic with dirstatemap `removefile`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47506
diff
changeset
|
231 |
if entry is None and "_alldirs" in self.__dict__: |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
232 |
self._alldirs.addpath(f) |
43551
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43508
diff
changeset
|
233 |
if "filefoldmap" in self.__dict__: |
35105
e6c64744781f
dirstate: move dropping of folded filenames into the dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35104
diff
changeset
|
234 |
normed = util.normcase(f) |
e6c64744781f
dirstate: move dropping of folded filenames into the dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35104
diff
changeset
|
235 |
self.filefoldmap.pop(normed, None) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
236 |
self._map[f] = dirstatetuple(b'r', 0, size, 0) |
35103
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
237 |
self.nonnormalset.add(f) |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
238 |
|
35104
a947cf872799
dirstate: move management of the dirstate dirs into the dirstatemap
Mark Thomas <mbthomas@fb.com>
parents:
35103
diff
changeset
|
239 |
def dropfile(self, f, oldstate): |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
240 |
""" |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
241 |
Remove a file from the dirstate. Returns True if the file was |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
242 |
previously recorded. |
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
243 |
""" |
35103
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
244 |
exists = self._map.pop(f, None) is not None |
35104
a947cf872799
dirstate: move management of the dirstate dirs into the dirstatemap
Mark Thomas <mbthomas@fb.com>
parents:
35103
diff
changeset
|
245 |
if exists: |
43551
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43508
diff
changeset
|
246 |
if oldstate != b"r" and "_dirs" in self.__dict__: |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
247 |
self._dirs.delpath(f) |
43551
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43508
diff
changeset
|
248 |
if "_alldirs" in self.__dict__: |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
249 |
self._alldirs.delpath(f) |
43551
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43508
diff
changeset
|
250 |
if "filefoldmap" in self.__dict__: |
35105
e6c64744781f
dirstate: move dropping of folded filenames into the dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35104
diff
changeset
|
251 |
normed = util.normcase(f) |
e6c64744781f
dirstate: move dropping of folded filenames into the dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35104
diff
changeset
|
252 |
self.filefoldmap.pop(normed, None) |
35103
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
253 |
self.nonnormalset.discard(f) |
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
254 |
return exists |
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
255 |
|
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
256 |
def clearambiguoustimes(self, files, now): |
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
257 |
for f in files: |
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
258 |
e = self.get(f) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
259 |
if e is not None and e[0] == b'n' and e[3] == now: |
47489
3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47488
diff
changeset
|
260 |
self._map[f] = dirstatetuple(e[0], e[1], e[2], AMBIGUOUS_TIME) |
35103
19b75779b7c3
dirstate: move management of nonnormal sets into dirstate map
Mark Thomas <mbthomas@fb.com>
parents:
35102
diff
changeset
|
261 |
self.nonnormalset.add(f) |
35102
853b7c41d19c
dirstate: add explicit methods for modifying dirstate
Mark Thomas <mbthomas@fb.com>
parents:
35101
diff
changeset
|
262 |
|
34340
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
263 |
def nonnormalentries(self): |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
264 |
'''Compute the nonnormal dirstate entries from the dmap''' |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
265 |
try: |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
266 |
return parsers.nonnormalotherparententries(self._map) |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
267 |
except AttributeError: |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
268 |
nonnorm = set() |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
269 |
otherparent = set() |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43090
diff
changeset
|
270 |
for fname, e in pycompat.iteritems(self._map): |
47489
3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47488
diff
changeset
|
271 |
if e[0] != b'n' or e[3] == AMBIGUOUS_TIME: |
34340
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
272 |
nonnorm.add(fname) |
47487
cb29484eaade
dirstate: introduce a symbolic constant for the FROM_P2 marker
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47486
diff
changeset
|
273 |
if e[0] == b'n' and e[2] == FROM_P2: |
34340
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
274 |
otherparent.add(fname) |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
275 |
return nonnorm, otherparent |
4ac04418ce66
dirstate: move nonnormalentries to dirstatemap
Durham Goode <durham@fb.com>
parents:
34339
diff
changeset
|
276 |
|
34676
bfddc3d678ae
dirstate: remove _filefoldmap property cache
Durham Goode <durham@fb.com>
parents:
34675
diff
changeset
|
277 |
@propertycache |
34341
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
278 |
def filefoldmap(self): |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
279 |
"""Returns a dictionary mapping normalized case paths to their |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
280 |
non-normalized versions. |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
281 |
""" |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
282 |
try: |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
283 |
makefilefoldmap = parsers.make_file_foldmap |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
284 |
except AttributeError: |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
285 |
pass |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
286 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
287 |
return makefilefoldmap( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
288 |
self._map, util.normcasespec, util.normcasefallback |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
289 |
) |
34341
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
290 |
|
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
291 |
f = {} |
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
292 |
normcase = util.normcase |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43090
diff
changeset
|
293 |
for name, s in pycompat.iteritems(self._map): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
294 |
if s[0] != b'r': |
34341
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
295 |
f[normcase(name)] = name |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
296 |
f[b'.'] = b'.' # prevents useless util.fspath() invocation |
34341
d8b35920b7b1
dirstate: move filefoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34340
diff
changeset
|
297 |
return f |
34342
af9722412ac3
dirstate: move _dirs to dirstatemap
Durham Goode <durham@fb.com>
parents:
34341
diff
changeset
|
298 |
|
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
299 |
def hastrackeddir(self, d): |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
300 |
""" |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
301 |
Returns True if the dirstate contains a tracked (not removed) file |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
302 |
in this directory. |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
303 |
""" |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
304 |
return d in self._dirs |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
305 |
|
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
306 |
def hasdir(self, d): |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
307 |
""" |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
308 |
Returns True if the dirstate contains a file (tracked or removed) |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
309 |
in this directory. |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
310 |
""" |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
311 |
return d in self._alldirs |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
312 |
|
34677
014bd2a555c8
dirstate: remove _dirs property cache
Durham Goode <durham@fb.com>
parents:
34676
diff
changeset
|
313 |
@propertycache |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
314 |
def _dirs(self): |
43571
c21aca51b392
utils: move the `dirs` definition in pathutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43554
diff
changeset
|
315 |
return pathutil.dirs(self._map, b'r') |
34344
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
316 |
|
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
317 |
@propertycache |
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
318 |
def _alldirs(self): |
43571
c21aca51b392
utils: move the `dirs` definition in pathutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43554
diff
changeset
|
319 |
return pathutil.dirs(self._map) |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
320 |
|
34344
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
321 |
def _opendirstatefile(self): |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
322 |
fp, mode = txnutil.trypending(self._root, self._opener, self._filename) |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
323 |
if self._pendingmode is not None and self._pendingmode != mode: |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
324 |
fp.close() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
325 |
raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
326 |
_(b'working directory state may be changed parallelly') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
327 |
) |
34344
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
328 |
self._pendingmode = mode |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
329 |
return fp |
c36c3fa7d35b
dirstate: move opendirstatefile to dirstatemap
Durham Goode <durham@fb.com>
parents:
34343
diff
changeset
|
330 |
|
34345
0c3e3810cdb6
dirstate: move parent reading to the dirstatemap class
Durham Goode <durham@fb.com>
parents:
34344
diff
changeset
|
331 |
def parents(self): |
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
332 |
if not self._parents: |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
333 |
try: |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
334 |
fp = self._opendirstatefile() |
45252
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
335 |
st = fp.read(2 * self._nodelen) |
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
336 |
fp.close() |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
337 |
except IOError as err: |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
338 |
if err.errno != errno.ENOENT: |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
339 |
raise |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
340 |
# File doesn't exist, so the current state is empty |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 |
st = b'' |
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
342 |
|
34345
0c3e3810cdb6
dirstate: move parent reading to the dirstatemap class
Durham Goode <durham@fb.com>
parents:
34344
diff
changeset
|
343 |
l = len(st) |
45252
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
344 |
if l == self._nodelen * 2: |
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
345 |
self._parents = ( |
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
346 |
st[: self._nodelen], |
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
347 |
st[self._nodelen : 2 * self._nodelen], |
4f0e03d980f3
dirstate: isolate node len dependency for the pure version
Joerg Sonnenberger <joerg@bec.de>
parents:
44911
diff
changeset
|
348 |
) |
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
349 |
elif l == 0: |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
350 |
self._parents = ( |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
351 |
self._nodeconstants.nullid, |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
352 |
self._nodeconstants.nullid, |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
353 |
) |
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
354 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
355 |
raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
356 |
_(b'working directory state appears damaged!') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
357 |
) |
34346
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
358 |
|
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
359 |
return self._parents |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
360 |
|
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
361 |
def setparents(self, p1, p2): |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
362 |
self._parents = (p1, p2) |
ec769bba34d3
dirstate: move parents source of truth to dirstatemap
Durham Goode <durham@fb.com>
parents:
34345
diff
changeset
|
363 |
self._dirtyparents = True |
34672
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
364 |
|
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
365 |
def read(self): |
34675
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
366 |
# ignore HG_PENDING because identity is used only for writing |
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
367 |
self.identity = util.filestat.frompath( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
368 |
self._opener.join(self._filename) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
369 |
) |
34675
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
370 |
|
34672
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
371 |
try: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
372 |
fp = self._opendirstatefile() |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
373 |
try: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
374 |
st = fp.read() |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
375 |
finally: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
376 |
fp.close() |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
377 |
except IOError as err: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
378 |
if err.errno != errno.ENOENT: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
379 |
raise |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
380 |
return |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
381 |
if not st: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
382 |
return |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
383 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
384 |
if util.safehasattr(parsers, b'dict_new_presized'): |
34672
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
385 |
# Make an estimate of the number of files in the dirstate based on |
45269
ad7006830106
dirstate: restore original estimation and update comment
Joerg Sonnenberger <joerg@bec.de>
parents:
45267
diff
changeset
|
386 |
# its size. This trades wasting some memory for avoiding costly |
ad7006830106
dirstate: restore original estimation and update comment
Joerg Sonnenberger <joerg@bec.de>
parents:
45267
diff
changeset
|
387 |
# resizes. Each entry have a prefix of 17 bytes followed by one or |
ad7006830106
dirstate: restore original estimation and update comment
Joerg Sonnenberger <joerg@bec.de>
parents:
45267
diff
changeset
|
388 |
# two path names. Studies on various large-scale real-world repositories |
ad7006830106
dirstate: restore original estimation and update comment
Joerg Sonnenberger <joerg@bec.de>
parents:
45267
diff
changeset
|
389 |
# found 54 bytes a reasonable upper limit for the average path names. |
ad7006830106
dirstate: restore original estimation and update comment
Joerg Sonnenberger <joerg@bec.de>
parents:
45267
diff
changeset
|
390 |
# Copy entries are ignored for the sake of this estimate. |
ad7006830106
dirstate: restore original estimation and update comment
Joerg Sonnenberger <joerg@bec.de>
parents:
45267
diff
changeset
|
391 |
self._map = parsers.dict_new_presized(len(st) // 71) |
34672
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
392 |
|
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
393 |
# Python's garbage collector triggers a GC each time a certain number |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
394 |
# of container objects (the number being defined by |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
395 |
# gc.get_threshold()) are allocated. parse_dirstate creates a tuple |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
396 |
# for each file in the dirstate. The C version then immediately marks |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
397 |
# them as not to be tracked by the collector. However, this has no |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
398 |
# effect on when GCs are triggered, only on what objects the GC looks |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
399 |
# into. This means that O(number of files) GCs are unavoidable. |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
400 |
# Depending on when in the process's lifetime the dirstate is parsed, |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
401 |
# this can get very expensive. As a workaround, disable GC while |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
402 |
# parsing the dirstate. |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
403 |
# |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
404 |
# (we cannot decorate the function directly since it is in a C module) |
42763
760a7851e9ba
rust-parsers: move parser bindings to their own file and Python module
Raphaël Gomès <rgomes@octobus.net>
parents:
42472
diff
changeset
|
405 |
parse_dirstate = util.nogc(parsers.parse_dirstate) |
34672
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
406 |
p = parse_dirstate(self._map, self.copymap, st) |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
407 |
if not self._dirtyparents: |
e159f217230e
dirstate: move _read into dirstatemap
Durham Goode <durham@fb.com>
parents:
34481
diff
changeset
|
408 |
self.setparents(*p) |
34673
e2214632c3a2
dirstate: move write into dirstatemap
Durham Goode <durham@fb.com>
parents:
34672
diff
changeset
|
409 |
|
34935
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
410 |
# Avoid excess attribute lookups by fast pathing certain checks |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
411 |
self.__contains__ = self._map.__contains__ |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
412 |
self.__getitem__ = self._map.__getitem__ |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
413 |
self.get = self._map.get |
ffeea2406276
dirstate: remove excess attribute lookups for dirstate.status (issue5714)
Durham Goode <durham@fb.com>
parents:
34934
diff
changeset
|
414 |
|
34673
e2214632c3a2
dirstate: move write into dirstatemap
Durham Goode <durham@fb.com>
parents:
34672
diff
changeset
|
415 |
def write(self, st, now): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
416 |
st.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
417 |
parsers.pack_dirstate(self._map, self.copymap, self.parents(), now) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
418 |
) |
34673
e2214632c3a2
dirstate: move write into dirstatemap
Durham Goode <durham@fb.com>
parents:
34672
diff
changeset
|
419 |
st.close() |
e2214632c3a2
dirstate: move write into dirstatemap
Durham Goode <durham@fb.com>
parents:
34672
diff
changeset
|
420 |
self._dirtyparents = False |
34674
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
421 |
self.nonnormalset, self.otherparentset = self.nonnormalentries() |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
422 |
|
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
423 |
@propertycache |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
424 |
def nonnormalset(self): |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
425 |
nonnorm, otherparents = self.nonnormalentries() |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
426 |
self.otherparentset = otherparents |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
427 |
return nonnorm |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
428 |
|
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
429 |
@propertycache |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
430 |
def otherparentset(self): |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
431 |
nonnorm, otherparents = self.nonnormalentries() |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
432 |
self.nonnormalset = nonnorm |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
433 |
return otherparents |
60927b19ed65
dirstate: move nonnormal and otherparent sets to dirstatemap
Durham Goode <durham@fb.com>
parents:
34673
diff
changeset
|
434 |
|
47108
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
435 |
def non_normal_or_other_parent_paths(self): |
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
436 |
return self.nonnormalset.union(self.otherparentset) |
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
437 |
|
34675
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
438 |
@propertycache |
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
439 |
def identity(self): |
34934
6e66033f91cc
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Durham Goode <durham@fb.com>
parents:
34933
diff
changeset
|
440 |
self._map |
34675
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
441 |
return self.identity |
c6ef9a2498a5
dirstate: move identity to dirstatemap
Durham Goode <durham@fb.com>
parents:
34674
diff
changeset
|
442 |
|
34678
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
443 |
@propertycache |
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
444 |
def dirfoldmap(self): |
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
445 |
f = {} |
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
446 |
normcase = util.normcase |
35107
61888bd0b300
dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents:
35106
diff
changeset
|
447 |
for name in self._dirs: |
34678
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
448 |
f[normcase(name)] = name |
e8a89ed7ce96
dirstate: move the _dirfoldmap to dirstatemap
Durham Goode <durham@fb.com>
parents:
34677
diff
changeset
|
449 |
return f |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
450 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
451 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
452 |
if rustmod is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
453 |
|
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
454 |
class dirstatemap(object): |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
455 |
def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2): |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
456 |
self._use_dirstate_v2 = use_dirstate_v2 |
46793
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
45957
diff
changeset
|
457 |
self._nodeconstants = nodeconstants |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
458 |
self._ui = ui |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
459 |
self._opener = opener |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
460 |
self._root = root |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
461 |
self._filename = b'dirstate' |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
462 |
self._nodelen = 20 # Also update Rust code when changing this! |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
463 |
self._parents = None |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
464 |
self._dirtyparents = False |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
465 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
466 |
# for consistent view between _pl() and _read() invocations |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
467 |
self._pendingmode = None |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
468 |
|
47328
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
469 |
self._use_dirstate_tree = self._ui.configbool( |
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
470 |
b"experimental", |
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
471 |
b"dirstate-tree.in-memory", |
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
472 |
False, |
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
473 |
) |
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
474 |
|
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
475 |
def addfile( |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
476 |
self, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
477 |
f, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
478 |
state=None, |
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
479 |
mode=0, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
480 |
size=None, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
481 |
mtime=None, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
482 |
added=False, |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
483 |
merged=False, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
484 |
from_p2=False, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
485 |
possibly_dirty=False, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
486 |
): |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
487 |
return self._rustmap.addfile( |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
488 |
f, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
489 |
state, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
490 |
mode, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
491 |
size, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
492 |
mtime, |
47525
fe4641cf9b72
dirstate: use a `added` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47524
diff
changeset
|
493 |
added, |
47527
c6b91a9c242a
dirstate: use a `merged` parameter to _addpath
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47525
diff
changeset
|
494 |
merged, |
47521
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
495 |
from_p2, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
496 |
possibly_dirty, |
abed645b8e96
dirstate: move the handling of special case within the dirstatemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
497 |
) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
498 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
499 |
def removefile(self, *args, **kwargs): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
500 |
return self._rustmap.removefile(*args, **kwargs) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
501 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
502 |
def dropfile(self, *args, **kwargs): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
503 |
return self._rustmap.dropfile(*args, **kwargs) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
504 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
505 |
def clearambiguoustimes(self, *args, **kwargs): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
506 |
return self._rustmap.clearambiguoustimes(*args, **kwargs) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
507 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
508 |
def nonnormalentries(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
509 |
return self._rustmap.nonnormalentries() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
510 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
511 |
def get(self, *args, **kwargs): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
512 |
return self._rustmap.get(*args, **kwargs) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
513 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
514 |
@property |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
515 |
def copymap(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
516 |
return self._rustmap.copymap() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
517 |
|
47357
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
518 |
def directories(self): |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
519 |
return self._rustmap.directories() |
3b9914b28133
dirstate-v2: Add --dirs to debugdirstate command
Simon Sapin <simon.sapin@octobus.net>
parents:
47356
diff
changeset
|
520 |
|
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
521 |
def preload(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
522 |
self._rustmap |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
523 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
524 |
def clear(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
525 |
self._rustmap.clear() |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
526 |
self.setparents( |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
527 |
self._nodeconstants.nullid, self._nodeconstants.nullid |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
528 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
529 |
util.clearcachedproperty(self, b"_dirs") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
530 |
util.clearcachedproperty(self, b"_alldirs") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
531 |
util.clearcachedproperty(self, b"dirfoldmap") |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
532 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
533 |
def items(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
534 |
return self._rustmap.items() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
535 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
536 |
def keys(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
537 |
return iter(self._rustmap) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
538 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
539 |
def __contains__(self, key): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
540 |
return key in self._rustmap |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
541 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
542 |
def __getitem__(self, item): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
543 |
return self._rustmap[item] |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
544 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
545 |
def __len__(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
546 |
return len(self._rustmap) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
547 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
548 |
def __iter__(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
549 |
return iter(self._rustmap) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
550 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
551 |
# forward for python2,3 compat |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
552 |
iteritems = items |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
553 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
554 |
def _opendirstatefile(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
555 |
fp, mode = txnutil.trypending( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
556 |
self._root, self._opener, self._filename |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
557 |
) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
558 |
if self._pendingmode is not None and self._pendingmode != mode: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
559 |
fp.close() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
560 |
raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
561 |
_(b'working directory state may be changed parallelly') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
562 |
) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
563 |
self._pendingmode = mode |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
564 |
return fp |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
565 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
566 |
def setparents(self, p1, p2): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
567 |
self._parents = (p1, p2) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
568 |
self._dirtyparents = True |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
569 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
570 |
def parents(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
571 |
if not self._parents: |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
572 |
if self._use_dirstate_v2: |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
573 |
offset = len(rustmod.V2_FORMAT_MARKER) |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
574 |
else: |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
575 |
offset = 0 |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
576 |
read_len = offset + self._nodelen * 2 |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
577 |
try: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
578 |
fp = self._opendirstatefile() |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
579 |
st = fp.read(read_len) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
580 |
fp.close() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
581 |
except IOError as err: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
582 |
if err.errno != errno.ENOENT: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
583 |
raise |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
584 |
# File doesn't exist, so the current state is empty |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
585 |
st = b'' |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
586 |
|
47135
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
587 |
l = len(st) |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
588 |
if l == read_len: |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
589 |
st = st[offset:] |
47135
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
590 |
self._parents = ( |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
591 |
st[: self._nodelen], |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
592 |
st[self._nodelen : 2 * self._nodelen], |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
593 |
) |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
594 |
elif l == 0: |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
595 |
self._parents = ( |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
596 |
self._nodeconstants.nullid, |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
597 |
self._nodeconstants.nullid, |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
598 |
) |
b6339a993b91
rust: Remove handling of `parents` in `DirstateMap`
Simon Sapin <simon.sapin@octobus.net>
parents:
47109
diff
changeset
|
599 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
600 |
raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
601 |
_(b'working directory state appears damaged!') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
602 |
) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
603 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
604 |
return self._parents |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
605 |
|
47136
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
606 |
@propertycache |
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
607 |
def _rustmap(self): |
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
608 |
""" |
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
609 |
Fills the Dirstatemap when called. |
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
610 |
""" |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
611 |
# ignore HG_PENDING because identity is used only for writing |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
612 |
self.identity = util.filestat.frompath( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
613 |
self._opener.join(self._filename) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42931
diff
changeset
|
614 |
) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
615 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
616 |
try: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
617 |
fp = self._opendirstatefile() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
618 |
try: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
619 |
st = fp.read() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
620 |
finally: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
621 |
fp.close() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
622 |
except IOError as err: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
623 |
if err.errno != errno.ENOENT: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
624 |
raise |
47136
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
625 |
st = b'' |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
626 |
|
47136
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
627 |
self._rustmap, parents = rustmod.DirstateMap.new( |
47328
a43d256c041a
dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents:
47291
diff
changeset
|
628 |
self._use_dirstate_tree, self._use_dirstate_v2, st |
47136
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
629 |
) |
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
630 |
|
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
631 |
if parents and not self._dirtyparents: |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
632 |
self.setparents(*parents) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
633 |
|
43280
5d4046594d6f
rust-dirstatemap: remove additional lookups in dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
43274
diff
changeset
|
634 |
self.__contains__ = self._rustmap.__contains__ |
5d4046594d6f
rust-dirstatemap: remove additional lookups in dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
43274
diff
changeset
|
635 |
self.__getitem__ = self._rustmap.__getitem__ |
5d4046594d6f
rust-dirstatemap: remove additional lookups in dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
43274
diff
changeset
|
636 |
self.get = self._rustmap.get |
47136
9aba0cde0ed9
rust: Read dirstate from disk in DirstateMap constructor
Simon Sapin <simon.sapin@octobus.net>
parents:
47135
diff
changeset
|
637 |
return self._rustmap |
43280
5d4046594d6f
rust-dirstatemap: remove additional lookups in dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents:
43274
diff
changeset
|
638 |
|
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
639 |
def write(self, st, now): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
640 |
parents = self.parents() |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
641 |
packed = self._rustmap.write( |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
642 |
self._use_dirstate_v2, parents[0], parents[1], now |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
643 |
) |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47288
diff
changeset
|
644 |
st.write(packed) |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
645 |
st.close() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
646 |
self._dirtyparents = False |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
647 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
648 |
@propertycache |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
649 |
def filefoldmap(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
650 |
"""Returns a dictionary mapping normalized case paths to their |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
651 |
non-normalized versions. |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
652 |
""" |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
653 |
return self._rustmap.filefoldmapasdict() |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
654 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
655 |
def hastrackeddir(self, d): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
656 |
return self._rustmap.hastrackeddir(d) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
657 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
658 |
def hasdir(self, d): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
659 |
return self._rustmap.hasdir(d) |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
660 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
661 |
@propertycache |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
662 |
def identity(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
663 |
self._rustmap |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
664 |
return self.identity |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
665 |
|
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
666 |
@property |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
667 |
def nonnormalset(self): |
44181
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44156
diff
changeset
|
668 |
nonnorm = self._rustmap.non_normal_entries() |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
669 |
return nonnorm |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
670 |
|
44156
7f5410dfc8a6
rust-dirstatemap: add missing @propertycache
Raphaël Gomès <rgomes@octobus.net>
parents:
44078
diff
changeset
|
671 |
@propertycache |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
672 |
def otherparentset(self): |
44181
71e13cfd6154
rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents:
44156
diff
changeset
|
673 |
otherparents = self._rustmap.other_parent_entries() |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
674 |
return otherparents |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
675 |
|
47108
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
676 |
def non_normal_or_other_parent_paths(self): |
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
677 |
return self._rustmap.non_normal_or_other_parent_paths() |
e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
678 |
|
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
679 |
@propertycache |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
680 |
def dirfoldmap(self): |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
681 |
f = {} |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
682 |
normcase = util.normcase |
47482
eb416759af7e
dirstate: Removed unused instances of `DirsMultiset`
Simon Sapin <simon.sapin@octobus.net>
parents:
47357
diff
changeset
|
683 |
for name, _pseudo_entry in self.directories(): |
42771
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
684 |
f[normcase(name)] = name |
749ef8c31187
rust-dirstate: call rust dirstatemap from Python
Raphaël Gomès <rgomes@octobus.net>
parents:
42763
diff
changeset
|
685 |
return f |