From bbfbfd8956a203cb86d19885ba967e3e44c16d41 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Wed, 21 Dec 2011 22:09:53 +0100 Subject: [PATCH] Allow user to override sanity checks (LP: #896733). --- debian/changelog | 1 + ubuntutools/sponsor_patch/question.py | 19 ++++++++++++++++++- ubuntutools/sponsor_patch/source_package.py | 16 +++++++--------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index f29d95e..eaa2cce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ ubuntu-dev-tools (0.138) UNRELEASED; urgency=low - Use syncpackage instead of subscribing ubuntu-archive for sync requests, because syncpackage supports sponsorship now. - Check if the sponsored bug is marked as duplicate (LP: #896733). + - Allow user to override sanity checks (LP: #896733). [ Stefano Rivera ] * Correct reference to qemu-user-static in pbuilder-dist.1 (Closes: #651999) diff --git a/ubuntutools/sponsor_patch/question.py b/ubuntutools/sponsor_patch/question.py index a82c815..363153f 100644 --- a/ubuntutools/sponsor_patch/question.py +++ b/ubuntutools/sponsor_patch/question.py @@ -17,14 +17,31 @@ import sys -from ubuntutools.question import YesNoQuestion +from ubuntutools.question import Question, YesNoQuestion + +def ask_for_ignoring_or_fixing(): + """Ask the user to resolve an issue manually or ignore it. + + Returns false if the user want to fix the issue and returns true if the user + want to ignore the issue. + """ + + question = Question(["yes", "ignore", "no"]) + answer = question.ask("Do you want to resolve this issue manually", "yes") + if answer == "no": + user_abort() + return answer == "ignore" def ask_for_manual_fixing(): + """Ask the user to resolve an issue manually.""" + answer = YesNoQuestion().ask("Do you want to resolve this issue manually", "yes") if answer == "no": user_abort() def user_abort(): + """Print abort and quit the program.""" + print "User abort." sys.exit(2) diff --git a/ubuntutools/sponsor_patch/source_package.py b/ubuntutools/sponsor_patch/source_package.py index 6809669..a6cc4d4 100644 --- a/ubuntutools/sponsor_patch/source_package.py +++ b/ubuntutools/sponsor_patch/source_package.py @@ -28,7 +28,9 @@ from ubuntutools import subprocess from ubuntutools.harvest import Harvest from ubuntutools.question import Question, YesNoQuestion -from ubuntutools.sponsor_patch.question import ask_for_manual_fixing, user_abort +from ubuntutools.sponsor_patch.question import (ask_for_ignoring_or_fixing, + ask_for_manual_fixing, + user_abort) def _get_series(launchpad): """Returns a tuple with the development and list of supported series.""" @@ -270,16 +272,14 @@ class SourcePackage(object): Logger.error(("%s is not an allowed series. It needs to be one " "of %s.") % (self._changelog.distributions, ", ".join(allowed))) - ask_for_manual_fixing() - return False + return ask_for_ignoring_or_fixing() elif upload and upload.startswith("ppa/"): allowed = supported_series + [devel_series] if self._changelog.distributions not in allowed: Logger.error(("%s is not an allowed series. It needs to be one " "of %s.") % (self._changelog.distributions, ", ".join(allowed))) - ask_for_manual_fixing() - return False + return ask_for_ignoring_or_fixing() return True def check_version(self, previous_version): @@ -292,8 +292,7 @@ class SourcePackage(object): if self._version <= previous_version: Logger.error("The version %s is not greater than the already " "available %s.", self._version, previous_version) - ask_for_manual_fixing() - return False + return ask_for_ignoring_or_fixing() return True def check_sync_request_version(self, bug_number, task): @@ -363,8 +362,7 @@ class SourcePackage(object): if lp_bug.id not in fixed_bugs: Logger.error("Launchpad bug #%i is not closed by new version." % \ (lp_bug.id)) - ask_for_manual_fixing() - return False + return ask_for_ignoring_or_fixing() return True def _print_logs(self):