diff options
-rwxr-xr-x | batch-stabilize.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/batch-stabilize.py b/batch-stabilize.py index e2c4976..db869bb 100755 --- a/batch-stabilize.py +++ b/batch-stabilize.py @@ -2,10 +2,12 @@ # Copyright 2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import glob import itertools import optparse import os import re +import shutil import subprocess import sys @@ -23,7 +25,10 @@ def print_and_log(message, log): def run_command(args, cwd, log): try: - log.write("Running %r in %s...\n" % (args, cwd)) + message = "Running %r in %s...\n" % (args, cwd) + sys.stdout.write(message) + log.write(message) + cmd = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = cmd.communicate()[0] log.write("Finished with exit code %d\n" % cmd.returncode) @@ -111,13 +116,15 @@ if __name__ == "__main__": cvs_path = os.path.join(options.repo, pn) print_and_log('Working in %s...' % cvs_path, log_file) - # Remove existing changelog to avoid adding duplicate entries. - try: - os.remove(os.path.join(cvs_path, 'ChangeLog')) - except OSError: - pass + # Remove whole directory to prevent problems with conflicts. + if os.path.exists(cvs_path): + try: + shutil.rmtree(cvs_path) + except OSError: + print '!!! rmtree %s failed' % cvs_path + sys.exit(1) - if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0: + if run_command(["cvs", "up", pn], options.repo, log_file)[0] != 0: print '!!! cvs up failed' sys.exit(1) if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0: |