[PATCH] bzr gives the right error when not in a branch
Robert Collins
robertc at robertcollins.net
Mon Jan 16 22:03:59 GMT 2006
On Mon, 2006-01-16 at 14:20 -0600, John A Meinel wrote:
> plain text document attachment (correct-working-tree-error.patch)
> === added file 'bzrlib/tests/blackbox/test_outside_wt.py'
> --- /dev/null
> +++ bzrlib/tests/blackbox/test_outside_wt.py
> @@ -0,0 +1,54 @@
> +# Copyright (C) 2005 by Canonical Ltd
2006 now I think ;)
> +# -*- coding: utf-8 -*-
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> +
> +
> +"""\
> +Black-box tests for running bzr outside of a working tree.
> +"""
Docstrings should always open on the same line as the quotes:
"""Black-box...
> +
> +import os
> +import sys
Is sys used at all ?
> +from bzrlib.branch import Branch
is Branch actually used ?
> +from bzrlib.tests import TestCaseInTempDir
> +
> +
> +class TestOutsideWT(TestCaseInTempDir):
> + """Test that bzr gives proper errors outside of a working tree."""
> +
> + def test_log(self):
> + os.chdir('/tmp')
> + cwd = os.getcwdu()
> + out, err = self.run_bzr('log', retcode=3)
> +
> + self.assertEqual(u'bzr: ERROR: Not a branch: %s\n' % (cwd,),
> + err)
> +
> + def test_http_log(self):
> + out, err = self.run_bzr('log',
> + 'http://aosehuasotehu/invalid/', retcode=3)
> +
> + self.assertEqual(u'bzr: ERROR: Not a branch:'
> + u' http://aosehuasotehu/invalid/\n', err)
> +
> + def test_abs_log(self):
> + out, err = self.run_bzr('log', '/tmp/path/not/branch', retcode=3)
> +
> + self.assertEqual(u'bzr: ERROR: Not a branch:'
> + u' /tmp/path/not/branch\n', err)
> +
> +
>
> === modified file 'bzrlib/tests/blackbox/__init__.py'
> --- bzrlib/tests/blackbox/__init__.py
> +++ bzrlib/tests/blackbox/__init__.py
> @@ -32,6 +32,7 @@
> 'bzrlib.tests.blackbox.test_diff',
> 'bzrlib.tests.blackbox.test_export',
> 'bzrlib.tests.blackbox.test_missing',
> + 'bzrlib.tests.blackbox.test_outside_wt',
> 'bzrlib.tests.blackbox.test_pull',
> 'bzrlib.tests.blackbox.test_revno',
> 'bzrlib.tests.blackbox.test_revision_info',
>
> === modified file 'bzrlib/workingtree.py'
> --- bzrlib/workingtree.py
> +++ bzrlib/workingtree.py
> @@ -235,6 +235,7 @@
> if path.find('://') != -1:
> raise NotBranchError(path=path)
> path = abspath(path)
> + orig_path = path[:]
> tail = u''
> while True:
> try:
> @@ -249,7 +250,7 @@
> path = os.path.dirname(path)
> if lastpath == path:
> # reached the root, whatever that may be
> - raise NotBranchError(path=path)
> + raise NotBranchError(path=orig_path)
>
> def __iter__(self):
> """Iterate through file_ids for this tree.
+1 with the above issues addressed.
Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060117/0ad67793/attachment.pgp
More information about the bazaar
mailing list