annotate mercurial/pure/parsers.py @ 47255:78230d036e5d

revlog: simplify the replace_sidedata_info code We already know how to serialize and de-serialize and enty. So lets just do that and modify the entry tuple directly. This avoid having to duplicated binary operation in complicated code. Differential Revision: https://phab.mercurial-scm.org/D10641
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 04 May 2021 00:02:48 +0200
parents 3b04cf976c67
children 130c9f7ed914
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
1 # parsers.py - Python implementation of parsers.c
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
2 #
46819
d4ba4d51f85f contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents: 46730
diff changeset
3 # Copyright 2009 Olivia Mackall <olivia@selenic.com> and others
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 7945
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 8225
diff changeset
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 )
43573
845e5b313783 revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43106
diff changeset
17 from .. import (
47246
6b1eae313b2f revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47157
diff changeset
18 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
19 pycompat,
845e5b313783 revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43106
diff changeset
20 util,
845e5b313783 revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43106
diff changeset
21 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
22
44035
ab595920de0e revlogutils: move the NodeMap class in a dedicated nodemap module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43663
diff changeset
23 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
24 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
25
36964
644a02f6b34f util: prefer "bytesio" to "stringio"
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34338
diff changeset
26 stringio = pycompat.bytesio
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
27
31230
37596c980662 parsers: alias long to int on Python 3
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29133
diff changeset
28
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
29 _pack = struct.pack
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
30 _unpack = struct.unpack
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
31 _compress = zlib.compress
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
32 _decompress = zlib.decompress
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
33
21809
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
34 # Some code below makes tuples directly because it's more convenient. However,
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
35 # code outside this module should always use dirstatetuple.
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
36 def dirstatetuple(*x):
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
37 # x is a tuple
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
38 return x
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
39
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
40
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
41 def gettype(q):
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
42 return int(q & 0xFFFF)
7945
94d7e14cfa42 pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents: 7873
diff changeset
43
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
44
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
45 def offset_type(offset, type):
31535
61ff3852f6ed pure: use int instead of long
Martin von Zweigbergk <martinvonz@google.com>
parents: 31230
diff changeset
46 return int(int(offset) << 16 | type)
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
47
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
48
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
49 class BaseIndexObject(object):
46674
e83327af26f1 pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents: 46479
diff changeset
50 # 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
51 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
52 # 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
53 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
54 # 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
55 int_size = struct.calcsize(b'>i')
e83327af26f1 pure-parsers: document index class constants
Raphaël Gomès <rgomes@octobus.net>
parents: 46479
diff changeset
56 # An empty index entry, used as a default value to be overridden, or nullrev
47156
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
57 null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0)
46479
095fa99ae5f5 revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents: 45957
diff changeset
58
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
59 @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
60 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
61 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
62
43622
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
63 @property
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
64 def nodemap(self):
43663
c207c46a86b9 py3: pass a bytes value for "msg" to nouideprecwarn()
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 43622
diff changeset
65 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
66 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
67 return self._nodemap
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
68
43573
845e5b313783 revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43106
diff changeset
69 @util.propertycache
43622
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
70 def _nodemap(self):
47055
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46974
diff changeset
71 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
72 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
73 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
74 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
75 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
76
43582
0c659fc20207 index: add a `has_node` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43581
diff changeset
77 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
78 """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
79 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
80
43600
bd87114ce341 index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43582
diff changeset
81 def rev(self, node):
bd87114ce341 index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43582
diff changeset
82 """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
83
bd87114ce341 index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43582
diff changeset
84 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
85 return self._nodemap[node]
43600
bd87114ce341 index: add a `rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43582
diff changeset
86
43602
b56de57c45ce index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43600
diff changeset
87 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
88 """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
89
b56de57c45ce index: add a `get_rev` method (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43600
diff changeset
90 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
91 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
92
43581
642433629e20 revlog: deal with nodemap deletion within the index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43579
diff changeset
93 def _stripnodes(self, start):
43622
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
94 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
95 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
96 n = self[r][7]
43622
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
97 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
98
43573
845e5b313783 revlog: move the nodemap into the index object (for pure)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43106
diff changeset
99 def clearcaches(self):
43622
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
100 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
101
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
102 def __len__(self):
38890
781b2720d2ac index: don't include nullid in len()
Martin von Zweigbergk <martinvonz@google.com>
parents: 38889
diff changeset
103 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
104
38889
6104b203bec8 index: replace insert(-1, e) method by append(e) method
Martin von Zweigbergk <martinvonz@google.com>
parents: 38887
diff changeset
105 def append(self, tup):
43622
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
106 if '_nodemap' in vars(self):
02802fa87b74 revlog: deprecate direct `nodemap` access
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43602
diff changeset
107 self._nodemap[tup[7]] = len(self)
47157
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
108 data = self._pack_entry(tup)
45951
0ce15a8c7b8b revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents: 45647
diff changeset
109 self._extra.append(data)
7945
94d7e14cfa42 pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents: 7873
diff changeset
110
47157
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
111 def _pack_entry(self, entry):
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
112 assert entry[8] == 0
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
113 assert entry[9] == 0
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
114 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
115
39245
5961517fd2a8 index: rename _fix_index() since it no longer fixes the index
Martin von Zweigbergk <martinvonz@google.com>
parents: 39244
diff changeset
116 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
117 if not isinstance(i, int):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
118 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
119 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
120 raise IndexError
7945
94d7e14cfa42 pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents: 7873
diff changeset
121
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
122 def __getitem__(self, i):
39084
a1f934573c0b parsers: adjust pure-python version to mimic a3dacabd476b
Augie Fackler <augie@google.com>
parents: 38890
diff changeset
123 if i == -1:
46479
095fa99ae5f5 revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents: 45957
diff changeset
124 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
125 self._check_index(i)
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
126 if i >= self._lgt:
45951
0ce15a8c7b8b revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents: 45647
diff changeset
127 data = self._extra[i - self._lgt]
0ce15a8c7b8b revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents: 45647
diff changeset
128 else:
0ce15a8c7b8b revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents: 45647
diff changeset
129 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
130 data = self._data[index : index + self.entry_size]
47156
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
131 r = self._unpack_entry(data)
45951
0ce15a8c7b8b revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents: 45647
diff changeset
132 if self._lgt and i == 0:
0ce15a8c7b8b revlog: store new index entries as binary
Joerg Sonnenberger <joerg@bec.de>
parents: 45647
diff changeset
133 r = (offset_type(0, gettype(r[0])),) + r[1:]
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
134 return r
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
135
47156
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
136 def _unpack_entry(self, data):
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
137 r = self.index_format.unpack(data)
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
138 r = r + (0, 0)
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
139 return r
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
140
47078
d57386e5c80e revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47075
diff changeset
141 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
142 """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
143 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
144 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
145
d57386e5c80e revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47075
diff changeset
146 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
147 """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
148 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
149 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
150 if rev == 0:
47078
d57386e5c80e revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47075
diff changeset
151 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
152 return p
0d8ff1f4ab0c revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47055
diff changeset
153
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
154
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
155 class IndexObject(BaseIndexObject):
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
156 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
157 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
158 len(data),
0d8ff1f4ab0c revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47055
diff changeset
159 self.entry_size,
0d8ff1f4ab0c revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47055
diff changeset
160 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
161 )
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
162 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
163 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
164 self._extra = []
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
165
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
166 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
167 return i * self.entry_size
13253
61c9bc3da402 revlog: remove lazy index
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
168
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
169 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
170 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
171 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
172 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
173 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
174 self._stripnodes(i)
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
175 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
176 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
177 self._lgt = i
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
178 self._extra = []
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
179 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
180 self._extra = self._extra[: i - self._lgt]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
181
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
182
44356
6f9e8e142cea nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44035
diff changeset
183 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
184 """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
185
6f9e8e142cea nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44035
diff changeset
186 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
187 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
188 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
189 """
6f9e8e142cea nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44035
diff changeset
190
44357
7f4f7ef3133e nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44356
diff changeset
191 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
192 """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
193
7f4f7ef3133e nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44356
diff changeset
194 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
195 index."""
7f4f7ef3133e nodemap: add a optional `nodemap_add_full` method on indexes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44356
diff changeset
196 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
197
44367
50ad851efd9b nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44363
diff changeset
198 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
199 """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
200
50ad851efd9b nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44363
diff changeset
201 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
202 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
203 """
50ad851efd9b nodemap: introduce append-only incremental update of the persistent data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44363
diff changeset
204 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
205 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
206 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
207 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
208 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
209 )
44371
1d2b37def017 nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44370
diff changeset
210
1d2b37def017 nodemap: double check the source docket when doing incremental update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44370
diff changeset
211 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
212 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
213
44369
e41a164db7a9 nodemap: track the maximum revision tracked in the nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44367
diff changeset
214 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
215 """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
216
671f9479af0e nodemap: provide the on disk data to indexes who support it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44357
diff changeset
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225
44356
6f9e8e142cea nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44035
diff changeset
226
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
227 class InlinedIndexObject(BaseIndexObject):
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
228 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
229 self._data = data
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
230 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
231 self._inline_scan(self._lgt)
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
232 self._extra = []
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
233
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
234 def _inline_scan(self, lgt):
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
235 off = 0
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
236 if lgt is not None:
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
237 self._offsets = [0] * lgt
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
238 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
239 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
240 start = off + self.big_int_size
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
241 (s,) = struct.unpack(
46479
095fa99ae5f5 revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents: 45957
diff changeset
242 b'>i',
095fa99ae5f5 revlog: prepare pure parser for being overloaded
Raphaël Gomès <rgomes@octobus.net>
parents: 45957
diff changeset
243 self._data[start : start + self.int_size],
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
244 )
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
245 if lgt is not None:
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
246 self._offsets[count] = off
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
247 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
248 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
249 if off != len(self._data):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
250 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
251 return count
14421
639f26cab2f5 pure parsers: properly detect corrupt index files
Augie Fackler <durin42@gmail.com>
parents: 14064
diff changeset
252
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
253 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
254 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
255 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
256 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
257 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
258 self._stripnodes(i)
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
259 if i < self._lgt:
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
260 self._offsets = self._offsets[:i]
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
261 self._lgt = i
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
262 self._extra = []
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
263 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
264 self._extra = self._extra[: i - self._lgt]
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
265
29133
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
266 def _calculate_index(self, i):
255274719dc1 pure: write a really lazy version of pure indexObject
Maciej Fijalkowski <fijall@gmail.com>
parents: 28861
diff changeset
267 return self._offsets[i]
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
268
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
269
46717
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
270 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
271 if not inline:
46717
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
272 cls = IndexObject2 if revlogv2 else IndexObject
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
273 return cls(data), None
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
274 cls = InlinedIndexObject2 if revlogv2 else InlinedIndexObject
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
275 return cls(data, inline), (0, data)
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
276
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
277
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
278 class Index2Mixin(object):
46860
1dc86c2a43ce revlog: directly use the Struct object for related operation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46858
diff changeset
279 index_format = revlog_constants.INDEX_ENTRY_V2
46717
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
280
47095
223b47235d1c sidedata: enable sidedata computers to optionally rewrite flags
Raphaël Gomès <rgomes@octobus.net>
parents: 47078
diff changeset
281 def replace_sidedata_info(
47254
3b04cf976c67 revlog: use `rev` instead of `i` in replace_sidedata_info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47246
diff changeset
282 self, rev, sidedata_offset, sidedata_length, offset_flags
47095
223b47235d1c sidedata: enable sidedata computers to optionally rewrite flags
Raphaël Gomès <rgomes@octobus.net>
parents: 47078
diff changeset
283 ):
46730
502e795b55ac revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents: 46717
diff changeset
284 """
502e795b55ac revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents: 46717
diff changeset
285 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
286 ones.
502e795b55ac revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents: 46717
diff changeset
287 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
288 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
289 """
47254
3b04cf976c67 revlog: use `rev` instead of `i` in replace_sidedata_info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47246
diff changeset
290 if rev < 0:
46730
502e795b55ac revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents: 46717
diff changeset
291 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
292 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
293 if rev < self._lgt:
46730
502e795b55ac revlog-index: add `replace_sidedata_info` method
Raphaël Gomès <rgomes@octobus.net>
parents: 46717
diff changeset
294 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
295 raise KeyError(msg)
47255
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
296 else:
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
297 entry = list(self[rev])
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
298 entry[0] = offset_flags
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
299 entry[8] = sidedata_offset
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
300 entry[9] = sidedata_length
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
301 entry = tuple(entry)
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
302 new = self._pack_entry(entry)
78230d036e5d revlog: simplify the replace_sidedata_info code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47254
diff changeset
303 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
304
47156
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
305 def _unpack_entry(self, data):
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
306 return self.index_format.unpack(data)
4292bed8da7c revlog: make the index always return the same tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47095
diff changeset
307
47157
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
308 def _pack_entry(self, entry):
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
309 return self.index_format.pack(*entry)
47ffc754989a revlog: always "append" full size tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47156
diff changeset
310
47078
d57386e5c80e revlog: have an explicit "pack_header" method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47075
diff changeset
311 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
312 """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
313 entry = self[rev]
0d8ff1f4ab0c revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47055
diff changeset
314 p = revlog_constants.INDEX_ENTRY_V2.pack(*entry)
0d8ff1f4ab0c revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47055
diff changeset
315 return p
0d8ff1f4ab0c revlog: add a `entry_binary` method on index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47055
diff changeset
316
47246
6b1eae313b2f revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47157
diff changeset
317 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
318 """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
319 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
320 msg %= header
6b1eae313b2f revlogv2: store version information in the docket only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47157
diff changeset
321 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
322
46717
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
323
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
324 class IndexObject2(Index2Mixin, IndexObject):
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
325 pass
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
326
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
327
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
328 class InlinedIndexObject2(Index2Mixin, InlinedIndexObject):
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
329 def _inline_scan(self, lgt):
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
330 sidedata_length_pos = 72
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
331 off = 0
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
332 if lgt is not None:
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
333 self._offsets = [0] * lgt
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
334 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
335 while off <= len(self._data) - self.entry_size:
46717
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
336 start = off + self.big_int_size
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
337 (data_size,) = struct.unpack(
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
338 b'>i',
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
339 self._data[start : start + self.int_size],
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
340 )
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
341 start = off + sidedata_length_pos
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
342 (side_data_size,) = struct.unpack(
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
343 b'>i', self._data[start : start + self.int_size]
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
344 )
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
345 if lgt is not None:
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
346 self._offsets[count] = off
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
347 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
348 off += self.entry_size + data_size + side_data_size
46717
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
349 if off != len(self._data):
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
350 raise ValueError(b"corrupted data")
913485776542 revlog: introduce v2 format
Raphaël Gomès <rgomes@octobus.net>
parents: 46674
diff changeset
351 return count
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
352
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
353
44356
6f9e8e142cea nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44035
diff changeset
354 def parse_index_devel_nodemap(data, inline):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45951
diff changeset
355 """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
356 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
357
6f9e8e142cea nodemap: add a (python) index class for persistent nodemap testing
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44035
diff changeset
358
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
359 def parse_dirstate(dmap, copymap, st):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
360 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
361 # 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
362 format = b">cllll"
7945
94d7e14cfa42 pure/parsers: fix circular imports, import mercurial modules properly
Matt Mackall <mpm@selenic.com>
parents: 7873
diff changeset
363 e_size = struct.calcsize(format)
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
364 pos1 = 40
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
365 l = len(st)
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
366
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
367 # the inner loop
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
368 while pos1 < l:
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
369 pos2 = pos1 + e_size
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
370 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
371 pos1 = pos2 + e[4]
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
372 f = st[pos2:pos1]
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
373 if b'\0' in f:
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
374 f, c = f.split(b'\0')
7700
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
375 copymap[f] = c
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
376 dmap[f] = e[:4]
f410c552fa15 pure Python implementation of parsers.c
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
377 return parents
18567
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
378
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 39245
diff changeset
379
18567
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
380 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
381 now = int(now)
28861
86db5cb55d46 pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents: 27339
diff changeset
382 cs = stringio()
18567
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
383 write = cs.write
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
384 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
385 for f, e in pycompat.iteritems(dmap):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
386 if e[0] == b'n' and e[3] == now:
18567
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
387 # 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
388 # 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
389 # 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
390 # 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
391 # 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
392 # 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
393 # 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
394 # 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
395 # mistakenly treating such files as clean.
21809
e250b8300e6e parsers: inline fields of dirstate values in C version
Siddharth Agarwal <sid0@fb.com>
parents: 19652
diff changeset
396 e = dirstatetuple(e[0], e[1], e[2], -1)
18567
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
397 dmap[f] = e
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
398
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
399 if f in copymap:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
400 f = b"%s\0%s" % (f, copymap[f])
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
401 e = _pack(b">cllll", e[0], e[1], e[2], e[3], len(f))
18567
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
402 write(e)
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
403 write(f)
194e63c1ccb9 dirstate: move pure python dirstate packing to pure/parsers.py
Siddharth Agarwal <sid0@fb.com>
parents: 17425
diff changeset
404 return cs.getvalue()