##// END OF EJS Templates
maintainance: add repack and fsck for git maintainance execution list.
marcink -
r3009:ae9279cb default
parent child Browse files
Show More
@@ -32,8 +32,6 b' log = logging.getLogger(__name__)'
32 class RepoMaintenanceView(RepoAppView):
32 class RepoMaintenanceView(RepoAppView):
33 def load_default_context(self):
33 def load_default_context(self):
34 c = self._get_local_tmpl_context()
34 c = self._get_local_tmpl_context()
35
36
37 return c
35 return c
38
36
39 @LoginRequired()
37 @LoginRequired()
@@ -51,25 +51,81 b' class GitGC(MaintenanceTask):'
51 output = []
51 output = []
52 instance = self.db_repo.scm_instance()
52 instance = self.db_repo.scm_instance()
53
53
54 objects = self._count_objects(instance)
54 objects_before = self._count_objects(instance)
55 output.append(objects)
56 log.debug('GIT objects:%s', objects)
57
58 stdout, stderr = instance.run_git_command(
59 ['gc', '--aggressive'], fail_on_stderr=False)
60
55
61 out = 'executed git gc --aggressive'
56 log.debug('GIT objects:%s', objects_before)
62 if stderr:
57 cmd = ['gc', '--aggressive']
63 out = ''.join(stderr.splitlines())
58 stdout, stderr = instance.run_git_command(cmd, fail_on_stderr=False)
64
59
65 elif stdout:
60 out = 'executed {}'.format(' '.join(cmd))
66 out = ''.join(stdout.splitlines())
67
68 output.append(out)
61 output.append(out)
69
62
70 objects = self._count_objects(instance)
63 out = ''
71 log.debug('GIT objects:%s', objects)
64 if stderr:
72 output.append(objects)
65 out += ''.join(stderr.splitlines())
66
67 if stdout:
68 out += ''.join(stdout.splitlines())
69
70 if out:
71 output.append(out)
72
73 objects_after = self._count_objects(instance)
74 log.debug('GIT objects:%s', objects_after)
75 output.append('objects before :' + objects_before)
76 output.append('objects after :' + objects_after)
77
78 return '\n'.join(output)
79
80
81 class GitFSCK(MaintenanceTask):
82 human_name = 'GIT FSCK'
83
84 def run(self):
85 output = []
86 instance = self.db_repo.scm_instance()
87
88 cmd = ['fsck', '--full']
89 stdout, stderr = instance.run_git_command(cmd, fail_on_stderr=False)
90
91 out = 'executed {}'.format(' '.join(cmd))
92 output.append(out)
93
94 out = ''
95 if stderr:
96 out += ''.join(stderr.splitlines())
97
98 if stdout:
99 out += ''.join(stdout.splitlines())
100
101 if out:
102 output.append(out)
103
104 return '\n'.join(output)
105
106
107 class GitRepack(MaintenanceTask):
108 human_name = 'GIT Repack'
109
110 def run(self):
111 output = []
112 instance = self.db_repo.scm_instance()
113 cmd = ['repack', '-a', '-d',
114 '--window-memory', '10m', '--max-pack-size', '100m']
115 stdout, stderr = instance.run_git_command(cmd, fail_on_stderr=False)
116
117 out = 'executed {}'.format(' '.join(cmd))
118 output.append(out)
119 out = ''
120
121 if stderr:
122 out += ''.join(stderr.splitlines())
123
124 if stdout:
125 out += ''.join(stdout.splitlines())
126
127 if out:
128 output.append(out)
73
129
74 return '\n'.join(output)
130 return '\n'.join(output)
75
131
@@ -98,7 +154,7 b' class RepoMaintenance(object):'
98 """
154 """
99 tasks = {
155 tasks = {
100 'hg': [HGVerify],
156 'hg': [HGVerify],
101 'git': [GitGC],
157 'git': [GitFSCK, GitGC, GitRepack],
102 'svn': [SVNVerify],
158 'svn': [SVNVerify],
103 }
159 }
104
160
@@ -114,5 +170,6 b' class RepoMaintenance(object):'
114 def execute(self, db_repo):
170 def execute(self, db_repo):
115 executed_tasks = []
171 executed_tasks = []
116 for task in self.tasks[db_repo.repo_type]:
172 for task in self.tasks[db_repo.repo_type]:
117 executed_tasks.append(task(db_repo).run())
173 output = task.human_name + ':\n' + task(db_repo).run() + '\n--\n'
174 executed_tasks.append(output)
118 return executed_tasks
175 return executed_tasks
General Comments 0
You need to be logged in to leave comments. Login now