Configure init.defaultBranch in test repos
[stgit.git] / perf / create_synthetic_repo.py
blobbc64e586b26d738f826760ffd50701eef086f921
1 next_mark = 1
4 def get_mark():
5 global next_mark
6 next_mark += 1
7 return next_mark - 1
10 def write_data(s):
11 print('data %d' % len(s))
12 print(s)
15 def write_blob(s):
16 print('blob')
17 m = get_mark()
18 print('mark :%d' % m)
19 write_data(s)
20 return m
23 def write_commit(branch, files, msg, parent=None):
24 print('commit %s' % branch)
25 m = get_mark()
26 print('mark :%d' % m)
27 auth = 'X Ample <xa@example.com> %d +0000' % (1000000000 + m)
28 print('author %s' % auth)
29 print('committer %s' % auth)
30 write_data(msg)
31 if parent is not None:
32 print('from :%d' % parent)
33 for fn, fm in sorted(files.items()):
34 print('M 100644 :%d %s' % (fm, fn))
35 return m
38 def set_ref(ref, mark):
39 print('reset %s' % ref)
40 print('from :%d' % mark)
43 def stdblob(fn):
44 return ''.join('%d %s\n' % (x, fn) for x in range(10))
47 def iter_paths():
48 for i in range(32):
49 for j in range(32):
50 for k in range(32):
51 yield '%02d/%02d/%02d' % (i, j, k)
54 def setup():
55 def t(name):
56 return 'refs/tags/%s' % name
58 files = {fn: write_blob(stdblob(fn)) for fn in iter_paths()}
59 initial = write_commit(t('bomb-base'), files, 'Initial commit')
60 set_ref(t('bomb-top'), initial)
61 for fn in iter_paths():
62 write_commit(
63 t('bomb-top'),
64 {fn: write_blob(stdblob(fn) + 'Last line\n')},
65 'Add last line to %s' % fn,
67 write_commit(
68 t('add-file'),
69 {'woo-hoo.txt': write_blob('woo-hoo\n')},
70 'Add a new file',
71 parent=initial,
73 files = dict((fn, write_blob('First line\n' + stdblob(fn))) for fn in iter_paths())
74 write_commit(t('modify-all'), files, 'Add first line to all files', parent=initial)
77 setup()