author | Yuya Nishihara <yuya@tcha.org> |
Wed, 26 Sep 2018 20:33:09 +0900 | |
changeset 39832 | 85a474adaf26 |
parent 39491 | 4ca7a67c94c8 |
child 41331 | 56a0de3d581c |
child 41795 | b59676077654 |
permissions | -rwxr-xr-x |
39491
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
2 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
3 |
# generate-branchy-bundle - generate a branch for a "large" branchy repository |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
4 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
5 |
# Copyright 2018 Octobus, contact@octobus.net |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
6 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
7 |
# This software may be used and distributed according to the terms of the |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
8 |
# GNU General Public License version 2 or any later version. |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
9 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
10 |
# This script generates a repository suitable for testing delta computation |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
11 |
# strategies. |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
12 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
13 |
# The repository update a single "large" file with many updates. One fixed part |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
14 |
# of the files always get updated while the rest of the lines get updated over |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
15 |
# time. This update happens over many topological branches, some getting merged |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
16 |
# back. |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
17 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
18 |
# Running with `chg` in your path and `CHGHG` set is recommended for speed. |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
19 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
20 |
from __future__ import absolute_import, print_function |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
21 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
22 |
import hashlib |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
23 |
import os |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
24 |
import shutil |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
25 |
import subprocess |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
26 |
import sys |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
27 |
import tempfile |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
28 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
29 |
BUNDLE_NAME = 'big-file-churn.hg' |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
30 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
31 |
# constants for generating the repository |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
32 |
NB_CHANGESET = 5000 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
33 |
PERIOD_MERGING = 8 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
34 |
PERIOD_BRANCHING = 7 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
35 |
MOVE_BACK_MIN = 3 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
36 |
MOVE_BACK_RANGE = 5 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
37 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
38 |
# constants for generating the large file we keep updating |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
39 |
# |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
40 |
# At each revision, the beginning on the file change, |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
41 |
# and set of other lines changes too. |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
42 |
FILENAME='SPARSE-REVLOG-TEST-FILE' |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
43 |
NB_LINES = 10500 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
44 |
ALWAYS_CHANGE_LINES = 500 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
45 |
FILENAME = 'SPARSE-REVLOG-TEST-FILE' |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
46 |
OTHER_CHANGES = 300 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
47 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
48 |
def nextcontent(previous_content): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
49 |
"""utility to produce a new file content from the previous one""" |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
50 |
return hashlib.md5(previous_content).hexdigest() |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
51 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
52 |
def filecontent(iteridx, oldcontent): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
53 |
"""generate a new file content |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
54 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
55 |
The content is generated according the iteration index and previous |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
56 |
content""" |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
57 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
58 |
# initial call |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
59 |
if iteridx is None: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
60 |
current = '' |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
61 |
else: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
62 |
current = str(iteridx) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
63 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
64 |
for idx in xrange(NB_LINES): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
65 |
do_change_line = True |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
66 |
if oldcontent is not None and ALWAYS_CHANGE_LINES < idx: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
67 |
do_change_line = not ((idx - iteridx) % OTHER_CHANGES) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
68 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
69 |
if do_change_line: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
70 |
to_write = current + '\n' |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
71 |
current = nextcontent(current) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
72 |
else: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
73 |
to_write = oldcontent[idx] |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
74 |
yield to_write |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
75 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
76 |
def updatefile(filename, idx): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
77 |
"""update <filename> to be at appropriate content for iteration <idx>""" |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
78 |
existing = None |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
79 |
if idx is not None: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
80 |
with open(filename, 'rb') as old: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
81 |
existing = old.readlines() |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
82 |
with open(filename, 'wb') as target: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
83 |
for line in filecontent(idx, existing): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
84 |
target.write(line) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
85 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
86 |
def hg(command, *args): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
87 |
"""call a mercurial command with appropriate config and argument""" |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
88 |
env = os.environ.copy() |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
89 |
if 'CHGHG' in env: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
90 |
full_cmd = ['chg'] |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
91 |
else: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
92 |
full_cmd = ['hg'] |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
93 |
full_cmd.append('--quiet') |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
94 |
full_cmd.append(command) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
95 |
if command == 'commit': |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
96 |
# reproducible commit metadata |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
97 |
full_cmd.extend(['--date', '0 0', '--user', 'test']) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
98 |
elif command == 'merge': |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
99 |
# avoid conflicts by picking the local variant |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
100 |
full_cmd.extend(['--tool', ':merge-local']) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
101 |
full_cmd.extend(args) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
102 |
env['HGRCPATH'] = '' |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
103 |
return subprocess.check_call(full_cmd, env=env) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
104 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
105 |
def run(target): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
106 |
tmpdir = tempfile.mkdtemp(prefix='tmp-hg-test-big-file-bundle-') |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
107 |
try: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
108 |
os.chdir(tmpdir) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
109 |
hg('init') |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
110 |
updatefile(FILENAME, None) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
111 |
hg('commit', '--addremove', '--message', 'initial commit') |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
112 |
for idx in xrange(1, NB_CHANGESET + 1): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
113 |
if sys.stdout.isatty(): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
114 |
print("generating commit #%d/%d" % (idx, NB_CHANGESET)) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
115 |
if (idx % PERIOD_BRANCHING) == 0: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
116 |
move_back = MOVE_BACK_MIN + (idx % MOVE_BACK_RANGE) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
117 |
hg('update', ".~%d" % move_back) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
118 |
if (idx % PERIOD_MERGING) == 0: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
119 |
hg('merge', 'min(head())') |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
120 |
updatefile(FILENAME, idx) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
121 |
hg('commit', '--message', 'commit #%d' % idx) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
122 |
hg('bundle', '--all', target) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
123 |
with open(target, 'rb') as bundle: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
124 |
data = bundle.read() |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
125 |
digest = hashlib.md5(data).hexdigest() |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
126 |
with open(target + '.md5', 'wb') as md5file: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
127 |
md5file.write(digest + '\n') |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
128 |
if sys.stdout.isatty(): |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
129 |
print('bundle generated at "%s" md5: %s' % (target, digest)) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
130 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
131 |
finally: |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
132 |
shutil.rmtree(tmpdir) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
133 |
return 0 |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
134 |
|
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
135 |
if __name__ == '__main__': |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
136 |
orig = os.path.realpath(os.path.dirname(sys.argv[0])) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
137 |
target = os.path.join(orig, os.pardir, 'cache', BUNDLE_NAME) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
138 |
sys.exit(run(target)) |
4ca7a67c94c8
sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
139 |