##// END OF EJS Templates
nodemap: delete older raw data file when creating a new ones...
marmoute -
r44793:563dfdfd default
parent child Browse files
Show More
@@ -9,6 +9,7 b''
9 from __future__ import absolute_import
9 from __future__ import absolute_import
10
10
11 import os
11 import os
12 import re
12 import struct
13 import struct
13
14
14 from .. import (
15 from .. import (
@@ -71,6 +72,16 b' def _persist_nodemap(tr, revlog):'
71 data = persistent_data(revlog.index)
72 data = persistent_data(revlog.index)
72 uid = _make_uid()
73 uid = _make_uid()
73 datafile = _rawdata_filepath(revlog, uid)
74 datafile = _rawdata_filepath(revlog, uid)
75 olds = _other_rawdata_filepath(revlog, uid)
76 if olds:
77 realvfs = getattr(revlog, '_realopener', revlog.opener)
78
79 def cleanup(tr):
80 for oldfile in olds:
81 realvfs.tryunlink(oldfile)
82
83 callback_id = b"revlog-cleanup-nodemap-%s" % revlog.nodemap_file
84 tr.addpostclose(callback_id, cleanup)
74 # EXP-TODO: if this is a cache, this should use a cache vfs, not a
85 # EXP-TODO: if this is a cache, this should use a cache vfs, not a
75 # store vfs
86 # store vfs
76 with revlog.opener(datafile, b'w') as fd:
87 with revlog.opener(datafile, b'w') as fd:
@@ -136,6 +147,19 b' def _rawdata_filepath(revlog, uid):'
136 return b"%s-%s.nd" % (prefix, uid)
147 return b"%s-%s.nd" % (prefix, uid)
137
148
138
149
150 def _other_rawdata_filepath(revlog, uid):
151 prefix = revlog.nodemap_file[:-2]
152 pattern = re.compile(b"(^|/)%s-[0-9a-f]+\.nd$" % prefix)
153 new_file_path = _rawdata_filepath(revlog, uid)
154 new_file_name = revlog.opener.basename(new_file_path)
155 dirpath = revlog.opener.dirname(new_file_path)
156 others = []
157 for f in revlog.opener.listdir(dirpath):
158 if pattern.match(f) and f != new_file_name:
159 others.append(f)
160 return others
161
162
139 ### Nodemap Trie
163 ### Nodemap Trie
140 #
164 #
141 # This is a simple reference implementation to compute and persist a nodemap
165 # This is a simple reference implementation to compute and persist a nodemap
@@ -12,6 +12,8 b' Test the persistent on-disk nodemap'
12 $ hg debugbuilddag .+5000
12 $ hg debugbuilddag .+5000
13 $ f --size .hg/store/00changelog.n
13 $ f --size .hg/store/00changelog.n
14 .hg/store/00changelog.n: size=18
14 .hg/store/00changelog.n: size=18
15 $ f --sha256 .hg/store/00changelog-*.nd
16 .hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob)
15 $ hg debugnodemap --dump-new | f --sha256 --size
17 $ hg debugnodemap --dump-new | f --sha256 --size
16 size=122880, sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7
18 size=122880, sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7
17 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
19 $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
@@ -32,3 +34,15 b' Test the persistent on-disk nodemap'
32 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
34 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
33 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
35 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
34 00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
36 00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
37
38 add a new commit
39
40 $ hg up
41 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 $ echo foo > foo
43 $ hg add foo
44 $ hg ci -m 'foo'
45 $ f --size .hg/store/00changelog.n
46 .hg/store/00changelog.n: size=18
47 $ f --sha256 .hg/store/00changelog-*.nd --size
48 .hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob)
General Comments 0
You need to be logged in to leave comments. Login now