Merge lp:~roignac/apport/bugpattern-check_for_duplicates into lp:~ubuntu-bugcontrol/apport/ubuntu-bugpatterns

Proposed by Vadim Rutkovsky
Status: Merged
Merged at revision: 334
Proposed branch: lp:~roignac/apport/bugpattern-check_for_duplicates
Merge into: lp:~ubuntu-bugcontrol/apport/ubuntu-bugpatterns
Diff against target: 71 lines (+38/-13)
1 file modified
test-local (+38/-13)
To merge this branch: bzr merge lp:~roignac/apport/bugpattern-check_for_duplicates
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+74391@code.launchpad.net

Description of the change

test-local now checks that duplicate issues also match the pattern.
Maybe this should be optional?

To post a comment you must log in.
312. By Vadim Rutkovsky

Show correct bugnumber if any of duplicates didn't match the pattern

313. By Vadim Rutkovsky

Skip non apport-crash issues when checking for duplicates

Revision history for this message
Brian Murray (brian-murray) wrote :

This is great! I'm still playing with it now but thanks for doing this.

Revision history for this message
Brian Murray (brian-murray) wrote :

I'm leaving this as non-optional as I found the duplicate checking useful as it allowed me to expand a bug pattern. I did make some minor changes to your branch also.

I removed sys.exit from match_bug so it'll keep checking other duplicates.

Because the tags of a bug report are a list you don't really need to iterate over them.
  if 'apport-crash' in bug.tags:

And using total_size wasn't really necessary. This was sufficient:
  if bug.duplicates:

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test-local'
2--- test-local 2011-07-07 23:29:01 +0000
3+++ test-local 2011-09-07 13:22:25 +0000
4@@ -4,16 +4,26 @@
5
6 import apport
7 from apport.crashdb import get_crashdb
8+from launchpadlib.launchpad import Launchpad
9+
10+def match_bug(bugnumber):
11+ db = get_crashdb(None)
12+ report = db.download(bugnumber)
13+ match = report.search_bug_patterns('bugpatterns.xml')
14+
15+ if match:
16+ print 'LP: #%s: Matched bug pattern: %s' % (bugnumber, match )
17+ else:
18+ print 'LP: #%s: No match' % bugnumber
19+ sys.exit(1)
20+
21+lp = Launchpad.login_anonymously('apport', 'production')
22
23 if len(sys.argv) != 2:
24 print >> sys.stderr, 'Usage: %s <.crash file or bug number>' % sys.argv[0]
25 sys.exit(1)
26
27-if sys.argv[1].isdigit():
28- db = get_crashdb(None)
29- report = db.download(sys.argv[1])
30- #report.write(open('/tmp/report.crash', 'w'))
31-else:
32+if not sys.argv[1].isdigit():
33 report = apport.Report()
34 try:
35 f = open(sys.argv[1])
36@@ -22,12 +32,27 @@
37 sys.exit(1)
38 report.load(f)
39 f.close()
40-
41-match = report.search_bug_patterns('bugpatterns.xml')
42-
43-if match:
44- print 'LP: #%s: Matched bug pattern: %s' % ( sys.argv[1], match )
45+ match = report.search_bug_patterns('bugpatterns.xml')
46+
47+ if match:
48+ print 'LP: #%s: Matched bug pattern: %s' % ( sys.argv[1], match )
49+ sys.exit(0)
50+ else:
51+ print 'LP: #%s: No match' % sys.argv[1]
52+ sys.exit(1)
53+else:
54+ match_bug(sys.argv[1])
55+
56+ bug = lp.bugs[sys.argv[1]]
57+ # if bug is a duplicate - call this for parent
58+ if bug.duplicate_of:
59+ match_bug(bug.duplicate_of.id)
60+ if bug.duplicates.total_size:
61+ print "Checking duplicate bugs.."
62+ for duplicate in bug.duplicates:
63+ # Skip if not an apport bug
64+ for tag in duplicate.tags:
65+ if 'apport-crash' in tag:
66+ match_bug(duplicate.id)
67+
68 sys.exit(0)
69-else:
70- print 'LP: #%s: No match' % sys.argv[1]
71- sys.exit(1)