mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
New script, lp-set-dup, allows marking a bug and all its dups as a
duplicate of a new main bug.
This commit is contained in:
parent
0eea97796d
commit
dabbf89580
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -4,6 +4,8 @@ ubuntu-dev-tools (0.58) UNRELEASED; urgency=low
|
|||||||
* Fix a bunch of hyphen-used-as-minus-sign lintian informational tags.
|
* Fix a bunch of hyphen-used-as-minus-sign lintian informational tags.
|
||||||
* Don't repeat Section in the binary package's control chunk (pleases
|
* Don't repeat Section in the binary package's control chunk (pleases
|
||||||
lintian).
|
lintian).
|
||||||
|
* New script, lp-set-dup, allows marking a bug and all its dups as a
|
||||||
|
duplicate of a new main bug.
|
||||||
|
|
||||||
-- Jonathan Davies <jpds@ubuntu.com> Sat, 17 Jan 2009 21:04:55 +0000
|
-- Jonathan Davies <jpds@ubuntu.com> Sat, 17 Jan 2009 21:04:55 +0000
|
||||||
|
|
||||||
|
92
lp-set-dup
Executable file
92
lp-set-dup
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
"""Sets the "duplicate of" bug of a bug and its dups."""
|
||||||
|
|
||||||
|
# Copyright (c) 2009 Canonical Ltd.
|
||||||
|
#
|
||||||
|
# lp-set-dup is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation; either version 2, or (at your option) any
|
||||||
|
# later version.
|
||||||
|
#
|
||||||
|
# lp-set-dup is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with lp-set-dup; see the file COPYING. If not, write to the Free
|
||||||
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||||
|
# 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# Authors:
|
||||||
|
# Loïc Minier <lool@dooz.org>
|
||||||
|
|
||||||
|
import os, sys
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
from ubuntutools import common
|
||||||
|
|
||||||
|
def die(message):
|
||||||
|
print >> sys.stderr, "Fatal: " + message
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
usage = "Usage: %prog [-f] <new main bug> <bug to dup> [<bug to dup>...]"
|
||||||
|
optParser = OptionParser(usage)
|
||||||
|
optParser.add_option("-f", action = "store_true",
|
||||||
|
dest = "force", default = False,
|
||||||
|
help = "Skip confirmation prompt")
|
||||||
|
|
||||||
|
(options, args) = optParser.parse_args()
|
||||||
|
|
||||||
|
if len(args) < 2:
|
||||||
|
optParser.error("Need at least a new main bug and a bug to dup")
|
||||||
|
|
||||||
|
launchpad = None
|
||||||
|
try:
|
||||||
|
print "Setting up Launchpad"
|
||||||
|
launchpad = common.get_launchpad("ubuntu-dev-tools")
|
||||||
|
print "Launchpad setup complete"
|
||||||
|
except ImportError:
|
||||||
|
suggestion = "check whether python-launchpadlib is installed"
|
||||||
|
die("Couldn't setup Launchpad for the ubuntu-dev-tools consumer; check whether python-launchpadlib is installed")
|
||||||
|
except IOError:
|
||||||
|
suggestion = "you might want to \"manage-credentials create --consumer ubuntu-dev-tools --level 2\""
|
||||||
|
if launchpad is None:
|
||||||
|
die("Couldn't setup Launchpad for the ubuntu-dev-tools consumer; %s" (suggestion, ))
|
||||||
|
|
||||||
|
# check that the new main bug isn't a duplicate
|
||||||
|
new_main_bug = launchpad.bugs[args[0]]
|
||||||
|
new_main_dup_of = new_main_bug.duplicate_of
|
||||||
|
if new_main_dup_of is not None:
|
||||||
|
prog = os.path.basename(sys.argv[0])
|
||||||
|
die("New main bug %s is a duplicate of %s; try %s %s %s" % (new_main_bug.id, new_main_dup_of.id, prog, new_main_dup_of.id, " ".join(args[1:])))
|
||||||
|
|
||||||
|
# build list of bugs to process, first the dups then the bug
|
||||||
|
bugs_to_process = []
|
||||||
|
for b in args[1:]:
|
||||||
|
print "Processing %s" % (b)
|
||||||
|
bug = launchpad.bugs[b]
|
||||||
|
dups = bug.duplicates
|
||||||
|
if dups is not None:
|
||||||
|
bugs_to_process.extend(dups)
|
||||||
|
print "Found %i dups for %s" % (len(dups), b)
|
||||||
|
bugs_to_process.append(bug)
|
||||||
|
|
||||||
|
# process dups first, then their main bug
|
||||||
|
print "Would set the following bugs as duplicates of %s: %s" % (new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process]))
|
||||||
|
|
||||||
|
if not options.force:
|
||||||
|
try:
|
||||||
|
s = raw_input("Proceed [y/N]?")
|
||||||
|
except:
|
||||||
|
die("Aborted")
|
||||||
|
if s.lower() not in ("y", "yes"):
|
||||||
|
die("User aborted")
|
||||||
|
|
||||||
|
for bug in bugs_to_process:
|
||||||
|
print "Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id)
|
||||||
|
bug.duplicate_of = new_main_bug
|
||||||
|
bug.lp_save()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user