1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/usr/bin/python
import os, sys
import launchpadlib.launchpad
from lazr.restfulclient.errors import HTTPError
lp = launchpadlib.launchpad.Launchpad.login_with(os.path.basename(sys.argv[0]), u'production', version='devel')
CLEAN_STATES = [ 'Opinion', 'Invalid', 'Won\'t Fix', 'Expired' ]
MOVABLE_STATES = [ 'New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress' ]
COMPLETED_STATES = [ 'Fix Committed', 'Fix Released' ]
ubuntu = lp.distributions['ubuntu']
project_name = sys.argv[1] if len(sys.argv) > 1 else 'unity'
src_project = ubuntu.getSourcePackage(name=project_name)
upstream_project = src_project.upstream_product
src_bugs = src_project.searchTasks(status=MOVABLE_STATES+COMPLETED_STATES, order_by='-datecreated')
print "Downstream bugs found:",len(src_bugs)
i = 1
for task in src_bugs:
bug = task.bug
print "[%.02f %d/%d]" % ((i * 100.0 / len(src_bugs)), i, len(src_bugs)),
try:
found_upstream = False
for r in task.related_tasks:
if r.target == upstream_project:
found_upstream = True
break
if found_upstream:
print "Bug",bug.web_link,"has already an upstream bug"
i += 1
continue
print "Bug",bug.web_link,"needs to be upstreamed...",
upstream_task = bug.addTask(target=upstream_project)
upstream_task.status = task.status
upstream_task.importance = task.importance
upstream_task.assignee = task.assignee
upstream_task.lp_save()
print "done!"
except HTTPError:
print "ERROR!"
i += 1
|