From 5d030258b71c4c47d10259bf1e9daaad76076812 Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Mon, 6 Feb 2017 20:02:43 +0100 Subject: automatically undo changes incase ftp-release-list triggered updates fail to apply --- mgagnome | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mgagnome b/mgagnome index 2cfc16a..7346a69 100755 --- a/mgagnome +++ b/mgagnome @@ -647,7 +647,9 @@ class SpecFile(object): # try again patches = self.patches continue - sys.exit(1) + + print("ERROR: Problem removing merged patch: %s" % failed_patch, file=sys.stderr) + return False if cmd and len(cmd_output) > LOGLINES: print('+ %s' % cmd, file=sys.stdout) @@ -1495,13 +1497,22 @@ def cmd_package_new_version(options, parser): try: Downstream.co(package, cwd=root) except subprocess.CalledProcessError: + subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) sys.exit(1) # SpecFile class handles the actual version+release change # XXX - module should reflect upstream name, this gives it the package name s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package), module=package) print("%s => %s" % (s.version, options.version)) + + # XXX - Duplicate check as should not revert changes if specfile has already been changed + if not s.ensure_no_local_changes(options.force): + sys.exit(1) + if not s.update(options.version, force=options.force): + # XXX - hack to automatically revert changes when auto upgrading from ftp release list + if options.hexdigest is not None: + subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd, stdout=subprocess.DEVNULL) sys.exit(1) # Check hash, if given -- cgit v1.2.1