-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
executable file
·119 lines (102 loc) · 2.59 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python
import os
import time
import threading
import sys
class Committer(object):
def __init__(self):
pass
def modifyFile(self, iteration):
fd = open('a.txt', 'r+')
fd.write(str(iteration))
fd.close()
def commit(self, iteration):
os.system('git add .')
os.system("git commit -m 'Commit corresponding to iteration ---%s---'" % str(iteration))
#os.system('rm .git/gc.log')
if iteration % 25000 == 0 and iteration != 0:
os.system('git prune')
self.push()
os.system('git push')
def push(self):
os.system('git push')
def push_upstream(self, iteration):
os.system('git push --set-upstream origin %s' % str(iteration))
def branch(self, iteration):
os.system('git branch %s' % str(iteration))
os.system('git add .')
os.system("git commit -m 'Commit corresponding to iteration %s'" % str(iteration))
self.push_upstream(iteration)
def checkout(self, iteration):
self.modifyFile(iteration)
os.system('git branch %s' % str(iteration))
os.system('git checkout %s' % str(iteration))
os.system('git add .')
os.system("git commit -m 'Commit corresponding to iteration %s'" % str(iteration))
self.push_upstream(iteration)
def tag(self, iteration):
os.system("git tag -a 1.0.%s -m 'Release of version 1.0.%s" % (iteration, iteration))
os.system('git push --tags')
def branch(i):
obj = Committer()
while True:
obj.modifyFile(i)
obj.checkout(i)
i = i + 1
def commit(i):
obj = Committer()
while True:
obj.modifyFile(i)
obj.commit(i)
i = i - 1
if i == 0:
sys.exit(1)
def tcommit(numthreads):
threads = list()
stringlist = list()
for i in range(numthreads):
stringlist.append('thread%s' % i)
# Now we have a list of files and a set of fil
for i in range(len(stringlist)):
t = threading.Thread(target=threadtcommit, args=[i])
threads.append(t)
t.start()
def threadtcommit(number):
obj = Committer()
i = 0
while True:
fd = open('thread%s.txt' % number, 'r+b') # thread0.txt... threadn.txt
fd.write('%s' % number)
fd.close()
obj.commit(i)
i = i + 1
def tag(number):
obj = Committer()
while True:
obj.tag(i)
i = i + 1
def release(number):
pass
def main():
script, action, goal = sys.argv
if goal == 'inf':
goal = 10000000
if action == 'branch':
branch(int(goal))
elif action == 'commit':
commit(int(goal))
elif action =='tcommit':
tcommit(int(8))
elif action == 'tag':
tag(int(goal))
else:
print('Invalid input. Choose between branch and commit, with an iteration number.')
sys.exit(1)
"""
threads = list()
t = threading.Thread(target=worker)
threads.append(t)
t.start()
"""
if __name__ == '__main__':
main()