diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-08-05 20:14:38 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-08-05 20:35:03 +0100 |
commit | acc048b4ee9aea7dc90395a091b0de5968047268 (patch) | |
tree | d26085725bc7abd4284da66af500685c6231575f /lorry | |
parent | 235ed194d7a3094db7f9e2e4d93c5b1750f55e3a (diff) | |
download | lorry-acc048b4ee9aea7dc90395a091b0de5968047268.tar.gz |
lorry: Only log number of commits pruned from marks files
Logging each pruned commit can result in very long logs for some
repositories. This is a problem for Lorry Controller because job
status updates result in copying the entire log and not just the new
log lines.
There's not much value in listing all the commit hashes, so log the
number of commits instead. Update the test case accordingly.
Diffstat (limited to 'lorry')
-rwxr-xr-x | lorry | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -743,6 +743,7 @@ class Lorry(cliapp.Application): mark_re = re.compile(r':(\S+) ([0-9a-f]{40,})\n') marks_temp_fd, marks_temp_name = \ tempfile.mkstemp(dir=os.path.dirname(marks_name)) + n_pruned = 0 try: with open(marks_temp_fd, 'w') as marks_out, \ open(marks_name, 'r') as marks_in: @@ -759,11 +760,14 @@ class Lorry(cliapp.Application): elif match.group(2) in reachable: marks_out.write(line) else: - self.progress('%s: pruning unreachable commit %s' - % (marks_name, match.group(2))) + n_pruned += 1 # On success, replace marks file with temporary file os.rename(marks_temp_name, marks_name) + + if n_pruned: + self.progress('%s: pruned %d unreachable commit(s)' + % (marks_name, n_pruned)) except: # On failure, delete temporary file os.unlink(marks_temp_name) |