From acc048b4ee9aea7dc90395a091b0de5968047268 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 5 Aug 2020 20:14:38 +0100 Subject: 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. --- lorry | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lorry') diff --git a/lorry b/lorry index c2019d4..9a10045 100755 --- a/lorry +++ b/lorry @@ -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) -- cgit v1.2.1