diff options
-rwxr-xr-x | batch-stabilize.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/batch-stabilize.py b/batch-stabilize.py index db869bb..877e5dc 100755 --- a/batch-stabilize.py +++ b/batch-stabilize.py @@ -6,6 +6,7 @@ import glob import itertools import optparse import os +import pickle import re import shutil import subprocess @@ -37,6 +38,10 @@ def run_command(args, cwd, log): finally: log.flush() +def save_state(done_bugs): + with open('batch-stabilize.state', 'w') as state_file: + pickle.dump(done_bugs, state_file) + class MyBugz(bugz.bugzilla.Bugz): def get_input(self, prompt): return raw_input(prompt) @@ -58,6 +63,11 @@ if __name__ == "__main__": if args: parser.error("unrecognized command-line args") + done_bugs = [] + if os.path.exists('batch-stabilize.state'): + with open('batch-stabilize.state', 'r') as state_file: + done_bugs = pickle.load(state_file) + url = 'https://bugs.gentoo.org' print 'You may be prompted for your Gentoo Bugzilla username and password (%s).' % url bugzilla = MyBugz(url) @@ -110,6 +120,10 @@ if __name__ == "__main__": with open('batch-stabilize.log', 'a') as log_file: for bug_id in stabilization_dict: + if bug_id in done_bugs: + print_and_log('Skipping bug #%d because it is marked as done.' % bug_id, log_file) + continue + print_and_log('Working on bug %d...' % bug_id, log_file) commit_message = "%s stable wrt bug #%d" % (options.arch, bug_id) for (pn, ebuild_name) in stabilization_dict[bug_id]: @@ -140,10 +154,11 @@ if __name__ == "__main__": # It seems that cvs diff returns 1 if there are differences. if return_code == 0 and not output: print_and_log('Seems already keyworded, skipping.', log_file) + done_bugs.append(bug_id) + save_state(done_bugs) continue if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0: - print '!!! echangelog failed' - sys.exit(1) + print_and_log('echangelog failed, maybe just the Manifest is being updated; continuing', log_file) if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0: print '!!! repoman manifest failed' sys.exit(1) @@ -162,6 +177,8 @@ if __name__ == "__main__": if not has_my_arch: print_and_log('Seems that bugzilla has already been updated.', log_file) + done_bugs.append(bug_id) + save_state(done_bugs) continue print_and_log('Posting automated reply in bugzilla...', log_file) @@ -181,3 +198,9 @@ if __name__ == "__main__": status='RESOLVED', resolution='FIXED') print_and_log('Succesfully updated bug %d and closed it.' % bug_id, log_file) + + done_bugs.append(bug_id) + save_state(done_bugs) + + if os.path.exists('batch-stabilize.state'): + os.remove('batch-stabilize.state') |