##// END OF EJS Templates
test-sparse-revlog: commit the repo content in a single in-mem transaction...
marmoute -
r53336:83f87912 default
parent child Browse files
Show More
@@ -14,8 +14,6
14 # of the files always get updated while the rest of the lines get updated over
14 # of the files always get updated while the rest of the lines get updated over
15 # time. This update happens over many topological branches, some getting merged
15 # time. This update happens over many topological branches, some getting merged
16 # back.
16 # back.
17 #
18 # Running with `chg` in your path and `CHGHG` set is recommended for speed.
19
17
20
18
21 import hashlib
19 import hashlib
@@ -25,6 +23,10 import subprocess
25 import sys
23 import sys
26 import tempfile
24 import tempfile
27
25
26 import mercurial.context
27 import mercurial.hg
28 import mercurial.ui
29
28 BUNDLE_NAME = 'big-file-churn.hg'
30 BUNDLE_NAME = 'big-file-churn.hg'
29
31
30 # constants for generating the repository
32 # constants for generating the repository
@@ -218,27 +220,47 def hg(command, *args):
218 return subprocess.check_call(full_cmd, env=env)
220 return subprocess.check_call(full_cmd, env=env)
219
221
220
222
223 def write_repo(path):
224 """write repository content in memory"""
225 repo = mercurial.hg.repository(
226 mercurial.ui.ui.load(),
227 path=path.encode('utf-8'),
228 )
229 nodemap = {None: repo.nodeconstants.nullid}
230 with repo.lock(), repo.transaction(b'bundle-generation'):
231 for idx, (p1, p2) in GRAPH.items():
232 if sys.stdout.isatty():
233 print("generating commit #%d/%d" % (idx, NB_CHANGESET))
234
235 file_fn = lambda repo, memctx, path: mercurial.context.memfilectx(
236 repo,
237 memctx,
238 path,
239 data=b''.join(CONTENT.pop(idx)()),
240 )
241
242 mc = mercurial.context.memctx(
243 repo,
244 (nodemap[p1], nodemap[p2]),
245 b'commit #%d' % idx if idx else b'initial commit',
246 [FILENAME.encode('ascii')],
247 file_fn,
248 user=b"test",
249 date=(0, 0),
250 )
251 nodemap[idx] = repo.commitctx(mc)
252
253
221 def run(target):
254 def run(target):
222 tmpdir = tempfile.mkdtemp(prefix='tmp-hg-test-big-file-bundle-')
255 tmpdir = tempfile.mkdtemp(prefix='tmp-hg-test-big-file-bundle-')
223 try:
256 try:
224 os.chdir(tmpdir)
257 os.chdir(tmpdir)
225 hg('init')
258 hg(
226 for idx, (p1, p2) in GRAPH.items():
259 'init',
227 if sys.stdout.isatty():
260 '--config',
228 print("generating commit #%d/%d" % (idx, NB_CHANGESET))
261 'format.maxchainlen=%d' % NB_CHANGESET,
229 if p1 is not None and p1 != idx - 1:
262 )
230 hg('update', "%d" % p1)
263 write_repo(tmpdir)
231 if p2 is not None:
232 hg('merge', "%d" % p2)
233 with open(FILENAME, 'wb') as f:
234 # pop the value to let it be garbage collection eventually.
235 for line in CONTENT.pop(idx)():
236 f.write(line)
237 if idx == 0:
238 hg('add', FILENAME)
239 hg('commit', '--addremove', '--message', 'initial commit')
240 else:
241 hg('commit', '--message', 'commit #%d' % idx)
242 hg('bundle', '--all', target, '--config', 'devel.bundle.delta=p1')
264 hg('bundle', '--all', target, '--config', 'devel.bundle.delta=p1')
243 with open(target, 'rb') as bundle:
265 with open(target, 'rb') as bundle:
244 data = bundle.read()
266 data = bundle.read()
General Comments 0
You need to be logged in to leave comments. Login now