~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
94
94
        """Create a bzr dir."""
95
95
        t = get_transport(url)
96
96
        t.mkdir('.bzr')
97
 
        t.put('.bzr/branch-format', StringIO(self.get_format_string()))
 
97
        t.put_bytes('.bzr/branch-format', self.get_format_string())
98
98
        return SampleBzrDir(t, self)
99
99
 
100
100
    def is_supported(self):
129
129
    def test_find_format_unknown_format(self):
130
130
        t = get_transport(self.get_url())
131
131
        t.mkdir('.bzr')
132
 
        t.put('.bzr/branch-format', StringIO())
 
132
        t.put_bytes('.bzr/branch-format', '')
133
133
        self.assertRaises(UnknownFormatError,
134
134
                          bzrdir.BzrDirFormat.find_format,
135
135
                          get_transport('.'))
392
392
            get_transport(self.get_readonly_url('g/p/q')))
393
393
        self.assertEqual('g/p/q', relpath)
394
394
 
 
395
    def test_open_from_transport(self):
 
396
        # transport pointing at bzrdir should give a bzrdir with root transport
 
397
        # set to the given transport
 
398
        control = bzrdir.BzrDir.create(self.get_url())
 
399
        transport = get_transport(self.get_url())
 
400
        opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport)
 
401
        self.assertEqual(transport.base, opened_bzrdir.root_transport.base)
 
402
        self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir)
 
403
        
 
404
    def test_open_from_transport_no_bzrdir(self):
 
405
        transport = get_transport(self.get_url())
 
406
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
 
407
                          transport)
 
408
 
 
409
    def test_open_from_transport_bzrdir_in_parent(self):
 
410
        control = bzrdir.BzrDir.create(self.get_url())
 
411
        transport = get_transport(self.get_url())
 
412
        transport.mkdir('subdir')
 
413
        transport = transport.clone('subdir')
 
414
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
 
415
                          transport)
 
416
 
395
417
 
396
418
class TestMeta1DirFormat(TestCaseWithTransport):
397
419
    """Tests specific to the meta1 dir format."""