Do not mess-up with commit message formatting when sending email
[stgit/dwhite.git] / perf / create_synthetic_repo.py
blob4d6ef6bcf5ded9f1c8b0655d53e1bfd114d59a43
1 next_mark = 1
2 def get_mark():
3 global next_mark
4 next_mark += 1
5 return (next_mark - 1)
7 def write_data(s):
8 print 'data %d' % len(s)
9 print s
11 def write_blob(s):
12 print 'blob'
13 m = get_mark()
14 print 'mark :%d' % m
15 write_data(s)
16 return m
18 def write_commit(branch, files, msg, parent = None):
19 print 'commit %s' % branch
20 m = get_mark()
21 print 'mark :%d' % m
22 auth = 'X Ample <xa@example.com> %d +0000' % (1000000000 + m)
23 print 'author %s' % auth
24 print 'committer %s' % auth
25 write_data(msg)
26 if parent != None:
27 print 'from :%d' % parent
28 for fn, fm in sorted(files.iteritems()):
29 print 'M 100644 :%d %s' % (fm, fn)
30 return m
32 def set_ref(ref, mark):
33 print 'reset %s' % ref
34 print 'from :%d' % mark
36 def stdblob(fn):
37 return ''.join('%d %s\n' % (x, fn) for x in xrange(10))
39 def iter_paths():
40 for i in xrange(32):
41 for j in xrange(32):
42 for k in xrange(32):
43 yield '%02d/%02d/%02d' % (i, j, k)
45 def setup():
46 def t(name): return 'refs/tags/%s' % name
47 files = dict((fn, write_blob(stdblob(fn))) for fn in iter_paths())
48 initial = write_commit(t('bomb-base'), files, 'Initial commit')
49 set_ref(t('bomb-top'), initial)
50 for fn in iter_paths():
51 write_commit(t('bomb-top'),
52 { fn: write_blob(stdblob(fn) + 'Last line\n') },
53 'Add last line to %s' % fn)
54 write_commit(t('add-file'), { 'woo-hoo.txt': write_blob('woo-hoo\n') },
55 'Add a new file', parent = initial)
56 files = dict((fn, write_blob('First line\n' + stdblob(fn)))
57 for fn in iter_paths())
58 write_commit(t('modify-all'), files, 'Add first line to all files',
59 parent = initial)
61 setup()