author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Fri, 27 Aug 2021 18:00:47 +0200 | |
changeset 47969 | 508394e38580 |
parent 47968 | dbf2d03850a2 |
child 48002 | 4e6f27230aee |
permissions | -rw-r--r-- |
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 |
|
27339
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
8 |
from __future__ import absolute_import |
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
9 |
|
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
10 |
import struct |
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
11 |
import zlib |
6ab8c6511a6a
parsers: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24634
diff
changeset
|
12 |
|
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
13 |
from ..node import ( |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
14 |
nullrev, |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
15 |
sha1nodeconstants, |
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
16 |
) |
47566
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
17 |
from ..thirdparty import attr |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
18 |
from .. import ( |
47246
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
19 |
error, |
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
20 |
pycompat, |
47400
ac60a1366a49
revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47281
diff
changeset
|
21 |
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
|
22 |
util, |
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
23 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
24 |
|
44035
ab595920de0e
revlogutils: move the NodeMap class in a dedicated nodemap module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43663
diff
changeset
|
25 |
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
|
26 |
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
|
27 |
|
36964
644a02f6b34f
util: prefer "bytesio" to "stringio"
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34338
diff
changeset
|
28 |
stringio = pycompat.bytesio |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
29 |
|
31230
37596c980662
parsers: alias long to int on Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29133
diff
changeset
|
30 |
|
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
31 |
_pack = struct.pack |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
32 |
_unpack = struct.unpack |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
33 |
_compress = zlib.compress |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
34 |
_decompress = zlib.decompress |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
35 |
|
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
|
36 |
|
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
37 |
# 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
|
38 |
FROM_P2 = -2 |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
39 |
|
47516
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
40 |
# 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
|
41 |
NONNORMAL = -1 |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
42 |
|
47540
1a6302427eb9
dirstate-item: use need_delay when packing dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
diff
changeset
|
43 |
# 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
|
44 |
AMBIGUOUS_TIME = -1 |
1a6302427eb9
dirstate-item: use need_delay when packing dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
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 |
|
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
|
47 |
@attr.s(slots=True, init=False) |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47538
diff
changeset
|
48 |
class DirstateItem(object): |
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
|
49 |
"""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
|
50 |
|
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
|
51 |
It contains: |
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
|
52 |
|
47495
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
53 |
- state (one of 'n', 'a', 'r', 'm') |
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
54 |
- mode, |
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
55 |
- size, |
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
56 |
- mtime, |
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
57 |
""" |
084ed6a7c6fd
dirstate: document the dirstatetuple content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47400
diff
changeset
|
58 |
|
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
|
59 |
_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
|
60 |
_p1_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
|
61 |
_p2_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
|
62 |
# the three item above should probably be combined |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
63 |
# |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
64 |
# However it is unclear if they properly cover some of the most advanced |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
65 |
# merge case. So we should probably wait on this to be settled. |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
66 |
_merged = 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
|
67 |
_clean_p1 = 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
|
68 |
_clean_p2 = 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
|
69 |
_possibly_dirty = attr.ib() |
47566
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
70 |
_mode = attr.ib() |
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
71 |
_size = attr.ib() |
3df817387ea3
parsers: move DirstateItem to attr.s
Augie Fackler <augie@google.com>
parents:
47540
diff
changeset
|
72 |
_mtime = 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
|
73 |
|
47926
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
74 |
def __init__( |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
75 |
self, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
76 |
wc_tracked=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
77 |
p1_tracked=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
78 |
p2_tracked=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
79 |
merged=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
80 |
clean_p1=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
81 |
clean_p2=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
82 |
possibly_dirty=False, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
83 |
parentfiledata=None, |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
84 |
): |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
85 |
if merged and (clean_p1 or clean_p2): |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
86 |
msg = b'`merged` argument incompatible with `clean_p1`/`clean_p2`' |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
87 |
raise error.ProgrammingError(msg) |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
88 |
|
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
|
89 |
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
|
90 |
self._p1_tracked = p1_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
|
91 |
self._p2_tracked = p2_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
|
92 |
self._merged = merged |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
93 |
self._clean_p1 = clean_p1 |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
94 |
self._clean_p2 = clean_p2 |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
95 |
self._possibly_dirty = possibly_dirty |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
96 |
if parentfiledata is 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
|
97 |
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
|
98 |
self._size = 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
|
99 |
self._mtime = 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
|
100 |
else: |
47926
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
101 |
self._mode = parentfiledata[0] |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
102 |
self._size = parentfiledata[1] |
22c39f8acf78
dirstate-item: feed more information to `__init__`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47921
diff
changeset
|
103 |
self._mtime = 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
|
104 |
|
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
105 |
@classmethod |
47936
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
106 |
def new_added(cls): |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
107 |
"""constructor to help legacy API to build a new "added" item |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
108 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
109 |
Should eventually be removed |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
110 |
""" |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
111 |
instance = cls() |
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
|
112 |
instance._wc_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
113 |
instance._p1_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
|
114 |
instance._p2_tracked = False |
47936
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
115 |
return instance |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
116 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
117 |
@classmethod |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
118 |
def new_merged(cls): |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
119 |
"""constructor to help legacy API to build a new "merged" item |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
120 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
121 |
Should eventually be removed |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
122 |
""" |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
123 |
instance = cls() |
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
|
124 |
instance._wc_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
125 |
instance._p1_tracked = True # might not be True because of rename ? |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
126 |
instance._p2_tracked = True # might not be True because of rename ? |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
127 |
instance._merged = True |
47936
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
128 |
return instance |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
129 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
130 |
@classmethod |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
131 |
def new_from_p2(cls): |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
132 |
"""constructor to help legacy API to build a new "from_p2" item |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
133 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
134 |
Should eventually be removed |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
135 |
""" |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
136 |
instance = cls() |
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
|
137 |
instance._wc_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
138 |
instance._p1_tracked = False # might actually be True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
139 |
instance._p2_tracked = True |
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 |
instance._clean_p2 = True |
47936
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
141 |
return instance |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
142 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
143 |
@classmethod |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
144 |
def new_possibly_dirty(cls): |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
145 |
"""constructor to help legacy API to build a new "possibly_dirty" item |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
146 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
147 |
Should eventually be removed |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
148 |
""" |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
149 |
instance = cls() |
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
|
150 |
instance._wc_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
151 |
instance._p1_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
152 |
instance._possibly_dirty = True |
47936
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
153 |
return instance |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
154 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
155 |
@classmethod |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
156 |
def new_normal(cls, mode, size, mtime): |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
157 |
"""constructor to help legacy API to build a new "normal" item |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
158 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
159 |
Should eventually be removed |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
160 |
""" |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
161 |
assert size != FROM_P2 |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
162 |
assert size != NONNORMAL |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
163 |
instance = cls() |
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
|
164 |
instance._wc_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
165 |
instance._p1_tracked = True |
47936
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
166 |
instance._mode = mode |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
167 |
instance._size = size |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
168 |
instance._mtime = mtime |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
169 |
return instance |
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
170 |
|
c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47926
diff
changeset
|
171 |
@classmethod |
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
172 |
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
|
173 |
"""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
|
174 |
|
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
175 |
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
|
176 |
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
|
177 |
""" |
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
|
178 |
if state == b'm': |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
179 |
return cls.new_merged() |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
180 |
elif state == b'a': |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
181 |
return cls.new_added() |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
182 |
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
|
183 |
instance = cls() |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
184 |
instance._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
|
185 |
if size == NONNORMAL: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
186 |
instance._merged = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
187 |
instance._p1_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
|
188 |
True # might not be True because of rename ? |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
189 |
) |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
190 |
instance._p2_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
|
191 |
True # might not be True because of rename ? |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
192 |
) |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
193 |
elif size == FROM_P2: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
194 |
instance._clean_p2 = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
195 |
instance._p1_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
|
196 |
False # We actually don't know (file history) |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
197 |
) |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
198 |
instance._p2_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
199 |
else: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
200 |
instance._p1_tracked = True |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
201 |
return instance |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
202 |
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
|
203 |
if size == FROM_P2: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
204 |
return cls.new_from_p2() |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
205 |
elif size == NONNORMAL: |
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 |
return cls.new_possibly_dirty() |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
207 |
elif mtime == AMBIGUOUS_TIME: |
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 |
instance = cls.new_normal(mode, size, 42) |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
209 |
instance._mtime = 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
|
210 |
instance._possibly_dirty = True |
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 |
return instance |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
212 |
else: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
213 |
return cls.new_normal(mode, size, mtime) |
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 |
else: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
215 |
raise RuntimeError(b'unknown state: %s' % state) |
47665
a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47664
diff
changeset
|
216 |
|
47666
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
217 |
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
|
218 |
"""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
|
219 |
|
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
220 |
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
|
221 |
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
|
222 |
""" |
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
|
223 |
self._possibly_dirty = True |
47666
e53256a9f9c5
dirstate-item: add a `set_possibly_dirty` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47665
diff
changeset
|
224 |
|
47921
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
225 |
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
|
226 |
"""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
|
227 |
|
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
228 |
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
|
229 |
""" |
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
230 |
# backup the previous state (useful for merge) |
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
|
231 |
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
|
232 |
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
|
233 |
self._size = 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
|
234 |
self._mtime = None |
47921
3853e6ee160d
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47686
diff
changeset
|
235 |
|
47512
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
236 |
@property |
47536
8e4b9fe31334
dirstate-entry: add a `mode` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47532
diff
changeset
|
237 |
def mode(self): |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
238 |
return self.v1_mode() |
47536
8e4b9fe31334
dirstate-entry: add a `mode` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47532
diff
changeset
|
239 |
|
8e4b9fe31334
dirstate-entry: add a `mode` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47532
diff
changeset
|
240 |
@property |
47537
0e5800c88eb4
dirstate-entry: add a `size` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47536
diff
changeset
|
241 |
def size(self): |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
242 |
return self.v1_size() |
47537
0e5800c88eb4
dirstate-entry: add a `size` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47536
diff
changeset
|
243 |
|
0e5800c88eb4
dirstate-entry: add a `size` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47536
diff
changeset
|
244 |
@property |
47538
77fce401a2bb
dirstate-entry: add a `mtime` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47537
diff
changeset
|
245 |
def mtime(self): |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
246 |
return self.v1_mtime() |
47538
77fce401a2bb
dirstate-entry: add a `mtime` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47537
diff
changeset
|
247 |
|
77fce401a2bb
dirstate-entry: add a `mtime` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47537
diff
changeset
|
248 |
@property |
47512
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
249 |
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
|
250 |
""" |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
251 |
States are: |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
252 |
n normal |
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
|
769037a279ec
dirstate-entry: add a `state` property (and use it)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47509
diff
changeset
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
""" |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
261 |
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
|
262 |
|
47513
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
263 |
@property |
47531
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
264 |
def tracked(self): |
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
265 |
"""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
|
266 |
return self._wc_tracked |
47531
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
267 |
|
f5b8f0b9c129
dirstate-entry: add a `tracked` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47526
diff
changeset
|
268 |
@property |
47526
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
269 |
def added(self): |
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
270 |
"""True if the file has been added""" |
47960
03f57915e0ce
dirstate-item: implement `added` in a simpler way
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47959
diff
changeset
|
271 |
return self._wc_tracked and not (self._p1_tracked or self._p2_tracked) |
47526
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
272 |
|
8bcae9bf9e8d
dirstate-entry: add a `added` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47517
diff
changeset
|
273 |
@property |
47513
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
274 |
def merged(self): |
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
275 |
"""True if the file has been merged |
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
276 |
|
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
277 |
Should only be set if a merge is in progress in the dirstate |
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
278 |
""" |
47961
7c37d153c22d
dirstate-item: implement `merged` in a simpler way
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47960
diff
changeset
|
279 |
return self._wc_tracked and self._merged |
47513
10e740292dff
dirstate-entry: add a `merged` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47512
diff
changeset
|
280 |
|
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
281 |
@property |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
282 |
def from_p2(self): |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
283 |
"""True if the file have been fetched from p2 during the current merge |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
284 |
|
47517
28632eb3ca3e
dirstate-entry: restrict `from_p2` property to tracked file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47516
diff
changeset
|
285 |
This is only True is the file is currently tracked. |
28632eb3ca3e
dirstate-entry: restrict `from_p2` property to tracked file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47516
diff
changeset
|
286 |
|
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
287 |
Should only be set if a merge is in progress in the dirstate |
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
288 |
""" |
47966
97e9f3fd9324
dirstate-item: add more logic to `from_p2`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47965
diff
changeset
|
289 |
if not self._wc_tracked: |
97e9f3fd9324
dirstate-item: add more logic to `from_p2`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47965
diff
changeset
|
290 |
return False |
97e9f3fd9324
dirstate-item: add more logic to `from_p2`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47965
diff
changeset
|
291 |
return self._clean_p2 or (not self._p1_tracked and self._p2_tracked) |
47514
559aee84b889
dirstate-entry: add a `from_p2` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47513
diff
changeset
|
292 |
|
47515
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
293 |
@property |
47516
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
294 |
def from_p2_removed(self): |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
295 |
"""True if the file has been removed, but was "from_p2" initially |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
296 |
|
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
297 |
This property seems like an abstraction leakage and should probably be |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
298 |
dealt in this class (or maybe the dirstatemap) directly. |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
299 |
""" |
47963
59eddbaa5bfb
dirstate-item: implement `from_p2_removed` in a simpler way
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47962
diff
changeset
|
300 |
return self.removed and self._clean_p2 |
47516
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
301 |
|
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
302 |
@property |
47515
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
303 |
def removed(self): |
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
304 |
"""True if the file has been removed""" |
47964
774e235d13c3
dirstate-item: implement `removed` in a simpler way
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47963
diff
changeset
|
305 |
return not self._wc_tracked and (self._p1_tracked or self._p2_tracked) |
47515
c94d3ff46fd5
dirstate-entry: add a `removed` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47514
diff
changeset
|
306 |
|
47516
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
307 |
@property |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
308 |
def merged_removed(self): |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
309 |
"""True if the file has been removed, but was "merged" initially |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
310 |
|
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
311 |
This property seems like an abstraction leakage and should probably be |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
312 |
dealt in this class (or maybe the dirstatemap) directly. |
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
313 |
""" |
47965
f94cc63df859
dirstate-item: implement `merged_removed` in a simpler way
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47964
diff
changeset
|
314 |
return self.removed and self._merged |
47516
b8ffe85e399b
dirstate-entry: `merged_removed` and `from_p2_removed` properties
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47515
diff
changeset
|
315 |
|
47685
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
316 |
@property |
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
317 |
def dm_nonnormal(self): |
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
318 |
"""True is the entry is non-normal in the dirstatemap sense |
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
319 |
|
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
320 |
There is no reason for any code, but the dirstatemap one to use this. |
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
321 |
""" |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
322 |
return self.v1_state() != b'n' or self.v1_mtime() == AMBIGUOUS_TIME |
47685
265cdfaad372
dirstate-item: introduce a `dm_nonnormal` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47667
diff
changeset
|
323 |
|
47686
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
324 |
@property |
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
325 |
def dm_otherparent(self): |
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
326 |
"""True is the entry is `otherparent` in the dirstatemap sense |
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
327 |
|
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
328 |
There is no reason for any code, but the dirstatemap one to use this. |
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
329 |
""" |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
330 |
return self.v1_size() == FROM_P2 |
47686
e43128ee436f
dirstate-item: introduce a `dm_otherparent` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47685
diff
changeset
|
331 |
|
47509
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
332 |
def v1_state(self): |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
333 |
"""return a "state" 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
|
334 |
if not (self._p1_tracked or self._p2_tracked or self._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
|
335 |
# 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
|
336 |
# 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
|
337 |
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
|
338 |
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
|
339 |
return b'r' |
47967
0d185f73c619
dirstate-item: implement v1_state with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47966
diff
changeset
|
340 |
elif self.merged: |
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
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
|
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
347 |
def v1_mode(self): |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
348 |
"""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
|
349 |
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
|
350 |
|
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
351 |
def v1_size(self): |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
352 |
"""return a "size" 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
|
353 |
if not (self._p1_tracked or self._p2_tracked or self._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
|
354 |
# 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
|
355 |
# 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
|
356 |
raise RuntimeError('untracked item') |
47968
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
357 |
elif self.merged_removed: |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
358 |
return NONNORMAL |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
359 |
elif self.from_p2_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
|
360 |
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
|
361 |
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
|
362 |
return 0 |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
363 |
elif self.merged: |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
364 |
return FROM_P2 |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
365 |
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
|
366 |
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
|
367 |
elif self.from_p2: |
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
|
368 |
return FROM_P2 |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
369 |
elif self._possibly_dirty: |
47968
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
370 |
return self._size if self._size is not None else NONNORMAL |
dbf2d03850a2
dirstate-item: implement `v1_size` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47967
diff
changeset
|
371 |
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
|
372 |
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
|
373 |
|
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
374 |
def v1_mtime(self): |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
375 |
"""return a "mtime" 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
|
376 |
if not (self._p1_tracked or self._p2_tracked or self._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
|
377 |
# 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
|
378 |
# 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
|
379 |
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
|
380 |
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
|
381 |
return 0 |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
382 |
elif self._possibly_dirty: |
b81f52ca8075
dirstate-item: keep the full information in memory (for pure form)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47957
diff
changeset
|
383 |
return AMBIGUOUS_TIME |
47969
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
384 |
elif self.merged: |
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
|
385 |
return AMBIGUOUS_TIME |
47969
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
386 |
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
|
387 |
return AMBIGUOUS_TIME |
47969
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
388 |
elif self.from_p2: |
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
389 |
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
|
390 |
else: |
47969
508394e38580
dirstate-item: implement `v1_mtime` with higher level block
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47968
diff
changeset
|
391 |
return self._mtime if self._mtime 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
|
392 |
|
47532
ccbabaee5c36
dirstate-entry: add a `need_delay` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47531
diff
changeset
|
393 |
def need_delay(self, now): |
ccbabaee5c36
dirstate-entry: add a `need_delay` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47531
diff
changeset
|
394 |
"""True if the stored mtime would be ambiguous with the current time""" |
47957
05f2be3affe3
dirstate-item: have all the logic go through the v1_ accessors
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47956
diff
changeset
|
395 |
return self.v1_state() == b'n' and self.v1_mtime() == now |
47532
ccbabaee5c36
dirstate-entry: add a `need_delay` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47531
diff
changeset
|
396 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
397 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
398 |
def gettype(q): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
399 |
return int(q & 0xFFFF) |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
400 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
401 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
402 |
class BaseIndexObject(object): |
47279
9d1a8829f959
revlog: signal which revlog index are compatible with Rust
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47278
diff
changeset
|
403 |
# 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
|
404 |
rust_ext_compat = 0 |
46674
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
405 |
# 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
|
406 |
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
|
407 |
# 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
|
408 |
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
|
409 |
# 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
|
410 |
int_size = struct.calcsize(b'>i') |
e83327af26f1
pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents:
46479
diff
changeset
|
411 |
# 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
|
412 |
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
|
413 |
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
|
414 |
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
|
415 |
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
|
416 |
-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
|
417 |
-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
|
418 |
-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
|
419 |
-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
|
420 |
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
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
revlog_constants.COMP_MODE_INLINE, |
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
|
425 |
) |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
426 |
|
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
|
427 |
@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
|
428 |
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
|
429 |
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
|
430 |
|
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
431 |
@property |
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
432 |
def nodemap(self): |
43663
c207c46a86b9
py3: pass a bytes value for "msg" to nouideprecwarn()
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
43622
diff
changeset
|
433 |
msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]" |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
434 |
util.nouideprecwarn(msg, b'5.3', stacklevel=2) |
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
435 |
return self._nodemap |
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
436 |
|
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
437 |
@util.propertycache |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
438 |
def _nodemap(self): |
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46974
diff
changeset
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
|
43582
0c659fc20207
index: add a `has_node` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43581
diff
changeset
|
445 |
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
|
446 |
"""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
|
447 |
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
|
448 |
|
43600
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
449 |
def rev(self, node): |
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
450 |
"""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
|
451 |
|
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
452 |
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
|
453 |
return self._nodemap[node] |
43600
bd87114ce341
index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43582
diff
changeset
|
454 |
|
43602
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
455 |
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
|
456 |
"""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
|
457 |
|
b56de57c45ce
index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43600
diff
changeset
|
458 |
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
|
459 |
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
|
460 |
|
43581
642433629e20
revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43579
diff
changeset
|
461 |
def _stripnodes(self, start): |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
462 |
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
|
463 |
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
|
464 |
n = self[r][7] |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
465 |
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
|
466 |
|
43573
845e5b313783
revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
467 |
def clearcaches(self): |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
468 |
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
|
469 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
470 |
def __len__(self): |
38890
781b2720d2ac
index: don't include nullid in len()
Martin von Zweigbergk <martinvonz@google.com>
parents:
38889
diff
changeset
|
471 |
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
|
472 |
|
38889
6104b203bec8
index: replace insert(-1, e) method by append(e) method
Martin von Zweigbergk <martinvonz@google.com>
parents:
38887
diff
changeset
|
473 |
def append(self, tup): |
43622
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
474 |
if '_nodemap' in vars(self): |
02802fa87b74
revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43602
diff
changeset
|
475 |
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
|
476 |
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
|
477 |
self._extra.append(data) |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
478 |
|
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
|
479 |
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
|
480 |
assert entry[8] == 0 |
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
481 |
assert entry[9] == 0 |
47ffc754989a
revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47156
diff
changeset
|
482 |
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
|
483 |
|
39245
5961517fd2a8
index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents:
39244
diff
changeset
|
484 |
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
|
485 |
if not isinstance(i, int): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
486 |
raise TypeError(b"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
|
487 |
if i < 0 or i >= len(self): |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
488 |
raise IndexError |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
489 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
490 |
def __getitem__(self, i): |
39084
a1f934573c0b
parsers: adjust pure-python version to mimic a3dacabd476b
Augie Fackler <augie@google.com>
parents:
38890
diff
changeset
|
491 |
if i == -1: |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
492 |
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
|
493 |
self._check_index(i) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
494 |
if i >= self._lgt: |
45951
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
495 |
data = self._extra[i - self._lgt] |
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
496 |
else: |
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
497 |
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
|
498 |
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
|
499 |
r = self._unpack_entry(i, data) |
45951
0ce15a8c7b8b
revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents:
45647
diff
changeset
|
500 |
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
|
501 |
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
|
502 |
r = (offset,) + r[1:] |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
503 |
return r |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
504 |
|
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
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
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
|
512 |
) |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
513 |
return r |
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
514 |
|
47078
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
515 |
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
|
516 |
"""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
|
517 |
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
|
518 |
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
|
519 |
|
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
520 |
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
|
521 |
"""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
|
522 |
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
|
523 |
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
|
524 |
if rev == 0: |
47078
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
525 |
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
|
526 |
return p |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
527 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
528 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
529 |
class IndexObject(BaseIndexObject): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
530 |
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
|
531 |
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
|
532 |
len(data), |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
533 |
self.entry_size, |
0d8ff1f4ab0c
revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47055
diff
changeset
|
534 |
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
|
535 |
) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
536 |
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
|
537 |
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
|
538 |
self._extra = [] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
539 |
|
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
540 |
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
|
541 |
return i * self.entry_size |
13253 | 542 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
543 |
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
|
544 |
if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
545 |
raise ValueError(b"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
|
546 |
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
|
547 |
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
|
548 |
self._stripnodes(i) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
549 |
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
|
550 |
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
|
551 |
self._lgt = i |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
552 |
self._extra = [] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
553 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
554 |
self._extra = self._extra[: i - self._lgt] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
555 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
556 |
|
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
557 |
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
|
558 |
"""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
|
559 |
|
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
""" |
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
564 |
|
44357
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
565 |
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
|
566 |
"""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
|
567 |
|
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
568 |
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
|
569 |
index.""" |
7f4f7ef3133e
nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44356
diff
changeset
|
570 |
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
|
571 |
|
44367
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
572 |
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
|
573 |
"""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
|
574 |
|
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
575 |
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
|
576 |
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
|
577 |
""" |
50ad851efd9b
nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44363
diff
changeset
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
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
|
582 |
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
|
583 |
) |
44371
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
584 |
|
1d2b37def017
nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44370
diff
changeset
|
585 |
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
|
586 |
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
|
587 |
|
44369
e41a164db7a9
nodemap: track the maximum revision tracked in the nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44367
diff
changeset
|
588 |
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
|
589 |
"""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
|
590 |
|
671f9479af0e
nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44357
diff
changeset
|
591 |
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
|
592 |
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
|
593 |
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
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
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
|
598 |
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
|
599 |
|
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
600 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
601 |
class InlinedIndexObject(BaseIndexObject): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
602 |
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
|
603 |
self._data = data |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
604 |
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
|
605 |
self._inline_scan(self._lgt) |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
606 |
self._extra = [] |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
607 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
608 |
def _inline_scan(self, lgt): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
609 |
off = 0 |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
610 |
if lgt is not None: |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
611 |
self._offsets = [0] * lgt |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
612 |
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
|
613 |
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
|
614 |
start = off + self.big_int_size |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
615 |
(s,) = struct.unpack( |
46479
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
616 |
b'>i', |
095fa99ae5f5
revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
617 |
self._data[start : start + self.int_size], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
618 |
) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
619 |
if lgt is not None: |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
620 |
self._offsets[count] = off |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
621 |
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
|
622 |
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
|
623 |
if off != len(self._data): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
624 |
raise ValueError(b"corrupted data") |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
625 |
return count |
14421
639f26cab2f5
pure parsers: properly detect corrupt index files
Augie Fackler <durin42@gmail.com>
parents:
14064
diff
changeset
|
626 |
|
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
627 |
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
|
628 |
if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
629 |
raise ValueError(b"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
|
630 |
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
|
631 |
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
|
632 |
self._stripnodes(i) |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
633 |
if i < self._lgt: |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
634 |
self._offsets = self._offsets[:i] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
635 |
self._lgt = i |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
636 |
self._extra = [] |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
637 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
638 |
self._extra = self._extra[: i - self._lgt] |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
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 _calculate_index(self, i): |
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
641 |
return self._offsets[i] |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
642 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
643 |
|
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
644 |
def parse_index2(data, inline, revlogv2=False): |
29133
255274719dc1
pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents:
28861
diff
changeset
|
645 |
if not inline: |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
646 |
cls = IndexObject2 if revlogv2 else IndexObject |
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
647 |
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
|
648 |
cls = InlinedIndexObject |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
649 |
return cls(data, inline), (0, data) |
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
650 |
|
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
651 |
|
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
652 |
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
|
653 |
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
|
654 |
|
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
655 |
|
47273
468e451fc0de
revlogv2: drop the code related to inlined revlogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47270
diff
changeset
|
656 |
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
|
657 |
index_format = revlog_constants.INDEX_ENTRY_V2 |
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
658 |
|
47095
223b47235d1c
sidedata: enable sidedata computers to optionally rewrite flags
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
659 |
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
|
660 |
self, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
661 |
rev, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
662 |
sidedata_offset, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
663 |
sidedata_length, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
664 |
offset_flags, |
07641bafa646
revlog: compress sidedata when doing "post-pull" sidedata update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47267
diff
changeset
|
665 |
compression_mode, |
47095
223b47235d1c
sidedata: enable sidedata computers to optionally rewrite flags
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
666 |
): |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
667 |
""" |
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
668 |
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
|
669 |
ones. |
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
670 |
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
|
671 |
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
|
672 |
""" |
47254
3b04cf976c67
revlog: use `rev` instead of `i` in replace_sidedata_info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47246
diff
changeset
|
673 |
if rev < 0: |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
674 |
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
|
675 |
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
|
676 |
if rev < self._lgt: |
46730
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
677 |
msg = b"cannot rewrite entries outside of this transaction" |
502e795b55ac
revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents:
46717
diff
changeset
|
678 |
raise KeyError(msg) |
47255
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
679 |
else: |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
680 |
entry = list(self[rev]) |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
681 |
entry[0] = offset_flags |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
682 |
entry[8] = sidedata_offset |
78230d036e5d
revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47254
diff
changeset
|
683 |
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
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
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
|
688 |
|
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
|
689 |
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
|
690 |
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
|
691 |
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
|
692 |
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
|
693 |
sidedata_comp = (data[10] & (3 << 2)) >> 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
|
694 |
return entry + (data_comp, sidedata_comp) |
47156
4292bed8da7c
revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47095
diff
changeset
|
695 |
|
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
|
696 |
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
|
697 |
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
|
698 |
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
|
699 |
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
|
700 |
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
|
701 |
|
2b69555e4875
revlog: introduce a compression mode for sidedata in the revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47262
diff
changeset
|
702 |
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
|
703 |
|
47078
d57386e5c80e
revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47075
diff
changeset
|
704 |
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
|
705 |
"""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
|
706 |
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
|
707 |
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
|
708 |
|
47246
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
709 |
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
|
710 |
"""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
|
711 |
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
|
712 |
msg %= header |
6b1eae313b2f
revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47157
diff
changeset
|
713 |
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
|
714 |
|
46717
913485776542
revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents:
46674
diff
changeset
|
715 |
|
47281
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
716 |
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
|
717 |
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
|
718 |
|
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
719 |
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
|
720 |
items = self.index_format.unpack(data) |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
721 |
entry = items[:3] + (rev, rev) + items[3:8] |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
722 |
data_comp = items[8] & 3 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
723 |
sidedata_comp = (items[8] >> 2) & 3 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
724 |
return entry + (data_comp, sidedata_comp) |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
725 |
|
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
726 |
def _pack_entry(self, rev, entry): |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
727 |
assert entry[3] == rev, entry[3] |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
728 |
assert entry[4] == rev, entry[4] |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
729 |
data = entry[:3] + entry[5:10] |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
730 |
data_comp = entry[10] & 3 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
731 |
sidedata_comp = (entry[11] & 3) << 2 |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
732 |
data += (data_comp | sidedata_comp,) |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
733 |
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
|
734 |
|
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47279
diff
changeset
|
735 |
|
44356
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
736 |
def parse_index_devel_nodemap(data, inline): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45951
diff
changeset
|
737 |
"""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
|
738 |
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
|
739 |
|
6f9e8e142cea
nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44035
diff
changeset
|
740 |
|
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
741 |
def parse_dirstate(dmap, copymap, st): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
742 |
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
|
743 |
# 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
|
744 |
format = b">cllll" |
7945
94d7e14cfa42
pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents:
7873
diff
changeset
|
745 |
e_size = struct.calcsize(format) |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
746 |
pos1 = 40 |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
747 |
l = len(st) |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
748 |
|
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
749 |
# the inner loop |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
750 |
while pos1 < l: |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
751 |
pos2 = pos1 + e_size |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
752 |
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
|
753 |
pos1 = pos2 + e[4] |
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
754 |
f = st[pos2:pos1] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
755 |
if b'\0' in f: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
756 |
f, c = f.split(b'\0') |
7700
f410c552fa15
pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff
changeset
|
757 |
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
|
758 |
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
|
759 |
return parents |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
760 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
39245
diff
changeset
|
761 |
|
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
762 |
def pack_dirstate(dmap, copymap, pl, now): |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
763 |
now = int(now) |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
27339
diff
changeset
|
764 |
cs = stringio() |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
765 |
write = cs.write |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
766 |
write(b"".join(pl)) |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43077
diff
changeset
|
767 |
for f, e in pycompat.iteritems(dmap): |
47540
1a6302427eb9
dirstate-item: use need_delay when packing dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47539
diff
changeset
|
768 |
if e.need_delay(now): |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
769 |
# The file was last modified "simultaneously" with the current |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
770 |
# write to dirstate (i.e. within the same second for file- |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
771 |
# systems with a granularity of 1 sec). This commonly happens |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
772 |
# for at least a couple of files on 'update'. |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
773 |
# The user could change the file without changing its size |
19652
187bf2dde7c1
pack_dirstate: only invalidate mtime for files written in the last second
Siddharth Agarwal <sid0@fb.com>
parents:
18567
diff
changeset
|
774 |
# within the same second. Invalidate the file's mtime in |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
775 |
# dirstate, forcing future 'status' calls to compare the |
19652
187bf2dde7c1
pack_dirstate: only invalidate mtime for files written in the last second
Siddharth Agarwal <sid0@fb.com>
parents:
18567
diff
changeset
|
776 |
# contents of the file if the size is the same. This prevents |
187bf2dde7c1
pack_dirstate: only invalidate mtime for files written in the last second
Siddharth Agarwal <sid0@fb.com>
parents:
18567
diff
changeset
|
777 |
# mistakenly treating such files as clean. |
47667
d06ced90c80f
dirstate-item: use `set_possibly_dirty` in `pure.pack_dirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47666
diff
changeset
|
778 |
e.set_possibly_dirty() |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
779 |
|
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
780 |
if f in copymap: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
781 |
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
|
782 |
e = _pack( |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
783 |
b">cllll", |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
784 |
e.v1_state(), |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
785 |
e.v1_mode(), |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
786 |
e.v1_size(), |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
787 |
e.v1_mtime(), |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
788 |
len(f), |
80dc1d452993
dirstate-entry: introduce dedicated accessors for v1 serialization
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47508
diff
changeset
|
789 |
) |
18567
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
790 |
write(e) |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
791 |
write(f) |
194e63c1ccb9
dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents:
17425
diff
changeset
|
792 |
return cs.getvalue() |