Show More
@@ -44,6 +44,28 ALWAYS_CHANGE_LINES = 500 | |||||
44 | OTHER_CHANGES = 300 |
|
44 | OTHER_CHANGES = 300 | |
45 |
|
45 | |||
46 |
|
46 | |||
|
47 | def build_graph(): | |||
|
48 | heads = {0} | |||
|
49 | graph = {0: (None, None)} | |||
|
50 | for idx in range(1, NB_CHANGESET + 1): | |||
|
51 | p, _ = parents = [idx - 1, None] | |||
|
52 | if (idx % PERIOD_BRANCHING) == 0: | |||
|
53 | back = MOVE_BACK_MIN + (idx % MOVE_BACK_RANGE) | |||
|
54 | for _ in range(back): | |||
|
55 | p = graph.get(p, (p,))[0] | |||
|
56 | parents[0] = p | |||
|
57 | if (idx % PERIOD_MERGING) == 0: | |||
|
58 | parents[1] = min(heads) | |||
|
59 | for p in parents: | |||
|
60 | heads.discard(p) | |||
|
61 | heads.add(idx) | |||
|
62 | graph[idx] = tuple(parents) | |||
|
63 | return graph | |||
|
64 | ||||
|
65 | ||||
|
66 | GRAPH = build_graph() | |||
|
67 | ||||
|
68 | ||||
47 | def nextcontent(previous_content): |
|
69 | def nextcontent(previous_content): | |
48 | """utility to produce a new file content from the previous one""" |
|
70 | """utility to produce a new file content from the previous one""" | |
49 | return hashlib.md5(previous_content).hexdigest().encode('ascii') |
|
71 | return hashlib.md5(previous_content).hexdigest().encode('ascii') | |
@@ -56,7 +78,7 def filecontent(iteridx, oldcontent): | |||||
56 | content""" |
|
78 | content""" | |
57 |
|
79 | |||
58 | # initial call |
|
80 | # initial call | |
59 |
if iteridx |
|
81 | if iteridx == 0: | |
60 | current = b'' |
|
82 | current = b'' | |
61 | else: |
|
83 | else: | |
62 | current = b"%d" % iteridx |
|
84 | current = b"%d" % iteridx | |
@@ -77,7 +99,7 def filecontent(iteridx, oldcontent): | |||||
77 | def updatefile(filename, idx): |
|
99 | def updatefile(filename, idx): | |
78 | """update <filename> to be at appropriate content for iteration <idx>""" |
|
100 | """update <filename> to be at appropriate content for iteration <idx>""" | |
79 | existing = None |
|
101 | existing = None | |
80 |
if idx |
|
102 | if idx > 0: | |
81 | with open(filename, 'rb') as old: |
|
103 | with open(filename, 'rb') as old: | |
82 | existing = old.readlines() |
|
104 | existing = old.readlines() | |
83 | with open(filename, 'wb') as target: |
|
105 | with open(filename, 'wb') as target: | |
@@ -110,18 +132,19 def run(target): | |||||
110 | try: |
|
132 | try: | |
111 | os.chdir(tmpdir) |
|
133 | os.chdir(tmpdir) | |
112 | hg('init') |
|
134 | hg('init') | |
113 | updatefile(FILENAME, None) |
|
135 | for idx, (p1, p2) in GRAPH.items(): | |
114 | hg('commit', '--addremove', '--message', 'initial commit') |
|
|||
115 | for idx in range(1, NB_CHANGESET + 1): |
|
|||
116 | if sys.stdout.isatty(): |
|
136 | if sys.stdout.isatty(): | |
117 | print("generating commit #%d/%d" % (idx, NB_CHANGESET)) |
|
137 | print("generating commit #%d/%d" % (idx, NB_CHANGESET)) | |
118 | if (idx % PERIOD_BRANCHING) == 0: |
|
138 | if p1 is not None and p1 != idx - 1: | |
119 | move_back = MOVE_BACK_MIN + (idx % MOVE_BACK_RANGE) |
|
139 | hg('update', "%d" % p1) | |
120 | hg('update', "max(0+.~%d)" % move_back) |
|
140 | if p2 is not None: | |
121 | if (idx % PERIOD_MERGING) == 0: |
|
141 | hg('merge', "%d" % p2) | |
122 | hg('merge', 'min(head())') |
|
|||
123 | updatefile(FILENAME, idx) |
|
142 | updatefile(FILENAME, idx) | |
124 | hg('commit', '--message', 'commit #%d' % idx) |
|
143 | if idx == 0: | |
|
144 | hg('add', FILENAME) | |||
|
145 | hg('commit', '--addremove', '--message', 'initial commit') | |||
|
146 | else: | |||
|
147 | hg('commit', '--message', 'commit #%d' % idx) | |||
125 | hg('bundle', '--all', target, '--config', 'devel.bundle.delta=p1') |
|
148 | hg('bundle', '--all', target, '--config', 'devel.bundle.delta=p1') | |
126 | with open(target, 'rb') as bundle: |
|
149 | with open(target, 'rb') as bundle: | |
127 | data = bundle.read() |
|
150 | data = bundle.read() |
General Comments 0
You need to be logged in to leave comments.
Login now