[BUG] failure of find_branch causes Branch.__str__ to be called on a half-constructed branch.

Aaron Bentley aaron.bentley at utoronto.ca
Thu May 26 14:58:40 BST 2005


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

Hi,

This command fails when .be does not exist:

abentley at troll:~/bzrtools2$ bzr remove .be
bzr: error: u'/home/abentley/bzrtools2/.be' does not exist
~  at /home/abentley/bzr.dev/bzrlib/branch.py:64 in find_branch_root()
~  see ~/.bzr.log for debug information
abentley at troll:~/bzrtools2$ bzr remove .be
bzr: error: u'/home/abentley/bzrtools2/.be' does not exist
Traceback (most recent call last):
~  File "/home/abentley/bin/bzr", line 47, in ?
~    sys.exit(bzrlib.commands.main(sys.argv))
~  File "/home/abentley/bzr.dev/bzrlib/commands.py", line 1210, in main
~    _report_exception('error: ' + e.args[0], quiet=quiet)
~  File "/home/abentley/bzr.dev/bzrlib/commands.py", line 1185, in
_report_exception
~    bzrlib.trace.log_exception()
~  File "/home/abentley/bzr.dev/bzrlib/trace.py", line 139, in log_exception
~    s = cgitb.text(sys.exc_info())
~  File "/home/abentley//lib/python2.3/cgitb.py", line 190, in text
~    formatvalue=lambda value: '=' + pydoc.text.repr(value))
~  File "/home/abentley//lib/python2.3/inspect.py", line 725, in
formatargvalues
~    specs.append(strseq(args[i], convert, join))
~  File "/home/abentley//lib/python2.3/inspect.py", line 680, in strseq
~    return convert(object)
~  File "/home/abentley//lib/python2.3/inspect.py", line 722, in convert
~    return formatarg(name) + formatvalue(locals[name])
~  File "/home/abentley//lib/python2.3/cgitb.py", line 190, in <lambda>
~    formatvalue=lambda value: '=' + pydoc.text.repr(value))
~  File "/home/abentley//lib/python2.3/repr.py", line 18, in repr
~    return self.repr1(x, self.maxlevel)
~  File "/home/abentley//lib/python2.3/pydoc.py", line 881, in repr1
~    return cram(stripid(repr(x)), self.maxother)
~  File "/home/abentley/bzr.dev/bzrlib/branch.py", line 126, in __str__
~    return '%s(%r)' % (self.__class__.__name__, self.base)
AttributeError: 'Branch' object has no attribute 'base'

This can be fixed by initializing Branch.base to None, although that's
almost certainly the wrong fix:

*** modified file 'bzrlib/branch.py'
- --- bzrlib/branch.py
+++ bzrlib/branch.py
@@ -107,6 +107,7 @@
~             self.base = os.path.realpath(base)
~             self._make_control()
~         elif find_root:
+            self.base = None
~             self.base = find_branch_root(base)
~         else:
~             self.base = os.path.realpath(base)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCldYQ0F+nu1YWqI0RAveoAJ9l2EAuscrDipWS1FJpQsbbQOWPFACaAqK1
Z7Vk2qngoAsVbgnqrzmCpS4=
=Tf/l
-----END PGP SIGNATURE-----




More information about the bazaar mailing list