Merge lp:~mbp/bzr/error-reporting into lp:bzr

Proposed by Martin Pool
Status: Superseded
Proposed branch: lp:~mbp/bzr/error-reporting
Merge into: lp:bzr
Prerequisite: lp:~mbp/bzr/assert-doctest
Diff against target: 183 lines (+90/-13) (has conflicts)
5 files modified
bzrlib/crash.py (+21/-9)
bzrlib/plugin.py (+11/-0)
bzrlib/tests/__init__.py (+1/-1)
bzrlib/tests/test_crash.py (+47/-3)
doc/en/release-notes/bzr-2.3.txt (+10/-0)
Text conflict in bzrlib/crash.py
Text conflict in bzrlib/tests/test_crash.py
Text conflict in doc/en/release-notes/bzr-2.3.txt
To merge this branch: bzr merge lp:~mbp/bzr/error-reporting
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+55677@code.launchpad.net

This proposal supersedes a proposal from 2011-03-31.

This proposal has been superseded by a proposal from 2011-03-31.

Description of the change

Per bug 716389 and previous feedback, this now shows just a concisely list of plugins in the non-apport crash message

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/28/2011 03:16 AM, Martin Pool wrote:
> Martin Pool has proposed merging lp:~mbp/bzr/error-reporting into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> Bug #716389 in Bazaar: "In-terminal crash report is far too long, containing full `bzr plugins` output"
> https://bugs.launchpad.net/bzr/+bug/716389
>
> For more details, see:
> https://code.launchpad.net/~mbp/bzr/error-reporting/+merge/55029
>
> This stops bzr printing a full list of plugins (too long!) on a non-apport error; per bug 716389
>

What if we printed out the short forms, rather than the long form. Right
now we show:
news_merge 2.4.0dev2
  Merge hook for bzr's NEWS file.
   /home/jameinel/dev/bzr/bzr.dev/bzrlib/plugins/news_merge

qbzr 0.20.0
  QBzr - Qt-based frontend for Bazaar
   /usr/lib/python2.6/dist-packages/bzrlib/plugins/qbzr

weave_fmt
  Weave formats.
   /home/jameinel/dev/bzr/bzr.dev/bzrlib/plugins/weave_fmt

And I agree that it is overly verbose. We could, instead do:
bash_completion 2.4.0dev2
bzrtools 2.3.1
changelog_merge 2.4.0dev2
launchpad 2.4.0dev2
loggerhead 1.18.0
netrc_credential_store 2.4.0dev2
news_merge 2.4.0dev2
qbzr 0.20.0
weave_fmt

I actually do find it useful to see the plugin versions as part of bug
reports that people manually copy & paste. I don't think we want to get
rid of it completely. I wonder if we could even put them all-on-one-line
like:

bash_completion 2.4.0dev2, bzrtools 2.3.1, changelog_merge 2.4.0dev2,
launchpad 2.4.0dev2, loggerhead 1.18.0, netrc_credential_store
2.4.0dev2, news_merge 2.4.0dev2, qbzr 0.20.0, weave_fmt

That would still allow us to say "the bug is in bzr-svn, and you're
running an older version".

Just a thought. I don't think I want to completely get rid of the plugin
list. I do agree that it obscures seeing the backtrace the way it is now.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2QcWYACgkQJdeBCYSNAAOr5ACfV4PuAXPTIomnKxTE6Jc3MAd8
oMgAoMWBSWUkh7fX0160a5EQg1eXgjxE
=4fJS
-----END PGP SIGNATURE-----

Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

I think one per line would still be too much: easily enough to make the
whole report more than a 25 line screen. But I can do one that puts them on
one line. It's true many bugs are related to plugins.
On 28/03/2011 10:34 PM, "John A Meinel" <email address hidden> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 03/28/2011 03:16 AM, Martin Pool wrote:
>> Martin Pool has proposed merging lp:~mbp/bzr/error-reporting into lp:bzr.
>>
>> Requested reviews:
>> bzr-core (bzr-core)
>> Related bugs:
>> Bug #716389 in Bazaar: "In-terminal crash report is far too long,
containing full `bzr plugins` output"
>> https://bugs.launchpad.net/bzr/+bug/716389
>>
>> For more details, see:
>> https://code.launchpad.net/~mbp/bzr/error-reporting/+merge/55029
>>
>> This stops bzr printing a full list of plugins (too long!) on a
non-apport error; per bug 716389
>>
>
> What if we printed out the short forms, rather than the long form. Right
> now we show:
> news_merge 2.4.0dev2
> Merge hook for bzr's NEWS file.
> /home/jameinel/dev/bzr/bzr.dev/bzrlib/plugins/news_merge
>
> qbzr 0.20.0
> QBzr - Qt-based frontend for Bazaar
> /usr/lib/python2.6/dist-packages/bzrlib/plugins/qbzr
>
> weave_fmt
> Weave formats.
> /home/jameinel/dev/bzr/bzr.dev/bzrlib/plugins/weave_fmt
>
>
> And I agree that it is overly verbose. We could, instead do:
> bash_completion 2.4.0dev2
> bzrtools 2.3.1
> changelog_merge 2.4.0dev2
> launchpad 2.4.0dev2
> loggerhead 1.18.0
> netrc_credential_store 2.4.0dev2
> news_merge 2.4.0dev2
> qbzr 0.20.0
> weave_fmt
>
> I actually do find it useful to see the plugin versions as part of bug
> reports that people manually copy & paste. I don't think we want to get
> rid of it completely. I wonder if we could even put them all-on-one-line
> like:
>
> bash_completion 2.4.0dev2, bzrtools 2.3.1, changelog_merge 2.4.0dev2,
> launchpad 2.4.0dev2, loggerhead 1.18.0, netrc_credential_store
> 2.4.0dev2, news_merge 2.4.0dev2, qbzr 0.20.0, weave_fmt
>
> That would still allow us to say "the bug is in bzr-svn, and you're
> running an older version".
>
> Just a thought. I don't think I want to completely get rid of the plugin
> list. I do agree that it obscures seeing the backtrace the way it is now.
>
> John
> =:->
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk2QcWYACgkQJdeBCYSNAAOr5ACfV4PuAXPTIomnKxTE6Jc3MAd8
> oMgAoMWBSWUkh7fX0160a5EQg1eXgjxE
> =4fJS
> -----END PGP SIGNATURE-----
>
> --
> https://code.launchpad.net/~mbp/bzr/error-reporting/+merge/55029
> You are the owner of lp:~mbp/bzr/error-reporting.

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

> bash_completion 2.4.0dev2, bzrtools 2.3.1, changelog_merge 2.4.0dev2,
> launchpad 2.4.0dev2, loggerhead 1.18.0, netrc_credential_store
> 2.4.0dev2, news_merge 2.4.0dev2, qbzr 0.20.0, weave_fmt
>
> That would still allow us to say "the bug is in bzr-svn, and you're
> running an older version".
>
> Just a thought. I don't think I want to completely get rid of the plugin
> list. I do agree that it obscures seeing the backtrace the way it is now.
I think putting them on one line would be a good idea. Usually the version of the plugin is the main thing that matters anyway. The summary lines aren't particularly useful when reading bug reports, and the location is rarely useful to see whether the plugin was loaded from system, site or user dir.

Cheers,

Jelmer

Revision history for this message
John A Meinel (jameinel) wrote :
Download full text (3.5 KiB)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/31/2011 6:49 AM, Martin Pool wrote:
> Martin Pool has proposed merging lp:~mbp/bzr/error-reporting into lp:bzr with lp:~mbp/bzr/assert-doctest as a prerequisite.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> Bug #716389 in Bazaar: "In-terminal crash report is far too long, containing full `bzr plugins` output"
> https://bugs.launchpad.net/bzr/+bug/716389
>
> For more details, see:
> https://code.launchpad.net/~mbp/bzr/error-reporting/+merge/55677
>
> Per bug 716389 and previous feedback, this now shows just a concisely list of plugins in the non-apport crash message
>

Right now plugin.describe_plugins() uses:
  plugin = loaded_plugins[name]
  version = plugin.__version__
  if version == 'unknown':
      version = ''

We might want to do that for the formatting, so you don't get:
bzrtools[unknown], qbzr[1.2.3]

I don't have strong feelings on it, though. It might be good to report
unknown...

This is what the formatting looks like here (I have a fair number of
'unknown' version plugins):

bzr 2.4.0dev2 on python 2.6.4 (Windows-Vista-6.0.6002-SP2)
arguments: ['C:/Users/jameinel/dev/bzr/jam-integration/bzr', 'assert-fail']
plugins: bash_completion[2.4.0dev2], bzrtools[2.1b1],
    changelog_merge[2.4.0dev2], check_chk[unknown], colo[0.2.1dev],
    dummy_request[unknown], dump[unknown], email[unknown],
explorer[1.1.0dev],
    fastimport[0.9.0dev], file_locking[0.1.0dev], gimmepdb[unknown],
    grep[0.2.0], in_ancestry[unknown], launchpad[2.4.0dev2],
    lock_test[0.1.0dev], loggerhead[1.18.0], loom[2.2.1dev],
    netrc_credential_store[2.4.0dev2], news_merge[2.4.0dev2],
    per_file_graph[unknown], pqm[1.4.0dev], pybloom[unknown],
    qbzr[0.20.0dev1], rebase[0.4.3dev], register[unknown],
    repodetails[1.9.0dev], search[1.7.0dev], start[unknown],
stats[0.1.0dev],
    test_groupcompress[unknown], time_iter_changes[unknown],
    track_wow_renames[0.0.1dev], update_copyright[0.1.0dev],
vimdiff[unknown],
    weave_fmt[unknown]
encoding: 'cp1252', fsenc: 'mbcs', lang: 'C.UTF-8'

...

=== modified file 'bzrlib/tests/__init__.py'
- --- bzrlib/tests/__init__.py 2011-03-31 04:48:22 +0000
+++ bzrlib/tests/__init__.py 2011-03-31 04:48:30 +0000
@@ -1465,7 +1465,7 @@
         checker = doctest.OutputChecker()
         if optionflags is None:
             # XXX: More here by default?
- - optionflags = doctest.ELLIPSIS
+ optionflags = doctest.ELLIPSIS | doctest.REPORT_UDIFF
         if not checker.check_output(expected, actual, optionflags):
             # The Doctest api insists on an internal object here but
doesn't
             # really need it; just pretend.

^- Looks like this was meant to be part of the earlier patch.

test_crash does pass here on a Windows machine. So I'm happy that the
doctest matcher worked for what you wanted.

I do think you could have crafted some sort of multiline regex to get
the same results as the doctest matcher. I suppose escaping '.' is a bit
ugly (no worse than <BLANKLINE>, IMO, and '.*' is shorter than '...')

You do get much better error messages, though. Since regexes tend to say
"no, didn't match" without any conte...

Read more...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/crash.py'
2--- bzrlib/crash.py 2011-01-20 23:07:25 +0000
3+++ bzrlib/crash.py 2011-03-31 04:48:30 +0000
4@@ -1,4 +1,8 @@
5+<<<<<<< TREE
6 # Copyright (C) 2009, 2010, 2011 Canonical Ltd
7+=======
8+# Copyright (C) 2009-2011 Canonical Ltd
9+>>>>>>> MERGE-SOURCE
10 #
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13@@ -84,19 +88,27 @@
14 """Report a bug by just printing a message to the user."""
15 trace.print_exception(exc_info, err_file)
16 err_file.write('\n')
17- err_file.write('bzr %s on python %s (%s)\n' % \
18- (bzrlib.__version__,
19- bzrlib._format_version_tuple(sys.version_info),
20- platform.platform(aliased=1)))
21- err_file.write('arguments: %r\n' % sys.argv)
22- err_file.write(
23+ import textwrap
24+ def print_wrapped(l):
25+ err_file.write(textwrap.fill(l,
26+ width=78, subsequent_indent=' ') + '\n')
27+ print_wrapped('bzr %s on python %s (%s)\n' % \
28+ (bzrlib.__version__,
29+ bzrlib._format_version_tuple(sys.version_info),
30+ platform.platform(aliased=1)))
31+ print_wrapped('arguments: %r\n' % sys.argv)
32+ print_wrapped(textwrap.fill(
33+ 'plugins: ' + plugin.format_concise_plugin_list(),
34+ width=78,
35+ subsequent_indent=' ',
36+ ) + '\n')
37+ print_wrapped(
38 'encoding: %r, fsenc: %r, lang: %r\n' % (
39 osutils.get_user_encoding(), sys.getfilesystemencoding(),
40 os.environ.get('LANG')))
41- err_file.write("plugins:\n")
42- err_file.write(_format_plugin_list())
43+ # We used to show all the plugins here, but it's too verbose.
44 err_file.write(
45- "\n\n"
46+ "\n"
47 "*** Bazaar has encountered an internal error. This probably indicates a\n"
48 " bug in Bazaar. You can help us fix it by filing a bug report at\n"
49 " https://bugs.launchpad.net/bzr/+filebug\n"
50
51=== modified file 'bzrlib/plugin.py'
52--- bzrlib/plugin.py 2011-01-20 01:02:34 +0000
53+++ bzrlib/plugin.py 2011-03-31 04:48:30 +0000
54@@ -451,6 +451,17 @@
55 return result
56
57
58+def format_concise_plugin_list():
59+ """Return a string holding a concise list of plugins and their version.
60+ """
61+ items = []
62+ for name, a_plugin in sorted(plugins().items()):
63+ items.append("%s[%s]" %
64+ (name, a_plugin.__version__))
65+ return ', '.join(items)
66+
67+
68+
69 class PluginsHelpIndex(object):
70 """A help index that returns help topics for plugins."""
71
72
73=== modified file 'bzrlib/tests/__init__.py'
74--- bzrlib/tests/__init__.py 2011-03-31 04:48:22 +0000
75+++ bzrlib/tests/__init__.py 2011-03-31 04:48:30 +0000
76@@ -1465,7 +1465,7 @@
77 checker = doctest.OutputChecker()
78 if optionflags is None:
79 # XXX: More here by default?
80- optionflags = doctest.ELLIPSIS
81+ optionflags = doctest.ELLIPSIS | doctest.REPORT_UDIFF
82 if not checker.check_output(expected, actual, optionflags):
83 # The Doctest api insists on an internal object here but doesn't
84 # really need it; just pretend.
85
86=== modified file 'bzrlib/tests/test_crash.py'
87--- bzrlib/tests/test_crash.py 2011-01-18 00:41:29 +0000
88+++ bzrlib/tests/test_crash.py 2011-03-31 04:48:30 +0000
89@@ -15,13 +15,12 @@
90 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
91
92
93+import doctest
94+import os
95 from StringIO import StringIO
96 import sys
97
98
99-import os
100-
101-
102 from bzrlib import (
103 config,
104 crash,
105@@ -77,6 +76,51 @@
106 self.assertContainsRe(report, 'test_apport_report')
107 # should also be in there
108 self.assertContainsRe(report, '(?m)^CommandLine:')
109+<<<<<<< TREE
110 self.assertContainsRe(
111 report,
112 'Failed to load plugin foo')
113+=======
114+
115+
116+class TestNonApportReporting(tests.TestCase):
117+ """Reporting of crash-type bugs without apport.
118+
119+ This should work in all environments.
120+ """
121+
122+ def setup_fake_plugins(self):
123+ def fake_plugins():
124+ fake = plugin.PlugIn('fake_plugin', plugin)
125+ fake.version_info = lambda: (1, 2, 3)
126+ return {"fake_plugin": fake}
127+ self.overrideAttr(plugin, 'plugins', fake_plugins)
128+
129+ def test_report_bug_legacy(self):
130+ self.setup_fake_plugins()
131+ err_file = StringIO()
132+ try:
133+ raise AssertionError("my error")
134+ except AssertionError, e:
135+ pass
136+ crash.report_bug_legacy(sys.exc_info(), err_file)
137+ self.assertDoctestExampleMatches("""\
138+bzr: ERROR: exceptions.AssertionError: my error
139+<BLANKLINE>
140+Traceback (most recent call last):
141+ ...
142+AssertionError: my error
143+<BLANKLINE>
144+bzr ... on python ...
145+arguments: ...
146+plugins: fake_plugin[1.2.3]
147+encoding: ...
148+<BLANKLINE>
149+*** Bazaar has encountered an internal error. This probably indicates a
150+ bug in Bazaar. You can help us fix it by filing a bug report at
151+ https://bugs.launchpad.net/bzr/+filebug
152+ including this traceback and a description of the problem.
153+""",
154+ err_file.getvalue(),
155+ )
156+>>>>>>> MERGE-SOURCE
157
158=== modified file 'doc/en/release-notes/bzr-2.3.txt'
159--- doc/en/release-notes/bzr-2.3.txt 2011-03-31 04:48:22 +0000
160+++ doc/en/release-notes/bzr-2.3.txt 2011-03-31 04:48:30 +0000
161@@ -5,6 +5,7 @@
162 .. toctree::
163 :maxdepth: 1
164
165+<<<<<<< TREE
166 bzr 2.3.2
167 #########
168
169@@ -80,6 +81,15 @@
170 in python > 2.7.1). (Vincent Ladeuil, #654733)
171
172
173+=======
174+Bug Fixes
175+*********
176+
177+ * When reporting a crash without apport, don't print the full list of
178+ plugins because it's often too long.
179+ (Martin Pool, #716389)
180+
181+>>>>>>> MERGE-SOURCE
182 bzr 2.3.1
183 #########
184