annotate tests/artifacts/scripts/generate-churning-bundle.py @ 52439:83f87912c5e0

test-sparse-revlog: commit the repo content in a single in-mem transaction I don't like to use the internal API like that, but it make the whole generation twice faster on my machine and suitable for always run during tests. However it also mean the `--pure` version of the test will run this with the pure source code and be unbearably slow. However if another flavor generated the file, pure will be able to simply reuse it, so it seems fine.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 04 Dec 2024 05:29:28 +0100
parents 9feb175c028d
children 24c3b3dbab08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45830
c102b704edb5 global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43110
diff changeset
1 #!/usr/bin/env python3
39491
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
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
19 import hashlib
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
20 import os
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
21 import shutil
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
22 import subprocess
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
23 import sys
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
24 import tempfile
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
25
52439
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
26 import mercurial.context
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
27 import mercurial.hg
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
28 import mercurial.ui
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
29
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
30 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
31
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
32 # 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
33 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
34 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
35 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
36 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
37 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
38
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
39 # 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
40 #
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
41 # 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
42 # and set of other lines changes too.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
43 FILENAME = 'SPARSE-REVLOG-TEST-FILE'
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
44 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
45 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
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
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
48
52437
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
49 def build_graph():
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
50 heads = {0}
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
51 graph = {0: (None, None)}
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
52 for idx in range(1, NB_CHANGESET + 1):
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
53 p, _ = parents = [idx - 1, None]
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
54 if (idx % PERIOD_BRANCHING) == 0:
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
55 back = MOVE_BACK_MIN + (idx % MOVE_BACK_RANGE)
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
56 for _ in range(back):
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
57 p = graph.get(p, (p,))[0]
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
58 parents[0] = p
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
59 if (idx % PERIOD_MERGING) == 0:
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
60 parents[1] = min(heads)
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
61 for p in parents:
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
62 heads.discard(p)
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
63 heads.add(idx)
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
64 graph[idx] = tuple(parents)
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
65 return graph
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
66
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
67
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
68 GRAPH = build_graph()
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
69
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
70
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
71 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
72 """utility to produce a new file content from the previous one"""
51274
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
73 return hashlib.md5(previous_content).hexdigest().encode('ascii')
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
74
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
75
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
76 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
77 """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
78
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
79 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
80 content"""
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
81
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
82 # initial call
52437
e26b738430a1 test-sparse-revlog: pre-generate the graph structure in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52436
diff changeset
83 if iteridx == 0:
51274
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
84 current = b''
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
85 else:
51274
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
86 current = b"%d" % iteridx
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
87
43110
1fcf79e9943a tests: use range() in generate-churning-module.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43076
diff changeset
88 for idx in range(NB_LINES):
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
89 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
90 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
91 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
92
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
93 if do_change_line:
51274
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
94 to_write = current + b'\n'
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
95 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
96 else:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
97 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
98 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
99
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
100
52438
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
101 def merge_content(base, left, right):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
102 """merge two file content to produce a new one
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
103
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
104 use unambiguous update on each side when possible, and produce a new line
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
105 whenever a merge is needed. Similar to what the manifest would do.
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
106 """
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
107 for old, left, right in zip(base, left, right):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
108 if old == left and old == right:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
109 yield old
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
110 elif old == left and old != right:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
111 yield right
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
112 elif old != left and old == right:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
113 yield left
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
114 else:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
115 yield nextcontent(left + right)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
116
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
117
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
118 def ancestors(graph, rev):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
119 """return the set of ancestors of revision <rev>"""
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
120 to_proceed = {rev}
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
121 seen = set(to_proceed)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
122 while to_proceed:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
123 current = to_proceed.pop()
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
124 for p in graph[current]:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
125 if p is None:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
126 continue
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
127 if p in seen:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
128 continue
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
129 to_proceed.add(p)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
130 seen.add(p)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
131 return seen
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
132
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
133
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
134 def gca(graph, left, right):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
135 """find the greater common ancestors of left and right
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
136
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
137 Note that the algorithm is stupid and N² when run on all merge, however
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
138 this should not be a too much issue given the current scale.
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
139 """
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
140 return max(ancestors(graph, left) & ancestors(graph, right))
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
141
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
142
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
143 def make_one_content_fn(idx, base, left, right):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
144 """build a function that build the content on demand
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
145
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
146 The dependency are kept are reference to make sure they are not
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
147 garbage-collected until we use them. Once we computed the current content,
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
148 we make sure to drop their reference to allow them to be garbage collected.
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
149 """
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
150
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
151 def content_fn(idx=idx, base=base, left=left, right=right):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
152 if left is None:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
153 new = filecontent(idx, None)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
154 elif base is None:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
155 new = filecontent(idx, left())
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
156 else:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
157 merged = merge_content(base(), left(), right())
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
158 new = filecontent(idx, list(merged))
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
159 return list(new)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
160
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
161 del idx
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
162 del base
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
163 del left
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
164 del right
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
165
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
166 value = None
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
167 cf = [content_fn]
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
168 del content_fn
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
169
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
170 def final_fn():
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
171 nonlocal value
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
172 if value is None:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
173 content_fn = cf.pop()
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
174 value = list(content_fn())
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
175 del content_fn
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
176 return value
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
177
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
178 return final_fn
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
179
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
180
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
181 def build_content_graph(graph):
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
182 """produce file content for all revision
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
183
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
184 The content will be generated on demande and cached. Cleanup the
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
185 dictionnary are you use it to reduce memory usage.
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
186 """
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
187 content = {}
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
188 for idx, (p1, p2) in graph.items():
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
189 base = left = right = None
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
190 if p1 is not None:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
191 left = content[p1]
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
192 if p2 is not None:
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
193 right = content[p2]
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
194 base_rev = gca(graph, p1, p2)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
195 base = content[base_rev]
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
196 content[idx] = make_one_content_fn(idx, base, left, right)
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
197 return content
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
198
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
199
9feb175c028d test-sparse-revlog: build the content directly in memory
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52437
diff changeset
200 CONTENT = build_content_graph(GRAPH)
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
201
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
202
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
203 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
204 """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
205 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
206 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
207 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
208 else:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
209 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
210 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
211 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
212 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
213 # 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
214 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
215 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
216 # 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
217 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
218 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
219 env['HGRCPATH'] = ''
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
220 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
221
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
222
52439
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
223 def write_repo(path):
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
224 """write repository content in memory"""
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
225 repo = mercurial.hg.repository(
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
226 mercurial.ui.ui.load(),
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
227 path=path.encode('utf-8'),
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
228 )
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
229 nodemap = {None: repo.nodeconstants.nullid}
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
230 with repo.lock(), repo.transaction(b'bundle-generation'):
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
231 for idx, (p1, p2) in GRAPH.items():
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
232 if sys.stdout.isatty():
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
233 print("generating commit #%d/%d" % (idx, NB_CHANGESET))
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
234
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
235 file_fn = lambda repo, memctx, path: mercurial.context.memfilectx(
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
236 repo,
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
237 memctx,
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
238 path,
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
239 data=b''.join(CONTENT.pop(idx)()),
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
240 )
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
241
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
242 mc = mercurial.context.memctx(
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
243 repo,
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
244 (nodemap[p1], nodemap[p2]),
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
245 b'commit #%d' % idx if idx else b'initial commit',
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
246 [FILENAME.encode('ascii')],
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
247 file_fn,
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
248 user=b"test",
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
249 date=(0, 0),
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
250 )
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
251 nodemap[idx] = repo.commitctx(mc)
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
252
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
253
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
254 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
255 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
256 try:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
257 os.chdir(tmpdir)
52439
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
258 hg(
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
259 'init',
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
260 '--config',
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
261 'format.maxchainlen=%d' % NB_CHANGESET,
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
262 )
83f87912c5e0 test-sparse-revlog: commit the repo content in a single in-mem transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52438
diff changeset
263 write_repo(tmpdir)
41795
b59676077654 test: stabilize bundle generation for test-sparse-revlog.t
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39491
diff changeset
264 hg('bundle', '--all', target, '--config', 'devel.bundle.delta=p1')
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
265 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
266 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
267 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
268 with open(target + '.md5', 'wb') as md5file:
51274
d7155949535e generate-churning-bundle: fix script for python3
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
269 md5file.write(digest.encode('ascii') + b'\n')
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
270 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
271 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
272
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
273 finally:
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
274 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
275 return 0
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
276
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41800
diff changeset
277
39491
4ca7a67c94c8 sparse-revlog: add a test checking revlog deltas for a churning file
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
278 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
279 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
280 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
281 sys.exit(run(target))