/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/check-newsbugs.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
import getopt, re, sys
6
6
try:
7
 
    from launchpadbugs import connector
8
 
except ImportError:
9
 
    print "Please install launchpadbugs from lp:python-launchpad-bugs"
10
 
    sys.exit(1)
11
 
 
12
 
options, args = getopt.gnu_getopt(sys.argv, "l", ["launchpad"])
 
7
    from launchpadlib.launchpad import Launchpad
 
8
    from lazr.restfulclient import errors
 
9
except ImportError:
 
10
    print "Please install launchpadlib from lp:launchpadlib"
 
11
    sys.exit(1)
 
12
try:
 
13
    import hydrazine
 
14
except ImportError:
 
15
    print "Please install hydrazine from lp:hydrazine"
 
16
    sys.exit(1)
 
17
 
 
18
 
 
19
options, args = getopt.gnu_getopt(sys.argv, "lw", ["launchpad", 'webbrowser'])
13
20
options = dict(options)
14
21
 
15
22
if len(args) == 1:
16
 
    print "Usage: check-newsbugs [--launchpad] NEWS"
 
23
    print ("Usage: check-newsbugs [--launchpad][--webbrowser] "
 
24
           "doc/en/release-notes/bzr-x.y.txt")
17
25
    print "Options:"
18
26
    print "--launchpad     Print out Launchpad mail commands for closing bugs "
19
27
    print "                that are already fixed."
 
28
    print "--webbrowser    Open launchpad bug pages for bugs that are already "
 
29
    print "                fixed."
20
30
    sys.exit(1)
21
31
 
22
32
 
23
33
def report_notmarked(bug, task, section):
24
 
    print 
25
 
    print "Bug %d was mentioned in NEWS but is not marked fix released:" % (bug.bugnumber, )
 
34
    print
 
35
    print "Bug %d was mentioned in NEWS but is not marked fix released:" % (bug.id, )
26
36
    print "Launchpad title: %s" % bug.title
27
37
    print "NEWS summary: "
28
38
    print section
29
39
    if "--launchpad" in options or "-l" in options:
30
 
        print "  bug %d" % bug.bugnumber
31
 
        print "  affects bzr"
 
40
        print "  bug %d" % bug.id
 
41
        print "  affects %s" % task.bug_target_name
32
42
        print "  status fixreleased"
 
43
    if "--webbrowser" in options or "-w" in options:
 
44
        import webbrowser
 
45
        webbrowser.open('http://pad.lv/%s>' % (bug.id,))
33
46
 
34
47
 
35
48
def read_news_bugnos(path):
60
73
    finally:
61
74
        f.close()
62
75
 
63
 
open_bug = connector.ConnectBug("TEXT")
64
 
 
 
76
 
 
77
def print_bug_url(bugno):
 
78
    print '<URL:http://pad.lv/%s>' % (bugno,)
 
79
 
 
80
launchpad = hydrazine.create_session()
65
81
bugnos = read_news_bugnos(args[1])
66
82
for bugno, section in bugnos:
67
 
    bug = open_bug(url="https://bugs.launchpad.net/bzr/+bug/%d" % bugno)
 
83
    try:
 
84
        bug = launchpad.bugs[bugno]
 
85
    except errors.HTTPError, e:
 
86
        if e.response.status == 401:
 
87
            print_bug_url(bugno)
 
88
            # Private, we can't access the bug content
 
89
            print '%s is private and cannot be accessed' % (bugno,)
 
90
            continue
 
91
        raise
 
92
 
68
93
    found_bzr = False
69
 
    for task in bug.infotable:
70
 
        if task.affects == "bzr":
 
94
    fix_released = False
 
95
    for task in bug.bug_tasks:
 
96
        parts = task.bug_target_name.split('/')
 
97
        if len(parts) == 1:
 
98
            project = parts[0]
 
99
            distribution = None
 
100
        else:
 
101
            project = parts[0]
 
102
            distribution = parts[1]
 
103
        if project == "bzr":
71
104
            found_bzr = True
72
 
            if task.status != "Fix Released":
73
 
                report_notmarked(bug, task, section)
 
105
            if not fix_released and task.status == "Fix Released":
 
106
                # We could check that the NEWS section and task_status are in
 
107
                # sync, but that would be overkill. (case at hand: bug #416732)
 
108
                fix_released = True
 
109
 
74
110
    if not found_bzr:
 
111
        print_bug_url(bugno)
75
112
        print "Bug %d was mentioned in NEWS but is not marked as affecting bzr" % bugno
 
113
    elif not fix_released:
 
114
        print_bug_url(bugno)
 
115
        report_notmarked(bug, task, section)