diff --git a/debian/changelog b/debian/changelog index 40da23e..e358834 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,18 @@ ubuntu-dev-tools (0.26) UNRELEASED; urgency=low + [ Stephan Hermann ] * pbuild-dist: fixed a bug with the *sudo call. changed from $SUDOREPLACE "pbuilder" to $SUDOREPLACE -- pbuilder ... - -- Stephan Hermann Wed, 23 Jan 2008 20:21:42 +0100 + [ Daniel Hahler ] + * requestsync: + * If interaction is required (for an explanation to drop the Ubuntu + changes), edit the report in the sensible-editor. + When interaction is not required, ask the user if she wants to edit. + (LP: #190351) + * Exit, if versions in Ubuntu and Debian are the same already. + + -- Daniel Hahler Sat, 09 Feb 2008 02:23:44 +0100 ubuntu-dev-tools (0.25) hardy; urgency=low diff --git a/requestsync b/requestsync index 02d93a1..0d9c5d0 100755 --- a/requestsync +++ b/requestsync @@ -83,6 +83,14 @@ def debian_component(sourcepkg): component = raw_comp[1].strip() return component +def wait_for_enter_or_exit(): + """Helper function to wait for ENTER and catch Control-C for abortion.""" + try: + raw_input() + except KeyboardInterrupt: + print 'Abort requested. No sync request filed.' + sys.exit(1) + def usage(): print '''Usage: requestsync [-h|-n|-s|-k |--lp] [basever] @@ -138,12 +146,8 @@ def mail_bug(source_package, subscribe, status, bugtitle, bugtext, keyid = None) print mail - print 'Press enter to file this bug, Control-C to abort.' - try: - raw_input() - except KeyboardInterrupt: - print 'Abort requested. No sync request filed.' - sys.exit(1) + print 'Press ENTER to file this bug, Control-C to abort.' + wait_for_enter_or_exit() # get server address mailserver = os.getenv('DEBSMTP') @@ -211,12 +215,8 @@ def post_bug(source_package, subscibe, status, bugtitle, bugtext): print 'Summary:\n%s\n\nDescription:\n%s' % (bugtitle, bugtext) - print 'Press enter to file this bug, Control-C to abort.' - try: - raw_input() - except KeyboardInterrupt: - print 'Abort requested. No sync request filed.' - sys.exit(1) + print 'Press ENTER to file this bug, Control-C to abort.' + wait_for_enter_or_exit() # Create bug Bug = launchpadbugs.connector.ConnectBug() @@ -241,6 +241,8 @@ if __name__ == '__main__': sponsorship = False keyid = None use_lp_bugs = False + need_interaction = False + edit_report = False try: opts, args = getopt.gnu_getopt(sys.argv[1:], 'hnsk:', ('lp')) @@ -281,24 +283,21 @@ if __name__ == '__main__': else: subscribe = 'ubuntu-universe-sponsors' - report = '''Please sync %s %s (%s) from Debian unstable (%s). -''' % (srcpkg, deb_version, component, debiancomponent) + report = 'Please sync %s %s (%s) from Debian unstable (%s).\n\n' % (srcpkg, deb_version, component, debiancomponent) title = report[:-2] base_ver = cur_ver uidx = base_ver.find('ubuntu') if uidx > 0: base_ver = base_ver[:uidx] + need_interaction = True - print 'Explanation of the Ubuntu delta and why it can be dropped:' - explanation = '\nExplanation of the Ubuntu delta and why it can be dropped:\n' - while (explanation[-2:] != '\n\n'): - try: - explanation += raw_input() + '\n' - except KeyboardInterrupt: - print 'Abort requested. No sync request filed.' - sys.exit(1) - report += explanation + print 'There have been changes made in Ubuntu.' + print 'Please edit the report and give an explanation.' + print 'Press ENTER to start your editor. Press Control-C to abort now. Not saving the report file will abort the request, too.' + wait_for_enter_or_exit() + report += '\nExplanation of the Ubuntu delta and why it can be dropped:\n\n' + \ + 'ENTER_EXPLANATION_HERE\n\n' uidx = base_ver.find('build') if uidx > 0: @@ -310,6 +309,39 @@ if __name__ == '__main__': report += 'Changelog since current %s version %s:\n\n' % (release, cur_ver) report += debian_changelog(srcpkg, debiancomponent, base_ver) + '\n' + # Do we want to edit the report? + if need_interaction: + edit_report = True + else: + val = raw_input('Do you want to edit the report [y/N]? ') + if val.lower() in ('y', 'yes'): + edit_report = True + + if edit_report: + # Create tempfile and remember mtime + import tempfile + report_file = tempfile.NamedTemporaryFile( prefix='requestsync_' ) + report_file.file.write(report) + report_file.file.flush() + mtime_before = os.stat( report_file.name ).st_mtime + + # Launch editor + try: + editor = subprocess.check_call( ['sensible-editor', report_file.name] ) + except CalledProcessError, e: + print >>sys.stderr, 'sensible-editor returned with %s: %s\nAborting.' % (editor.returncode, e) + sys.exit(1) + + # Check if the tempfile has been changed + report_file_info = os.stat( report_file.name ) + if mtime_before == os.stat( report_file.name ).st_mtime: + print >>sys.stderr, 'The temporary file %s has not been changed. Aborting. [Press ENTER]' % (report_file.name,) + raw_input() + sys.exit(1) + report_file.file.seek(0) + report = report_file.file.read() + report_file.file.close() + # mail or post the sync request srcpkg = not newsource and srcpkg or None if use_lp_bugs: