Mercurial > hg-stable
annotate mercurial/pure/parsers.py @ 52182:fa58f4f97337 stable tip
ci: shard the test run on mac os X
This should comes with some benefit:
- spread the load across more runner,
- reduce the real-time CI run,
- reduce the "retry" run when we need them.
We start with the Mac jobs, but that would be tremendously useful for Windows
too.
For linux, we need to reduce the startup overhead for this to be worth it.
Building smaller image and speeding up clone should help with that.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 08 Nov 2024 17:08:11 +0100 |
parents | 609700e5d8df |
children |
rev | line source |
---|---|
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
1 # parsers.py - Python implementation of parsers.c |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
2 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46730
diff
changeset
|
3 # Copyright 2009 Olivia Mackall <olivia@selenic.com> and others |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
7945
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
7 |
51901
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51799
diff
changeset
|
8 from __future__ import annotations |
27339
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
9 |
48964
5aafc3c5bdec
py3: use io.BytesIO directly
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48772
diff
changeset
|
10 import io |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
11 import stat |
27339
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
12 import struct |
51788
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
13 import typing |
27339
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
14 import zlib |
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
15 |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
16 from ..node import ( |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
17 nullrev, |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
18 sha1nodeconstants, |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
19 ) |
47566
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
20 from ..thirdparty import attr |
51788
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
21 |
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
22 # Force pytype to use the non-vendored package |
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
23 if typing.TYPE_CHECKING: |
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
24 # noinspection PyPackageRequirements |
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
25 import attr |
278af66e6595
typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents:
51762
diff
changeset
|
26 |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
27 from .. import ( |
47246
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
28 error, |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
29 pycompat, |
47400
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47281
diff
changeset
|
30 revlogutils, |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
31 util, |
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
32 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
33 |
44035
ab595920de0e
revlogutils: move the NodeMap class in a dedicated nodemap module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43663
diff
changeset
|
34 from ..revlogutils import nodemap as nodemaputil |
46857
cc65cea90edb
revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
35 from ..revlogutils import constants as revlog_constants |
44035
ab595920de0e
revlogutils: move the NodeMap class in a dedicated nodemap module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43663
diff
changeset
|
36 |
48964
5aafc3c5bdec
py3: use io.BytesIO directly
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48772
diff
changeset
|
37 stringio = io.BytesIO |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
38 |
31230
37596c980662
parsers: alias long to int on Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29133
diff
changeset
|
39 |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
40 _pack = struct.pack |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
41 _unpack = struct.unpack |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
42 _compress = zlib.compress |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
43 _decompress = zlib.decompress |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
44 |
47507
d4c795576aeb
dirstate-entry: turn dirstate tuple into a real object (like in C)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47495
diff
changeset
|
45 |
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
46 # a special value used internally for `size` if the file come from the other parent |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
47 FROM_P2 = -2 |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
48 |
47516
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
49 # a special value used internally for `size` if the file is modified/merged/added |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
50 NONNORMAL = -1 |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
51 |
47540
1a6302427eb9
dirstate-item: use need_delay when packing dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
diff
changeset
|
52 # a special value used internally for `time` if the time is ambigeous |
1a6302427eb9
dirstate-item: use need_delay when packing dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
diff
changeset
|
53 AMBIGUOUS_TIME = -1 |
1a6302427eb9
dirstate-item: use need_delay when packing dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
diff
changeset
|
54 |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
55 # Bits of the `flags` byte inside a node in the file format |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
56 DIRSTATE_V2_WDIR_TRACKED = 1 << 0 |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
57 DIRSTATE_V2_P1_TRACKED = 1 << 1 |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
58 DIRSTATE_V2_P2_INFO = 1 << 2 |
48277
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
59 DIRSTATE_V2_MODE_EXEC_PERM = 1 << 3 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
60 DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 4 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
61 DIRSTATE_V2_HAS_FALLBACK_EXEC = 1 << 5 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
62 DIRSTATE_V2_FALLBACK_EXEC = 1 << 6 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
63 DIRSTATE_V2_HAS_FALLBACK_SYMLINK = 1 << 7 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
64 DIRSTATE_V2_FALLBACK_SYMLINK = 1 << 8 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
65 DIRSTATE_V2_EXPECTED_STATE_IS_MODIFIED = 1 << 9 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
66 DIRSTATE_V2_HAS_MODE_AND_SIZE = 1 << 10 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
67 DIRSTATE_V2_HAS_MTIME = 1 << 11 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
68 DIRSTATE_V2_MTIME_SECOND_AMBIGUOUS = 1 << 12 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
69 DIRSTATE_V2_DIRECTORY = 1 << 13 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
70 DIRSTATE_V2_ALL_UNKNOWN_RECORDED = 1 << 14 |
749946b6a641
dirstate-v2: reorder flag to group related one together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48275
diff
changeset
|
71 DIRSTATE_V2_ALL_IGNORED_RECORDED = 1 << 15 |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
72 |
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
73 |
47664
119b9c8db94d
dirstate-item: use an explicit __init__ function instead of the attrs one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47569
diff
changeset
|
74 @attr.s(slots=True, init=False) |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
49004
diff
changeset
|
75 class DirstateItem: |
47507
d4c795576aeb
dirstate-entry: turn dirstate tuple into a real object (like in C)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47495
diff
changeset
|
76 """represent a dirstate entry |
d4c795576aeb
dirstate-entry: turn dirstate tuple into a real object (like in C)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47495
diff
changeset
|
77 |
48124
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
78 It hold multiple attributes |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
79 |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
80 # about file tracking |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
81 - wc_tracked: is the file tracked by the working copy |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
82 - p1_tracked: is the file tracked in working copy first parent |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
83 - p2_info: the file has been involved in some merge operation. Either |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
84 because it was actually merged, or because the p2 version was |
48200
77fc340acad7
dirstate-v2: Document flags/mode/size/mtime fields of tree nodes
Simon Sapin <simon.sapin@octobus.net>
parents:
48176
diff
changeset
|
85 ahead, or because some rename moved it there. In either case |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
86 `hg status` will want it displayed as modified. |
48124
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
87 |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
88 # about the file state expected from p1 manifest: |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
89 - mode: the file mode in p1 |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
90 - size: the file size in p1 |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
91 |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
92 These value can be set to None, which mean we don't have a meaningful value |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
93 to compare with. Either because we don't really care about them as there |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
94 `status` is known without having to look at the disk or because we don't |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
95 know these right now and a full comparison will be needed to find out if |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
96 the file is clean. |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
97 |
48124
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
98 # about the file state on disk last time we saw it: |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
99 - mtime: the last known clean mtime for the file. |
fabf687df0ff
dirstate-item: update the attribute documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48123
diff
changeset
|
100 |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
101 This value can be set to None if no cachable state exist. Either because we |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
102 do not care (see previous section) or because we could not cache something |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
103 yet. |
47495
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
104 """ |
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
105 |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
106 _wc_tracked = attr.ib() |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
107 _p1_tracked = attr.ib() |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
108 _p2_info = attr.ib() |
47566
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
109 _mode = attr.ib() |
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
110 _size = attr.ib() |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
111 _mtime_s = attr.ib() |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
112 _mtime_ns = attr.ib() |
48263
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
113 _fallback_exec = attr.ib() |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
114 _fallback_symlink = attr.ib() |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
115 _mtime_second_ambiguous = attr.ib() |
47507
d4c795576aeb
dirstate-entry: turn dirstate tuple into a real object (like in C)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47495
diff
changeset
|
116 |
47926
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
117 def __init__( |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
118 self, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
119 wc_tracked=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
120 p1_tracked=False, |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
121 p2_info=False, |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
122 has_meaningful_data=True, |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
123 has_meaningful_mtime=True, |
47926
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
124 parentfiledata=None, |
48264
948570aa7630
dirstate: make DirstateItem constructor accept fallback value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48263
diff
changeset
|
125 fallback_exec=None, |
948570aa7630
dirstate: make DirstateItem constructor accept fallback value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48263
diff
changeset
|
126 fallback_symlink=None, |
47926
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
127 ): |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
128 self._wc_tracked = wc_tracked |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
129 self._p1_tracked = p1_tracked |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
130 self._p2_info = p2_info |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
131 |
48264
948570aa7630
dirstate: make DirstateItem constructor accept fallback value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48263
diff
changeset
|
132 self._fallback_exec = fallback_exec |
948570aa7630
dirstate: make DirstateItem constructor accept fallback value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48263
diff
changeset
|
133 self._fallback_symlink = fallback_symlink |
48263
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
134 |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
135 self._mode = None |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
136 self._size = None |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
137 self._mtime_s = None |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
138 self._mtime_ns = None |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
139 self._mtime_second_ambiguous = False |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
140 if parentfiledata is None: |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
141 has_meaningful_mtime = False |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
142 has_meaningful_data = False |
48426
3d6eb119200d
dirstate-item: allow mtime to be None in "parentdata"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48277
diff
changeset
|
143 elif parentfiledata[2] is None: |
3d6eb119200d
dirstate-item: allow mtime to be None in "parentdata"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48277
diff
changeset
|
144 has_meaningful_mtime = False |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
145 if has_meaningful_data: |
47926
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
146 self._mode = parentfiledata[0] |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
147 self._size = parentfiledata[1] |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
148 if has_meaningful_mtime: |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
149 ( |
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
150 self._mtime_s, |
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
151 self._mtime_ns, |
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
152 self._mtime_second_ambiguous, |
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
153 ) = parentfiledata[2] |
47664
119b9c8db94d
dirstate-item: use an explicit __init__ function instead of the attrs one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47569
diff
changeset
|
154 |
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
155 @classmethod |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
156 def from_v2_data(cls, flags, size, mtime_s, mtime_ns): |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
157 """Build a new DirstateItem object from V2 data""" |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
158 has_mode_size = bool(flags & DIRSTATE_V2_HAS_MODE_AND_SIZE) |
48275
bb240915f69f
dirstate-v2: adjust the meaning of directory flags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48273
diff
changeset
|
159 has_meaningful_mtime = bool(flags & DIRSTATE_V2_HAS_MTIME) |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
160 mode = None |
48261
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
161 |
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
162 if flags & +DIRSTATE_V2_EXPECTED_STATE_IS_MODIFIED: |
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
163 # we do not have support for this flag in the code yet, |
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
164 # force a lookup for this file. |
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
165 has_mode_size = False |
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
166 has_meaningful_mtime = False |
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
167 |
48265
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
168 fallback_exec = None |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
169 if flags & DIRSTATE_V2_HAS_FALLBACK_EXEC: |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
170 fallback_exec = flags & DIRSTATE_V2_FALLBACK_EXEC |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
171 |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
172 fallback_symlink = None |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
173 if flags & DIRSTATE_V2_HAS_FALLBACK_SYMLINK: |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
174 fallback_symlink = flags & DIRSTATE_V2_FALLBACK_SYMLINK |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
175 |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
176 if has_mode_size: |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
177 assert stat.S_IXUSR == 0o100 |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
178 if flags & DIRSTATE_V2_MODE_EXEC_PERM: |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
179 mode = 0o755 |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
180 else: |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
181 mode = 0o644 |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
182 if flags & DIRSTATE_V2_MODE_IS_SYMLINK: |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
183 mode |= stat.S_IFLNK |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
184 else: |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
185 mode |= stat.S_IFREG |
48450
be2317167a9b
dirstate-item: make sure we load `mtime-second-ambiguous` from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48449
diff
changeset
|
186 |
be2317167a9b
dirstate-item: make sure we load `mtime-second-ambiguous` from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48449
diff
changeset
|
187 second_ambiguous = flags & DIRSTATE_V2_MTIME_SECOND_AMBIGUOUS |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
188 return cls( |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
189 wc_tracked=bool(flags & DIRSTATE_V2_WDIR_TRACKED), |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
190 p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED), |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
191 p2_info=bool(flags & DIRSTATE_V2_P2_INFO), |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
192 has_meaningful_data=has_mode_size, |
48261
1730b2fceaa1
dirstate-v2: adds a flag to mark a file as modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48244
diff
changeset
|
193 has_meaningful_mtime=has_meaningful_mtime, |
48450
be2317167a9b
dirstate-item: make sure we load `mtime-second-ambiguous` from disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48449
diff
changeset
|
194 parentfiledata=(mode, size, (mtime_s, mtime_ns, second_ambiguous)), |
48265
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
195 fallback_exec=fallback_exec, |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
196 fallback_symlink=fallback_symlink, |
48233
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
197 ) |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
198 |
a32a96079e2d
dirstate-v2: initial Python parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48200
diff
changeset
|
199 @classmethod |
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
200 def from_v1_data(cls, state, mode, size, mtime): |
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
201 """Build a new DirstateItem object from V1 data |
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
202 |
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
203 Since the dirstate-v1 format is frozen, the signature of this function |
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
204 is not expected to change, unlike the __init__ one. |
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
205 """ |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
206 if state == b'm': |
48166
7a8c9869e4fe
dirstate-item: replace call to new_merged
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48165
diff
changeset
|
207 return cls(wc_tracked=True, p1_tracked=True, p2_info=True) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
208 elif state == b'a': |
48168
d342815ff827
dirstate-item: replace call to new_added
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48167
diff
changeset
|
209 return cls(wc_tracked=True) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
210 elif state == b'r': |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
211 if size == NONNORMAL: |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
212 p1_tracked = True |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
213 p2_info = True |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
214 elif size == FROM_P2: |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
215 p1_tracked = False |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
216 p2_info = True |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
217 else: |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
218 p1_tracked = True |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
219 p2_info = False |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
220 return cls(p1_tracked=p1_tracked, p2_info=p2_info) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
221 elif state == b'n': |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
222 if size == FROM_P2: |
48170
da304f78a0e1
dirstate-item: replace call to new_from_p2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48169
diff
changeset
|
223 return cls(wc_tracked=True, p2_info=True) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
224 elif size == NONNORMAL: |
48172
898de425bcd6
dirstate-item: replace call to new_possibly_dirty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48171
diff
changeset
|
225 return cls(wc_tracked=True, p1_tracked=True) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
226 elif mtime == AMBIGUOUS_TIME: |
48174
79ebbe19d9e3
dirstate-item: replace a call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48173
diff
changeset
|
227 return cls( |
79ebbe19d9e3
dirstate-item: replace a call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48173
diff
changeset
|
228 wc_tracked=True, |
79ebbe19d9e3
dirstate-item: replace a call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48173
diff
changeset
|
229 p1_tracked=True, |
79ebbe19d9e3
dirstate-item: replace a call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48173
diff
changeset
|
230 has_meaningful_mtime=False, |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
231 parentfiledata=(mode, size, (42, 0, False)), |
48174
79ebbe19d9e3
dirstate-item: replace a call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48173
diff
changeset
|
232 ) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
233 else: |
48175
d0081dbca442
dirstate-item: replace call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48174
diff
changeset
|
234 return cls( |
d0081dbca442
dirstate-item: replace call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48174
diff
changeset
|
235 wc_tracked=True, |
d0081dbca442
dirstate-item: replace call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48174
diff
changeset
|
236 p1_tracked=True, |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
237 parentfiledata=(mode, size, (mtime, 0, False)), |
48175
d0081dbca442
dirstate-item: replace call to new_normal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48174
diff
changeset
|
238 ) |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
239 else: |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
240 raise RuntimeError('unknown state: %s' % pycompat.sysstr(state)) |
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
241 |
47666
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
242 def set_possibly_dirty(self): |
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
243 """Mark a file as "possibly dirty" |
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
244 |
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
245 This means the next status call will have to actually check its content |
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
246 to make sure it is correct. |
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
247 """ |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
248 self._mtime_s = None |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
249 self._mtime_ns = None |
47666
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
250 |
48002
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
251 def set_clean(self, mode, size, mtime): |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
252 """mark a file as "clean" cancelling potential "possibly dirty call" |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
253 |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
254 Note: this function is a descendant of `dirstate.normal` and is |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
255 currently expected to be call on "normal" entry only. There are not |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
256 reason for this to not change in the future as long as the ccode is |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
257 updated to preserve the proper state of the non-normal files. |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
258 """ |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
259 self._wc_tracked = True |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
260 self._p1_tracked = True |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
261 self._mode = mode |
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
262 self._size = size |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
263 self._mtime_s, self._mtime_ns, self._mtime_second_ambiguous = mtime |
48002
4e6f27230aee
dirstate: introduce a `set_clean` method on dirstate's map and items
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47969
diff
changeset
|
264 |
48014
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
265 def set_tracked(self): |
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
266 """mark a file as tracked in the working copy |
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
267 |
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
268 This will ultimately be called by command like `hg add`. |
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
269 """ |
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
270 self._wc_tracked = True |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
271 # `set_tracked` is replacing various `normallookup` call. So we mark |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
272 # the files as needing lookup |
48014
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
273 # |
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
274 # Consider dropping this in the future in favor of something less broad. |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
275 self._mtime_s = None |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
276 self._mtime_ns = None |
48014
0d2a404f1932
dirstate: introduce a set_tracked method on "map" and "item"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48002
diff
changeset
|
277 |
47921
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
278 def set_untracked(self): |
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
279 """mark a file as untracked in the working copy |
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
280 |
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
281 This will ultimately be called by command like `hg remove`. |
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
282 """ |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
283 self._wc_tracked = False |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
284 self._mode = None |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
285 self._size = None |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
286 self._mtime_s = None |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
287 self._mtime_ns = None |
47921
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
288 |
48075
a660d8a53267
dirstate: use a new `drop_merge_data` in `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48014
diff
changeset
|
289 def drop_merge_data(self): |
49174
4c75f00b199e
dirstate-item: add missing bit of docstring
Raphaël Gomès <rgomes@octobus.net>
parents:
49109
diff
changeset
|
290 """remove all "merge-only" information from a DirstateItem |
48075
a660d8a53267
dirstate: use a new `drop_merge_data` in `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48014
diff
changeset
|
291 |
a660d8a53267
dirstate: use a new `drop_merge_data` in `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48014
diff
changeset
|
292 This is to be call by the dirstatemap code when the second parent is dropped |
a660d8a53267
dirstate: use a new `drop_merge_data` in `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48014
diff
changeset
|
293 """ |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
294 if self._p2_info: |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
295 self._p2_info = False |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
296 self._mode = None |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
297 self._size = None |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
298 self._mtime_s = None |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
299 self._mtime_ns = None |
48075
a660d8a53267
dirstate: use a new `drop_merge_data` in `setparent`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48014
diff
changeset
|
300 |
47512
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
301 @property |
47536
8e4b9fe31334
dirstate-entry: add a `mode` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47532
diff
changeset
|
302 def mode(self): |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
303 return self._v1_mode() |
47536
8e4b9fe31334
dirstate-entry: add a `mode` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47532
diff
changeset
|
304 |
8e4b9fe31334
dirstate-entry: add a `mode` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47532
diff
changeset
|
305 @property |
47537
0e5800c88eb4
dirstate-entry: add a `size` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47536
diff
changeset
|
306 def size(self): |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
307 return self._v1_size() |
47537
0e5800c88eb4
dirstate-entry: add a `size` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47536
diff
changeset
|
308 |
0e5800c88eb4
dirstate-entry: add a `size` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47536
diff
changeset
|
309 @property |
47538
77fce401a2bb
dirstate-entry: add a `mtime` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47537
diff
changeset
|
310 def mtime(self): |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
311 return self._v1_mtime() |
47538
77fce401a2bb
dirstate-entry: add a `mtime` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47537
diff
changeset
|
312 |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
313 def mtime_likely_equal_to(self, other_mtime): |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
314 self_sec = self._mtime_s |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
315 if self_sec is None: |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
316 return False |
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
317 self_ns = self._mtime_ns |
48446
111098af6356
dirstate-item: add a "second_ambiguous` flag in the mtime tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48440
diff
changeset
|
318 other_sec, other_ns, second_ambiguous = other_mtime |
48447
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
319 if self_sec != other_sec: |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
320 # seconds are different theses mtime are definitly not equal |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
321 return False |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
322 elif other_ns == 0 or self_ns == 0: |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
323 # at least one side as no nano-seconds information |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
324 |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
325 if self._mtime_second_ambiguous: |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
326 # We cannot trust the mtime in this case |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
327 return False |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
328 else: |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
329 # the "seconds" value was reliable on its own. We are good to go. |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
330 return True |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
331 else: |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
332 # We have nano second information, let us use them ! |
af303ae33cd7
dirstate-item: implement the comparison logic for mtime-second-ambiguous
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
333 return self_ns == other_ns |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
334 |
47538
77fce401a2bb
dirstate-entry: add a `mtime` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47537
diff
changeset
|
335 @property |
47512
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
336 def state(self): |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
337 """ |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
338 States are: |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
339 n normal |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
340 m needs merging |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
341 r marked for removal |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
342 a marked for addition |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
343 |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
344 XXX This "state" is a bit obscure and mostly a direct expression of the |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
345 dirstatev1 format. It would make sense to ultimately deprecate it in |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
346 favor of the more "semantic" attributes. |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
347 """ |
48123
d73b42f905f8
dirstate-item: use `any_tracked` more
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
348 if not self.any_tracked: |
48100
418611f18fd8
dirstate-entry: use `?` for the state of entry without any tracking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48099
diff
changeset
|
349 return b'?' |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
350 return self._v1_state() |
47512
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
351 |
47513
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
352 @property |
48263
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
353 def has_fallback_exec(self): |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
354 """True if "fallback" information are available for the "exec" bit |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
355 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
356 Fallback information can be stored in the dirstate to keep track of |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
357 filesystem attribute tracked by Mercurial when the underlying file |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
358 system or operating system does not support that property, (e.g. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
359 Windows). |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
360 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
361 Not all version of the dirstate on-disk storage support preserving this |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
362 information. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
363 """ |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
364 return self._fallback_exec is not None |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
365 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
366 @property |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
367 def fallback_exec(self): |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
368 """ "fallback" information for the executable bit |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
369 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
370 True if the file should be considered executable when we cannot get |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
371 this information from the files system. False if it should be |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
372 considered non-executable. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
373 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
374 See has_fallback_exec for details.""" |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
375 return self._fallback_exec |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
376 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
377 @fallback_exec.setter |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
378 def set_fallback_exec(self, value): |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
379 """control "fallback" executable bit |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
380 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
381 Set to: |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
382 - True if the file should be considered executable, |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
383 - False if the file should be considered non-executable, |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
384 - None if we do not have valid fallback data. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
385 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
386 See has_fallback_exec for details.""" |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
387 if value is None: |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
388 self._fallback_exec = None |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
389 else: |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
390 self._fallback_exec = bool(value) |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
391 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
392 @property |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
393 def has_fallback_symlink(self): |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
394 """True if "fallback" information are available for symlink status |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
395 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
396 Fallback information can be stored in the dirstate to keep track of |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
397 filesystem attribute tracked by Mercurial when the underlying file |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
398 system or operating system does not support that property, (e.g. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
399 Windows). |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
400 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
401 Not all version of the dirstate on-disk storage support preserving this |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
402 information.""" |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
403 return self._fallback_symlink is not None |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
404 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
405 @property |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
406 def fallback_symlink(self): |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
407 """ "fallback" information for symlink status |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
408 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
409 True if the file should be considered executable when we cannot get |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
410 this information from the files system. False if it should be |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
411 considered non-executable. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
412 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
413 See has_fallback_exec for details.""" |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
414 return self._fallback_symlink |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
415 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
416 @fallback_symlink.setter |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
417 def set_fallback_symlink(self, value): |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
418 """control "fallback" symlink status |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
419 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
420 Set to: |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
421 - True if the file should be considered a symlink, |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
422 - False if the file should be considered not a symlink, |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
423 - None if we do not have valid fallback data. |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
424 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
425 See has_fallback_symlink for details.""" |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
426 if value is None: |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
427 self._fallback_symlink = None |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
428 else: |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
429 self._fallback_symlink = bool(value) |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
430 |
602c8e8411f5
dirstate: add a concept of "fallback" flags to dirstate item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48262
diff
changeset
|
431 @property |
47531
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
432 def tracked(self): |
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
433 """True is the file is tracked in the working copy""" |
47959
f1033c2d9b66
dirstate-item: implement `tracked` in a simpler way
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47958
diff
changeset
|
434 return self._wc_tracked |
47531
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
435 |
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
436 @property |
48099
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48098
diff
changeset
|
437 def any_tracked(self): |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48098
diff
changeset
|
438 """True is the file is tracked anywhere (wc or parents)""" |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
439 return self._wc_tracked or self._p1_tracked or self._p2_info |
48099
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48098
diff
changeset
|
440 |
79bc60ca5946
dirstate-item: introduce a `any_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48098
diff
changeset
|
441 @property |
47526
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
442 def added(self): |
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
443 """True if the file has been added""" |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
444 return self._wc_tracked and not (self._p1_tracked or self._p2_info) |
47526
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
445 |
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
446 @property |
49915
3eac92509484
dirstate-entry: add `modified` property
Raphaël Gomès <rgomes@octobus.net>
parents:
49174
diff
changeset
|
447 def modified(self): |
3eac92509484
dirstate-entry: add `modified` property
Raphaël Gomès <rgomes@octobus.net>
parents:
49174
diff
changeset
|
448 """True if the file has been modified""" |
3eac92509484
dirstate-entry: add `modified` property
Raphaël Gomès <rgomes@octobus.net>
parents:
49174
diff
changeset
|
449 return self._wc_tracked and self._p1_tracked and self._p2_info |
3eac92509484
dirstate-entry: add `modified` property
Raphaël Gomès <rgomes@octobus.net>
parents:
49174
diff
changeset
|
450 |
3eac92509484
dirstate-entry: add `modified` property
Raphaël Gomès <rgomes@octobus.net>
parents:
49174
diff
changeset
|
451 @property |
48098
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
452 def maybe_clean(self): |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
453 """True if the file has a chance to be in the "clean" state""" |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
454 if not self._wc_tracked: |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
455 return False |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
456 elif not self._p1_tracked: |
48098
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
457 return False |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
458 elif self._p2_info: |
48098
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
459 return False |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
460 return True |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
461 |
80783e553bd5
dirstate-item: introduce a `maybe_clean` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48082
diff
changeset
|
462 @property |
48155
21542d4cb568
dirstate-item: introduce a `p1_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48154
diff
changeset
|
463 def p1_tracked(self): |
21542d4cb568
dirstate-item: introduce a `p1_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48154
diff
changeset
|
464 """True if the file is tracked in the first parent manifest""" |
21542d4cb568
dirstate-item: introduce a `p1_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48154
diff
changeset
|
465 return self._p1_tracked |
21542d4cb568
dirstate-item: introduce a `p1_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48154
diff
changeset
|
466 |
21542d4cb568
dirstate-item: introduce a `p1_tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48154
diff
changeset
|
467 @property |
48154
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
468 def p2_info(self): |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
469 """True if the file needed to merge or apply any input from p2 |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
470 |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
471 See the class documentation for details. |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
472 """ |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
473 return self._wc_tracked and self._p2_info |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
474 |
fb3b41d583c2
dirstate-item: introduce a `p2_info` property that combine two others
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48150
diff
changeset
|
475 @property |
47515
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
476 def removed(self): |
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
477 """True if the file has been removed""" |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
478 return not self._wc_tracked and (self._p1_tracked or self._p2_info) |
47515
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
479 |
48234
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
480 def v2_data(self): |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
481 """Returns (flags, mode, size, mtime) for v2 serialization""" |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
482 flags = 0 |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
483 if self._wc_tracked: |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
484 flags |= DIRSTATE_V2_WDIR_TRACKED |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
485 if self._p1_tracked: |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
486 flags |= DIRSTATE_V2_P1_TRACKED |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
487 if self._p2_info: |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
488 flags |= DIRSTATE_V2_P2_INFO |
48241
db5897321351
dirstate-v2: Use attributes as intended instead of properties in v2_data()
Simon Sapin <simon.sapin@octobus.net>
parents:
48234
diff
changeset
|
489 if self._mode is not None and self._size is not None: |
48234
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
490 flags |= DIRSTATE_V2_HAS_MODE_AND_SIZE |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
491 if self.mode & stat.S_IXUSR: |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
492 flags |= DIRSTATE_V2_MODE_EXEC_PERM |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
493 if stat.S_ISLNK(self.mode): |
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
494 flags |= DIRSTATE_V2_MODE_IS_SYMLINK |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
495 if self._mtime_s is not None: |
48275
bb240915f69f
dirstate-v2: adjust the meaning of directory flags
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48273
diff
changeset
|
496 flags |= DIRSTATE_V2_HAS_MTIME |
48449
995aaacb12d7
dirstate-item: make sure we set the mtime-second-ambiguous on v2 write
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48448
diff
changeset
|
497 if self._mtime_second_ambiguous: |
995aaacb12d7
dirstate-item: make sure we set the mtime-second-ambiguous on v2 write
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48448
diff
changeset
|
498 flags |= DIRSTATE_V2_MTIME_SECOND_AMBIGUOUS |
48265
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
499 |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
500 if self._fallback_exec is not None: |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
501 flags |= DIRSTATE_V2_HAS_FALLBACK_EXEC |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
502 if self._fallback_exec: |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
503 flags |= DIRSTATE_V2_FALLBACK_EXEC |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
504 |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
505 if self._fallback_symlink is not None: |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
506 flags |= DIRSTATE_V2_HAS_FALLBACK_SYMLINK |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
507 if self._fallback_symlink: |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
508 flags |= DIRSTATE_V2_FALLBACK_SYMLINK |
b874e8d81a98
dirstate-v2: preserve the fallback values on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48264
diff
changeset
|
509 |
48262
dfc5a505ddc5
dirstate-v2: adds two flag to track the presence of some unrecorded files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48261
diff
changeset
|
510 # Note: we do not need to do anything regarding |
dfc5a505ddc5
dirstate-v2: adds two flag to track the presence of some unrecorded files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48261
diff
changeset
|
511 # DIRSTATE_V2_ALL_UNKNOWN_RECORDED and DIRSTATE_V2_ALL_IGNORED_RECORDED |
dfc5a505ddc5
dirstate-v2: adds two flag to track the presence of some unrecorded files
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48261
diff
changeset
|
512 # since we never set _DIRSTATE_V2_HAS_DIRCTORY_MTIME |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
513 return (flags, self._size or 0, self._mtime_s or 0, self._mtime_ns or 0) |
48234
7e78c72ee3ea
dirstate-v2: Initial Python serializer
Raphaël Gomès <rgomes@octobus.net>
parents:
48233
diff
changeset
|
514 |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
515 def _v1_state(self): |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
516 """return a "state" suitable for v1 serialization""" |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
517 if not self.any_tracked: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
518 # the object has no state to record, this is -currently- |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
519 # unsupported |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
520 raise RuntimeError('untracked item') |
47967
0d185f73c619
dirstate-item: implement v1_state with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47966
diff
changeset
|
521 elif self.removed: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
522 return b'r' |
48164
8f88307f8e07
dirstate-item: replace another usage of `merged`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48162
diff
changeset
|
523 elif self._p1_tracked and self._p2_info: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
524 return b'm' |
47967
0d185f73c619
dirstate-item: implement v1_state with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47966
diff
changeset
|
525 elif self.added: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
526 return b'a' |
47967
0d185f73c619
dirstate-item: implement v1_state with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47966
diff
changeset
|
527 else: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
528 return b'n' |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
529 |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
530 def _v1_mode(self): |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
531 """return a "mode" suitable for v1 serialization""" |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
532 return self._mode if self._mode is not None else 0 |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
533 |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
534 def _v1_size(self): |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
535 """return a "size" suitable for v1 serialization""" |
48123
d73b42f905f8
dirstate-item: use `any_tracked` more
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
536 if not self.any_tracked: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
537 # the object has no state to record, this is -currently- |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
538 # unsupported |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
539 raise RuntimeError('untracked item') |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
540 elif self.removed and self._p1_tracked and self._p2_info: |
47968
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
541 return NONNORMAL |
48161
6ac2b417d5d7
dirstate-item: directly use `p2_info` in `v1_size`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48155
diff
changeset
|
542 elif self._p2_info: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
543 return FROM_P2 |
47968
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
544 elif self.removed: |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
545 return 0 |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
546 elif self.added: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
547 return NONNORMAL |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
548 elif self._size is None: |
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
549 return NONNORMAL |
47968
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
550 else: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
551 return self._size |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
552 |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
553 def _v1_mtime(self): |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
554 """return a "mtime" suitable for v1 serialization""" |
48123
d73b42f905f8
dirstate-item: use `any_tracked` more
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48122
diff
changeset
|
555 if not self.any_tracked: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
556 # the object has no state to record, this is -currently- |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
557 # unsupported |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
558 raise RuntimeError('untracked item') |
47969
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
559 elif self.removed: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
560 return 0 |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
561 elif self._mtime_s is None: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
562 return AMBIGUOUS_TIME |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
563 elif self._p2_info: |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
564 return AMBIGUOUS_TIME |
48150
38488d488ec1
dirstate-item: change the internal storage and constructor value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48125
diff
changeset
|
565 elif not self._p1_tracked: |
47969
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
566 return AMBIGUOUS_TIME |
48448
0b3f3a3ca50a
dirstate-item: ignore mtime to write v1 when `mtime-second-ambiguous` is set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
567 elif self._mtime_second_ambiguous: |
0b3f3a3ca50a
dirstate-item: ignore mtime to write v1 when `mtime-second-ambiguous` is set
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
568 return AMBIGUOUS_TIME |
47958
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
569 else: |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48265
diff
changeset
|
570 return self._mtime_s |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
571 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
572 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
573 def gettype(q): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
574 return int(q & 0xFFFF) |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
575 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
576 |
49037
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
49004
diff
changeset
|
577 class BaseIndexObject: |
47279
9d1a8829f959
revlog: signal which revlog index are compatible with Rust
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47278
diff
changeset
|
578 # Can I be passed to an algorithme implemented in Rust ? |
9d1a8829f959
revlog: signal which revlog index are compatible with Rust
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47278
diff
changeset
|
579 rust_ext_compat = 0 |
46674
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
580 # Format of an index entry according to Python's `struct` language |
46860
1dc86c2a43ce
revlog: directly use the Struct object for related operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46858
diff
changeset
|
581 index_format = revlog_constants.INDEX_ENTRY_V1 |
46674
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
582 # Size of a C unsigned long long int, platform independent |
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
583 big_int_size = struct.calcsize(b'>Q') |
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
584 # Size of a C long int, platform independent |
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
585 int_size = struct.calcsize(b'>i') |
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
586 # An empty index entry, used as a default value to be overridden, or nullrev |
47260
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
587 null_item = ( |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
588 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
589 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
590 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
591 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
592 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
593 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
594 -1, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
595 sha1nodeconstants.nullid, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
596 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
597 0, |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
598 revlog_constants.COMP_MODE_INLINE, |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
599 revlog_constants.COMP_MODE_INLINE, |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48534
diff
changeset
|
600 revlog_constants.RANK_UNKNOWN, |
47260
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
601 ) |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
602 |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
603 @util.propertycache |
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
604 def entry_size(self): |
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
605 return self.index_format.size |
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
606 |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
607 @util.propertycache |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
608 def _nodemap(self): |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
609 nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: nullrev}) |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
610 for r in range(0, len(self)): |
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
611 n = self[r][7] |
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
612 nodemap[n] = r |
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
613 return nodemap |
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
614 |
43582
0c659fc20207
index: add a `has_node` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
615 def has_node(self, node): |
0c659fc20207
index: add a `has_node` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
616 """return True if the node exist in the index""" |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
617 return node in self._nodemap |
43582
0c659fc20207
index: add a `has_node` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
618 |
43600
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
619 def rev(self, node): |
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
620 """return a revision for a node |
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
621 |
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
622 If the node is unknown, raise a RevlogError""" |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
623 return self._nodemap[node] |
43600
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
624 |
43602
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
625 def get_rev(self, node): |
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
626 """return a revision for a node |
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
627 |
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
628 If the node is unknown, return None""" |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
629 return self._nodemap.get(node) |
43602
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
630 |
43581
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
631 def _stripnodes(self, start): |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
632 if '_nodemap' in vars(self): |
43581
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
633 for r in range(start, len(self)): |
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
634 n = self[r][7] |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
635 del self._nodemap[n] |
43581
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
636 |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
637 def clearcaches(self): |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
638 self.__dict__.pop('_nodemap', None) |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
639 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
640 def __len__(self): |
38890
781b2720d2ac
index: don't include nullid in len()
Martin von Zweigbergk <martinvonz@google.com>
parents:
38889
diff
changeset
|
641 return self._lgt + len(self._extra) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
642 |
38889
6104b203bec8
index: replace insert(-1, e) method by append(e) method
Martin von Zweigbergk <martinvonz@google.com>
parents:
38887
diff
changeset
|
643 def append(self, tup): |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
644 if '_nodemap' in vars(self): |
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
645 self._nodemap[tup[7]] = len(self) |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
646 data = self._pack_entry(len(self), tup) |
45951
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
647 self._extra.append(data) |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
648 |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
649 def _pack_entry(self, rev, entry): |
47157
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
650 assert entry[8] == 0 |
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
651 assert entry[9] == 0 |
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
652 return self.index_format.pack(*entry[:8]) |
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
653 |
39245
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
654 def _check_index(self, i): |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
655 if not isinstance(i, int): |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
656 raise TypeError("expecting int indexes") |
39244
ec6d5a9d1631
index: don't include nullid in boundary check in pure code
Martin von Zweigbergk <martinvonz@google.com>
parents:
39084
diff
changeset
|
657 if i < 0 or i >= len(self): |
48533
30741bbea550
revlog: add some information about the revision we cannot find
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48450
diff
changeset
|
658 raise IndexError(i) |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
659 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
660 def __getitem__(self, i): |
39084
a1f934573c0b
parsers: adjust pure-python version to mimic a3dacabd476b
Augie Fackler <augie@google.com>
parents:
38890
diff
changeset
|
661 if i == -1: |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
662 return self.null_item |
39245
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
663 self._check_index(i) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
664 if i >= self._lgt: |
45951
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
665 data = self._extra[i - self._lgt] |
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
666 else: |
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
667 index = self._calculate_index(i) |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
668 data = self._data[index : index + self.entry_size] |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
669 r = self._unpack_entry(i, data) |
45951
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
670 if self._lgt and i == 0: |
47400
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47281
diff
changeset
|
671 offset = revlogutils.offset_type(0, gettype(r[0])) |
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47281
diff
changeset
|
672 r = (offset,) + r[1:] |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
673 return r |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
674 |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
675 def _unpack_entry(self, rev, data): |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
676 r = self.index_format.unpack(data) |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
677 r = r + ( |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
678 0, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
679 0, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
680 revlog_constants.COMP_MODE_INLINE, |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
681 revlog_constants.COMP_MODE_INLINE, |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48534
diff
changeset
|
682 revlog_constants.RANK_UNKNOWN, |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
683 ) |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
684 return r |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
685 |
47078
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
686 def pack_header(self, header): |
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
687 """pack header information as binary""" |
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
688 v_fmt = revlog_constants.INDEX_HEADER |
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
689 return v_fmt.pack(header) |
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
690 |
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
691 def entry_binary(self, rev): |
47075
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
692 """return the raw binary string representing a revision""" |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
693 entry = self[rev] |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
694 p = revlog_constants.INDEX_ENTRY_V1.pack(*entry[:8]) |
47075
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
695 if rev == 0: |
47078
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
696 p = p[revlog_constants.INDEX_HEADER.size :] |
47075
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
697 return p |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
698 |
52009
609700e5d8df
head-revs: add a native implementation of the `stop_rev` parameter
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51999
diff
changeset
|
699 def headrevs(self, excluded_revs=None, stop_rev=None): |
51999
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
700 count = len(self) |
52009
609700e5d8df
head-revs: add a native implementation of the `stop_rev` parameter
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51999
diff
changeset
|
701 if stop_rev is not None: |
609700e5d8df
head-revs: add a native implementation of the `stop_rev` parameter
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51999
diff
changeset
|
702 count = min(count, stop_rev) |
51999
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
703 if not count: |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
704 return [nullrev] |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
705 # we won't iter over filtered rev so nobody is a head at start |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
706 ishead = [0] * (count + 1) |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
707 revs = range(count) |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
708 if excluded_revs is not None: |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
709 revs = (r for r in revs if r not in excluded_revs) |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
710 |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
711 for r in revs: |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
712 ishead[r] = 1 # I may be an head |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
713 e = self[r] |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
714 ishead[e[5]] = ishead[e[6]] = 0 # my parent are not |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
715 return [r for r, val in enumerate(ishead) if val] |
22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51901
diff
changeset
|
716 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
717 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
718 class IndexObject(BaseIndexObject): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
719 def __init__(self, data): |
47075
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
720 assert len(data) % self.entry_size == 0, ( |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
721 len(data), |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
722 self.entry_size, |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
723 len(data) % self.entry_size, |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
724 ) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
725 self._data = data |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
726 self._lgt = len(data) // self.entry_size |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
727 self._extra = [] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
728 |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
729 def _calculate_index(self, i): |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
730 return i * self.entry_size |
13253 | 731 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
732 def __delitem__(self, i): |
34338
531332502568
style: always use `x is not None` instead of `not x is None`
Alex Gaynor <agaynor@mozilla.com>
parents:
32411
diff
changeset
|
733 if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
734 raise ValueError("deleting slices only supports a:-1 with step 1") |
39245
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
735 i = i.start |
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
736 self._check_index(i) |
43581
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
737 self._stripnodes(i) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
738 if i < self._lgt: |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
739 self._data = self._data[: i * self.entry_size] |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
740 self._lgt = i |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
741 self._extra = [] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
742 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
743 self._extra = self._extra[: i - self._lgt] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
744 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
745 |
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
746 class PersistentNodeMapIndexObject(IndexObject): |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
747 """a Debug oriented class to test persistent nodemap |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
748 |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
749 We need a simple python object to test API and higher level behavior. See |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
750 the Rust implementation for more serious usage. This should be used only |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
751 through the dedicated `devel.persistent-nodemap` config. |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
752 """ |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
753 |
44357
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
754 def nodemap_data_all(self): |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
755 """Return bytes containing a full serialization of a nodemap |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
756 |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
757 The nodemap should be valid for the full set of revisions in the |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
758 index.""" |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
759 return nodemaputil.persistent_data(self) |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
760 |
44367
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
761 def nodemap_data_incremental(self): |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
762 """Return bytes containing a incremental update to persistent nodemap |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
763 |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
764 This containst the data for an append-only update of the data provided |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
765 in the last call to `update_nodemap_data`. |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
766 """ |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
767 if self._nm_root is None: |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
768 return None |
44371
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
769 docket = self._nm_docket |
44370
8374b69aef75
nodemap: track the total and unused amount of data in the rawdata file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44369
diff
changeset
|
770 changed, data = nodemaputil.update_persistent_data( |
44371
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
771 self, self._nm_root, self._nm_max_idx, self._nm_docket.tip_rev |
44367
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
772 ) |
44371
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
773 |
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
774 self._nm_root = self._nm_max_idx = self._nm_docket = None |
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
775 return docket, changed, data |
44367
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
776 |
44369
e41a164db7a9
nodemap: track the maximum revision tracked in the nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44367
diff
changeset
|
777 def update_nodemap_data(self, docket, nm_data): |
e41a164db7a9
nodemap: track the maximum revision tracked in the nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44367
diff
changeset
|
778 """provide full block of persisted binary data for a nodemap |
44363
671f9479af0e
nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44357
diff
changeset
|
779 |
671f9479af0e
nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44357
diff
changeset
|
780 The data are expected to come from disk. See `nodemap_data_all` for a |
671f9479af0e
nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44357
diff
changeset
|
781 produceur of such data.""" |
671f9479af0e
nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44357
diff
changeset
|
782 if nm_data is not None: |
44367
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
783 self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data) |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
784 if self._nm_root: |
44371
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
785 self._nm_docket = docket |
44367
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
786 else: |
44371
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
787 self._nm_root = self._nm_max_idx = self._nm_docket = None |
44363
671f9479af0e
nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44357
diff
changeset
|
788 |
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
789 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
790 class InlinedIndexObject(BaseIndexObject): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
791 def __init__(self, data, inline=0): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
792 self._data = data |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
793 self._lgt = self._inline_scan(None) |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
794 self._inline_scan(self._lgt) |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
795 self._extra = [] |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
796 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
797 def _inline_scan(self, lgt): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
798 off = 0 |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
799 if lgt is not None: |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
800 self._offsets = [0] * lgt |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
801 count = 0 |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
802 while off <= len(self._data) - self.entry_size: |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
803 start = off + self.big_int_size |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
804 (s,) = struct.unpack( |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
805 b'>i', |
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
806 self._data[start : start + self.int_size], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
807 ) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
808 if lgt is not None: |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
809 self._offsets[count] = off |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
810 count += 1 |
46974
3c9208702db3
revlog: replace revlog._io.size with a new revlog.index.entry_size
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46860
diff
changeset
|
811 off += self.entry_size + s |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
812 if off != len(self._data): |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
813 raise ValueError("corrupted data") |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
814 return count |
14421
639f26cab2f5
pure parsers: properly detect corrupt index files
Augie Fackler <durin42@gmail.com>
parents:
14064
diff
changeset
|
815 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
816 def __delitem__(self, i): |
34338
531332502568
style: always use `x is not None` instead of `not x is None`
Alex Gaynor <agaynor@mozilla.com>
parents:
32411
diff
changeset
|
817 if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
818 raise ValueError("deleting slices only supports a:-1 with step 1") |
39245
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
819 i = i.start |
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
820 self._check_index(i) |
43581
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
821 self._stripnodes(i) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
822 if i < self._lgt: |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
823 self._offsets = self._offsets[:i] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
824 self._lgt = i |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
825 self._extra = [] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
826 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
827 self._extra = self._extra[: i - self._lgt] |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
828 |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
829 def _calculate_index(self, i): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
830 return self._offsets[i] |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
831 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
832 |
48772
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
833 def parse_index2(data, inline, format=revlog_constants.REVLOGV1): |
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
834 if format == revlog_constants.CHANGELOGV2: |
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
835 return parse_index_cl_v2(data) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
836 if not inline: |
48772
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
837 if format == revlog_constants.REVLOGV2: |
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
838 cls = IndexObject2 |
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
839 else: |
1bb62821f080
revlog: register changelogv2 C implementation in parsers
pacien <pacien.trangirard@pacien.net>
parents:
48564
diff
changeset
|
840 cls = IndexObject |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
841 return cls(data), None |
47273
468e451fc0de
revlogv2: drop the code related to inlined revlogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47270
diff
changeset
|
842 cls = InlinedIndexObject |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
843 return cls(data, inline), (0, data) |
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
844 |
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
845 |
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
846 def parse_index_cl_v2(data): |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
847 return IndexChangelogV2(data), None |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
848 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
849 |
47273
468e451fc0de
revlogv2: drop the code related to inlined revlogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47270
diff
changeset
|
850 class IndexObject2(IndexObject): |
46860
1dc86c2a43ce
revlog: directly use the Struct object for related operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46858
diff
changeset
|
851 index_format = revlog_constants.INDEX_ENTRY_V2 |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
852 |
47095
223b47235d1c
sidedata: enable sidedata computers to optionally rewrite flags
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
853 def replace_sidedata_info( |
47270
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
854 self, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
855 rev, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
856 sidedata_offset, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
857 sidedata_length, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
858 offset_flags, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
859 compression_mode, |
47095
223b47235d1c
sidedata: enable sidedata computers to optionally rewrite flags
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
860 ): |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
861 """ |
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
862 Replace an existing index entry's sidedata offset and length with new |
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
863 ones. |
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
864 This cannot be used outside of the context of sidedata rewriting, |
47254
3b04cf976c67
revlog: use `rev` instead of `i` in replace_sidedata_info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47246
diff
changeset
|
865 inside the transaction that creates the revision `rev`. |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
866 """ |
47254
3b04cf976c67
revlog: use `rev` instead of `i` in replace_sidedata_info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47246
diff
changeset
|
867 if rev < 0: |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
868 raise KeyError |
47254
3b04cf976c67
revlog: use `rev` instead of `i` in replace_sidedata_info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47246
diff
changeset
|
869 self._check_index(rev) |
47255
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
870 if rev < self._lgt: |
51799
d748fd2647f8
pure: stringify builtin exception messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
51788
diff
changeset
|
871 msg = "cannot rewrite entries outside of this transaction" |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
872 raise KeyError(msg) |
47255
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
873 else: |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
874 entry = list(self[rev]) |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
875 entry[0] = offset_flags |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
876 entry[8] = sidedata_offset |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
877 entry[9] = sidedata_length |
47270
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
878 entry[11] = compression_mode |
47255
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
879 entry = tuple(entry) |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
880 new = self._pack_entry(rev, entry) |
47255
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
881 self._extra[rev - self._lgt] = new |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
882 |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
883 def _unpack_entry(self, rev, data): |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
884 data = self.index_format.unpack(data) |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
885 entry = data[:10] |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
886 data_comp = data[10] & 3 |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
887 sidedata_comp = (data[10] & (3 << 2)) >> 2 |
48536
52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48534
diff
changeset
|
888 return entry + (data_comp, sidedata_comp, revlog_constants.RANK_UNKNOWN) |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
889 |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
890 def _pack_entry(self, rev, entry): |
47267
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
891 data = entry[:10] |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
892 data_comp = entry[10] & 3 |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
893 sidedata_comp = (entry[11] & 3) << 2 |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
894 data += (data_comp | sidedata_comp,) |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
895 |
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
896 return self.index_format.pack(*data) |
47157
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
897 |
47078
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
898 def entry_binary(self, rev): |
47075
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
899 """return the raw binary string representing a revision""" |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
900 entry = self[rev] |
47278
55d280bc59fa
revlog: pass around the `rev` we deal with when packing/unpacking entry
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47273
diff
changeset
|
901 return self._pack_entry(rev, entry) |
47075
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
902 |
47246
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
903 def pack_header(self, header): |
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
904 """pack header information as binary""" |
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
905 msg = 'version header should go in the docket, not the index: %d' |
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
906 msg %= header |
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
907 raise error.ProgrammingError(msg) |
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
908 |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
909 |
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
910 class IndexChangelogV2(IndexObject2): |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
911 index_format = revlog_constants.INDEX_ENTRY_CL_V2 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
912 |
48537
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
913 null_item = ( |
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
914 IndexObject2.null_item[: revlog_constants.ENTRY_RANK] |
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
915 + (0,) # rank of null is 0 |
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
916 + IndexObject2.null_item[revlog_constants.ENTRY_RANK :] |
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
917 ) |
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
918 |
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
919 def _unpack_entry(self, rev, data, r=True): |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
920 items = self.index_format.unpack(data) |
48534
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
921 return ( |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
922 items[revlog_constants.INDEX_ENTRY_V2_IDX_OFFSET], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
923 items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
924 items[revlog_constants.INDEX_ENTRY_V2_IDX_UNCOMPRESSED_LENGTH], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
925 rev, |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
926 rev, |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
927 items[revlog_constants.INDEX_ENTRY_V2_IDX_PARENT_1], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
928 items[revlog_constants.INDEX_ENTRY_V2_IDX_PARENT_2], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
929 items[revlog_constants.INDEX_ENTRY_V2_IDX_NODEID], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
930 items[revlog_constants.INDEX_ENTRY_V2_IDX_SIDEDATA_OFFSET], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
931 items[ |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
932 revlog_constants.INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
933 ], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
934 items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3, |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
935 (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2) |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
936 & 3, |
48537
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
937 items[revlog_constants.INDEX_ENTRY_V2_IDX_RANK], |
48534
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
938 ) |
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
939 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
940 def _pack_entry(self, rev, entry): |
48534
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
941 base = entry[revlog_constants.ENTRY_DELTA_BASE] |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
942 link_rev = entry[revlog_constants.ENTRY_LINK_REV] |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
943 assert base == rev, (base, rev) |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
944 assert link_rev == rev, (link_rev, rev) |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
945 data = ( |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
946 entry[revlog_constants.ENTRY_DATA_OFFSET], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
947 entry[revlog_constants.ENTRY_DATA_COMPRESSED_LENGTH], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
948 entry[revlog_constants.ENTRY_DATA_UNCOMPRESSED_LENGTH], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
949 entry[revlog_constants.ENTRY_PARENT_1], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
950 entry[revlog_constants.ENTRY_PARENT_2], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
951 entry[revlog_constants.ENTRY_NODE_ID], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
952 entry[revlog_constants.ENTRY_SIDEDATA_OFFSET], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
953 entry[revlog_constants.ENTRY_SIDEDATA_COMPRESSED_LENGTH], |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
954 entry[revlog_constants.ENTRY_DATA_COMPRESSION_MODE] & 3 |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
955 | (entry[revlog_constants.ENTRY_SIDEDATA_COMPRESSION_MODE] & 3) |
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
956 << 2, |
48537
c5d6c874766a
rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48536
diff
changeset
|
957 entry[revlog_constants.ENTRY_RANK], |
48534
2c6084f67a86
changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48533
diff
changeset
|
958 ) |
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
959 return self.index_format.pack(*data) |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
960 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
961 |
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
962 def parse_index_devel_nodemap(data, inline): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45951
diff
changeset
|
963 """like parse_index2, but alway return a PersistentNodeMapIndexObject""" |
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
964 return PersistentNodeMapIndexObject(data), None |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
965 |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
966 |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
967 def parse_dirstate(dmap, copymap, st): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
968 parents = [st[:20], st[20:40]] |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
14995
diff
changeset
|
969 # dereference fields so they will be local in loop |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
970 format = b">cllll" |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
971 e_size = struct.calcsize(format) |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
972 pos1 = 40 |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
973 l = len(st) |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
974 |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
975 # the inner loop |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
976 while pos1 < l: |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
977 pos2 = pos1 + e_size |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
978 e = _unpack(b">cllll", st[pos1:pos2]) # a literal here is faster |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
979 pos1 = pos2 + e[4] |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
980 f = st[pos2:pos1] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
981 if b'\0' in f: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
982 f, c = f.split(b'\0') |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
983 copymap[f] = c |
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
984 dmap[f] = DirstateItem.from_v1_data(*e[:4]) |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
985 return parents |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
986 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
987 |
48440
434de12918fd
dirstate: remove need_delay logic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48426
diff
changeset
|
988 def pack_dirstate(dmap, copymap, pl): |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
27339
diff
changeset
|
989 cs = stringio() |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
990 write = cs.write |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
991 write(b"".join(pl)) |
49004
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48966
diff
changeset
|
992 for f, e in dmap.items(): |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
993 if f in copymap: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
994 f = b"%s\0%s" % (f, copymap[f]) |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
995 e = _pack( |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
996 b">cllll", |
49109
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
997 e._v1_state(), |
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
998 e._v1_mode(), |
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
999 e._v1_size(), |
be9bf75a837c
dirstate: remove v1_* methods from Python/C/Rust shared API
Raphaël Gomès <rgomes@octobus.net>
parents:
49037
diff
changeset
|
1000 e._v1_mtime(), |
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
1001 len(f), |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
1002 ) |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
1003 write(e) |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
1004 write(f) |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
1005 return cs.getvalue() |