Show More
@@ -408,7 +408,6 b' coreconfigitem(' | |||||
408 | # TODO before getting `persistent-nodemap` out of experimental |
|
408 | # TODO before getting `persistent-nodemap` out of experimental | |
409 | # |
|
409 | # | |
410 | # * code/tests around aborted transaction |
|
410 | # * code/tests around aborted transaction | |
411 | # * code/tests around pending data for hooks |
|
|||
412 | # * regenerate a new nodemap when the unused/total ration is to high |
|
411 | # * regenerate a new nodemap when the unused/total ration is to high | |
413 | # * decide for a "status" of the persistent nodemap and associated location |
|
412 | # * decide for a "status" of the persistent nodemap and associated location | |
414 | # - part of the store next the revlog itself (new requirements) |
|
413 | # - part of the store next the revlog itself (new requirements) |
@@ -436,7 +436,14 b' class revlog(object):' | |||||
436 | self.datafile = datafile or (indexfile[:-2] + b".d") |
|
436 | self.datafile = datafile or (indexfile[:-2] + b".d") | |
437 | self.nodemap_file = None |
|
437 | self.nodemap_file = None | |
438 | if persistentnodemap: |
|
438 | if persistentnodemap: | |
439 | self.nodemap_file = indexfile[:-2] + b".n" |
|
439 | if indexfile.endswith(b'.a'): | |
|
440 | pending_path = indexfile[:-4] + b".n.a" | |||
|
441 | if opener.exists(pending_path): | |||
|
442 | self.nodemap_file = pending_path | |||
|
443 | else: | |||
|
444 | self.nodemap_file = indexfile[:-4] + b".n" | |||
|
445 | else: | |||
|
446 | self.nodemap_file = indexfile[:-2] + b".n" | |||
440 |
|
447 | |||
441 | self.opener = opener |
|
448 | self.opener = opener | |
442 | # When True, indexfile is opened with checkambig=True at writing, to |
|
449 | # When True, indexfile is opened with checkambig=True at writing, to |
@@ -75,6 +75,9 b' def setup_persistent_nodemap(tr, revlog)' | |||||
75 | callback_id = b"revlog-persistent-nodemap-%s" % revlog.nodemap_file |
|
75 | callback_id = b"revlog-persistent-nodemap-%s" % revlog.nodemap_file | |
76 | if tr.hasfinalize(callback_id): |
|
76 | if tr.hasfinalize(callback_id): | |
77 | return # no need to register again |
|
77 | return # no need to register again | |
|
78 | tr.addpending( | |||
|
79 | callback_id, lambda tr: _persist_nodemap(tr, revlog, pending=True) | |||
|
80 | ) | |||
78 | tr.addfinalize(callback_id, lambda tr: _persist_nodemap(tr, revlog)) |
|
81 | tr.addfinalize(callback_id, lambda tr: _persist_nodemap(tr, revlog)) | |
79 |
|
82 | |||
80 |
|
83 | |||
@@ -101,7 +104,7 b' def update_persistent_nodemap(revlog):' | |||||
101 | notr._postclose[k](None) |
|
104 | notr._postclose[k](None) | |
102 |
|
105 | |||
103 |
|
106 | |||
104 | def _persist_nodemap(tr, revlog): |
|
107 | def _persist_nodemap(tr, revlog, pending=False): | |
105 | """Write nodemap data on disk for a given revlog |
|
108 | """Write nodemap data on disk for a given revlog | |
106 | """ |
|
109 | """ | |
107 | if getattr(revlog, 'filteredrevs', ()): |
|
110 | if getattr(revlog, 'filteredrevs', ()): | |
@@ -169,7 +172,10 b' def _persist_nodemap(tr, revlog):' | |||||
169 | target_docket.tip_node = revlog.node(target_docket.tip_rev) |
|
172 | target_docket.tip_node = revlog.node(target_docket.tip_rev) | |
170 | # EXP-TODO: if this is a cache, this should use a cache vfs, not a |
|
173 | # EXP-TODO: if this is a cache, this should use a cache vfs, not a | |
171 | # store vfs |
|
174 | # store vfs | |
172 | with revlog.opener(revlog.nodemap_file, b'w', atomictemp=True) as fp: |
|
175 | file_path = revlog.nodemap_file | |
|
176 | if pending: | |||
|
177 | file_path += b'.a' | |||
|
178 | with revlog.opener(file_path, b'w', atomictemp=True) as fp: | |||
173 | fp.write(target_docket.serialize()) |
|
179 | fp.write(target_docket.serialize()) | |
174 | revlog._nodemap_docket = target_docket |
|
180 | revlog._nodemap_docket = target_docket | |
175 | if feed_data: |
|
181 | if feed_data: | |
@@ -304,7 +310,10 b' class NodeMapDocket(object):' | |||||
304 |
|
310 | |||
305 | def _rawdata_filepath(revlog, docket): |
|
311 | def _rawdata_filepath(revlog, docket): | |
306 | """The (vfs relative) nodemap's rawdata file for a given uid""" |
|
312 | """The (vfs relative) nodemap's rawdata file for a given uid""" | |
307 |
|
|
313 | if revlog.nodemap_file.endswith(b'.n.a'): | |
|
314 | prefix = revlog.nodemap_file[:-4] | |||
|
315 | else: | |||
|
316 | prefix = revlog.nodemap_file[:-2] | |||
308 | return b"%s-%s.nd" % (prefix, docket.uid) |
|
317 | return b"%s-%s.nd" % (prefix, docket.uid) | |
309 |
|
318 | |||
310 |
|
319 |
@@ -281,3 +281,39 b' the nodemap should detect the changelog ' | |||||
281 | data-unused: 0 |
|
281 | data-unused: 0 | |
282 | $ hg log -r "$OTHERNODE" -T '{rev}\n' |
|
282 | $ hg log -r "$OTHERNODE" -T '{rev}\n' | |
283 | 5002 |
|
283 | 5002 | |
|
284 | ||||
|
285 | Check transaction related property | |||
|
286 | ================================== | |||
|
287 | ||||
|
288 | An up to date nodemap should be available to shell hooks, | |||
|
289 | ||||
|
290 | $ echo dsljfl > a | |||
|
291 | $ hg add a | |||
|
292 | $ hg ci -m a | |||
|
293 | $ hg debugnodemap --metadata | |||
|
294 | uid: ???????????????? (glob) | |||
|
295 | tip-rev: 5003 | |||
|
296 | tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf | |||
|
297 | data-length: 123008 | |||
|
298 | data-unused: 0 | |||
|
299 | $ echo babar2 > babar | |||
|
300 | $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata" | |||
|
301 | uid: ???????????????? (glob) | |||
|
302 | tip-rev: 5004 | |||
|
303 | tip-node: ba87cd9559559e4b91b28cb140d003985315e031 | |||
|
304 | data-length: 123328 (pure !) | |||
|
305 | data-length: 123328 (rust !) | |||
|
306 | data-length: 123136 (no-pure no-rust !) | |||
|
307 | data-unused: 192 (pure !) | |||
|
308 | data-unused: 192 (rust !) | |||
|
309 | data-unused: 0 (no-pure no-rust !) | |||
|
310 | $ hg debugnodemap --metadata | |||
|
311 | uid: ???????????????? (glob) | |||
|
312 | tip-rev: 5004 | |||
|
313 | tip-node: ba87cd9559559e4b91b28cb140d003985315e031 | |||
|
314 | data-length: 123328 (pure !) | |||
|
315 | data-length: 123328 (rust !) | |||
|
316 | data-length: 123136 (no-pure no-rust !) | |||
|
317 | data-unused: 192 (pure !) | |||
|
318 | data-unused: 192 (rust !) | |||
|
319 | data-unused: 0 (no-pure no-rust !) |
General Comments 0
You need to be logged in to leave comments.
Login now