##// 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 32 class RepoMaintenanceView(RepoAppView):
33 33 def load_default_context(self):
34 34 c = self._get_local_tmpl_context()
35
36
37 35 return c
38 36
39 37 @LoginRequired()
@@ -51,25 +51,81 b' class GitGC(MaintenanceTask):'
51 51 output = []
52 52 instance = self.db_repo.scm_instance()
53 53
54 objects = 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)
54 objects_before = self._count_objects(instance)
60 55
61 out = 'executed git gc --aggressive'
62 if stderr:
63 out = ''.join(stderr.splitlines())
56 log.debug('GIT objects:%s', objects_before)
57 cmd = ['gc', '--aggressive']
58 stdout, stderr = instance.run_git_command(cmd, fail_on_stderr=False)
64 59
65 elif stdout:
66 out = ''.join(stdout.splitlines())
67
60 out = 'executed {}'.format(' '.join(cmd))
68 61 output.append(out)
69 62
70 objects = self._count_objects(instance)
71 log.debug('GIT objects:%s', objects)
72 output.append(objects)
63 out = ''
64 if stderr:
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 130 return '\n'.join(output)
75 131
@@ -98,7 +154,7 b' class RepoMaintenance(object):'
98 154 """
99 155 tasks = {
100 156 'hg': [HGVerify],
101 'git': [GitGC],
157 'git': [GitFSCK, GitGC, GitRepack],
102 158 'svn': [SVNVerify],
103 159 }
104 160
@@ -114,5 +170,6 b' class RepoMaintenance(object):'
114 170 def execute(self, db_repo):
115 171 executed_tasks = []
116 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 175 return executed_tasks
General Comments 0
You need to be logged in to leave comments. Login now