mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
Use EditBugReport instead of requestsync's edit_report. Drop that.
This commit is contained in:
parent
f06bc5b375
commit
d4fbed617f
@ -26,8 +26,7 @@ from ubuntutools.lp.lpapicache import Launchpad, Distribution
|
|||||||
from ubuntutools.lp.udtexceptions import PackageNotFoundException
|
from ubuntutools.lp.udtexceptions import PackageNotFoundException
|
||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.rdepends import query_rdepends, RDependsException
|
from ubuntutools.rdepends import query_rdepends, RDependsException
|
||||||
from ubuntutools.requestsync.common import edit_report
|
from ubuntutools.question import YesNoQuestion, EditBugReport
|
||||||
from ubuntutools.question import YesNoQuestion
|
|
||||||
|
|
||||||
|
|
||||||
class DestinationException(Exception):
|
class DestinationException(Exception):
|
||||||
@ -195,7 +194,9 @@ def request_backport(package_spph, source, destinations):
|
|||||||
+ [""]
|
+ [""]
|
||||||
) % subst)
|
) % subst)
|
||||||
|
|
||||||
subject, body = edit_report(subject, body, changes_required=True)
|
editor = EditBugReport(subject, body)
|
||||||
|
editor.edit()
|
||||||
|
subject, body = editor.get_report()
|
||||||
|
|
||||||
Logger.normal('The final report is:\nSummary: %s\nDescription:\n%s\n',
|
Logger.normal('The final report is:\nSummary: %s\nDescription:\n%s\n',
|
||||||
subject, body)
|
subject, body)
|
||||||
|
19
requestsync
19
requestsync
@ -36,8 +36,8 @@ from distro_info import UbuntuDistroInfo
|
|||||||
from ubuntutools.config import UDTConfig, ubu_email
|
from ubuntutools.config import UDTConfig, ubu_email
|
||||||
from ubuntutools.lp import udtexceptions
|
from ubuntutools.lp import udtexceptions
|
||||||
from ubuntutools.misc import require_utf8
|
from ubuntutools.misc import require_utf8
|
||||||
from ubuntutools.requestsync.common import (edit_report, get_debian_changelog,
|
from ubuntutools.question import confirmation_prompt, EditBugReport
|
||||||
raw_input_exit_on_ctrlc)
|
from ubuntutools.requestsync.common import get_debian_changelog
|
||||||
|
|
||||||
#
|
#
|
||||||
# entry point
|
# entry point
|
||||||
@ -205,8 +205,7 @@ def main():
|
|||||||
print ("'%s' doesn't exist in 'Ubuntu %s'.\n"
|
print ("'%s' doesn't exist in 'Ubuntu %s'.\n"
|
||||||
"Do you want to sync a new package?"
|
"Do you want to sync a new package?"
|
||||||
% (srcpkg, release))
|
% (srcpkg, release))
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue '
|
confirmation_prompt()
|
||||||
'or [Ctrl-C] to abort. ')
|
|
||||||
newsource = True
|
newsource = True
|
||||||
|
|
||||||
# Get the requested Debian source package
|
# Get the requested Debian source package
|
||||||
@ -283,8 +282,7 @@ def main():
|
|||||||
'>>> ENTER_EXPLANATION_HERE <<<\n\n')
|
'>>> ENTER_EXPLANATION_HERE <<<\n\n')
|
||||||
|
|
||||||
if need_interaction:
|
if need_interaction:
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue.'
|
confirmation_prompt()
|
||||||
'Press [Ctrl-C] to abort now. ')
|
|
||||||
|
|
||||||
base_version = force_base_version or ubuntu_version
|
base_version = force_base_version or ubuntu_version
|
||||||
|
|
||||||
@ -306,8 +304,13 @@ def main():
|
|||||||
changelog = "XXX FIXME: add changelog here XXX"
|
changelog = "XXX FIXME: add changelog here XXX"
|
||||||
report += changelog
|
report += changelog
|
||||||
|
|
||||||
(title, report) = edit_report(title, report,
|
editor = EditBugReport(title, report)
|
||||||
changes_required=need_interaction)
|
if need_interaction:
|
||||||
|
editor.edit()
|
||||||
|
else:
|
||||||
|
editor.optional_edit()
|
||||||
|
title, report = editor.get_report()
|
||||||
|
|
||||||
if 'XXX FIXME' in report:
|
if 'XXX FIXME' in report:
|
||||||
print >> sys.stderr, ("E: changelog boilerplate found in report, "
|
print >> sys.stderr, ("E: changelog boilerplate found in report, "
|
||||||
"please manually add changelog when using '-C'")
|
"please manually add changelog when using '-C'")
|
||||||
|
@ -22,22 +22,10 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
import re
|
|
||||||
import tempfile
|
|
||||||
from debian.changelog import Changelog
|
from debian.changelog import Changelog
|
||||||
|
|
||||||
from ubuntutools import subprocess
|
from ubuntutools import subprocess
|
||||||
|
|
||||||
def raw_input_exit_on_ctrlc(*args, **kwargs):
|
|
||||||
'''
|
|
||||||
A wrapper around raw_input() to exit with a normalized message on Control-C
|
|
||||||
'''
|
|
||||||
try:
|
|
||||||
return raw_input(*args, **kwargs)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print '\nAbort requested. No sync request filed.'
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def get_changelog(srcpkg, distro):
|
def get_changelog(srcpkg, distro):
|
||||||
'''
|
'''
|
||||||
Download and return a parsed changelog for srcpackage, from
|
Download and return a parsed changelog for srcpackage, from
|
||||||
@ -83,68 +71,3 @@ def get_debian_changelog(srcpkg, version):
|
|||||||
break
|
break
|
||||||
new_entries.append(unicode(block))
|
new_entries.append(unicode(block))
|
||||||
return u''.join(new_entries)
|
return u''.join(new_entries)
|
||||||
|
|
||||||
def edit_report(subject, body, changes_required = False):
|
|
||||||
'''
|
|
||||||
Ask if the user wants to edit a report (consisting of subject and body)
|
|
||||||
in sensible-editor.
|
|
||||||
|
|
||||||
If changes_required is True then the file has to be edited before we
|
|
||||||
can proceed.
|
|
||||||
|
|
||||||
Returns (new_subject, new_body).
|
|
||||||
'''
|
|
||||||
|
|
||||||
editing_finished = False
|
|
||||||
while not editing_finished:
|
|
||||||
report = 'Summary (one line):\n%s\n\nDescription:\n%s' % (subject, body)
|
|
||||||
|
|
||||||
if not changes_required:
|
|
||||||
print 'Currently the report looks as follows:\n%s' % report
|
|
||||||
while True:
|
|
||||||
val = raw_input_exit_on_ctrlc('Do you want to edit the report '
|
|
||||||
'[y/N]? ')
|
|
||||||
if val.lower() in ('y', 'yes'):
|
|
||||||
break
|
|
||||||
elif val.lower() in ('n', 'no', ''):
|
|
||||||
editing_finished = True
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print 'Invalid answer.'
|
|
||||||
|
|
||||||
if not editing_finished:
|
|
||||||
# Create tempfile and remember mtime
|
|
||||||
report_file = tempfile.NamedTemporaryFile(prefix='requestsync_')
|
|
||||||
report_file.write(report.encode('utf-8'))
|
|
||||||
report_file.flush()
|
|
||||||
mtime_before = os.stat(report_file.name).st_mtime
|
|
||||||
|
|
||||||
# Launch editor
|
|
||||||
try:
|
|
||||||
subprocess.check_call(['sensible-editor', report_file.name])
|
|
||||||
except subprocess.CalledProcessError, e:
|
|
||||||
print >> sys.stderr, ('Error calling sensible-editor: %s\n'
|
|
||||||
'Aborting.' % e)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Check if the tempfile has been changed
|
|
||||||
if changes_required:
|
|
||||||
if mtime_before == os.stat(report_file.name).st_mtime:
|
|
||||||
print ('The report has not been changed, but you have to '
|
|
||||||
'explain why the Ubuntu changes can be dropped.')
|
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to retry or '
|
|
||||||
'[Control-C] to abort. ')
|
|
||||||
else:
|
|
||||||
changes_required = False
|
|
||||||
|
|
||||||
report_file.seek(0)
|
|
||||||
report = report_file.read().decode('utf-8')
|
|
||||||
report_file.close()
|
|
||||||
|
|
||||||
# Undecorate report again
|
|
||||||
(subject, body) = report.split("\nDescription:\n", 1)
|
|
||||||
# Remove prefix and whitespace from subject
|
|
||||||
subject = re.sub('^Summary \(one line\):\s*', '', subject,
|
|
||||||
1).strip()
|
|
||||||
|
|
||||||
return (subject, body)
|
|
||||||
|
@ -26,9 +26,9 @@ import urllib2
|
|||||||
from debian.deb822 import Changes
|
from debian.deb822 import Changes
|
||||||
from distro_info import DebianDistroInfo
|
from distro_info import DebianDistroInfo
|
||||||
|
|
||||||
from ubuntutools.requestsync.common import raw_input_exit_on_ctrlc
|
|
||||||
from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam,
|
from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam,
|
||||||
DistributionSourcePackage)
|
DistributionSourcePackage)
|
||||||
|
from ubuntutools.question import confirmation_prompt
|
||||||
|
|
||||||
def get_debian_srcpkg(name, release):
|
def get_debian_srcpkg(name, release):
|
||||||
debian = Distribution('debian')
|
debian = Distribution('debian')
|
||||||
@ -60,7 +60,7 @@ Your sync request shall require an approval by a member of the appropriate
|
|||||||
sponsorship team, who shall be subscribed to this bug report.
|
sponsorship team, who shall be subscribed to this bug report.
|
||||||
This must be done before it can be processed by a member of the Ubuntu Archive
|
This must be done before it can be processed by a member of the Ubuntu Archive
|
||||||
team.'''
|
team.'''
|
||||||
raw_input_exit_on_ctrlc('If the above is correct please press [Enter] ')
|
confirmation_prompt()
|
||||||
|
|
||||||
return need_sponsor
|
return need_sponsor
|
||||||
|
|
||||||
@ -88,8 +88,7 @@ def check_existing_reports(srcpkg):
|
|||||||
'Please check the above URL to verify this before '
|
'Please check the above URL to verify this before '
|
||||||
'continuing.'
|
'continuing.'
|
||||||
% (bug.title, bug.web_link))
|
% (bug.title, bug.web_link))
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] '
|
confirmation_prompt()
|
||||||
'to abort. ')
|
|
||||||
|
|
||||||
def get_ubuntu_delta_changelog(srcpkg):
|
def get_ubuntu_delta_changelog(srcpkg):
|
||||||
'''
|
'''
|
||||||
@ -133,7 +132,7 @@ def post_bug(srcpkg, subscribe, status, bugtitle, bugtext):
|
|||||||
|
|
||||||
print ('The final report is:\nSummary: %s\nDescription:\n%s\n'
|
print ('The final report is:\nSummary: %s\nDescription:\n%s\n'
|
||||||
% (bugtitle, bugtext))
|
% (bugtitle, bugtext))
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
|
confirmation_prompt()
|
||||||
|
|
||||||
if srcpkg:
|
if srcpkg:
|
||||||
bug_target = DistributionSourcePackage(
|
bug_target = DistributionSourcePackage(
|
||||||
|
@ -30,8 +30,8 @@ from devscripts.logger import Logger
|
|||||||
from distro_info import DebianDistroInfo
|
from distro_info import DebianDistroInfo
|
||||||
|
|
||||||
from ubuntutools.archive import rmadison, FakeSPPH
|
from ubuntutools.archive import rmadison, FakeSPPH
|
||||||
from ubuntutools.requestsync.common import (get_changelog,
|
from ubuntutools.requestsync.common import get_changelog
|
||||||
raw_input_exit_on_ctrlc)
|
from ubuntutools.question import confirmation_prompt, YesNoQuestion
|
||||||
from ubuntutools import subprocess
|
from ubuntutools import subprocess
|
||||||
from ubuntutools.lp.udtexceptions import PackageNotFoundException
|
from ubuntutools.lp.udtexceptions import PackageNotFoundException
|
||||||
|
|
||||||
@ -71,17 +71,12 @@ def need_sponsorship(name, component, release):
|
|||||||
component.
|
component.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
while True:
|
val = YesNoQuestion().ask("Do you have upload permissions for the "
|
||||||
print ("Do you have upload permissions for the '%s' component "
|
"'%s' component or the package '%s' in "
|
||||||
"or the package '%s' in Ubuntu %s?"
|
"Ubuntu %s?\n"
|
||||||
% (component, name, release))
|
"If in doubt answer 'n'."
|
||||||
val = raw_input_exit_on_ctrlc("If in doubt answer 'n'. [y/N]? ")
|
% (component, name, release), 'no')
|
||||||
if val.lower() in ('y', 'yes'):
|
return val == 'no'
|
||||||
return False
|
|
||||||
elif val.lower() in ('n', 'no', ''):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
print 'Invalid answer'
|
|
||||||
|
|
||||||
def check_existing_reports(srcpkg):
|
def check_existing_reports(srcpkg):
|
||||||
'''
|
'''
|
||||||
@ -90,7 +85,7 @@ def check_existing_reports(srcpkg):
|
|||||||
print ('Please check on '
|
print ('Please check on '
|
||||||
'https://bugs.launchpad.net/ubuntu/+source/%s/+bugs\n'
|
'https://bugs.launchpad.net/ubuntu/+source/%s/+bugs\n'
|
||||||
'for duplicate sync requests before continuing.' % srcpkg)
|
'for duplicate sync requests before continuing.' % srcpkg)
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
|
confirmation_prompt()
|
||||||
|
|
||||||
def get_ubuntu_delta_changelog(srcpkg):
|
def get_ubuntu_delta_changelog(srcpkg):
|
||||||
'''
|
'''
|
||||||
@ -166,7 +161,7 @@ Content-Type: text/plain; charset=UTF-8
|
|||||||
%s''' % (myemailaddr, to, bugtitle, signed_report)
|
%s''' % (myemailaddr, to, bugtitle, signed_report)
|
||||||
|
|
||||||
print 'The final report is:\n%s' % mail
|
print 'The final report is:\n%s' % mail
|
||||||
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
|
confirmation_prompt()
|
||||||
|
|
||||||
# connect to the server
|
# connect to the server
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user