Merge lp:~spiv/bzr/just-add-repr-687653-2.2 into lp:bzr/2.2

Proposed by Andrew Bennetts
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5115
Proposed branch: lp:~spiv/bzr/just-add-repr-687653-2.2
Merge into: lp:bzr/2.2
Diff against target: 28 lines (+7/-0)
2 files modified
NEWS (+4/-0)
bzrlib/errors.py (+3/-0)
To merge this branch: bzr merge lp:~spiv/bzr/just-add-repr-687653-2.2
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+43319@code.launchpad.net

Commit message

Override __repr__ in NotBranchError to avoid side-effects during repr(e).

Description of the change

An simpler alternative to <https://code.launchpad.net/~mbp/bzr/687653-notbrancherror/+merge/43314>. Override __repr__ to make it simple and safe (instead of calling our custom _format which calls open_repository).

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

This is a nice minimal fix for 2.2, and apparently fixes the issue in production.

I think generally we shouldn't have any objects doing real work from their str or repr method, and exceptions should be a lot like value objects.

Perhaps we should have an optional ".hint()" method that the ui can call.

I am kind of inclined to delete this in trunk but it's not really a priority.

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2010-12-02 09:29:41 +0000
+++ NEWS 2010-12-10 04:52:57 +0000
@@ -25,6 +25,10 @@
25Bug Fixes25Bug Fixes
26*********26*********
2727
28* Don't probe for a repository from within ``NotBranchError.__repr__``,
29 because this can cause knock-on errors at awkward times.
30 (Andrew Bennetts, #687653)
31
28* RevisionTree.is_executable no longer returns None for directories and32* RevisionTree.is_executable no longer returns None for directories and
29 symlinks. Instead, it returns False, like other Trees and methods.33 symlinks. Instead, it returns False, like other Trees and methods.
30 (Aaron Bentley, #681885)34 (Aaron Bentley, #681885)
3135
=== modified file 'bzrlib/errors.py'
--- bzrlib/errors.py 2010-10-11 05:06:26 +0000
+++ bzrlib/errors.py 2010-12-10 04:52:57 +0000
@@ -713,6 +713,9 @@
713 self.bzrdir = bzrdir713 self.bzrdir = bzrdir
714 PathError.__init__(self, path=path)714 PathError.__init__(self, path=path)
715715
716 def __repr__(self):
717 return '<%s %r>' % (self.__class__.__name__, self.__dict__)
718
716 def _format(self):719 def _format(self):
717 # XXX: Ideally self.detail would be a property, but Exceptions in720 # XXX: Ideally self.detail would be a property, but Exceptions in
718 # Python 2.4 have to be old-style classes so properties don't work.721 # Python 2.4 have to be old-style classes so properties don't work.

Subscribers

People subscribed via source and target branches