##// END OF EJS Templates
nodemap: track the maximum revision tracked in the nodemap...
marmoute -
r44807:e41a164d default
parent child Browse files
Show More
@@ -2137,6 +2137,7 b' def debugnodemap(ui, repo, **opts):'
2137 if nm_data is not None:
2137 if nm_data is not None:
2138 docket, data = nm_data
2138 docket, data = nm_data
2139 ui.write((b"uid: %s\n") % docket.uid)
2139 ui.write((b"uid: %s\n") % docket.uid)
2140 ui.write((b"tip-rev: %d\n") % docket.tip_rev)
2140
2141
2141
2142
2142 @command(
2143 @command(
@@ -170,15 +170,15 b' class PersistentNodeMapIndexObject(Index'
170 self._nm_root = self._nm_max_idx = self._nm_rev = None
170 self._nm_root = self._nm_max_idx = self._nm_rev = None
171 return data
171 return data
172
172
173 def update_nodemap_data(self, nm_data):
173 def update_nodemap_data(self, docket, nm_data):
174 """provide full blokc of persisted binary data for a nodemap
174 """provide full block of persisted binary data for a nodemap
175
175
176 The data are expected to come from disk. See `nodemap_data_all` for a
176 The data are expected to come from disk. See `nodemap_data_all` for a
177 produceur of such data."""
177 produceur of such data."""
178 if nm_data is not None:
178 if nm_data is not None:
179 self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data)
179 self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data)
180 if self._nm_root:
180 if self._nm_root:
181 self._nm_rev = len(self) - 1
181 self._nm_rev = docket.tip_rev
182 else:
182 else:
183 self._nm_root = self._nm_max_idx = self._nm_rev = None
183 self._nm_root = self._nm_max_idx = self._nm_rev = None
184
184
@@ -639,7 +639,7 b' class revlog(object):'
639 if use_nodemap:
639 if use_nodemap:
640 nodemap_data = nodemaputil.persisted_data(self)
640 nodemap_data = nodemaputil.persisted_data(self)
641 if nodemap_data is not None:
641 if nodemap_data is not None:
642 index.update_nodemap_data(nodemap_data[1])
642 index.update_nodemap_data(*nodemap_data)
643 except (ValueError, IndexError):
643 except (ValueError, IndexError):
644 raise error.RevlogError(
644 raise error.RevlogError(
645 _(b"index %s is corrupted") % self.indexfile
645 _(b"index %s is corrupted") % self.indexfile
@@ -36,9 +36,11 b' def persisted_data(revlog):'
36 if version != ONDISK_VERSION:
36 if version != ONDISK_VERSION:
37 return None
37 return None
38 offset += S_VERSION.size
38 offset += S_VERSION.size
39 (uid_size,) = S_HEADER.unpack(pdata[offset : offset + S_HEADER.size])
39 headers = S_HEADER.unpack(pdata[offset : offset + S_HEADER.size])
40 uid_size, tip_rev = headers
40 offset += S_HEADER.size
41 offset += S_HEADER.size
41 docket = NodeMapDocket(pdata[offset : offset + uid_size])
42 docket = NodeMapDocket(pdata[offset : offset + uid_size])
43 docket.tip_rev = tip_rev
42
44
43 filename = _rawdata_filepath(revlog, docket)
45 filename = _rawdata_filepath(revlog, docket)
44 return docket, revlog.opener.tryread(filename)
46 return docket, revlog.opener.tryread(filename)
@@ -94,6 +96,7 b' def _persist_nodemap(tr, revlog):'
94 # store vfs
96 # store vfs
95 with revlog.opener(datafile, b'w') as fd:
97 with revlog.opener(datafile, b'w') as fd:
96 fd.write(data)
98 fd.write(data)
99 target_docket.tip_rev = revlog.tiprev()
97 # EXP-TODO: if this is a cache, this should use a cache vfs, not a
100 # EXP-TODO: if this is a cache, this should use a cache vfs, not a
98 # store vfs
101 # store vfs
99 with revlog.opener(revlog.nodemap_file, b'w', atomictemp=True) as fp:
102 with revlog.opener(revlog.nodemap_file, b'w', atomictemp=True) as fp:
@@ -142,7 +145,7 b' def _persist_nodemap(tr, revlog):'
142 ONDISK_VERSION = 0
145 ONDISK_VERSION = 0
143
146
144 S_VERSION = struct.Struct(">B")
147 S_VERSION = struct.Struct(">B")
145 S_HEADER = struct.Struct(">B")
148 S_HEADER = struct.Struct(">BQ")
146
149
147 ID_SIZE = 8
150 ID_SIZE = 8
148
151
@@ -164,15 +167,19 b' class NodeMapDocket(object):'
164 if uid is None:
167 if uid is None:
165 uid = _make_uid()
168 uid = _make_uid()
166 self.uid = uid
169 self.uid = uid
170 self.tip_rev = None
167
171
168 def copy(self):
172 def copy(self):
169 return NodeMapDocket(uid=self.uid)
173 new = NodeMapDocket(uid=self.uid)
174 new.tip_rev = self.tip_rev
175 return new
170
176
171 def serialize(self):
177 def serialize(self):
172 """return serialized bytes for a docket using the passed uid"""
178 """return serialized bytes for a docket using the passed uid"""
173 data = []
179 data = []
174 data.append(S_VERSION.pack(ONDISK_VERSION))
180 data.append(S_VERSION.pack(ONDISK_VERSION))
175 data.append(S_HEADER.pack(len(self.uid)))
181 headers = (len(self.uid), self.tip_rev)
182 data.append(S_HEADER.pack(*headers))
176 data.append(self.uid)
183 data.append(self.uid)
177 return b''.join(data)
184 return b''.join(data)
178
185
@@ -14,8 +14,9 b' Test the persistent on-disk nodemap'
14 $ hg debugbuilddag .+5000
14 $ hg debugbuilddag .+5000
15 $ hg debugnodemap --metadata
15 $ hg debugnodemap --metadata
16 uid: ???????????????? (glob)
16 uid: ???????????????? (glob)
17 tip-rev: 5000
17 $ f --size .hg/store/00changelog.n
18 $ f --size .hg/store/00changelog.n
18 .hg/store/00changelog.n: size=18
19 .hg/store/00changelog.n: size=26
19 $ f --sha256 .hg/store/00changelog-*.nd
20 $ f --sha256 .hg/store/00changelog-*.nd
20 .hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob)
21 .hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob)
21 $ hg debugnodemap --dump-new | f --sha256 --size
22 $ hg debugnodemap --dump-new | f --sha256 --size
@@ -51,8 +52,9 b' add a new commit'
51 $ hg ci -m 'foo'
52 $ hg ci -m 'foo'
52 $ hg debugnodemap --metadata
53 $ hg debugnodemap --metadata
53 uid: ???????????????? (glob)
54 uid: ???????????????? (glob)
55 tip-rev: 5001
54 $ f --size .hg/store/00changelog.n
56 $ f --size .hg/store/00changelog.n
55 .hg/store/00changelog.n: size=18
57 .hg/store/00changelog.n: size=26
56
58
57 (The pure code use the debug code that perform incremental update, the C code reencode from scratch)
59 (The pure code use the debug code that perform incremental update, the C code reencode from scratch)
58
60
General Comments 0
You need to be logged in to leave comments. Login now