57
57
# check that the new main bug isn't a duplicate
59
59
new_main_bug = launchpad.bugs[args[0]]
60
except HTTPError, error:
60
except HTTPError as error:
61
61
if error.response.status == 401:
62
print >> sys.stderr, ("E: Don't have enough permissions to access "
62
print(("E: Don't have enough permissions to access "
63
"bug %s") % (args[0]), file=sys.stderr)
68
68
if new_main_dup_of is not None:
71
answer = raw_input("Bug %s is a duplicate of %s; would you like to "
71
answer = input("Bug %s is a duplicate of %s; would you like to "
72
72
"use %s as the new main bug instead? [y/N]" % \
73
73
(new_main_bug.id, new_main_dup_of.id,
74
74
new_main_dup_of.id))
81
81
# build list of bugs to process, first the dups then the bug
82
82
bugs_to_process = []
83
83
for bug_number in args[1:]:
84
print "Processing %s" % (bug_number)
84
print("Processing %s" % (bug_number))
86
86
bug = launchpad.bugs[bug_number]
87
except HTTPError, error:
87
except HTTPError as error:
88
88
if error.response.status == 401:
89
print >> sys.stderr, ("W: Don't have enough permissions to "
90
"access bug %s") % (bug_number)
91
print >> sys.stderr, "W: %s" % (error.content)
89
print(("W: Don't have enough permissions to "
90
"access bug %s") % (bug_number), file=sys.stderr)
91
print("W: %s" % (error.content), file=sys.stderr)
95
95
dups = bug.duplicates
96
96
if dups is not None:
97
97
bugs_to_process.extend(dups)
98
print "Found %i dups for %s" % (len(dups), bug_number)
98
print("Found %i dups for %s" % (len(dups), bug_number))
99
99
bugs_to_process.append(bug)
101
101
# process dups first, then their main bug
102
print "Would set the following bugs as duplicates of %s: %s" % \
103
(new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process]))
102
print("Would set the following bugs as duplicates of %s: %s" % \
103
(new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process])))
105
105
if not options.force:
108
answer = raw_input("Proceed? [y/N]")
108
answer = input("Proceed? [y/N]")
111
111
if answer.lower() not in ("y", "yes"):
112
112
die("User aborted")
114
114
for bug in bugs_to_process:
115
print "Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id)
115
print("Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id))
116
116
bug.duplicate_of = new_main_bug