Merge lp:~vila/bzr/cleanup into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5326
Proposed branch: lp:~vila/bzr/cleanup
Merge into: lp:bzr
Diff against target: 3505 lines (+653/-611)
72 files modified
bzrlib/_annotator_py.py (+1/-1)
bzrlib/add.py (+1/-1)
bzrlib/annotate.py (+1/-1)
bzrlib/benchmarks/bench_commit.py (+1/-2)
bzrlib/breakin.py (+1/-1)
bzrlib/btree_index.py (+3/-2)
bzrlib/builtins.py (+4/-4)
bzrlib/filters/eol.py (+1/-1)
bzrlib/osutils.py (+23/-29)
bzrlib/plugins/launchpad/account.py (+7/-4)
bzrlib/plugins/launchpad/test_lp_directory.py (+3/-3)
bzrlib/symbol_versioning.py (+1/-1)
bzrlib/tests/__init__.py (+25/-21)
bzrlib/tests/blackbox/__init__.py (+1/-1)
bzrlib/tests/blackbox/test_alias.py (+1/-1)
bzrlib/tests/blackbox/test_aliases.py (+1/-1)
bzrlib/tests/blackbox/test_cat_revision.py (+1/-1)
bzrlib/tests/blackbox/test_check.py (+1/-1)
bzrlib/tests/blackbox/test_dpush.py (+1/-1)
bzrlib/tests/blackbox/test_filesystem_cicp.py (+1/-1)
bzrlib/tests/blackbox/test_find_merge_base.py (+1/-1)
bzrlib/tests/blackbox/test_ignored.py (+1/-1)
bzrlib/tests/blackbox/test_merge_directive.py (+1/-1)
bzrlib/tests/blackbox/test_missing.py (+1/-1)
bzrlib/tests/blackbox/test_modified.py (+1/-1)
bzrlib/tests/blackbox/test_nick.py (+1/-1)
bzrlib/tests/blackbox/test_remove.py (+1/-1)
bzrlib/tests/blackbox/test_remove_tree.py (+1/-1)
bzrlib/tests/blackbox/test_revert.py (+1/-1)
bzrlib/tests/blackbox/test_revision_info.py (+1/-1)
bzrlib/tests/blackbox/test_serve.py (+4/-3)
bzrlib/tests/blackbox/test_upgrade.py (+10/-9)
bzrlib/tests/blackbox/test_whoami.py (+1/-1)
bzrlib/tests/http_utils.py (+14/-2)
bzrlib/tests/per_branch/test_bound_sftp.py (+2/-2)
bzrlib/tests/per_branch/test_permissions.py (+1/-2)
bzrlib/tests/per_branch/test_stacking.py (+1/-2)
bzrlib/tests/per_bzrdir/test_bzrdir.py (+20/-21)
bzrlib/tests/per_interbranch/__init__.py (+1/-2)
bzrlib/tests/per_interbranch/test_pull.py (+1/-1)
bzrlib/tests/per_interbranch/test_push.py (+0/-1)
bzrlib/tests/per_interbranch/test_update_revisions.py (+1/-1)
bzrlib/tests/per_interrepository/__init__.py (+3/-3)
bzrlib/tests/per_intertree/__init__.py (+0/-1)
bzrlib/tests/per_repository/test_fetch.py (+1/-2)
bzrlib/tests/per_repository/test_has_same_location.py (+7/-4)
bzrlib/tests/per_repository/test_reconcile.py (+10/-7)
bzrlib/tests/per_versionedfile.py (+21/-16)
bzrlib/tests/per_workingtree/test_pull.py (+0/-1)
bzrlib/tests/test_btree_index.py (+106/-105)
bzrlib/tests/test_bzrdir.py (+2/-0)
bzrlib/tests/test_debug.py (+8/-7)
bzrlib/tests/test_directory_service.py (+2/-2)
bzrlib/tests/test_http.py (+15/-6)
bzrlib/tests/test_index.py (+245/-234)
bzrlib/tests/test_knit.py (+3/-3)
bzrlib/tests/test_lockable_files.py (+6/-6)
bzrlib/tests/test_osutils.py (+1/-1)
bzrlib/tests/test_osutils_encodings.py (+1/-1)
bzrlib/tests/test_permissions.py (+5/-5)
bzrlib/tests/test_reconcile.py (+8/-5)
bzrlib/tests/test_remote.py (+4/-4)
bzrlib/tests/test_selftest.py (+5/-8)
bzrlib/tests/test_sftp_transport.py (+4/-5)
bzrlib/tests/test_smart_request.py (+9/-7)
bzrlib/tests/test_transport_log.py (+3/-3)
bzrlib/tests/test_upgrade.py (+26/-26)
bzrlib/tests/test_workingtree.py (+2/-2)
bzrlib/textmerge.py (+1/-1)
bzrlib/transport/decorator.py (+5/-5)
bzrlib/transport/remote.py (+1/-1)
bzrlib/workingtree.py (+4/-5)
To merge this branch: bzr merge lp:~vila/bzr/cleanup
Reviewer Review Type Date Requested Status
John A Meinel Needs Fixing
Review via email: mp+28315@code.launchpad.net

This proposal supersedes a proposal from 2010-06-23.

Commit message

Cleanup tests importing get_transport.

Description of the change

This patch cleans a bunch of import in tests.
Most of them focus on get_transport being imported as a symbol which makes it impossible to wrap.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote : Posted in a previous version of this proposal

Oh, and it fixes some bugs in the http tests regarding parametrisation, no bugs in the code were uncovered though.

Revision history for this message
John A Meinel (jameinel) wrote :

There is a small regression in osutils, in that it will force-loading of 'shutil' always, rather than only when someone calls 'shutil.rmtree'.

I also have some gripes about test_http being hard to understand (it made it difficult to understand why this patch was ok). However I filed a bug on that (bug #597791) and doesn't need to block this patch.

So 'tweak', and land with a small fix to osutils.

review: Needs Fixing
Revision history for this message
John A Meinel (jameinel) wrote :

Marking as WIP for feed-pqm's sake. I'm not entirely happy with that status, because I'd really like to keep it more alive than WIP. (We tend to forget it exists once it is in WIP because it doesn't show up on the main page.)

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) 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 'bzrlib/_annotator_py.py'
--- bzrlib/_annotator_py.py 2010-06-04 03:09:35 +0000
+++ bzrlib/_annotator_py.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/add.py'
--- bzrlib/add.py 2010-06-21 21:50:57 +0000
+++ bzrlib/add.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2006 Canonical Ltd1# Copyright (C) 2005-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/annotate.py'
--- bzrlib/annotate.py 2010-06-04 03:09:35 +0000
+++ bzrlib/annotate.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Canonical Ltd1# Copyright (C) 2005-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/benchmarks/bench_commit.py'
--- bzrlib/benchmarks/bench_commit.py 2009-03-23 14:59:43 +0000
+++ bzrlib/benchmarks/bench_commit.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
2020
21from bzrlib.benchmarks import Benchmark21from bzrlib.benchmarks import Benchmark
22from bzrlib.transport.memory import MemoryServer22from bzrlib.transport.memory import MemoryServer
23from bzrlib.transport import get_transport
2423
2524
26class CommitBenchmark(Benchmark):25class CommitBenchmark(Benchmark):
2726
=== modified file 'bzrlib/breakin.py'
--- bzrlib/breakin.py 2010-06-02 04:50:35 +0000
+++ bzrlib/breakin.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006, 2007, 2009 Canonical Ltd1# Copyright (C) 2007, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/btree_index.py'
--- bzrlib/btree_index.py 2010-03-25 12:32:24 +0000
+++ bzrlib/btree_index.py 2010-06-29 17:48:31 +0000
@@ -33,9 +33,9 @@
33 osutils,33 osutils,
34 static_tuple,34 static_tuple,
35 trace,35 trace,
36 transport,
36 )37 )
37from bzrlib.index import _OPTION_NODE_REFS, _OPTION_KEY_ELEMENTS, _OPTION_LEN38from bzrlib.index import _OPTION_NODE_REFS, _OPTION_KEY_ELEMENTS, _OPTION_LEN
38from bzrlib.transport import get_transport
3939
4040
41_BTSIGNATURE = "B+Tree Graph Index 2\n"41_BTSIGNATURE = "B+Tree Graph Index 2\n"
@@ -193,7 +193,8 @@
193 new_backing_file, size = self._spill_mem_keys_without_combining()193 new_backing_file, size = self._spill_mem_keys_without_combining()
194 # Note: The transport here isn't strictly needed, because we will use194 # Note: The transport here isn't strictly needed, because we will use
195 # direct access to the new_backing._file object195 # direct access to the new_backing._file object
196 new_backing = BTreeGraphIndex(get_transport('.'), '<temp>', size)196 new_backing = BTreeGraphIndex(transport.get_transport('.'),
197 '<temp>', size)
197 # GC will clean up the file198 # GC will clean up the file
198 new_backing._file = new_backing_file199 new_backing._file = new_backing_file
199 if self._combine_backing_indices:200 if self._combine_backing_indices:
200201
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2010-06-17 08:53:15 +0000
+++ bzrlib/builtins.py 2010-06-29 17:48:31 +0000
@@ -4920,17 +4920,17 @@
49204920
4921 def run(self, port=None, inet=False, directory=None, allow_writes=False,4921 def run(self, port=None, inet=False, directory=None, allow_writes=False,
4922 protocol=None):4922 protocol=None):
4923 from bzrlib.transport import get_transport, transport_server_registry4923 from bzrlib import transport
4924 if directory is None:4924 if directory is None:
4925 directory = os.getcwd()4925 directory = os.getcwd()
4926 if protocol is None:4926 if protocol is None:
4927 protocol = transport_server_registry.get()4927 protocol = transport.transport_server_registry.get()
4928 host, port = self.get_host_and_port(port)4928 host, port = self.get_host_and_port(port)
4929 url = urlutils.local_path_to_url(directory)4929 url = urlutils.local_path_to_url(directory)
4930 if not allow_writes:4930 if not allow_writes:
4931 url = 'readonly+' + url4931 url = 'readonly+' + url
4932 transport = get_transport(url)4932 t = transport.get_transport(url)
4933 protocol(transport, host, port, inet)4933 protocol(t, host, port, inet)
49344934
49354935
4936class cmd_join(Command):4936class cmd_join(Command):
49374937
=== modified file 'bzrlib/filters/eol.py'
--- bzrlib/filters/eol.py 2010-06-02 04:56:07 +0000
+++ bzrlib/filters/eol.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/osutils.py'
--- bzrlib/osutils.py 2010-06-25 20:34:05 +0000
+++ bzrlib/osutils.py 2010-06-29 17:48:31 +0000
@@ -18,7 +18,6 @@
18import os18import os
19import re19import re
20import stat20import stat
21from stat import S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE
22import sys21import sys
23import time22import time
24import codecs23import codecs
@@ -27,23 +26,18 @@
27lazy_import(globals(), """26lazy_import(globals(), """
28from datetime import datetime27from datetime import datetime
29import getpass28import getpass
30from ntpath import (abspath as _nt_abspath,29import ntpath
31 join as _nt_join,
32 normpath as _nt_normpath,
33 realpath as _nt_realpath,
34 splitdrive as _nt_splitdrive,
35 )
36import posixpath30import posixpath
31# We need to import both shutil and rmtree as we export the later on posix
32# and need the former on windows
37import shutil33import shutil
38from shutil import (34from shutil import rmtree
39 rmtree,
40 )
41import socket35import socket
42import subprocess36import subprocess
37# We need to import both tempfile and mkdtemp as we export the later on posix
38# and need the former on windows
43import tempfile39import tempfile
44from tempfile import (40from tempfile import mkdtemp
45 mkdtemp,
46 )
47import unicodedata41import unicodedata
4842
49from bzrlib import (43from bzrlib import (
@@ -304,13 +298,13 @@
304 running python.exe under cmd.exe return capital C:\\298 running python.exe under cmd.exe return capital C:\\
305 running win32 python inside a cygwin shell returns lowercase c:\\299 running win32 python inside a cygwin shell returns lowercase c:\\
306 """300 """
307 drive, path = _nt_splitdrive(path)301 drive, path = ntpath.splitdrive(path)
308 return drive.upper() + path302 return drive.upper() + path
309303
310304
311def _win32_abspath(path):305def _win32_abspath(path):
312 # Real _nt_abspath doesn't have a problem with a unicode cwd306 # Real ntpath.abspath doesn't have a problem with a unicode cwd
313 return _win32_fixdrive(_nt_abspath(unicode(path)).replace('\\', '/'))307 return _win32_fixdrive(ntpath.abspath(unicode(path)).replace('\\', '/'))
314308
315309
316def _win98_abspath(path):310def _win98_abspath(path):
@@ -327,30 +321,30 @@
327 # /path => C:/path321 # /path => C:/path
328 path = unicode(path)322 path = unicode(path)
329 # check for absolute path323 # check for absolute path
330 drive = _nt_splitdrive(path)[0]324 drive = ntpath.splitdrive(path)[0]
331 if drive == '' and path[:2] not in('//','\\\\'):325 if drive == '' and path[:2] not in('//','\\\\'):
332 cwd = os.getcwdu()326 cwd = os.getcwdu()
333 # we cannot simply os.path.join cwd and path327 # we cannot simply os.path.join cwd and path
334 # because os.path.join('C:','/path') produce '/path'328 # because os.path.join('C:','/path') produce '/path'
335 # and this is incorrect329 # and this is incorrect
336 if path[:1] in ('/','\\'):330 if path[:1] in ('/','\\'):
337 cwd = _nt_splitdrive(cwd)[0]331 cwd = ntpath.splitdrive(cwd)[0]
338 path = path[1:]332 path = path[1:]
339 path = cwd + '\\' + path333 path = cwd + '\\' + path
340 return _win32_fixdrive(_nt_normpath(path).replace('\\', '/'))334 return _win32_fixdrive(ntpath.normpath(path).replace('\\', '/'))
341335
342336
343def _win32_realpath(path):337def _win32_realpath(path):
344 # Real _nt_realpath doesn't have a problem with a unicode cwd338 # Real ntpath.realpath doesn't have a problem with a unicode cwd
345 return _win32_fixdrive(_nt_realpath(unicode(path)).replace('\\', '/'))339 return _win32_fixdrive(ntpath.realpath(unicode(path)).replace('\\', '/'))
346340
347341
348def _win32_pathjoin(*args):342def _win32_pathjoin(*args):
349 return _nt_join(*args).replace('\\', '/')343 return ntpath.join(*args).replace('\\', '/')
350344
351345
352def _win32_normpath(path):346def _win32_normpath(path):
353 return _win32_fixdrive(_nt_normpath(unicode(path)).replace('\\', '/'))347 return _win32_fixdrive(ntpath.normpath(unicode(path)).replace('\\', '/'))
354348
355349
356def _win32_getcwd():350def _win32_getcwd():
@@ -358,7 +352,7 @@
358352
359353
360def _win32_mkdtemp(*args, **kwargs):354def _win32_mkdtemp(*args, **kwargs):
361 return _win32_fixdrive(tempfile.mkdtemp(*args, **kwargs).replace('\\', '/'))355 return _win32_fixdrive(mkdtemp(*args, **kwargs).replace('\\', '/'))
362356
363357
364def _win32_rename(old, new):358def _win32_rename(old, new):
@@ -395,7 +389,7 @@
395basename = os.path.basename389basename = os.path.basename
396split = os.path.split390split = os.path.split
397splitext = os.path.splitext391splitext = os.path.splitext
398# These were already imported into local scope392# These were already lazily imported into local scope
399# mkdtemp = tempfile.mkdtemp393# mkdtemp = tempfile.mkdtemp
400# rmtree = shutil.rmtree394# rmtree = shutil.rmtree
401395
@@ -509,7 +503,7 @@
509def isdir(f):503def isdir(f):
510 """True if f is an accessible directory."""504 """True if f is an accessible directory."""
511 try:505 try:
512 return S_ISDIR(os.lstat(f)[ST_MODE])506 return stat.S_ISDIR(os.lstat(f)[stat.ST_MODE])
513 except OSError:507 except OSError:
514 return False508 return False
515509
@@ -517,14 +511,14 @@
517def isfile(f):511def isfile(f):
518 """True if f is a regular file."""512 """True if f is a regular file."""
519 try:513 try:
520 return S_ISREG(os.lstat(f)[ST_MODE])514 return stat.S_ISREG(os.lstat(f)[stat.ST_MODE])
521 except OSError:515 except OSError:
522 return False516 return False
523517
524def islink(f):518def islink(f):
525 """True if f is a symlink."""519 """True if f is a symlink."""
526 try:520 try:
527 return S_ISLNK(os.lstat(f)[ST_MODE])521 return stat.S_ISLNK(os.lstat(f)[stat.ST_MODE])
528 except OSError:522 except OSError:
529 return False523 return False
530524
@@ -870,7 +864,7 @@
870864
871def filesize(f):865def filesize(f):
872 """Return size of given open file."""866 """Return size of given open file."""
873 return os.fstat(f.fileno())[ST_SIZE]867 return os.fstat(f.fileno())[stat.ST_SIZE]
874868
875869
876# Define rand_bytes based on platform.870# Define rand_bytes based on platform.
877871
=== modified file 'bzrlib/plugins/launchpad/account.py'
--- bzrlib/plugins/launchpad/account.py 2009-04-27 16:10:10 +0000
+++ bzrlib/plugins/launchpad/account.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2007, 2008 Canonical Ltd1# Copyright (C) 2007-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -20,9 +20,12 @@
20than once for each place that needs to take it into account.20than once for each place that needs to take it into account.
21"""21"""
2222
23from bzrlib import errors, trace23from bzrlib import (
24 errors,
25 trace,
26 transport,
27 )
24from bzrlib.config import AuthenticationConfig, GlobalConfig28from bzrlib.config import AuthenticationConfig, GlobalConfig
25from bzrlib.transport import get_transport
2629
2730
28LAUNCHPAD_BASE = 'https://launchpad.net/'31LAUNCHPAD_BASE = 'https://launchpad.net/'
@@ -97,7 +100,7 @@
97 uploaded SSH keys.100 uploaded SSH keys.
98 """101 """
99 if _transport is None:102 if _transport is None:
100 _transport = get_transport(LAUNCHPAD_BASE)103 _transport = transport.get_transport(LAUNCHPAD_BASE)
101104
102 try:105 try:
103 data = _transport.get_bytes('~%s/+sshkeys' % username)106 data = _transport.get_bytes('~%s/+sshkeys' % username)
104107
=== modified file 'bzrlib/plugins/launchpad/test_lp_directory.py'
--- bzrlib/plugins/launchpad/test_lp_directory.py 2010-05-20 18:23:10 +0000
+++ bzrlib/plugins/launchpad/test_lp_directory.py 2010-06-29 17:48:31 +0000
@@ -22,6 +22,7 @@
22from bzrlib import (22from bzrlib import (
23 errors,23 errors,
24 tests,24 tests,
25 transport,
25 )26 )
26from bzrlib.branch import Branch27from bzrlib.branch import Branch
27from bzrlib.directory_service import directories28from bzrlib.directory_service import directories
@@ -29,7 +30,6 @@
29 TestCaseInTempDir,30 TestCaseInTempDir,
30 TestCaseWithMemoryTransport31 TestCaseWithMemoryTransport
31)32)
32from bzrlib.transport import get_transport
33from bzrlib.plugins.launchpad import (33from bzrlib.plugins.launchpad import (
34 _register_directory,34 _register_directory,
35 lp_registration,35 lp_registration,
@@ -217,8 +217,8 @@
217 directories.register('lp:', FooService, 'Map lp URLs to local urls')217 directories.register('lp:', FooService, 'Map lp URLs to local urls')
218 self.addCleanup(_register_directory)218 self.addCleanup(_register_directory)
219 self.addCleanup(directories.remove, 'lp:')219 self.addCleanup(directories.remove, 'lp:')
220 transport = get_transport('lp:///apt')220 t = transport.get_transport('lp:///apt')
221 branch = Branch.open_from_transport(transport)221 branch = Branch.open_from_transport(t)
222 self.assertEqual(target_branch.base, branch.base)222 self.assertEqual(target_branch.base, branch.base)
223223
224224
225225
=== modified file 'bzrlib/symbol_versioning.py'
--- bzrlib/symbol_versioning.py 2010-06-25 06:11:21 +0000
+++ bzrlib/symbol_versioning.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2010-06-25 06:12:56 +0000
+++ bzrlib/tests/__init__.py 2010-06-29 17:48:31 +0000
@@ -29,7 +29,7 @@
2929
30import atexit30import atexit
31import codecs31import codecs
32from copy import copy32import copy
33from cStringIO import StringIO33from cStringIO import StringIO
34import difflib34import difflib
35import doctest35import doctest
@@ -37,12 +37,12 @@
37import logging37import logging
38import math38import math
39import os39import os
40from pprint import pformat40import pprint
41import random41import random
42import re42import re
43import shlex43import shlex
44import stat44import stat
45from subprocess import Popen, PIPE, STDOUT45import subprocess
46import sys46import sys
47import tempfile47import tempfile
48import threading48import threading
@@ -74,6 +74,7 @@
74 ui,74 ui,
75 urlutils,75 urlutils,
76 registry,76 registry,
77 transport as _mod_transport,
77 workingtree,78 workingtree,
78 )79 )
79import bzrlib.branch80import bzrlib.branch
@@ -103,11 +104,9 @@
103 )104 )
104import bzrlib.trace105import bzrlib.trace
105from bzrlib.transport import (106from bzrlib.transport import (
106 get_transport,
107 memory,107 memory,
108 pathfilter,108 pathfilter,
109 )109 )
110import bzrlib.transport
111from bzrlib.trace import mutter, note110from bzrlib.trace import mutter, note
112from bzrlib.tests import (111from bzrlib.tests import (
113 test_server,112 test_server,
@@ -943,7 +942,7 @@
943942
944 def permit_dir(self, name):943 def permit_dir(self, name):
945 """Permit a directory to be used by this test. See permit_url."""944 """Permit a directory to be used by this test. See permit_url."""
946 name_transport = get_transport(name)945 name_transport = _mod_transport.get_transport(name)
947 self.permit_url(name)946 self.permit_url(name)
948 self.permit_url(name_transport.base)947 self.permit_url(name_transport.base)
949948
@@ -1028,7 +1027,7 @@
1028 self.addCleanup(transport_server.stop_server)1027 self.addCleanup(transport_server.stop_server)
1029 # Obtain a real transport because if the server supplies a password, it1028 # Obtain a real transport because if the server supplies a password, it
1030 # will be hidden from the base on the client side.1029 # will be hidden from the base on the client side.
1031 t = get_transport(transport_server.get_url())1030 t = _mod_transport.get_transport(transport_server.get_url())
1032 # Some transport servers effectively chroot the backing transport;1031 # Some transport servers effectively chroot the backing transport;
1033 # others like SFTPServer don't - users of the transport can walk up the1032 # others like SFTPServer don't - users of the transport can walk up the
1034 # transport to read the entire backing transport. This wouldn't matter1033 # transport to read the entire backing transport. This wouldn't matter
@@ -1095,7 +1094,7 @@
1095 message += '\n'1094 message += '\n'
1096 raise AssertionError("%snot equal:\na = %s\nb = %s\n"1095 raise AssertionError("%snot equal:\na = %s\nb = %s\n"
1097 % (message,1096 % (message,
1098 pformat(a), pformat(b)))1097 pprint.pformat(a), pprint.pformat(b)))
10991098
1100 assertEquals = assertEqual1099 assertEquals = assertEqual
11011100
@@ -1986,7 +1985,9 @@
1986 if not allow_plugins:1985 if not allow_plugins:
1987 command.append('--no-plugins')1986 command.append('--no-plugins')
1988 command.extend(process_args)1987 command.extend(process_args)
1989 process = self._popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE)1988 process = self._popen(command, stdin=subprocess.PIPE,
1989 stdout=subprocess.PIPE,
1990 stderr=subprocess.PIPE)
1990 finally:1991 finally:
1991 restore_environment()1992 restore_environment()
1992 if cwd is not None:1993 if cwd is not None:
@@ -2000,7 +2001,7 @@
2000 Allows tests to override this method to intercept the calls made to2001 Allows tests to override this method to intercept the calls made to
2001 Popen for introspection.2002 Popen for introspection.
2002 """2003 """
2003 return Popen(*args, **kwargs)2004 return subprocess.Popen(*args, **kwargs)
20042005
2005 def get_source_path(self):2006 def get_source_path(self):
2006 """Return the path of the directory containing bzrlib."""2007 """Return the path of the directory containing bzrlib."""
@@ -2186,7 +2187,7 @@
21862187
2187 :param relpath: a path relative to the base url.2188 :param relpath: a path relative to the base url.
2188 """2189 """
2189 t = get_transport(self.get_url(relpath))2190 t = _mod_transport.get_transport(self.get_url(relpath))
2190 self.assertFalse(t.is_readonly())2191 self.assertFalse(t.is_readonly())
2191 return t2192 return t
21922193
@@ -2198,7 +2199,7 @@
21982199
2199 :param relpath: a path relative to the base url.2200 :param relpath: a path relative to the base url.
2200 """2201 """
2201 t = get_transport(self.get_readonly_url(relpath))2202 t = _mod_transport.get_transport(self.get_readonly_url(relpath))
2202 self.assertTrue(t.is_readonly())2203 self.assertTrue(t.is_readonly())
2203 return t2204 return t
22042205
@@ -2334,7 +2335,7 @@
2334 propagating. This method ensures than a test did not leaked.2335 propagating. This method ensures than a test did not leaked.
2335 """2336 """
2336 root = TestCaseWithMemoryTransport.TEST_ROOT2337 root = TestCaseWithMemoryTransport.TEST_ROOT
2337 self.permit_url(get_transport(root).base)2338 self.permit_url(_mod_transport.get_transport(root).base)
2338 wt = workingtree.WorkingTree.open(root)2339 wt = workingtree.WorkingTree.open(root)
2339 last_rev = wt.last_revision()2340 last_rev = wt.last_revision()
2340 if last_rev != 'null:':2341 if last_rev != 'null:':
@@ -2385,7 +2386,7 @@
2385 # might be a relative or absolute path2386 # might be a relative or absolute path
2386 maybe_a_url = self.get_url(relpath)2387 maybe_a_url = self.get_url(relpath)
2387 segments = maybe_a_url.rsplit('/', 1)2388 segments = maybe_a_url.rsplit('/', 1)
2388 t = get_transport(maybe_a_url)2389 t = _mod_transport.get_transport(maybe_a_url)
2389 if len(segments) > 1 and segments[-1] not in ('', '.'):2390 if len(segments) > 1 and segments[-1] not in ('', '.'):
2390 t.ensure_base()2391 t.ensure_base()
2391 if format is None:2392 if format is None:
@@ -2413,7 +2414,8 @@
2413 backing_server = self.get_server()2414 backing_server = self.get_server()
2414 smart_server = test_server.SmartTCPServer_for_testing()2415 smart_server = test_server.SmartTCPServer_for_testing()
2415 self.start_server(smart_server, backing_server)2416 self.start_server(smart_server, backing_server)
2416 remote_transport = get_transport(smart_server.get_url()).clone(path)2417 remote_transport = _mod_transport.get_transport(smart_server.get_url()
2418 ).clone(path)
2417 return remote_transport2419 return remote_transport
24182420
2419 def make_branch_and_memory_tree(self, relpath, format=None):2421 def make_branch_and_memory_tree(self, relpath, format=None):
@@ -2568,7 +2570,7 @@
2568 "a list or a tuple. Got %r instead" % (shape,))2570 "a list or a tuple. Got %r instead" % (shape,))
2569 # It's OK to just create them using forward slashes on windows.2571 # It's OK to just create them using forward slashes on windows.
2570 if transport is None or transport.is_readonly():2572 if transport is None or transport.is_readonly():
2571 transport = get_transport(".")2573 transport = _mod_transport.get_transport(".")
2572 for name in shape:2574 for name in shape:
2573 self.assertIsInstance(name, basestring)2575 self.assertIsInstance(name, basestring)
2574 if name[-1] == '/':2576 if name[-1] == '/':
@@ -3315,10 +3317,12 @@
3315 '--subunit']3317 '--subunit']
3316 if '--no-plugins' in sys.argv:3318 if '--no-plugins' in sys.argv:
3317 argv.append('--no-plugins')3319 argv.append('--no-plugins')
3318 # stderr=STDOUT would be ideal, but until we prevent noise on3320 # stderr=subprocess.STDOUT would be ideal, but until we prevent
3319 # stderr it can interrupt the subunit protocol.3321 # noise on stderr it can interrupt the subunit protocol.
3320 process = Popen(argv, stdin=PIPE, stdout=PIPE, stderr=PIPE,3322 process = subprocess.Popen(argv, stdin=subprocess.PIPE,
3321 bufsize=1)3323 stdout=subprocess.PIPE,
3324 stderr=subprocess.PIPE,
3325 bufsize=1)
3322 test = TestInSubprocess(process, test_list_file_name)3326 test = TestInSubprocess(process, test_list_file_name)
3323 result.append(test)3327 result.append(test)
3324 except:3328 except:
@@ -4043,7 +4047,7 @@
4043 :param new_id: The id to assign to it.4047 :param new_id: The id to assign to it.
4044 :return: The new test.4048 :return: The new test.
4045 """4049 """
4046 new_test = copy(test)4050 new_test = copy.copy(test)
4047 new_test.id = lambda: new_id4051 new_test.id = lambda: new_id
4048 return new_test4052 return new_test
40494053
40504054
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- bzrlib/tests/blackbox/__init__.py 2010-06-20 22:38:35 +0000
+++ bzrlib/tests/blackbox/__init__.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005-2007, 2010 Canonical Ltd1# Copyright (C) 2005-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_alias.py'
--- bzrlib/tests/blackbox/test_alias.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_alias.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2006, 2007 Canonical Ltd1# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_aliases.py'
--- bzrlib/tests/blackbox/test_aliases.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_aliases.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2006 Canonical Ltd1# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_cat_revision.py'
--- bzrlib/tests/blackbox/test_cat_revision.py 2010-06-11 06:52:28 +0000
+++ bzrlib/tests/blackbox/test_cat_revision.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2004-2010 Canonical Ltd1# Copyright (C) 2007-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_check.py'
--- bzrlib/tests/blackbox/test_check.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_check.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2007, 2009 Canonical Ltd1# Copyright (C) 2007-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_dpush.py'
--- bzrlib/tests/blackbox/test_dpush.py 2010-06-20 22:38:35 +0000
+++ bzrlib/tests/blackbox/test_dpush.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2007-2010 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_filesystem_cicp.py'
--- bzrlib/tests/blackbox/test_filesystem_cicp.py 2010-06-11 07:23:10 +0000
+++ bzrlib/tests/blackbox/test_filesystem_cicp.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2008, 2010 Canonical Ltd1# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_find_merge_base.py'
--- bzrlib/tests/blackbox/test_find_merge_base.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_find_merge_base.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005 Canonical Ltd1# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# This program is free software; you can redistribute it and/or modify4# This program is free software; you can redistribute it and/or modify
55
=== modified file 'bzrlib/tests/blackbox/test_ignored.py'
--- bzrlib/tests/blackbox/test_ignored.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_ignored.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006-2010 Canonical Ltd1# Copyright (C) 2006, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_merge_directive.py'
--- bzrlib/tests/blackbox/test_merge_directive.py 2010-05-28 14:15:28 +0000
+++ bzrlib/tests/blackbox/test_merge_directive.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2007 Canonical Ltd1# Copyright (C) 2007, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_missing.py'
--- bzrlib/tests/blackbox/test_missing.py 2010-05-28 14:15:28 +0000
+++ bzrlib/tests/blackbox/test_missing.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2008 Canonical Ltd1# Copyright (C) 2005-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_modified.py'
--- bzrlib/tests/blackbox/test_modified.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_modified.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006-2010 Canonical Ltd1# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# This program is free software; you can redistribute it and/or modify4# This program is free software; you can redistribute it and/or modify
55
=== modified file 'bzrlib/tests/blackbox/test_nick.py'
--- bzrlib/tests/blackbox/test_nick.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_nick.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005-2010 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_remove.py'
--- bzrlib/tests/blackbox/test_remove.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_remove.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2006 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_remove_tree.py'
--- bzrlib/tests/blackbox/test_remove_tree.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_remove_tree.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_revert.py'
--- bzrlib/tests/blackbox/test_revert.py 2010-06-11 07:32:12 +0000
+++ bzrlib/tests/blackbox/test_revert.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2007 Canonical Ltd1# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_revision_info.py'
--- bzrlib/tests/blackbox/test_revision_info.py 2010-06-20 22:38:35 +0000
+++ bzrlib/tests/blackbox/test_revision_info.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2004-2005, 2009-2010 Canonical Ltd1# Copyright (C) 2005-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- bzrlib/tests/blackbox/test_serve.py 2010-02-17 17:11:16 +0000
+++ bzrlib/tests/blackbox/test_serve.py 2010-06-29 17:48:31 +0000
@@ -31,6 +31,7 @@
31 errors,31 errors,
32 osutils,32 osutils,
33 revision as _mod_revision,33 revision as _mod_revision,
34 transport,
34 urlutils,35 urlutils,
35 )36 )
36from bzrlib.branch import Branch37from bzrlib.branch import Branch
@@ -43,7 +44,7 @@
43 TestSkipped,44 TestSkipped,
44 )45 )
45from bzrlib.trace import mutter46from bzrlib.trace import mutter
46from bzrlib.transport import get_transport, remote47from bzrlib.transport import remote
4748
4849
49class TestBzrServeBase(TestCaseWithTransport):50class TestBzrServeBase(TestCaseWithTransport):
@@ -192,8 +193,8 @@
192 def test_bzr_serve_port_readonly(self):193 def test_bzr_serve_port_readonly(self):
193 """bzr server should provide a read only filesystem by default."""194 """bzr server should provide a read only filesystem by default."""
194 process, url = self.start_server_port()195 process, url = self.start_server_port()
195 transport = get_transport(url)196 t = transport.get_transport(url)
196 self.assertRaises(errors.TransportNotPossible, transport.mkdir, 'adir')197 self.assertRaises(errors.TransportNotPossible, t.mkdir, 'adir')
197 self.assertServerFinishesCleanly(process)198 self.assertServerFinishesCleanly(process)
198199
199 def test_bzr_serve_port_readwrite(self):200 def test_bzr_serve_port_readwrite(self):
200201
=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- bzrlib/tests/blackbox/test_upgrade.py 2010-04-16 07:56:51 +0000
+++ bzrlib/tests/blackbox/test_upgrade.py 2010-06-29 17:48:31 +0000
@@ -21,6 +21,7 @@
21from bzrlib import (21from bzrlib import (
22 bzrdir,22 bzrdir,
23 repository,23 repository,
24 transport,
24 )25 )
25from bzrlib.tests import (26from bzrlib.tests import (
26 features,27 features,
@@ -28,7 +29,6 @@
28 TestCaseWithTransport,29 TestCaseWithTransport,
29 )30 )
30from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer31from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
31from bzrlib.transport import get_transport
32from bzrlib.repofmt.knitrepo import (32from bzrlib.repofmt.knitrepo import (
33 RepositoryFormatKnit1,33 RepositoryFormatKnit1,
34 )34 )
@@ -79,7 +79,8 @@
79 (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)79 (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
80 self.assertEqual("This is a checkout. The branch (%s) needs to be "80 self.assertEqual("This is a checkout. The branch (%s) needs to be "
81 "upgraded separately.\n"81 "upgraded separately.\n"
82 % get_transport(self.get_url('current_format_branch')).base,82 % transport.get_transport(
83 self.get_url('current_format_branch')).base,
83 out)84 out)
84 self.assertEqualDiff("bzr: ERROR: The branch format Meta "85 self.assertEqualDiff("bzr: ERROR: The branch format Meta "
85 "directory format 1 is already at the most "86 "directory format 1 is already at the most "
@@ -101,7 +102,7 @@
101 def test_upgrade_explicit_metaformat(self):102 def test_upgrade_explicit_metaformat(self):
102 # users can force an upgrade to metadir format.103 # users can force an upgrade to metadir format.
103 self.make_format_5_branch()104 self.make_format_5_branch()
104 url = get_transport(self.get_url('format_5_branch')).base105 url = transport.get_transport(self.get_url('format_5_branch')).base
105 # check --format takes effect106 # check --format takes effect
106 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())107 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
107 backup_dir = 'backup.bzr.~1~'108 backup_dir = 'backup.bzr.~1~'
@@ -125,7 +126,7 @@
125 # users can force an upgrade to knit format from a metadir weave126 # users can force an upgrade to knit format from a metadir weave
126 # branch127 # branch
127 self.make_metadir_weave_branch()128 self.make_metadir_weave_branch()
128 url = get_transport(self.get_url('metadir_weave_branch')).base129 url = transport.get_transport(self.get_url('metadir_weave_branch')).base
129 # check --format takes effect130 # check --format takes effect
130 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())131 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
131 backup_dir = 'backup.bzr.~1~'132 backup_dir = 'backup.bzr.~1~'
@@ -163,14 +164,14 @@
163164
164 def test_upgrade_with_existing_backup_dir(self):165 def test_upgrade_with_existing_backup_dir(self):
165 self.make_format_5_branch()166 self.make_format_5_branch()
166 transport = get_transport(self.get_url('format_5_branch'))167 t = transport.get_transport(self.get_url('format_5_branch'))
167 url = transport.base168 url = t.base
168 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())169 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
169 backup_dir1 = 'backup.bzr.~1~'170 backup_dir1 = 'backup.bzr.~1~'
170 backup_dir2 = 'backup.bzr.~2~'171 backup_dir2 = 'backup.bzr.~2~'
171 # explicitly create backup_dir1. bzr should create the .~2~ directory172 # explicitly create backup_dir1. bzr should create the .~2~ directory
172 # as backup173 # as backup
173 transport.mkdir(backup_dir1)174 t.mkdir(backup_dir1)
174 (out, err) = self.run_bzr(175 (out, err) = self.run_bzr(
175 ['upgrade', '--format=metaweave', url])176 ['upgrade', '--format=metaweave', url])
176 self.assertEqualDiff("""starting upgrade of %s177 self.assertEqualDiff("""starting upgrade of %s
@@ -186,14 +187,14 @@
186 self.assertTrue(isinstance(187 self.assertTrue(isinstance(
187 bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,188 bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
188 bzrdir.BzrDirMetaFormat1))189 bzrdir.BzrDirMetaFormat1))
189 self.assertTrue(transport.has(backup_dir2))190 self.assertTrue(t.has(backup_dir2))
190191
191class SFTPTests(TestCaseWithSFTPServer):192class SFTPTests(TestCaseWithSFTPServer):
192 """Tests for upgrade over sftp."""193 """Tests for upgrade over sftp."""
193194
194 def test_upgrade_url(self):195 def test_upgrade_url(self):
195 self.run_bzr('init --format=weave')196 self.run_bzr('init --format=weave')
196 t = get_transport(self.get_url())197 t = transport.get_transport(self.get_url())
197 url = t.base198 url = t.base
198 out, err = self.run_bzr(['upgrade', '--format=knit', url])199 out, err = self.run_bzr(['upgrade', '--format=knit', url])
199 backup_dir = 'backup.bzr.~1~'200 backup_dir = 'backup.bzr.~1~'
200201
=== modified file 'bzrlib/tests/blackbox/test_whoami.py'
--- bzrlib/tests/blackbox/test_whoami.py 2010-06-20 22:54:30 +0000
+++ bzrlib/tests/blackbox/test_whoami.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/http_utils.py'
--- bzrlib/tests/http_utils.py 2010-02-17 17:11:16 +0000
+++ bzrlib/tests/http_utils.py 2010-06-29 17:48:31 +0000
@@ -106,10 +106,20 @@
106 one. This will currently fail if the primary transport is not106 one. This will currently fail if the primary transport is not
107 backed by regular disk files.107 backed by regular disk files.
108 """108 """
109
110 # This can be overriden or parametrized by daughter clasess if needed, but
111 # it must exist so that the create_transport_readonly_server() method can
112 # propagate it.
113 _protocol_version = None
114
109 def setUp(self):115 def setUp(self):
110 super(TestCaseWithWebserver, self).setUp()116 super(TestCaseWithWebserver, self).setUp()
111 self.transport_readonly_server = http_server.HttpServer117 self.transport_readonly_server = http_server.HttpServer
112118
119 def create_transport_readonly_server(self):
120 return self.transport_readonly_server(
121 protocol_version=self._protocol_version)
122
113123
114class TestCaseWithTwoWebservers(TestCaseWithWebserver):124class TestCaseWithTwoWebservers(TestCaseWithWebserver):
115 """A support class providing readonly urls on two servers that are http://.125 """A support class providing readonly urls on two servers that are http://.
@@ -127,7 +137,8 @@
127137
128 This is mostly a hook for daughter classes.138 This is mostly a hook for daughter classes.
129 """139 """
130 return self.transport_secondary_server()140 return self.transport_secondary_server(
141 protocol_version=self._protocol_version)
131142
132 def get_secondary_server(self):143 def get_secondary_server(self):
133 """Get the server instance for the secondary transport."""144 """Get the server instance for the secondary transport."""
@@ -218,7 +229,8 @@
218 def create_transport_secondary_server(self):229 def create_transport_secondary_server(self):
219 """Create the secondary server redirecting to the primary server"""230 """Create the secondary server redirecting to the primary server"""
220 new = self.get_readonly_server()231 new = self.get_readonly_server()
221 redirecting = HTTPServerRedirecting()232 redirecting = HTTPServerRedirecting(
233 protocol_version=self._protocol_version)
222 redirecting.redirect_to(new.host, new.port)234 redirecting.redirect_to(new.host, new.port)
223 return redirecting235 return redirecting
224236
225237
=== modified file 'bzrlib/tests/per_branch/test_bound_sftp.py'
--- bzrlib/tests/per_branch/test_bound_sftp.py 2010-02-11 09:27:55 +0000
+++ bzrlib/tests/per_branch/test_bound_sftp.py 2010-06-29 17:48:31 +0000
@@ -144,13 +144,13 @@
144 wt_child2.commit, 'child2', rev_id='r@d-2')144 wt_child2.commit, 'child2', rev_id='r@d-2')
145145
146 def test_unbinding(self):146 def test_unbinding(self):
147 from bzrlib.transport import get_transport147 from bzrlib import transport
148 b_base, wt_child = self.create_branches()148 b_base, wt_child = self.create_branches()
149149
150 # TestCaseWithSFTPServer only allows you to connect one time150 # TestCaseWithSFTPServer only allows you to connect one time
151 # to the SFTP server. So we have to create a connection and151 # to the SFTP server. So we have to create a connection and
152 # keep it around, so that it can be reused152 # keep it around, so that it can be reused
153 __unused_t = get_transport(self.get_url('.'))153 __unused_t = transport.get_transport(self.get_url('.'))
154154
155 wt_base = b_base.bzrdir.open_workingtree()155 wt_base = b_base.bzrdir.open_workingtree()
156 open('base/a', 'wb').write('new base contents\n')156 open('base/a', 'wb').write('new base contents\n')
157157
=== modified file 'bzrlib/tests/per_branch/test_permissions.py'
--- bzrlib/tests/per_branch/test_permissions.py 2009-09-07 08:46:00 +0000
+++ bzrlib/tests/per_branch/test_permissions.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2008 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -38,7 +38,6 @@
38from bzrlib.remote import RemoteBranchFormat38from bzrlib.remote import RemoteBranchFormat
39from bzrlib.tests.test_permissions import chmod_r, check_mode_r39from bzrlib.tests.test_permissions import chmod_r, check_mode_r
40from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer40from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
41from bzrlib.transport import get_transport
42from bzrlib.workingtree import WorkingTree41from bzrlib.workingtree import WorkingTree
4342
4443
4544
=== modified file 'bzrlib/tests/per_branch/test_stacking.py'
--- bzrlib/tests/per_branch/test_stacking.py 2009-08-20 04:09:58 +0000
+++ bzrlib/tests/per_branch/test_stacking.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2008 Canonical Ltd1# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -26,7 +26,6 @@
26from bzrlib.smart import server26from bzrlib.smart import server
27from bzrlib.tests import TestNotApplicable, KnownFailure, transport_util27from bzrlib.tests import TestNotApplicable, KnownFailure, transport_util
28from bzrlib.tests.per_branch import TestCaseWithBranch28from bzrlib.tests.per_branch import TestCaseWithBranch
29from bzrlib.transport import get_transport
3029
3130
32unstackable_format_errors = (31unstackable_format_errors = (
3332
=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
--- bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-06-24 06:29:40 +0000
+++ bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-06-29 17:48:31 +0000
@@ -55,7 +55,6 @@
55 )55 )
56from bzrlib.tests.per_bzrdir import TestCaseWithBzrDir56from bzrlib.tests.per_bzrdir import TestCaseWithBzrDir
57from bzrlib.trace import mutter57from bzrlib.trace import mutter
58from bzrlib.transport import get_transport
59from bzrlib.transport.local import LocalTransport58from bzrlib.transport.local import LocalTransport
60from bzrlib.ui import (59from bzrlib.ui import (
61 CannedInputUIFactory,60 CannedInputUIFactory,
@@ -202,7 +201,7 @@
202 A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into201 A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
203 TestSkipped. Returns the newly sprouted bzrdir.202 TestSkipped. Returns the newly sprouted bzrdir.
204 """203 """
205 to_transport = get_transport(to_url)204 to_transport = transport.get_transport(to_url)
206 if not isinstance(to_transport, LocalTransport):205 if not isinstance(to_transport, LocalTransport):
207 raise TestSkipped('Cannot sprout to remote bzrdirs.')206 raise TestSkipped('Cannot sprout to remote bzrdirs.')
208 target = from_bzrdir.sprout(to_url, revision_id=revision_id,207 target = from_bzrdir.sprout(to_url, revision_id=revision_id,
@@ -1206,8 +1205,8 @@
1206 '_network_name', None),1205 '_network_name', None),
1207 None)1206 None)
1208 # supported formats must be able to init and open1207 # supported formats must be able to init and open
1209 t = get_transport(self.get_url())1208 t = transport.get_transport(self.get_url())
1210 readonly_t = get_transport(self.get_readonly_url())1209 readonly_t = transport.get_transport(self.get_readonly_url())
1211 made_control = self.bzrdir_format.initialize(t.base)1210 made_control = self.bzrdir_format.initialize(t.base)
1212 self.failUnless(isinstance(made_control, bzrdir.BzrDir))1211 self.failUnless(isinstance(made_control, bzrdir.BzrDir))
1213 self.assertEqual(self.bzrdir_format,1212 self.assertEqual(self.bzrdir_format,
@@ -1417,7 +1416,7 @@
1417 # test the formats specific behaviour for no-content or similar dirs.1416 # test the formats specific behaviour for no-content or similar dirs.
1418 self.assertRaises(NotBranchError,1417 self.assertRaises(NotBranchError,
1419 self.bzrdir_format.open,1418 self.bzrdir_format.open,
1420 get_transport(self.get_readonly_url()))1419 transport.get_transport(self.get_readonly_url()))
14211420
1422 def test_create_branch(self):1421 def test_create_branch(self):
1423 # a bzrdir can construct a branch and repository for itself.1422 # a bzrdir can construct a branch and repository for itself.
@@ -1426,7 +1425,7 @@
1426 # because the default open will not open them and1425 # because the default open will not open them and
1427 # they may not be initializable.1426 # they may not be initializable.
1428 return1427 return
1429 t = get_transport(self.get_url())1428 t = transport.get_transport(self.get_url())
1430 made_control = self.bzrdir_format.initialize(t.base)1429 made_control = self.bzrdir_format.initialize(t.base)
1431 made_repo = made_control.create_repository()1430 made_repo = made_control.create_repository()
1432 made_branch = made_control.create_branch()1431 made_branch = made_control.create_branch()
@@ -1439,7 +1438,7 @@
1439 # because the default open will not open them and1438 # because the default open will not open them and
1440 # they may not be initializable.1439 # they may not be initializable.
1441 return1440 return
1442 t = get_transport(self.get_url())1441 t = transport.get_transport(self.get_url())
1443 made_control = self.bzrdir_format.initialize(t.base)1442 made_control = self.bzrdir_format.initialize(t.base)
1444 made_repo = made_control.create_repository()1443 made_repo = made_control.create_repository()
1445 made_branch = made_control.create_branch()1444 made_branch = made_control.create_branch()
@@ -1454,7 +1453,7 @@
1454 # because the default open will not open them and1453 # because the default open will not open them and
1455 # they may not be initializable.1454 # they may not be initializable.
1456 return1455 return
1457 t = get_transport(self.get_url())1456 t = transport.get_transport(self.get_url())
1458 made_control = self.bzrdir_format.initialize(t.base)1457 made_control = self.bzrdir_format.initialize(t.base)
1459 made_repo = made_control.create_repository()1458 made_repo = made_control.create_repository()
1460 made_branch = made_control.create_branch()1459 made_branch = made_control.create_branch()
@@ -1475,7 +1474,7 @@
1475 # because the default open will not open them and1474 # because the default open will not open them and
1476 # they may not be initializable.1475 # they may not be initializable.
1477 return1476 return
1478 t = get_transport(self.get_url())1477 t = transport.get_transport(self.get_url())
1479 made_control = self.bzrdir_format.initialize(t.base)1478 made_control = self.bzrdir_format.initialize(t.base)
1480 made_repo = made_control.create_repository()1479 made_repo = made_control.create_repository()
1481 # Check that we have a repository object.1480 # Check that we have a repository object.
@@ -1490,7 +1489,7 @@
1490 # because the default open will not open them and1489 # because the default open will not open them and
1491 # they may not be initializable.1490 # they may not be initializable.
1492 return1491 return
1493 t = get_transport(self.get_url())1492 t = transport.get_transport(self.get_url())
1494 made_control = self.bzrdir_format.initialize(t.base)1493 made_control = self.bzrdir_format.initialize(t.base)
1495 try:1494 try:
1496 made_repo = made_control.create_repository(shared=True)1495 made_repo = made_control.create_repository(shared=True)
@@ -1507,7 +1506,7 @@
1507 # because the default open will not open them and1506 # because the default open will not open them and
1508 # they may not be initializable.1507 # they may not be initializable.
1509 return1508 return
1510 t = get_transport(self.get_url())1509 t = transport.get_transport(self.get_url())
1511 made_control = self.bzrdir_format.initialize(t.base)1510 made_control = self.bzrdir_format.initialize(t.base)
1512 made_repo = made_control.create_repository(shared=False)1511 made_repo = made_control.create_repository(shared=False)
1513 self.assertFalse(made_repo.is_shared())1512 self.assertFalse(made_repo.is_shared())
@@ -1518,7 +1517,7 @@
1518 # because the default open will not open them and1517 # because the default open will not open them and
1519 # they may not be initializable.1518 # they may not be initializable.
1520 return1519 return
1521 t = get_transport(self.get_url())1520 t = transport.get_transport(self.get_url())
1522 made_control = self.bzrdir_format.initialize(t.base)1521 made_control = self.bzrdir_format.initialize(t.base)
1523 made_repo = made_control.create_repository()1522 made_repo = made_control.create_repository()
1524 opened_repo = made_control.open_repository()1523 opened_repo = made_control.open_repository()
@@ -1646,7 +1645,7 @@
1646 def test_root_transport(self):1645 def test_root_transport(self):
1647 dir = self.make_bzrdir('.')1646 dir = self.make_bzrdir('.')
1648 self.assertEqual(dir.root_transport.base,1647 self.assertEqual(dir.root_transport.base,
1649 get_transport(self.get_url('.')).base)1648 transport.get_transport(self.get_url('.')).base)
16501649
1651 def test_find_repository_no_repo_under_standalone_branch(self):1650 def test_find_repository_no_repo_under_standalone_branch(self):
1652 # finding a repo stops at standalone branches even if there is a1651 # finding a repo stops at standalone branches even if there is a
@@ -1657,8 +1656,8 @@
1657 # need a shared repository to test this.1656 # need a shared repository to test this.
1658 return1657 return
1659 url = self.get_url('intermediate')1658 url = self.get_url('intermediate')
1660 get_transport(self.get_url()).mkdir('intermediate')1659 transport.get_transport(self.get_url()).mkdir('intermediate')
1661 get_transport(self.get_url()).mkdir('intermediate/child')1660 transport.get_transport(self.get_url()).mkdir('intermediate/child')
1662 made_control = self.bzrdir_format.initialize(url)1661 made_control = self.bzrdir_format.initialize(url)
1663 made_control.create_repository()1662 made_control.create_repository()
1664 innermost_control = self.bzrdir_format.initialize(1663 innermost_control = self.bzrdir_format.initialize(
@@ -1682,7 +1681,7 @@
1682 # need a shared repository to test this.1681 # need a shared repository to test this.
1683 return1682 return
1684 url = self.get_url('childbzrdir')1683 url = self.get_url('childbzrdir')
1685 get_transport(self.get_url()).mkdir('childbzrdir')1684 transport.get_transport(self.get_url()).mkdir('childbzrdir')
1686 made_control = self.bzrdir_format.initialize(url)1685 made_control = self.bzrdir_format.initialize(url)
1687 try:1686 try:
1688 child_repo = made_control.open_repository()1687 child_repo = made_control.open_repository()
@@ -1716,7 +1715,7 @@
1716 # need a shared repository to test this.1715 # need a shared repository to test this.
1717 return1716 return
1718 url = self.get_url('childrepo')1717 url = self.get_url('childrepo')
1719 get_transport(self.get_url()).mkdir('childrepo')1718 transport.get_transport(self.get_url()).mkdir('childrepo')
1720 child_control = self.bzrdir_format.initialize(url)1719 child_control = self.bzrdir_format.initialize(url)
1721 child_repo = child_control.create_repository(shared=True)1720 child_repo = child_control.create_repository(shared=True)
1722 opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))1721 opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
@@ -1735,8 +1734,8 @@
1735 # need a shared repository to test this.1734 # need a shared repository to test this.
1736 return1735 return
1737 url = self.get_url('intermediate')1736 url = self.get_url('intermediate')
1738 get_transport(self.get_url()).mkdir('intermediate')1737 transport.get_transport(self.get_url()).mkdir('intermediate')
1739 get_transport(self.get_url()).mkdir('intermediate/child')1738 transport.get_transport(self.get_url()).mkdir('intermediate/child')
1740 made_control = self.bzrdir_format.initialize(url)1739 made_control = self.bzrdir_format.initialize(url)
1741 try:1740 try:
1742 child_repo = made_control.open_repository()1741 child_repo = made_control.open_repository()
@@ -1981,7 +1980,7 @@
1981 # - do the vfs initialisation over the basic vfs transport1980 # - do the vfs initialisation over the basic vfs transport
1982 # XXX: TODO this should become a 'bzrdirlocation' api call.1981 # XXX: TODO this should become a 'bzrdirlocation' api call.
1983 url = self.get_vfs_only_url('subdir')1982 url = self.get_vfs_only_url('subdir')
1984 get_transport(self.get_vfs_only_url()).mkdir('subdir')1983 transport.get_transport(self.get_vfs_only_url()).mkdir('subdir')
1985 made_control = self.bzrdir_format.initialize(self.get_url('subdir'))1984 made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1986 try:1985 try:
1987 repo = made_control.open_repository()1986 repo = made_control.open_repository()
@@ -1997,7 +1996,7 @@
19971996
1998class TestBzrDirControlComponent(TestCaseWithBzrDir):1997class TestBzrDirControlComponent(TestCaseWithBzrDir):
1999 """BzrDir implementations adequately implement ControlComponent."""1998 """BzrDir implementations adequately implement ControlComponent."""
2000 1999
2001 def test_urls(self):2000 def test_urls(self):
2002 bd = self.make_bzrdir('bd')2001 bd = self.make_bzrdir('bd')
2003 self.assertIsInstance(bd.user_url, str)2002 self.assertIsInstance(bd.user_url, str)
20042003
=== modified file 'bzrlib/tests/per_interbranch/__init__.py'
--- bzrlib/tests/per_interbranch/__init__.py 2010-06-16 08:17:50 +0000
+++ bzrlib/tests/per_interbranch/__init__.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# This program is free software; you can redistribute it and/or modify4# This program is free software; you can redistribute it and/or modify
@@ -46,7 +46,6 @@
46 TestCaseWithTransport,46 TestCaseWithTransport,
47 multiply_tests,47 multiply_tests,
48 )48 )
49from bzrlib.transport import get_transport
5049
5150
52def make_scenarios(test_list):51def make_scenarios(test_list):
5352
=== modified file 'bzrlib/tests/per_interbranch/test_pull.py'
--- bzrlib/tests/per_interbranch/test_pull.py 2010-06-14 06:37:11 +0000
+++ bzrlib/tests/per_interbranch/test_pull.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2004, 2005, 2007, 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/per_interbranch/test_push.py'
--- bzrlib/tests/per_interbranch/test_push.py 2010-06-24 08:16:36 +0000
+++ bzrlib/tests/per_interbranch/test_push.py 2010-06-29 17:48:31 +0000
@@ -44,7 +44,6 @@
44from bzrlib.tests.per_interbranch import (44from bzrlib.tests.per_interbranch import (
45 TestCaseWithInterBranch,45 TestCaseWithInterBranch,
46 )46 )
47from bzrlib.transport import get_transport
48from bzrlib.tests import test_server47from bzrlib.tests import test_server
4948
5049
5150
=== modified file 'bzrlib/tests/per_interbranch/test_update_revisions.py'
--- bzrlib/tests/per_interbranch/test_update_revisions.py 2010-06-17 06:30:22 +0000
+++ bzrlib/tests/per_interbranch/test_update_revisions.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/per_interrepository/__init__.py'
--- bzrlib/tests/per_interrepository/__init__.py 2009-08-14 01:07:44 +0000
+++ bzrlib/tests/per_interrepository/__init__.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2# Authors: Robert Collins <robert.collins@canonical.com>2# Authors: Robert Collins <robert.collins@canonical.com>
3# -*- coding: utf-8 -*-3# -*- coding: utf-8 -*-
4#4#
@@ -26,6 +26,7 @@
26"""26"""
2727
2828
29from bzrlib import transport
29from bzrlib.errors import (30from bzrlib.errors import (
30 FileExists,31 FileExists,
31 UninitializableFormat,32 UninitializableFormat,
@@ -39,7 +40,6 @@
39 multiply_tests,40 multiply_tests,
40 )41 )
41from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir42from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
42from bzrlib.transport import get_transport
4343
4444
45def make_scenarios(transport_server, transport_readonly_server, formats):45def make_scenarios(transport_server, transport_readonly_server, formats):
@@ -143,7 +143,7 @@
143 segments = url.split('/')143 segments = url.split('/')
144 if segments and segments[-1] not in ('', '.'):144 if segments and segments[-1] not in ('', '.'):
145 parent = '/'.join(segments[:-1])145 parent = '/'.join(segments[:-1])
146 t = get_transport(parent)146 t = transport.get_transport(parent)
147 try:147 try:
148 t.mkdir(segments[-1])148 t.mkdir(segments[-1])
149 except FileExists:149 except FileExists:
150150
=== modified file 'bzrlib/tests/per_intertree/__init__.py'
--- bzrlib/tests/per_intertree/__init__.py 2010-02-17 17:11:16 +0000
+++ bzrlib/tests/per_intertree/__init__.py 2010-06-29 17:48:31 +0000
@@ -28,7 +28,6 @@
28 revisiontree,28 revisiontree,
29 tests,29 tests,
30 )30 )
31from bzrlib.transport import get_transport
32from bzrlib.transform import TransformPreview31from bzrlib.transform import TransformPreview
33from bzrlib.tests import (32from bzrlib.tests import (
34 default_transport,33 default_transport,
3534
=== modified file 'bzrlib/tests/per_repository/test_fetch.py'
--- bzrlib/tests/per_repository/test_fetch.py 2009-08-05 02:12:22 +0000
+++ bzrlib/tests/per_repository/test_fetch.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2007 Canonical Ltd1# Copyright (C) 2007-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -28,7 +28,6 @@
28from bzrlib.inventory import ROOT_ID28from bzrlib.inventory import ROOT_ID
29from bzrlib.tests import TestSkipped29from bzrlib.tests import TestSkipped
30from bzrlib.tests.per_repository import TestCaseWithRepository30from bzrlib.tests.per_repository import TestCaseWithRepository
31from bzrlib.transport import get_transport
3231
3332
34class TestFetchSameRepository(TestCaseWithRepository):33class TestFetchSameRepository(TestCaseWithRepository):
3534
=== modified file 'bzrlib/tests/per_repository/test_has_same_location.py'
--- bzrlib/tests/per_repository/test_has_same_location.py 2009-03-23 14:59:43 +0000
+++ bzrlib/tests/per_repository/test_has_same_location.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2007, 2008 Canonical Ltd1# Copyright (C) 2007-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -16,12 +16,14 @@
1616
17"""Tests for implementations of Repository.has_same_location."""17"""Tests for implementations of Repository.has_same_location."""
1818
19from bzrlib import bzrdir19from bzrlib import (
20 bzrdir,
21 transport,
22 )
20from bzrlib.tests import (23from bzrlib.tests import (
21 TestNotApplicable,24 TestNotApplicable,
22 )25 )
23from bzrlib.tests.per_repository import TestCaseWithRepository26from bzrlib.tests.per_repository import TestCaseWithRepository
24from bzrlib.transport import get_transport
2527
2628
27class TestHasSameLocation(TestCaseWithRepository):29class TestHasSameLocation(TestCaseWithRepository):
@@ -112,7 +114,8 @@
112 if repo._format == other_repo._format:114 if repo._format == other_repo._format:
113 # We're testing the default format! So we have to use a non-default115 # We're testing the default format! So we have to use a non-default
114 # format for other_repo.116 # format for other_repo.
115 get_transport(self.get_vfs_only_url()).delete_tree('other')117 transport.get_transport(self.get_vfs_only_url()
118 ).delete_tree('other')
116 other_repo = self.make_repository('other', format='metaweave')119 other_repo = self.make_repository('other', format='metaweave')
117 # Make sure the other_repo is not a RemoteRepository.120 # Make sure the other_repo is not a RemoteRepository.
118 other_bzrdir = bzrdir.BzrDir.open(self.get_vfs_only_url('other'))121 other_bzrdir = bzrdir.BzrDir.open(self.get_vfs_only_url('other'))
119122
=== modified file 'bzrlib/tests/per_repository/test_reconcile.py'
--- bzrlib/tests/per_repository/test_reconcile.py 2009-09-08 11:32:53 +0000
+++ bzrlib/tests/per_repository/test_reconcile.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -18,7 +18,10 @@
1818
1919
20import bzrlib20import bzrlib
21import bzrlib.errors as errors21from bzrlib import (
22 errors,
23 transport,
24 )
22from bzrlib.inventory import Inventory25from bzrlib.inventory import Inventory
23from bzrlib.reconcile import reconcile, Reconciler26from bzrlib.reconcile import reconcile, Reconciler
24from bzrlib.repofmt.knitrepo import RepositoryFormatKnit27from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
@@ -30,7 +33,6 @@
30from bzrlib.tests.per_repository import (33from bzrlib.tests.per_repository import (
31 TestCaseWithRepository,34 TestCaseWithRepository,
32 )35 )
33from bzrlib.transport import get_transport
34from bzrlib.uncommit import uncommit36from bzrlib.uncommit import uncommit
3537
3638
@@ -59,7 +61,7 @@
59 def setUp(self):61 def setUp(self):
60 super(TestsNeedingReweave, self).setUp()62 super(TestsNeedingReweave, self).setUp()
6163
62 t = get_transport(self.get_url())64 t = transport.get_transport(self.get_url())
63 # an empty inventory with no revision for testing with.65 # an empty inventory with no revision for testing with.
64 repo = self.make_repository('inventory_without_revision')66 repo = self.make_repository('inventory_without_revision')
65 repo.lock_write()67 repo.lock_write()
@@ -310,7 +312,7 @@
310 self.reduceLockdirTimeout()312 self.reduceLockdirTimeout()
311 super(TestReconcileWithIncorrectRevisionCache, self).setUp()313 super(TestReconcileWithIncorrectRevisionCache, self).setUp()
312314
313 t = get_transport(self.get_url())315 t = transport.get_transport(self.get_url())
314 # we need a revision with two parents in the wrong order316 # we need a revision with two parents in the wrong order
315 # which should trigger reinsertion.317 # which should trigger reinsertion.
316 # and another with the first one correct but the other two not318 # and another with the first one correct but the other two not
@@ -379,7 +381,7 @@
379381
380 def test_reconcile_wrong_order(self):382 def test_reconcile_wrong_order(self):
381 # a wrong order in primary parents is optionally correctable383 # a wrong order in primary parents is optionally correctable
382 t = get_transport(self.get_url()).clone('wrong-first-parent')384 t = transport.get_transport(self.get_url()).clone('wrong-first-parent')
383 d = bzrlib.bzrdir.BzrDir.open_from_transport(t)385 d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
384 repo = d.open_repository()386 repo = d.open_repository()
385 repo.lock_read()387 repo.lock_read()
@@ -408,7 +410,8 @@
408410
409 def test_reconcile_wrong_order_secondary_inventory(self):411 def test_reconcile_wrong_order_secondary_inventory(self):
410 # a wrong order in the parents for inventories is ignored.412 # a wrong order in the parents for inventories is ignored.
411 t = get_transport(self.get_url()).clone('reversed-secondary-parents')413 t = transport.get_transport(self.get_url()
414 ).clone('reversed-secondary-parents')
412 d = bzrlib.bzrdir.BzrDir.open_from_transport(t)415 d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
413 repo = d.open_repository()416 repo = d.open_repository()
414 self.checkUnreconciled(d, repo.reconcile())417 self.checkUnreconciled(d, repo.reconcile())
415418
=== modified file 'bzrlib/tests/per_versionedfile.py'
--- bzrlib/tests/per_versionedfile.py 2010-05-14 14:29:28 +0000
+++ bzrlib/tests/per_versionedfile.py 2010-06-29 17:48:31 +0000
@@ -31,6 +31,7 @@
31 knit as _mod_knit,31 knit as _mod_knit,
32 osutils,32 osutils,
33 progress,33 progress,
34 transport,
34 ui,35 ui,
35 )36 )
36from bzrlib.errors import (37from bzrlib.errors import (
@@ -56,7 +57,6 @@
56 )57 )
57from bzrlib.tests.http_utils import TestCaseWithWebserver58from bzrlib.tests.http_utils import TestCaseWithWebserver
58from bzrlib.trace import mutter59from bzrlib.trace import mutter
59from bzrlib.transport import get_transport
60from bzrlib.transport.memory import MemoryTransport60from bzrlib.transport.memory import MemoryTransport
61from bzrlib.tsort import topo_sort61from bzrlib.tsort import topo_sort
62from bzrlib.tuned_gzip import GzipFile62from bzrlib.tuned_gzip import GzipFile
@@ -849,10 +849,10 @@
849 self.assertEquals(('references_ghost', 'line_c\n'), origins[2])849 self.assertEquals(('references_ghost', 'line_c\n'), origins[2])
850850
851 def test_readonly_mode(self):851 def test_readonly_mode(self):
852 transport = get_transport(self.get_url('.'))852 t = transport.get_transport(self.get_url('.'))
853 factory = self.get_factory()853 factory = self.get_factory()
854 vf = factory('id', transport, 0777, create=True, access_mode='w')854 vf = factory('id', t, 0777, create=True, access_mode='w')
855 vf = factory('id', transport, access_mode='r')855 vf = factory('id', t, access_mode='r')
856 self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'base', [], [])856 self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'base', [], [])
857 self.assertRaises(errors.ReadOnlyError,857 self.assertRaises(errors.ReadOnlyError,
858 vf.add_lines_with_ghosts,858 vf.add_lines_with_ghosts,
@@ -880,12 +880,14 @@
880class TestWeave(TestCaseWithMemoryTransport, VersionedFileTestMixIn):880class TestWeave(TestCaseWithMemoryTransport, VersionedFileTestMixIn):
881881
882 def get_file(self, name='foo'):882 def get_file(self, name='foo'):
883 return WeaveFile(name, get_transport(self.get_url('.')), create=True,883 return WeaveFile(name, transport.get_transport(self.get_url('.')),
884 get_scope=self.get_transaction)884 create=True,
885 get_scope=self.get_transaction)
885886
886 def get_file_corrupted_text(self):887 def get_file_corrupted_text(self):
887 w = WeaveFile('foo', get_transport(self.get_url('.')), create=True,888 w = WeaveFile('foo', transport.get_transport(self.get_url('.')),
888 get_scope=self.get_transaction)889 create=True,
890 get_scope=self.get_transaction)
889 w.add_lines('v1', [], ['hello\n'])891 w.add_lines('v1', [], ['hello\n'])
890 w.add_lines('v2', ['v1'], ['hello\n', 'there\n'])892 w.add_lines('v2', ['v1'], ['hello\n', 'there\n'])
891893
@@ -919,14 +921,15 @@
919 return w921 return w
920922
921 def reopen_file(self, name='foo', create=False):923 def reopen_file(self, name='foo', create=False):
922 return WeaveFile(name, get_transport(self.get_url('.')), create=create,924 return WeaveFile(name, transport.get_transport(self.get_url('.')),
923 get_scope=self.get_transaction)925 create=create,
926 get_scope=self.get_transaction)
924927
925 def test_no_implicit_create(self):928 def test_no_implicit_create(self):
926 self.assertRaises(errors.NoSuchFile,929 self.assertRaises(errors.NoSuchFile,
927 WeaveFile,930 WeaveFile,
928 'foo',931 'foo',
929 get_transport(self.get_url('.')),932 transport.get_transport(self.get_url('.')),
930 get_scope=self.get_transaction)933 get_scope=self.get_transaction)
931934
932 def get_factory(self):935 def get_factory(self):
@@ -999,7 +1002,7 @@
999 # we should be able to read from http with a versioned file.1002 # we should be able to read from http with a versioned file.
1000 vf = self.get_file()1003 vf = self.get_file()
1001 # try an empty file access1004 # try an empty file access
1002 readonly_vf = self.get_factory()('foo', get_transport(1005 readonly_vf = self.get_factory()('foo', transport.get_transport(
1003 self.get_readonly_url('.')))1006 self.get_readonly_url('.')))
1004 self.assertEqual([], readonly_vf.versions())1007 self.assertEqual([], readonly_vf.versions())
10051008
@@ -1009,7 +1012,7 @@
1009 # now with feeling.1012 # now with feeling.
1010 vf.add_lines('1', [], ['a\n'])1013 vf.add_lines('1', [], ['a\n'])
1011 vf.add_lines('2', ['1'], ['b\n', 'a\n'])1014 vf.add_lines('2', ['1'], ['b\n', 'a\n'])
1012 readonly_vf = self.get_factory()('foo', get_transport(1015 readonly_vf = self.get_factory()('foo', transport.get_transport(
1013 self.get_readonly_url('.')))1016 self.get_readonly_url('.')))
1014 self.assertEqual(['1', '2'], vf.versions())1017 self.assertEqual(['1', '2'], vf.versions())
1015 self.assertEqual(['1', '2'], readonly_vf.versions())1018 self.assertEqual(['1', '2'], readonly_vf.versions())
@@ -1020,8 +1023,9 @@
1020class TestWeaveHTTP(TestCaseWithWebserver, TestReadonlyHttpMixin):1023class TestWeaveHTTP(TestCaseWithWebserver, TestReadonlyHttpMixin):
10211024
1022 def get_file(self):1025 def get_file(self):
1023 return WeaveFile('foo', get_transport(self.get_url('.')), create=True,1026 return WeaveFile('foo', transport.get_transport(self.get_url('.')),
1024 get_scope=self.get_transaction)1027 create=True,
1028 get_scope=self.get_transaction)
10251029
1026 def get_factory(self):1030 def get_factory(self):
1027 return WeaveFile1031 return WeaveFile
@@ -1271,7 +1275,8 @@
1271class TestWeaveMerge(TestCaseWithMemoryTransport, MergeCasesMixin):1275class TestWeaveMerge(TestCaseWithMemoryTransport, MergeCasesMixin):
12721276
1273 def get_file(self, name='foo'):1277 def get_file(self, name='foo'):
1274 return WeaveFile(name, get_transport(self.get_url('.')), create=True)1278 return WeaveFile(name, transport.get_transport(self.get_url('.')),
1279 create=True)
12751280
1276 def log_contents(self, w):1281 def log_contents(self, w):
1277 self.log('weave is:')1282 self.log('weave is:')
12781283
=== modified file 'bzrlib/tests/per_workingtree/test_pull.py'
--- bzrlib/tests/per_workingtree/test_pull.py 2010-01-11 23:02:32 +0000
+++ bzrlib/tests/per_workingtree/test_pull.py 2010-06-29 17:48:31 +0000
@@ -23,7 +23,6 @@
23from bzrlib.osutils import basename23from bzrlib.osutils import basename
24from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree24from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
25from bzrlib.trace import mutter25from bzrlib.trace import mutter
26from bzrlib.transport import get_transport
2726
2827
29class TestPull(TestCaseWithWorkingTree):28class TestPull(TestCaseWithWorkingTree):
3029
=== modified file 'bzrlib/tests/test_btree_index.py'
--- bzrlib/tests/test_btree_index.py 2010-03-25 17:09:53 +0000
+++ bzrlib/tests/test_btree_index.py 2010-06-29 17:48:31 +0000
@@ -27,6 +27,7 @@
27 lru_cache,27 lru_cache,
28 osutils,28 osutils,
29 tests,29 tests,
30 transport,
30 )31 )
31from bzrlib.tests import (32from bzrlib.tests import (
32 TestCaseWithTransport,33 TestCaseWithTransport,
@@ -34,7 +35,6 @@
34 multiply_tests,35 multiply_tests,
35 split_suite_by_condition,36 split_suite_by_condition,
36 )37 )
37from bzrlib.transport import get_transport
3838
3939
40def load_tests(standard_tests, module, loader):40def load_tests(standard_tests, module, loader):
@@ -280,10 +280,10 @@
280280
281 for node in nodes:281 for node in nodes:
282 builder.add_node(*node)282 builder.add_node(*node)
283 transport = get_transport('trace+' + self.get_url(''))283 t = transport.get_transport('trace+' + self.get_url(''))
284 size = transport.put_file('index', self.time(builder.finish))284 size = t.put_file('index', self.time(builder.finish))
285 del builder285 del builder
286 index = btree_index.BTreeGraphIndex(transport, 'index', size)286 index = btree_index.BTreeGraphIndex(t, 'index', size)
287 # Seed the metadata, we're using internal calls now.287 # Seed the metadata, we're using internal calls now.
288 index.key_count()288 index.key_count()
289 self.assertEqual(3, len(index._row_lengths),289 self.assertEqual(3, len(index._row_lengths),
@@ -409,9 +409,9 @@
409 self.assertEqual(None, builder._backing_indices[2])409 self.assertEqual(None, builder._backing_indices[2])
410 self.assertEqual(16, builder._backing_indices[3].key_count())410 self.assertEqual(16, builder._backing_indices[3].key_count())
411 # Now finish, and check we got a correctly ordered tree411 # Now finish, and check we got a correctly ordered tree
412 transport = self.get_transport('')412 t = self.get_transport('')
413 size = transport.put_file('index', builder.finish())413 size = t.put_file('index', builder.finish())
414 index = btree_index.BTreeGraphIndex(transport, 'index', size)414 index = btree_index.BTreeGraphIndex(t, 'index', size)
415 nodes = list(index.iter_all_entries())415 nodes = list(index.iter_all_entries())
416 self.assertEqual(sorted(nodes), nodes)416 self.assertEqual(sorted(nodes), nodes)
417 self.assertEqual(16, len(nodes))417 self.assertEqual(16, len(nodes))
@@ -607,7 +607,7 @@
607 for key, value, references in nodes:607 for key, value, references in nodes:
608 builder.add_node(key, value, references)608 builder.add_node(key, value, references)
609 stream = builder.finish()609 stream = builder.finish()
610 trans = get_transport('trace+' + self.get_url())610 trans = transport.get_transport('trace+' + self.get_url())
611 size = trans.put_file('index', stream)611 size = trans.put_file('index', stream)
612 return btree_index.BTreeGraphIndex(trans, 'index', size)612 return btree_index.BTreeGraphIndex(trans, 'index', size)
613613
@@ -648,57 +648,57 @@
648 self.assertEqual(0, len(index._leaf_node_cache))648 self.assertEqual(0, len(index._leaf_node_cache))
649649
650 def test_trivial_constructor(self):650 def test_trivial_constructor(self):
651 transport = get_transport('trace+' + self.get_url(''))651 t = transport.get_transport('trace+' + self.get_url(''))
652 index = btree_index.BTreeGraphIndex(transport, 'index', None)652 index = btree_index.BTreeGraphIndex(t, 'index', None)
653 # Checks the page size at load, but that isn't logged yet.653 # Checks the page size at load, but that isn't logged yet.
654 self.assertEqual([], transport._activity)654 self.assertEqual([], t._activity)
655655
656 def test_with_size_constructor(self):656 def test_with_size_constructor(self):
657 transport = get_transport('trace+' + self.get_url(''))657 t = transport.get_transport('trace+' + self.get_url(''))
658 index = btree_index.BTreeGraphIndex(transport, 'index', 1)658 index = btree_index.BTreeGraphIndex(t, 'index', 1)
659 # Checks the page size at load, but that isn't logged yet.659 # Checks the page size at load, but that isn't logged yet.
660 self.assertEqual([], transport._activity)660 self.assertEqual([], t._activity)
661661
662 def test_empty_key_count_no_size(self):662 def test_empty_key_count_no_size(self):
663 builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)663 builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)
664 transport = get_transport('trace+' + self.get_url(''))664 t = transport.get_transport('trace+' + self.get_url(''))
665 transport.put_file('index', builder.finish())665 t.put_file('index', builder.finish())
666 index = btree_index.BTreeGraphIndex(transport, 'index', None)666 index = btree_index.BTreeGraphIndex(t, 'index', None)
667 del transport._activity[:]667 del t._activity[:]
668 self.assertEqual([], transport._activity)668 self.assertEqual([], t._activity)
669 self.assertEqual(0, index.key_count())669 self.assertEqual(0, index.key_count())
670 # The entire index should have been requested (as we generally have the670 # The entire index should have been requested (as we generally have the
671 # size available, and doing many small readvs is inappropriate).671 # size available, and doing many small readvs is inappropriate).
672 # We can't tell how much was actually read here, but - check the code.672 # We can't tell how much was actually read here, but - check the code.
673 self.assertEqual([('get', 'index')], transport._activity)673 self.assertEqual([('get', 'index')], t._activity)
674674
675 def test_empty_key_count(self):675 def test_empty_key_count(self):
676 builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)676 builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)
677 transport = get_transport('trace+' + self.get_url(''))677 t = transport.get_transport('trace+' + self.get_url(''))
678 size = transport.put_file('index', builder.finish())678 size = t.put_file('index', builder.finish())
679 self.assertEqual(72, size)679 self.assertEqual(72, size)
680 index = btree_index.BTreeGraphIndex(transport, 'index', size)680 index = btree_index.BTreeGraphIndex(t, 'index', size)
681 del transport._activity[:]681 del t._activity[:]
682 self.assertEqual([], transport._activity)682 self.assertEqual([], t._activity)
683 self.assertEqual(0, index.key_count())683 self.assertEqual(0, index.key_count())
684 # The entire index should have been read, as 4K > size684 # The entire index should have been read, as 4K > size
685 self.assertEqual([('readv', 'index', [(0, 72)], False, None)],685 self.assertEqual([('readv', 'index', [(0, 72)], False, None)],
686 transport._activity)686 t._activity)
687687
688 def test_non_empty_key_count_2_2(self):688 def test_non_empty_key_count_2_2(self):
689 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)689 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
690 nodes = self.make_nodes(35, 2, 2)690 nodes = self.make_nodes(35, 2, 2)
691 for node in nodes:691 for node in nodes:
692 builder.add_node(*node)692 builder.add_node(*node)
693 transport = get_transport('trace+' + self.get_url(''))693 t = transport.get_transport('trace+' + self.get_url(''))
694 size = transport.put_file('index', builder.finish())694 size = t.put_file('index', builder.finish())
695 index = btree_index.BTreeGraphIndex(transport, 'index', size)695 index = btree_index.BTreeGraphIndex(t, 'index', size)
696 del transport._activity[:]696 del t._activity[:]
697 self.assertEqual([], transport._activity)697 self.assertEqual([], t._activity)
698 self.assertEqual(70, index.key_count())698 self.assertEqual(70, index.key_count())
699 # The entire index should have been read, as it is one page long.699 # The entire index should have been read, as it is one page long.
700 self.assertEqual([('readv', 'index', [(0, size)], False, None)],700 self.assertEqual([('readv', 'index', [(0, size)], False, None)],
701 transport._activity)701 t._activity)
702 self.assertEqual(1173, size)702 self.assertEqual(1173, size)
703703
704 def test_with_offset_no_size(self):704 def test_with_offset_no_size(self):
@@ -722,7 +722,7 @@
722722
723 def test__read_nodes_no_size_one_page_reads_once(self):723 def test__read_nodes_no_size_one_page_reads_once(self):
724 self.make_index(nodes=[(('key',), 'value', ())])724 self.make_index(nodes=[(('key',), 'value', ())])
725 trans = get_transport('trace+' + self.get_url())725 trans = transport.get_transport('trace+' + self.get_url())
726 index = btree_index.BTreeGraphIndex(trans, 'index', None)726 index = btree_index.BTreeGraphIndex(trans, 'index', None)
727 del trans._activity[:]727 del trans._activity[:]
728 nodes = dict(index._read_nodes([0]))728 nodes = dict(index._read_nodes([0]))
@@ -736,7 +736,7 @@
736 index.key_count()736 index.key_count()
737 num_pages = index._row_offsets[-1]737 num_pages = index._row_offsets[-1]
738 # Reopen with a traced transport and no size738 # Reopen with a traced transport and no size
739 trans = get_transport('trace+' + self.get_url())739 trans = transport.get_transport('trace+' + self.get_url())
740 index = btree_index.BTreeGraphIndex(trans, 'index', None)740 index = btree_index.BTreeGraphIndex(trans, 'index', None)
741 del trans._activity[:]741 del trans._activity[:]
742 nodes = dict(index._read_nodes([0]))742 nodes = dict(index._read_nodes([0]))
@@ -747,31 +747,31 @@
747 nodes = self.make_nodes(160, 2, 2)747 nodes = self.make_nodes(160, 2, 2)
748 for node in nodes:748 for node in nodes:
749 builder.add_node(*node)749 builder.add_node(*node)
750 transport = get_transport('trace+' + self.get_url(''))750 t = transport.get_transport('trace+' + self.get_url(''))
751 size = transport.put_file('index', builder.finish())751 size = t.put_file('index', builder.finish())
752 self.assertEqual(17692, size)752 self.assertEqual(17692, size)
753 index = btree_index.BTreeGraphIndex(transport, 'index', size)753 index = btree_index.BTreeGraphIndex(t, 'index', size)
754 del transport._activity[:]754 del t._activity[:]
755 self.assertEqual([], transport._activity)755 self.assertEqual([], t._activity)
756 self.assertEqual(320, index.key_count())756 self.assertEqual(320, index.key_count())
757 # The entire index should not have been read.757 # The entire index should not have been read.
758 self.assertEqual([('readv', 'index', [(0, 4096)], False, None)],758 self.assertEqual([('readv', 'index', [(0, 4096)], False, None)],
759 transport._activity)759 t._activity)
760760
761 def test_validate_one_page(self):761 def test_validate_one_page(self):
762 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)762 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
763 nodes = self.make_nodes(45, 2, 2)763 nodes = self.make_nodes(45, 2, 2)
764 for node in nodes:764 for node in nodes:
765 builder.add_node(*node)765 builder.add_node(*node)
766 transport = get_transport('trace+' + self.get_url(''))766 t = transport.get_transport('trace+' + self.get_url(''))
767 size = transport.put_file('index', builder.finish())767 size = t.put_file('index', builder.finish())
768 index = btree_index.BTreeGraphIndex(transport, 'index', size)768 index = btree_index.BTreeGraphIndex(t, 'index', size)
769 del transport._activity[:]769 del t._activity[:]
770 self.assertEqual([], transport._activity)770 self.assertEqual([], t._activity)
771 index.validate()771 index.validate()
772 # The entire index should have been read linearly.772 # The entire index should have been read linearly.
773 self.assertEqual([('readv', 'index', [(0, size)], False, None)],773 self.assertEqual([('readv', 'index', [(0, size)], False, None)],
774 transport._activity)774 t._activity)
775 self.assertEqual(1488, size)775 self.assertEqual(1488, size)
776776
777 def test_validate_two_pages(self):777 def test_validate_two_pages(self):
@@ -779,64 +779,65 @@
779 nodes = self.make_nodes(80, 2, 2)779 nodes = self.make_nodes(80, 2, 2)
780 for node in nodes:780 for node in nodes:
781 builder.add_node(*node)781 builder.add_node(*node)
782 transport = get_transport('trace+' + self.get_url(''))782 t = transport.get_transport('trace+' + self.get_url(''))
783 size = transport.put_file('index', builder.finish())783 size = t.put_file('index', builder.finish())
784 # Root page, 2 leaf pages784 # Root page, 2 leaf pages
785 self.assertEqual(9339, size)785 self.assertEqual(9339, size)
786 index = btree_index.BTreeGraphIndex(transport, 'index', size)786 index = btree_index.BTreeGraphIndex(t, 'index', size)
787 del transport._activity[:]787 del t._activity[:]
788 self.assertEqual([], transport._activity)788 self.assertEqual([], t._activity)
789 index.validate()789 index.validate()
790 # The entire index should have been read linearly.790 # The entire index should have been read linearly.
791 self.assertEqual([('readv', 'index', [(0, 4096)], False, None),791 self.assertEqual(
792 ('readv', 'index', [(4096, 4096), (8192, 1147)], False, None)],792 [('readv', 'index', [(0, 4096)], False, None),
793 transport._activity)793 ('readv', 'index', [(4096, 4096), (8192, 1147)], False, None)],
794 t._activity)
794 # XXX: TODO: write some badly-ordered nodes, and some pointers-to-wrong795 # XXX: TODO: write some badly-ordered nodes, and some pointers-to-wrong
795 # node and make validate find them.796 # node and make validate find them.
796797
797 def test_eq_ne(self):798 def test_eq_ne(self):
798 # two indices are equal when constructed with the same parameters:799 # two indices are equal when constructed with the same parameters:
799 transport1 = get_transport('trace+' + self.get_url(''))800 t1 = transport.get_transport('trace+' + self.get_url(''))
800 transport2 = get_transport(self.get_url(''))801 t2 = transport.get_transport(self.get_url(''))
801 self.assertTrue(802 self.assertTrue(
802 btree_index.BTreeGraphIndex(transport1, 'index', None) ==803 btree_index.BTreeGraphIndex(t1, 'index', None) ==
803 btree_index.BTreeGraphIndex(transport1, 'index', None))804 btree_index.BTreeGraphIndex(t1, 'index', None))
804 self.assertTrue(805 self.assertTrue(
805 btree_index.BTreeGraphIndex(transport1, 'index', 20) ==806 btree_index.BTreeGraphIndex(t1, 'index', 20) ==
806 btree_index.BTreeGraphIndex(transport1, 'index', 20))807 btree_index.BTreeGraphIndex(t1, 'index', 20))
807 self.assertFalse(808 self.assertFalse(
808 btree_index.BTreeGraphIndex(transport1, 'index', 20) ==809 btree_index.BTreeGraphIndex(t1, 'index', 20) ==
809 btree_index.BTreeGraphIndex(transport2, 'index', 20))810 btree_index.BTreeGraphIndex(t2, 'index', 20))
810 self.assertFalse(811 self.assertFalse(
811 btree_index.BTreeGraphIndex(transport1, 'inde1', 20) ==812 btree_index.BTreeGraphIndex(t1, 'inde1', 20) ==
812 btree_index.BTreeGraphIndex(transport1, 'inde2', 20))813 btree_index.BTreeGraphIndex(t1, 'inde2', 20))
813 self.assertFalse(814 self.assertFalse(
814 btree_index.BTreeGraphIndex(transport1, 'index', 10) ==815 btree_index.BTreeGraphIndex(t1, 'index', 10) ==
815 btree_index.BTreeGraphIndex(transport1, 'index', 20))816 btree_index.BTreeGraphIndex(t1, 'index', 20))
816 self.assertFalse(817 self.assertFalse(
817 btree_index.BTreeGraphIndex(transport1, 'index', None) !=818 btree_index.BTreeGraphIndex(t1, 'index', None) !=
818 btree_index.BTreeGraphIndex(transport1, 'index', None))819 btree_index.BTreeGraphIndex(t1, 'index', None))
819 self.assertFalse(820 self.assertFalse(
820 btree_index.BTreeGraphIndex(transport1, 'index', 20) !=821 btree_index.BTreeGraphIndex(t1, 'index', 20) !=
821 btree_index.BTreeGraphIndex(transport1, 'index', 20))822 btree_index.BTreeGraphIndex(t1, 'index', 20))
822 self.assertTrue(823 self.assertTrue(
823 btree_index.BTreeGraphIndex(transport1, 'index', 20) !=824 btree_index.BTreeGraphIndex(t1, 'index', 20) !=
824 btree_index.BTreeGraphIndex(transport2, 'index', 20))825 btree_index.BTreeGraphIndex(t2, 'index', 20))
825 self.assertTrue(826 self.assertTrue(
826 btree_index.BTreeGraphIndex(transport1, 'inde1', 20) !=827 btree_index.BTreeGraphIndex(t1, 'inde1', 20) !=
827 btree_index.BTreeGraphIndex(transport1, 'inde2', 20))828 btree_index.BTreeGraphIndex(t1, 'inde2', 20))
828 self.assertTrue(829 self.assertTrue(
829 btree_index.BTreeGraphIndex(transport1, 'index', 10) !=830 btree_index.BTreeGraphIndex(t1, 'index', 10) !=
830 btree_index.BTreeGraphIndex(transport1, 'index', 20))831 btree_index.BTreeGraphIndex(t1, 'index', 20))
831832
832 def test_iter_all_only_root_no_size(self):833 def test_iter_all_only_root_no_size(self):
833 self.make_index(nodes=[(('key',), 'value', ())])834 self.make_index(nodes=[(('key',), 'value', ())])
834 trans = get_transport('trace+' + self.get_url(''))835 t = transport.get_transport('trace+' + self.get_url(''))
835 index = btree_index.BTreeGraphIndex(trans, 'index', None)836 index = btree_index.BTreeGraphIndex(t, 'index', None)
836 del trans._activity[:]837 del t._activity[:]
837 self.assertEqual([(('key',), 'value')],838 self.assertEqual([(('key',), 'value')],
838 [x[1:] for x in index.iter_all_entries()])839 [x[1:] for x in index.iter_all_entries()])
839 self.assertEqual([('get', 'index')], trans._activity)840 self.assertEqual([('get', 'index')], t._activity)
840841
841 def test_iter_all_entries_reads(self):842 def test_iter_all_entries_reads(self):
842 # iterating all entries reads the header, then does a linear843 # iterating all entries reads the header, then does a linear
@@ -848,15 +849,15 @@
848 nodes = self.make_nodes(10000, 2, 2)849 nodes = self.make_nodes(10000, 2, 2)
849 for node in nodes:850 for node in nodes:
850 builder.add_node(*node)851 builder.add_node(*node)
851 transport = get_transport('trace+' + self.get_url(''))852 t = transport.get_transport('trace+' + self.get_url(''))
852 size = transport.put_file('index', builder.finish())853 size = t.put_file('index', builder.finish())
853 self.assertEqual(1303220, size, 'number of expected bytes in the'854 self.assertEqual(1303220, size, 'number of expected bytes in the'
854 ' output changed')855 ' output changed')
855 page_size = btree_index._PAGE_SIZE856 page_size = btree_index._PAGE_SIZE
856 del builder857 del builder
857 index = btree_index.BTreeGraphIndex(transport, 'index', size)858 index = btree_index.BTreeGraphIndex(t, 'index', size)
858 del transport._activity[:]859 del t._activity[:]
859 self.assertEqual([], transport._activity)860 self.assertEqual([], t._activity)
860 found_nodes = self.time(list, index.iter_all_entries())861 found_nodes = self.time(list, index.iter_all_entries())
861 bare_nodes = []862 bare_nodes = []
862 for node in found_nodes:863 for node in found_nodes:
@@ -883,7 +884,7 @@
883 readv_request[-1] = (readv_request[-1][0], 1303220 % page_size)884 readv_request[-1] = (readv_request[-1][0], 1303220 % page_size)
884 expected = [('readv', 'index', [(0, page_size)], False, None),885 expected = [('readv', 'index', [(0, page_size)], False, None),
885 ('readv', 'index', readv_request, False, None)]886 ('readv', 'index', readv_request, False, None)]
886 if expected != transport._activity:887 if expected != t._activity:
887 self.assertEqualDiff(pprint.pformat(expected),888 self.assertEqualDiff(pprint.pformat(expected),
888 pprint.pformat(transport._activity))889 pprint.pformat(transport._activity))
889890
@@ -903,12 +904,12 @@
903 nodes = self.make_nodes(160, 2, 2)904 nodes = self.make_nodes(160, 2, 2)
904 for node in nodes:905 for node in nodes:
905 builder.add_node(*node)906 builder.add_node(*node)
906 transport = get_transport('trace+' + self.get_url(''))907 t = transport.get_transport('trace+' + self.get_url(''))
907 size = transport.put_file('index', builder.finish())908 size = t.put_file('index', builder.finish())
908 del builder909 del builder
909 index = btree_index.BTreeGraphIndex(transport, 'index', size)910 index = btree_index.BTreeGraphIndex(t, 'index', size)
910 del transport._activity[:]911 del t._activity[:]
911 self.assertEqual([], transport._activity)912 self.assertEqual([], t._activity)
912 # search for one key913 # search for one key
913 found_nodes = list(index.iter_entries([nodes[30][0]]))914 found_nodes = list(index.iter_entries([nodes[30][0]]))
914 bare_nodes = []915 bare_nodes = []
@@ -922,7 +923,7 @@
922 # Should have read the root node, then one leaf page:923 # Should have read the root node, then one leaf page:
923 self.assertEqual([('readv', 'index', [(0, 4096)], False, None),924 self.assertEqual([('readv', 'index', [(0, 4096)], False, None),
924 ('readv', 'index', [(8192, 4096), ], False, None)],925 ('readv', 'index', [(8192, 4096), ], False, None)],
925 transport._activity)926 t._activity)
926927
927 def test_iter_key_prefix_1_element_key_None(self):928 def test_iter_key_prefix_1_element_key_None(self):
928 index = self.make_index()929 index = self.make_index()
@@ -1152,7 +1153,7 @@
1152 for node in nodes:1153 for node in nodes:
1153 builder.add_node(*node)1154 builder.add_node(*node)
1154 stream = builder.finish()1155 stream = builder.finish()
1155 trans = get_transport(self.get_url())1156 trans = transport.get_transport(self.get_url())
1156 size = trans.put_file('index', stream)1157 size = trans.put_file('index', stream)
1157 index = btree_index.BTreeGraphIndex(trans, 'index', size)1158 index = btree_index.BTreeGraphIndex(trans, 'index', size)
1158 self.assertEqual(500, index.key_count())1159 self.assertEqual(500, index.key_count())
@@ -1349,8 +1350,8 @@
1349 This doesn't actually create anything on disk, it just primes a1350 This doesn't actually create anything on disk, it just primes a
1350 BTreeGraphIndex with the recommended information.1351 BTreeGraphIndex with the recommended information.
1351 """1352 """
1352 index = btree_index.BTreeGraphIndex(get_transport('memory:///'),1353 index = btree_index.BTreeGraphIndex(
1353 'test-index', size=size)1354 transport.get_transport('memory:///'), 'test-index', size=size)
1354 if recommended_pages is not None:1355 if recommended_pages is not None:
1355 index._recommended_pages = recommended_pages1356 index._recommended_pages = recommended_pages
1356 return index1357 return index
13571358
=== modified file 'bzrlib/tests/test_bzrdir.py'
--- bzrlib/tests/test_bzrdir.py 2010-06-25 04:49:54 +0000
+++ bzrlib/tests/test_bzrdir.py 2010-06-29 17:48:31 +0000
@@ -1159,9 +1159,11 @@
1159 """1159 """
11601160
1161 def create_transport_readonly_server(self):1161 def create_transport_readonly_server(self):
1162 # We don't set the http protocol version, relying on the default
1162 return http_utils.HTTPServerRedirecting()1163 return http_utils.HTTPServerRedirecting()
11631164
1164 def create_transport_secondary_server(self):1165 def create_transport_secondary_server(self):
1166 # We don't set the http protocol version, relying on the default
1165 return http_utils.HTTPServerRedirecting()1167 return http_utils.HTTPServerRedirecting()
11661168
1167 def setUp(self):1169 def setUp(self):
11681170
=== modified file 'bzrlib/tests/test_debug.py'
--- bzrlib/tests/test_debug.py 2009-03-23 14:59:43 +0000
+++ bzrlib/tests/test_debug.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -20,13 +20,14 @@
20import os20import os
2121
2222
23from bzrlib import debug23from bzrlib import (
24 debug,
25 tests,
26 )
24from bzrlib.config import config_filename, ensure_config_dir_exists27from bzrlib.config import config_filename, ensure_config_dir_exists
25from bzrlib.transport import get_transport28
26from bzrlib.tests import TestCaseInTempDir29
2730class TestDebugFlags(tests.TestCaseInTempDir):
28
29class TestDebugFlags(TestCaseInTempDir):
3031
31 def test_set_debug_flags_from_config(self):32 def test_set_debug_flags_from_config(self):
32 # test both combinations because configobject automatically splits up33 # test both combinations because configobject automatically splits up
3334
=== modified file 'bzrlib/tests/test_directory_service.py'
--- bzrlib/tests/test_directory_service.py 2010-06-02 04:50:35 +0000
+++ bzrlib/tests/test_directory_service.py 2010-06-29 17:48:31 +0000
@@ -18,11 +18,11 @@
1818
19from bzrlib import (19from bzrlib import (
20 errors,20 errors,
21 transport,
21 urlutils,22 urlutils,
22 )23 )
23from bzrlib.directory_service import DirectoryServiceRegistry, directories24from bzrlib.directory_service import DirectoryServiceRegistry, directories
24from bzrlib.tests import TestCase, TestCaseWithTransport25from bzrlib.tests import TestCase, TestCaseWithTransport
25from bzrlib.transport import get_transport
2626
2727
28class FooService(object):28class FooService(object):
@@ -56,7 +56,7 @@
56 directories.register('foo:', FooService, 'Map foo URLs to http urls')56 directories.register('foo:', FooService, 'Map foo URLs to http urls')
57 self.addCleanup(directories.remove, 'foo:')57 self.addCleanup(directories.remove, 'foo:')
58 self.assertEqual(FooService.base + 'bar/',58 self.assertEqual(FooService.base + 'bar/',
59 get_transport('foo:bar').base)59 transport.get_transport('foo:bar').base)
6060
6161
62class TestAliasDirectory(TestCaseWithTransport):62class TestAliasDirectory(TestCaseWithTransport):
6363
=== modified file 'bzrlib/tests/test_http.py'
--- bzrlib/tests/test_http.py 2010-03-18 23:11:15 +0000
+++ bzrlib/tests/test_http.py 2010-06-29 17:48:31 +0000
@@ -89,6 +89,18 @@
89 _qualified_prefix='http+pycurl',)))89 _qualified_prefix='http+pycurl',)))
90 tests.multiply_tests(t_tests, transport_scenarios, result)90 tests.multiply_tests(t_tests, transport_scenarios, result)
9191
92 protocol_scenarios = [
93 ('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
94 ('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
95 ]
96
97 # some tests are parametrized by the protocol version only
98 p_tests, remaining_tests = tests.split_suite_by_condition(
99 remaining_tests, tests.condition_isinstance((
100 TestAuthOnRedirected,
101 )))
102 tests.multiply_tests(p_tests, protocol_scenarios, result)
103
92 # each implementation tested with each HTTP version104 # each implementation tested with each HTTP version
93 tp_tests, remaining_tests = tests.split_suite_by_condition(105 tp_tests, remaining_tests = tests.split_suite_by_condition(
94 remaining_tests, tests.condition_isinstance((106 remaining_tests, tests.condition_isinstance((
@@ -103,10 +115,6 @@
103 TestRanges,115 TestRanges,
104 TestSpecificRequestHandler,116 TestSpecificRequestHandler,
105 )))117 )))
106 protocol_scenarios = [
107 ('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
108 ('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
109 ]
110 tp_scenarios = tests.multiply_scenarios(transport_scenarios,118 tp_scenarios = tests.multiply_scenarios(transport_scenarios,
111 protocol_scenarios)119 protocol_scenarios)
112 tests.multiply_tests(tp_tests, tp_scenarios, result)120 tests.multiply_tests(tp_tests, tp_scenarios, result)
@@ -2156,13 +2164,14 @@
2156 _transport = _urllib.HttpTransport_urllib2164 _transport = _urllib.HttpTransport_urllib
21572165
2158 def create_transport_readonly_server(self):2166 def create_transport_readonly_server(self):
2159 return self._auth_server()2167 return self._auth_server(protocol_version=self._protocol_version)
21602168
2161 def create_transport_secondary_server(self):2169 def create_transport_secondary_server(self):
2162 """Create the secondary server redirecting to the primary server"""2170 """Create the secondary server redirecting to the primary server"""
2163 new = self.get_readonly_server()2171 new = self.get_readonly_server()
21642172
2165 redirecting = http_utils.HTTPServerRedirecting()2173 redirecting = http_utils.HTTPServerRedirecting(
2174 protocol_version=self._protocol_version)
2166 redirecting.redirect_to(new.host, new.port)2175 redirecting.redirect_to(new.host, new.port)
2167 return redirecting2176 return redirecting
21682177
21692178
=== modified file 'bzrlib/tests/test_index.py'
--- bzrlib/tests/test_index.py 2010-04-08 07:01:10 +0000
+++ bzrlib/tests/test_index.py 2010-06-29 17:48:31 +0000
@@ -16,16 +16,18 @@
1616
17"""Tests for indices."""17"""Tests for indices."""
1818
19from bzrlib import errors19from bzrlib import (
20from bzrlib.index import *20 errors,
21from bzrlib.tests import TestCaseWithMemoryTransport21 index,
22from bzrlib.transport import get_transport22 tests,
2323 transport,
2424 )
25class TestGraphIndexBuilder(TestCaseWithMemoryTransport):25
26
27class TestGraphIndexBuilder(tests.TestCaseWithMemoryTransport):
2628
27 def test_build_index_empty(self):29 def test_build_index_empty(self):
28 builder = GraphIndexBuilder()30 builder = index.GraphIndexBuilder()
29 stream = builder.finish()31 stream = builder.finish()
30 contents = stream.read()32 contents = stream.read()
31 self.assertEqual(33 self.assertEqual(
@@ -33,7 +35,7 @@
33 contents)35 contents)
3436
35 def test_build_index_empty_two_element_keys(self):37 def test_build_index_empty_two_element_keys(self):
36 builder = GraphIndexBuilder(key_elements=2)38 builder = index.GraphIndexBuilder(key_elements=2)
37 stream = builder.finish()39 stream = builder.finish()
38 contents = stream.read()40 contents = stream.read()
39 self.assertEqual(41 self.assertEqual(
@@ -41,7 +43,7 @@
41 contents)43 contents)
4244
43 def test_build_index_one_reference_list_empty(self):45 def test_build_index_one_reference_list_empty(self):
44 builder = GraphIndexBuilder(reference_lists=1)46 builder = index.GraphIndexBuilder(reference_lists=1)
45 stream = builder.finish()47 stream = builder.finish()
46 contents = stream.read()48 contents = stream.read()
47 self.assertEqual(49 self.assertEqual(
@@ -49,7 +51,7 @@
49 contents)51 contents)
5052
51 def test_build_index_two_reference_list_empty(self):53 def test_build_index_two_reference_list_empty(self):
52 builder = GraphIndexBuilder(reference_lists=2)54 builder = index.GraphIndexBuilder(reference_lists=2)
53 stream = builder.finish()55 stream = builder.finish()
54 contents = stream.read()56 contents = stream.read()
55 self.assertEqual(57 self.assertEqual(
@@ -57,7 +59,7 @@
57 contents)59 contents)
5860
59 def test_build_index_one_node_no_refs(self):61 def test_build_index_one_node_no_refs(self):
60 builder = GraphIndexBuilder()62 builder = index.GraphIndexBuilder()
61 builder.add_node(('akey', ), 'data')63 builder.add_node(('akey', ), 'data')
62 stream = builder.finish()64 stream = builder.finish()
63 contents = stream.read()65 contents = stream.read()
@@ -66,7 +68,7 @@
66 "akey\x00\x00\x00data\n\n", contents)68 "akey\x00\x00\x00data\n\n", contents)
6769
68 def test_build_index_one_node_no_refs_accepts_empty_reflist(self):70 def test_build_index_one_node_no_refs_accepts_empty_reflist(self):
69 builder = GraphIndexBuilder()71 builder = index.GraphIndexBuilder()
70 builder.add_node(('akey', ), 'data', ())72 builder.add_node(('akey', ), 'data', ())
71 stream = builder.finish()73 stream = builder.finish()
72 contents = stream.read()74 contents = stream.read()
@@ -78,7 +80,7 @@
78 # multipart keys are separated by \x00 - because they are fixed length,80 # multipart keys are separated by \x00 - because they are fixed length,
79 # not variable this does not cause any issues, and seems clearer to the81 # not variable this does not cause any issues, and seems clearer to the
80 # author.82 # author.
81 builder = GraphIndexBuilder(key_elements=2)83 builder = index.GraphIndexBuilder(key_elements=2)
82 builder.add_node(('akey', 'secondpart'), 'data')84 builder.add_node(('akey', 'secondpart'), 'data')
83 stream = builder.finish()85 stream = builder.finish()
84 contents = stream.read()86 contents = stream.read()
@@ -87,7 +89,7 @@
87 "akey\x00secondpart\x00\x00\x00data\n\n", contents)89 "akey\x00secondpart\x00\x00\x00data\n\n", contents)
8890
89 def test_add_node_empty_value(self):91 def test_add_node_empty_value(self):
90 builder = GraphIndexBuilder()92 builder = index.GraphIndexBuilder()
91 builder.add_node(('akey', ), '')93 builder.add_node(('akey', ), '')
92 stream = builder.finish()94 stream = builder.finish()
93 contents = stream.read()95 contents = stream.read()
@@ -97,7 +99,7 @@
9799
98 def test_build_index_nodes_sorted(self):100 def test_build_index_nodes_sorted(self):
99 # the highest sorted node comes first.101 # the highest sorted node comes first.
100 builder = GraphIndexBuilder()102 builder = index.GraphIndexBuilder()
101 # use three to have a good chance of glitching dictionary hash103 # use three to have a good chance of glitching dictionary hash
102 # lookups etc. Insert in randomish order that is not correct104 # lookups etc. Insert in randomish order that is not correct
103 # and not the reverse of the correct order.105 # and not the reverse of the correct order.
@@ -115,7 +117,7 @@
115117
116 def test_build_index_2_element_key_nodes_sorted(self):118 def test_build_index_2_element_key_nodes_sorted(self):
117 # multiple element keys are sorted first-key, second-key.119 # multiple element keys are sorted first-key, second-key.
118 builder = GraphIndexBuilder(key_elements=2)120 builder = index.GraphIndexBuilder(key_elements=2)
119 # use three values of each key element, to have a good chance of121 # use three values of each key element, to have a good chance of
120 # glitching dictionary hash lookups etc. Insert in randomish order that122 # glitching dictionary hash lookups etc. Insert in randomish order that
121 # is not correct and not the reverse of the correct order.123 # is not correct and not the reverse of the correct order.
@@ -144,7 +146,7 @@
144 "\n", contents)146 "\n", contents)
145147
146 def test_build_index_reference_lists_are_included_one(self):148 def test_build_index_reference_lists_are_included_one(self):
147 builder = GraphIndexBuilder(reference_lists=1)149 builder = index.GraphIndexBuilder(reference_lists=1)
148 builder.add_node(('key', ), 'data', ([], ))150 builder.add_node(('key', ), 'data', ([], ))
149 stream = builder.finish()151 stream = builder.finish()
150 contents = stream.read()152 contents = stream.read()
@@ -154,7 +156,7 @@
154 "\n", contents)156 "\n", contents)
155157
156 def test_build_index_reference_lists_with_2_element_keys(self):158 def test_build_index_reference_lists_with_2_element_keys(self):
157 builder = GraphIndexBuilder(reference_lists=1, key_elements=2)159 builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)
158 builder.add_node(('key', 'key2'), 'data', ([], ))160 builder.add_node(('key', 'key2'), 'data', ([], ))
159 stream = builder.finish()161 stream = builder.finish()
160 contents = stream.read()162 contents = stream.read()
@@ -164,7 +166,7 @@
164 "\n", contents)166 "\n", contents)
165167
166 def test_build_index_reference_lists_are_included_two(self):168 def test_build_index_reference_lists_are_included_two(self):
167 builder = GraphIndexBuilder(reference_lists=2)169 builder = index.GraphIndexBuilder(reference_lists=2)
168 builder.add_node(('key', ), 'data', ([], []))170 builder.add_node(('key', ), 'data', ([], []))
169 stream = builder.finish()171 stream = builder.finish()
170 contents = stream.read()172 contents = stream.read()
@@ -174,12 +176,12 @@
174 "\n", contents)176 "\n", contents)
175177
176 def test_clear_cache(self):178 def test_clear_cache(self):
177 builder = GraphIndexBuilder(reference_lists=2)179 builder = index.GraphIndexBuilder(reference_lists=2)
178 # This is a no-op, but the api should exist180 # This is a no-op, but the api should exist
179 builder.clear_cache()181 builder.clear_cache()
180182
181 def test_node_references_are_byte_offsets(self):183 def test_node_references_are_byte_offsets(self):
182 builder = GraphIndexBuilder(reference_lists=1)184 builder = index.GraphIndexBuilder(reference_lists=1)
183 builder.add_node(('reference', ), 'data', ([], ))185 builder.add_node(('reference', ), 'data', ([], ))
184 builder.add_node(('key', ), 'data', ([('reference', )], ))186 builder.add_node(('key', ), 'data', ([('reference', )], ))
185 stream = builder.finish()187 stream = builder.finish()
@@ -191,10 +193,11 @@
191 "\n", contents)193 "\n", contents)
192194
193 def test_node_references_are_cr_delimited(self):195 def test_node_references_are_cr_delimited(self):
194 builder = GraphIndexBuilder(reference_lists=1)196 builder = index.GraphIndexBuilder(reference_lists=1)
195 builder.add_node(('reference', ), 'data', ([], ))197 builder.add_node(('reference', ), 'data', ([], ))
196 builder.add_node(('reference2', ), 'data', ([], ))198 builder.add_node(('reference2', ), 'data', ([], ))
197 builder.add_node(('key', ), 'data', ([('reference', ), ('reference2', )], ))199 builder.add_node(('key', ), 'data',
200 ([('reference', ), ('reference2', )], ))
198 stream = builder.finish()201 stream = builder.finish()
199 contents = stream.read()202 contents = stream.read()
200 self.assertEqual(203 self.assertEqual(
@@ -205,9 +208,10 @@
205 "\n", contents)208 "\n", contents)
206209
207 def test_multiple_reference_lists_are_tab_delimited(self):210 def test_multiple_reference_lists_are_tab_delimited(self):
208 builder = GraphIndexBuilder(reference_lists=2)211 builder = index.GraphIndexBuilder(reference_lists=2)
209 builder.add_node(('keference', ), 'data', ([], []))212 builder.add_node(('keference', ), 'data', ([], []))
210 builder.add_node(('rey', ), 'data', ([('keference', )], [('keference', )]))213 builder.add_node(('rey', ), 'data',
214 ([('keference', )], [('keference', )]))
211 stream = builder.finish()215 stream = builder.finish()
212 contents = stream.read()216 contents = stream.read()
213 self.assertEqual(217 self.assertEqual(
@@ -217,8 +221,9 @@
217 "\n", contents)221 "\n", contents)
218222
219 def test_add_node_referencing_missing_key_makes_absent(self):223 def test_add_node_referencing_missing_key_makes_absent(self):
220 builder = GraphIndexBuilder(reference_lists=1)224 builder = index.GraphIndexBuilder(reference_lists=1)
221 builder.add_node(('rey', ), 'data', ([('beference', ), ('aeference2', )], ))225 builder.add_node(('rey', ), 'data',
226 ([('beference', ), ('aeference2', )], ))
222 stream = builder.finish()227 stream = builder.finish()
223 contents = stream.read()228 contents = stream.read()
224 self.assertEqual(229 self.assertEqual(
@@ -230,7 +235,7 @@
230235
231 def test_node_references_three_digits(self):236 def test_node_references_three_digits(self):
232 # test the node digit expands as needed.237 # test the node digit expands as needed.
233 builder = GraphIndexBuilder(reference_lists=1)238 builder = index.GraphIndexBuilder(reference_lists=1)
234 references = [(str(val), ) for val in reversed(range(9))]239 references = [(str(val), ) for val in reversed(range(9))]
235 builder.add_node(('2-key', ), '', (references, ))240 builder.add_node(('2-key', ), '', (references, ))
236 stream = builder.finish()241 stream = builder.finish()
@@ -252,7 +257,7 @@
252 def test_absent_has_no_reference_overhead(self):257 def test_absent_has_no_reference_overhead(self):
253 # the offsets after an absent record should be correct when there are258 # the offsets after an absent record should be correct when there are
254 # >1 reference lists.259 # >1 reference lists.
255 builder = GraphIndexBuilder(reference_lists=2)260 builder = index.GraphIndexBuilder(reference_lists=2)
256 builder.add_node(('parent', ), '', ([('aail', ), ('zther', )], []))261 builder.add_node(('parent', ), '', ([('aail', ), ('zther', )], []))
257 stream = builder.finish()262 stream = builder.finish()
258 contents = stream.read()263 contents = stream.read()
@@ -264,7 +269,7 @@
264 "\n", contents)269 "\n", contents)
265270
266 def test_add_node_bad_key(self):271 def test_add_node_bad_key(self):
267 builder = GraphIndexBuilder()272 builder = index.GraphIndexBuilder()
268 for bad_char in '\t\n\x0b\x0c\r\x00 ':273 for bad_char in '\t\n\x0b\x0c\r\x00 ':
269 self.assertRaises(errors.BadIndexKey, builder.add_node,274 self.assertRaises(errors.BadIndexKey, builder.add_node,
270 ('a%skey' % bad_char, ), 'data')275 ('a%skey' % bad_char, ), 'data')
@@ -279,30 +284,30 @@
279 self.assertRaises(errors.BadIndexKey, builder.add_node,284 self.assertRaises(errors.BadIndexKey, builder.add_node,
280 ('primary', 'secondary'), 'data')285 ('primary', 'secondary'), 'data')
281 # secondary key elements get checked too:286 # secondary key elements get checked too:
282 builder = GraphIndexBuilder(key_elements=2)287 builder = index.GraphIndexBuilder(key_elements=2)
283 for bad_char in '\t\n\x0b\x0c\r\x00 ':288 for bad_char in '\t\n\x0b\x0c\r\x00 ':
284 self.assertRaises(errors.BadIndexKey, builder.add_node,289 self.assertRaises(errors.BadIndexKey, builder.add_node,
285 ('prefix', 'a%skey' % bad_char), 'data')290 ('prefix', 'a%skey' % bad_char), 'data')
286291
287 def test_add_node_bad_data(self):292 def test_add_node_bad_data(self):
288 builder = GraphIndexBuilder()293 builder = index.GraphIndexBuilder()
289 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),294 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
290 'data\naa')295 'data\naa')
291 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),296 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
292 'data\x00aa')297 'data\x00aa')
293298
294 def test_add_node_bad_mismatched_ref_lists_length(self):299 def test_add_node_bad_mismatched_ref_lists_length(self):
295 builder = GraphIndexBuilder()300 builder = index.GraphIndexBuilder()
296 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),301 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
297 'data aa', ([], ))302 'data aa', ([], ))
298 builder = GraphIndexBuilder(reference_lists=1)303 builder = index.GraphIndexBuilder(reference_lists=1)
299 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),304 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
300 'data aa')305 'data aa')
301 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),306 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
302 'data aa', (), )307 'data aa', (), )
303 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),308 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
304 'data aa', ([], []))309 'data aa', ([], []))
305 builder = GraphIndexBuilder(reference_lists=2)310 builder = index.GraphIndexBuilder(reference_lists=2)
306 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),311 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
307 'data aa')312 'data aa')
308 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),313 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
@@ -312,7 +317,7 @@
312317
313 def test_add_node_bad_key_in_reference_lists(self):318 def test_add_node_bad_key_in_reference_lists(self):
314 # first list, first key - trivial319 # first list, first key - trivial
315 builder = GraphIndexBuilder(reference_lists=1)320 builder = index.GraphIndexBuilder(reference_lists=1)
316 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),321 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),
317 'data aa', ([('a key', )], ))322 'data aa', ([('a key', )], ))
318 # references keys must be tuples too323 # references keys must be tuples too
@@ -329,41 +334,41 @@
329 'data aa', ([('agoodkey', ), ('that is a bad key', )], ))334 'data aa', ([('agoodkey', ), ('that is a bad key', )], ))
330 # and if there is more than one list it should be getting checked335 # and if there is more than one list it should be getting checked
331 # too336 # too
332 builder = GraphIndexBuilder(reference_lists=2)337 builder = index.GraphIndexBuilder(reference_lists=2)
333 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),338 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),
334 'data aa', ([], ['a bad key']))339 'data aa', ([], ['a bad key']))
335340
336 def test_add_duplicate_key(self):341 def test_add_duplicate_key(self):
337 builder = GraphIndexBuilder()342 builder = index.GraphIndexBuilder()
338 builder.add_node(('key', ), 'data')343 builder.add_node(('key', ), 'data')
339 self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node, ('key', ),344 self.assertRaises(errors.BadIndexDuplicateKey,
340 'data')345 builder.add_node, ('key', ), 'data')
341346
342 def test_add_duplicate_key_2_elements(self):347 def test_add_duplicate_key_2_elements(self):
343 builder = GraphIndexBuilder(key_elements=2)348 builder = index.GraphIndexBuilder(key_elements=2)
344 builder.add_node(('key', 'key'), 'data')349 builder.add_node(('key', 'key'), 'data')
345 self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node,350 self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node,
346 ('key', 'key'), 'data')351 ('key', 'key'), 'data')
347352
348 def test_add_key_after_referencing_key(self):353 def test_add_key_after_referencing_key(self):
349 builder = GraphIndexBuilder(reference_lists=1)354 builder = index.GraphIndexBuilder(reference_lists=1)
350 builder.add_node(('key', ), 'data', ([('reference', )], ))355 builder.add_node(('key', ), 'data', ([('reference', )], ))
351 builder.add_node(('reference', ), 'data', ([],))356 builder.add_node(('reference', ), 'data', ([],))
352357
353 def test_add_key_after_referencing_key_2_elements(self):358 def test_add_key_after_referencing_key_2_elements(self):
354 builder = GraphIndexBuilder(reference_lists=1, key_elements=2)359 builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)
355 builder.add_node(('k', 'ey'), 'data', ([('reference', 'tokey')], ))360 builder.add_node(('k', 'ey'), 'data', ([('reference', 'tokey')], ))
356 builder.add_node(('reference', 'tokey'), 'data', ([],))361 builder.add_node(('reference', 'tokey'), 'data', ([],))
357362
358 def test_set_optimize(self):363 def test_set_optimize(self):
359 builder = GraphIndexBuilder(reference_lists=1, key_elements=2)364 builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)
360 builder.set_optimize(for_size=True)365 builder.set_optimize(for_size=True)
361 self.assertTrue(builder._optimize_for_size)366 self.assertTrue(builder._optimize_for_size)
362 builder.set_optimize(for_size=False)367 builder.set_optimize(for_size=False)
363 self.assertFalse(builder._optimize_for_size)368 self.assertFalse(builder._optimize_for_size)
364369
365370
366class TestGraphIndex(TestCaseWithMemoryTransport):371class TestGraphIndex(tests.TestCaseWithMemoryTransport):
367372
368 def make_key(self, number):373 def make_key(self, number):
369 return (str(number) + 'X'*100,)374 return (str(number) + 'X'*100,)
@@ -380,24 +385,24 @@
380 return nodes385 return nodes
381386
382 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):387 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):
383 builder = GraphIndexBuilder(ref_lists, key_elements=key_elements)388 builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
384 for key, value, references in nodes:389 for key, value, references in nodes:
385 builder.add_node(key, value, references)390 builder.add_node(key, value, references)
386 stream = builder.finish()391 stream = builder.finish()
387 trans = get_transport('trace+' + self.get_url())392 trans = transport.get_transport('trace+' + self.get_url())
388 size = trans.put_file('index', stream)393 size = trans.put_file('index', stream)
389 return GraphIndex(trans, 'index', size)394 return index.GraphIndex(trans, 'index', size)
390395
391 def make_index_with_offset(self, ref_lists=0, key_elements=1, nodes=[],396 def make_index_with_offset(self, ref_lists=0, key_elements=1, nodes=[],
392 offset=0):397 offset=0):
393 builder = GraphIndexBuilder(ref_lists, key_elements=key_elements)398 builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
394 for key, value, references in nodes:399 for key, value, references in nodes:
395 builder.add_node(key, value, references)400 builder.add_node(key, value, references)
396 content = builder.finish().read()401 content = builder.finish().read()
397 size = len(content)402 size = len(content)
398 trans = self.get_transport()403 trans = self.get_transport()
399 trans.put_bytes('index', (' '*offset) + content)404 trans.put_bytes('index', (' '*offset) + content)
400 return GraphIndex(trans, 'index', size, offset=offset)405 return index.GraphIndex(trans, 'index', size, offset=offset)
401406
402 def test_clear_cache(self):407 def test_clear_cache(self):
403 index = self.make_index()408 index = self.make_index()
@@ -408,18 +413,18 @@
408 def test_open_bad_index_no_error(self):413 def test_open_bad_index_no_error(self):
409 trans = self.get_transport()414 trans = self.get_transport()
410 trans.put_bytes('name', "not an index\n")415 trans.put_bytes('name', "not an index\n")
411 index = GraphIndex(trans, 'name', 13)416 idx = index.GraphIndex(trans, 'name', 13)
412417
413 def test_with_offset(self):418 def test_with_offset(self):
414 nodes = self.make_nodes(200)419 nodes = self.make_nodes(200)
415 index = self.make_index_with_offset(offset=1234567, nodes=nodes)420 idx = self.make_index_with_offset(offset=1234567, nodes=nodes)
416 self.assertEqual(200, index.key_count())421 self.assertEqual(200, idx.key_count())
417422
418 def test_buffer_all_with_offset(self):423 def test_buffer_all_with_offset(self):
419 nodes = self.make_nodes(200)424 nodes = self.make_nodes(200)
420 index = self.make_index_with_offset(offset=1234567, nodes=nodes)425 idx = self.make_index_with_offset(offset=1234567, nodes=nodes)
421 index._buffer_all()426 idx._buffer_all()
422 self.assertEqual(200, index.key_count())427 self.assertEqual(200, idx.key_count())
423428
424 def test_side_effect_buffering_with_offset(self):429 def test_side_effect_buffering_with_offset(self):
425 nodes = self.make_nodes(20)430 nodes = self.make_nodes(20)
@@ -830,9 +835,9 @@
830 self.assertEqual([], list(index.iter_entries([('a', )])))835 self.assertEqual([], list(index.iter_entries([('a', )])))
831836
832 def test_iter_missing_entry_empty_no_size(self):837 def test_iter_missing_entry_empty_no_size(self):
833 index = self.make_index()838 idx = self.make_index()
834 index = GraphIndex(index._transport, 'index', None)839 idx = index.GraphIndex(idx._transport, 'index', None)
835 self.assertEqual([], list(index.iter_entries([('a', )])))840 self.assertEqual([], list(idx.iter_entries([('a', )])))
836841
837 def test_iter_key_prefix_1_element_key_None(self):842 def test_iter_key_prefix_1_element_key_None(self):
838 index = self.make_index()843 index = self.make_index()
@@ -928,17 +933,17 @@
928 def test_validate_bad_index_errors(self):933 def test_validate_bad_index_errors(self):
929 trans = self.get_transport()934 trans = self.get_transport()
930 trans.put_bytes('name', "not an index\n")935 trans.put_bytes('name', "not an index\n")
931 index = GraphIndex(trans, 'name', 13)936 idx = index.GraphIndex(trans, 'name', 13)
932 self.assertRaises(errors.BadIndexFormatSignature, index.validate)937 self.assertRaises(errors.BadIndexFormatSignature, idx.validate)
933938
934 def test_validate_bad_node_refs(self):939 def test_validate_bad_node_refs(self):
935 index = self.make_index(2)940 idx = self.make_index(2)
936 trans = self.get_transport()941 trans = self.get_transport()
937 content = trans.get_bytes('index')942 content = trans.get_bytes('index')
938 # change the options line to end with a rather than a parseable number943 # change the options line to end with a rather than a parseable number
939 new_content = content[:-2] + 'a\n\n'944 new_content = content[:-2] + 'a\n\n'
940 trans.put_bytes('index', new_content)945 trans.put_bytes('index', new_content)
941 self.assertRaises(errors.BadIndexOptions, index.validate)946 self.assertRaises(errors.BadIndexOptions, idx.validate)
942947
943 def test_validate_missing_end_line_empty(self):948 def test_validate_missing_end_line_empty(self):
944 index = self.make_index(2)949 index = self.make_index(2)
@@ -1049,25 +1054,25 @@
1049 self.assertEqual(set(), search_keys)1054 self.assertEqual(set(), search_keys)
10501055
1051 def test_supports_unlimited_cache(self):1056 def test_supports_unlimited_cache(self):
1052 builder = GraphIndexBuilder(0, key_elements=1)1057 builder = index.GraphIndexBuilder(0, key_elements=1)
1053 stream = builder.finish()1058 stream = builder.finish()
1054 trans = get_transport(self.get_url())1059 trans = transport.get_transport(self.get_url())
1055 size = trans.put_file('index', stream)1060 size = trans.put_file('index', stream)
1056 # It doesn't matter what unlimited_cache does here, just that it can be1061 # It doesn't matter what unlimited_cache does here, just that it can be
1057 # passed1062 # passed
1058 index = GraphIndex(trans, 'index', size, unlimited_cache=True)1063 idx = index.GraphIndex(trans, 'index', size, unlimited_cache=True)
10591064
10601065
1061class TestCombinedGraphIndex(TestCaseWithMemoryTransport):1066class TestCombinedGraphIndex(tests.TestCaseWithMemoryTransport):
10621067
1063 def make_index(self, name, ref_lists=0, key_elements=1, nodes=[]):1068 def make_index(self, name, ref_lists=0, key_elements=1, nodes=[]):
1064 builder = GraphIndexBuilder(ref_lists, key_elements=key_elements)1069 builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
1065 for key, value, references in nodes:1070 for key, value, references in nodes:
1066 builder.add_node(key, value, references)1071 builder.add_node(key, value, references)
1067 stream = builder.finish()1072 stream = builder.finish()
1068 trans = self.get_transport()1073 trans = self.get_transport()
1069 size = trans.put_file(name, stream)1074 size = trans.put_file(name, stream)
1070 return GraphIndex(trans, name, size)1075 return index.GraphIndex(trans, name, size)
10711076
1072 def make_combined_index_with_missing(self, missing=['1', '2']):1077 def make_combined_index_with_missing(self, missing=['1', '2']):
1073 """Create a CombinedGraphIndex which will have missing indexes.1078 """Create a CombinedGraphIndex which will have missing indexes.
@@ -1079,9 +1084,9 @@
1079 :param missing: The underlying indexes to delete1084 :param missing: The underlying indexes to delete
1080 :return: (CombinedGraphIndex, reload_counter)1085 :return: (CombinedGraphIndex, reload_counter)
1081 """1086 """
1082 index1 = self.make_index('1', nodes=[(('1',), '', ())])1087 idx1 = self.make_index('1', nodes=[(('1',), '', ())])
1083 index2 = self.make_index('2', nodes=[(('2',), '', ())])1088 idx2 = self.make_index('2', nodes=[(('2',), '', ())])
1084 index3 = self.make_index('3', nodes=[1089 idx3 = self.make_index('3', nodes=[
1085 (('1',), '', ()),1090 (('1',), '', ()),
1086 (('2',), '', ())])1091 (('2',), '', ())])
10871092
@@ -1089,29 +1094,30 @@
1089 reload_counter = [0, 0, 0]1094 reload_counter = [0, 0, 0]
1090 def reload():1095 def reload():
1091 reload_counter[0] += 11096 reload_counter[0] += 1
1092 new_indices = [index3]1097 new_indices = [idx3]
1093 if index._indices == new_indices:1098 if idx._indices == new_indices:
1094 reload_counter[2] += 11099 reload_counter[2] += 1
1095 return False1100 return False
1096 reload_counter[1] += 11101 reload_counter[1] += 1
1097 index._indices[:] = new_indices1102 idx._indices[:] = new_indices
1098 return True1103 return True
1099 index = CombinedGraphIndex([index1, index2], reload_func=reload)1104 idx = index.CombinedGraphIndex([idx1, idx2], reload_func=reload)
1100 trans = self.get_transport()1105 trans = self.get_transport()
1101 for fname in missing:1106 for fname in missing:
1102 trans.delete(fname)1107 trans.delete(fname)
1103 return index, reload_counter1108 return idx, reload_counter
11041109
1105 def test_open_missing_index_no_error(self):1110 def test_open_missing_index_no_error(self):
1106 trans = self.get_transport()1111 trans = self.get_transport()
1107 index1 = GraphIndex(trans, 'missing', 100)1112 idx1 = index.GraphIndex(trans, 'missing', 100)
1108 index = CombinedGraphIndex([index1])1113 idx = index.CombinedGraphIndex([idx1])
11091114
1110 def test_add_index(self):1115 def test_add_index(self):
1111 index = CombinedGraphIndex([])1116 idx = index.CombinedGraphIndex([])
1112 index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])1117 idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1113 index.insert_index(0, index1)1118 idx.insert_index(0, idx1)
1114 self.assertEqual([(index1, ('key', ), '')], list(index.iter_all_entries()))1119 self.assertEqual([(idx1, ('key', ), '')],
1120 list(idx.iter_all_entries()))
11151121
1116 def test_clear_cache(self):1122 def test_clear_cache(self):
1117 log = []1123 log = []
@@ -1128,165 +1134,166 @@
1128 log.append(self._index)1134 log.append(self._index)
1129 return self._index.clear_cache()1135 return self._index.clear_cache()
11301136
1131 index = CombinedGraphIndex([])1137 idx = index.CombinedGraphIndex([])
1132 index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])1138 idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1133 index.insert_index(0, ClearCacheProxy(index1))1139 idx.insert_index(0, ClearCacheProxy(idx1))
1134 index2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])1140 idx2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
1135 index.insert_index(1, ClearCacheProxy(index2))1141 idx.insert_index(1, ClearCacheProxy(idx2))
1136 # CombinedGraphIndex should call 'clear_cache()' on all children1142 # CombinedGraphIndex should call 'clear_cache()' on all children
1137 index.clear_cache()1143 idx.clear_cache()
1138 self.assertEqual(sorted([index1, index2]), sorted(log))1144 self.assertEqual(sorted([idx1, idx2]), sorted(log))
11391145
1140 def test_iter_all_entries_empty(self):1146 def test_iter_all_entries_empty(self):
1141 index = CombinedGraphIndex([])1147 idx = index.CombinedGraphIndex([])
1142 self.assertEqual([], list(index.iter_all_entries()))1148 self.assertEqual([], list(idx.iter_all_entries()))
11431149
1144 def test_iter_all_entries_children_empty(self):1150 def test_iter_all_entries_children_empty(self):
1145 index1 = self.make_index('name')1151 idx1 = self.make_index('name')
1146 index = CombinedGraphIndex([index1])1152 idx = index.CombinedGraphIndex([idx1])
1147 self.assertEqual([], list(index.iter_all_entries()))1153 self.assertEqual([], list(idx.iter_all_entries()))
11481154
1149 def test_iter_all_entries_simple(self):1155 def test_iter_all_entries_simple(self):
1150 index1 = self.make_index('name', nodes=[(('name', ), 'data', ())])1156 idx1 = self.make_index('name', nodes=[(('name', ), 'data', ())])
1151 index = CombinedGraphIndex([index1])1157 idx = index.CombinedGraphIndex([idx1])
1152 self.assertEqual([(index1, ('name', ), 'data')],1158 self.assertEqual([(idx1, ('name', ), 'data')],
1153 list(index.iter_all_entries()))1159 list(idx.iter_all_entries()))
11541160
1155 def test_iter_all_entries_two_indices(self):1161 def test_iter_all_entries_two_indices(self):
1156 index1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])1162 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
1157 index2 = self.make_index('name2', nodes=[(('2', ), '', ())])1163 idx2 = self.make_index('name2', nodes=[(('2', ), '', ())])
1158 index = CombinedGraphIndex([index1, index2])1164 idx = index.CombinedGraphIndex([idx1, idx2])
1159 self.assertEqual([(index1, ('name', ), 'data'),1165 self.assertEqual([(idx1, ('name', ), 'data'),
1160 (index2, ('2', ), '')],1166 (idx2, ('2', ), '')],
1161 list(index.iter_all_entries()))1167 list(idx.iter_all_entries()))
11621168
1163 def test_iter_entries_two_indices_dup_key(self):1169 def test_iter_entries_two_indices_dup_key(self):
1164 index1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])1170 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
1165 index2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])1171 idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
1166 index = CombinedGraphIndex([index1, index2])1172 idx = index.CombinedGraphIndex([idx1, idx2])
1167 self.assertEqual([(index1, ('name', ), 'data')],1173 self.assertEqual([(idx1, ('name', ), 'data')],
1168 list(index.iter_entries([('name', )])))1174 list(idx.iter_entries([('name', )])))
11691175
1170 def test_iter_all_entries_two_indices_dup_key(self):1176 def test_iter_all_entries_two_indices_dup_key(self):
1171 index1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])1177 idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
1172 index2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])1178 idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
1173 index = CombinedGraphIndex([index1, index2])1179 idx = index.CombinedGraphIndex([idx1, idx2])
1174 self.assertEqual([(index1, ('name', ), 'data')],1180 self.assertEqual([(idx1, ('name', ), 'data')],
1175 list(index.iter_all_entries()))1181 list(idx.iter_all_entries()))
11761182
1177 def test_iter_key_prefix_2_key_element_refs(self):1183 def test_iter_key_prefix_2_key_element_refs(self):
1178 index1 = self.make_index('1', 1, key_elements=2, nodes=[1184 idx1 = self.make_index('1', 1, key_elements=2, nodes=[
1179 (('name', 'fin1'), 'data', ([('ref', 'erence')], ))])1185 (('name', 'fin1'), 'data', ([('ref', 'erence')], ))])
1180 index2 = self.make_index('2', 1, key_elements=2, nodes=[1186 idx2 = self.make_index('2', 1, key_elements=2, nodes=[
1181 (('name', 'fin2'), 'beta', ([], )),1187 (('name', 'fin2'), 'beta', ([], )),
1182 (('ref', 'erence'), 'refdata', ([], ))])1188 (('ref', 'erence'), 'refdata', ([], ))])
1183 index = CombinedGraphIndex([index1, index2])1189 idx = index.CombinedGraphIndex([idx1, idx2])
1184 self.assertEqual(set([(index1, ('name', 'fin1'), 'data', ((('ref', 'erence'),),)),1190 self.assertEqual(set([(idx1, ('name', 'fin1'), 'data',
1185 (index2, ('ref', 'erence'), 'refdata', ((), ))]),1191 ((('ref', 'erence'),),)),
1186 set(index.iter_entries_prefix([('name', 'fin1'), ('ref', 'erence')])))1192 (idx2, ('ref', 'erence'), 'refdata', ((), ))]),
1187 self.assertEqual(set([(index1, ('name', 'fin1'), 'data', ((('ref', 'erence'),),)),1193 set(idx.iter_entries_prefix([('name', 'fin1'),
1188 (index2, ('name', 'fin2'), 'beta', ((), ))]),1194 ('ref', 'erence')])))
1189 set(index.iter_entries_prefix([('name', None)])))1195 self.assertEqual(set([(idx1, ('name', 'fin1'), 'data',
1196 ((('ref', 'erence'),),)),
1197 (idx2, ('name', 'fin2'), 'beta', ((), ))]),
1198 set(idx.iter_entries_prefix([('name', None)])))
11901199
1191 def test_iter_nothing_empty(self):1200 def test_iter_nothing_empty(self):
1192 index = CombinedGraphIndex([])1201 idx = index.CombinedGraphIndex([])
1193 self.assertEqual([], list(index.iter_entries([])))1202 self.assertEqual([], list(idx.iter_entries([])))
11941203
1195 def test_iter_nothing_children_empty(self):1204 def test_iter_nothing_children_empty(self):
1196 index1 = self.make_index('name')1205 idx1 = self.make_index('name')
1197 index = CombinedGraphIndex([index1])1206 idx = index.CombinedGraphIndex([idx1])
1198 self.assertEqual([], list(index.iter_entries([])))1207 self.assertEqual([], list(idx.iter_entries([])))
11991208
1200 def test_iter_all_keys(self):1209 def test_iter_all_keys(self):
1201 index1 = self.make_index('1', 1, nodes=[1210 idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data',
1202 (('name', ), 'data', ([('ref', )], ))])1211 ([('ref', )], ))])
1203 index2 = self.make_index('2', 1, nodes=[1212 idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ((), ))])
1204 (('ref', ), 'refdata', ((), ))])1213 idx = index.CombinedGraphIndex([idx1, idx2])
1205 index = CombinedGraphIndex([index1, index2])1214 self.assertEqual(set([(idx1, ('name', ), 'data', ((('ref', ), ), )),
1206 self.assertEqual(set([(index1, ('name', ), 'data', ((('ref', ), ), )),1215 (idx2, ('ref', ), 'refdata', ((), ))]),
1207 (index2, ('ref', ), 'refdata', ((), ))]),1216 set(idx.iter_entries([('name', ), ('ref', )])))
1208 set(index.iter_entries([('name', ), ('ref', )])))
12091217
1210 def test_iter_all_keys_dup_entry(self):1218 def test_iter_all_keys_dup_entry(self):
1211 index1 = self.make_index('1', 1, nodes=[1219 idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data',
1212 (('name', ), 'data', ([('ref', )], )),1220 ([('ref', )], )),
1213 (('ref', ), 'refdata', ([], ))])1221 (('ref', ), 'refdata', ([], ))])
1214 index2 = self.make_index('2', 1, nodes=[1222 idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ([], ))])
1215 (('ref', ), 'refdata', ([], ))])1223 idx = index.CombinedGraphIndex([idx1, idx2])
1216 index = CombinedGraphIndex([index1, index2])1224 self.assertEqual(set([(idx1, ('name', ), 'data', ((('ref',),),)),
1217 self.assertEqual(set([(index1, ('name', ), 'data', ((('ref',),),)),1225 (idx1, ('ref', ), 'refdata', ((), ))]),
1218 (index1, ('ref', ), 'refdata', ((), ))]),1226 set(idx.iter_entries([('name', ), ('ref', )])))
1219 set(index.iter_entries([('name', ), ('ref', )])))
12201227
1221 def test_iter_missing_entry_empty(self):1228 def test_iter_missing_entry_empty(self):
1222 index = CombinedGraphIndex([])1229 idx = index.CombinedGraphIndex([])
1223 self.assertEqual([], list(index.iter_entries([('a', )])))1230 self.assertEqual([], list(idx.iter_entries([('a', )])))
12241231
1225 def test_iter_missing_entry_one_index(self):1232 def test_iter_missing_entry_one_index(self):
1226 index1 = self.make_index('1')1233 idx1 = self.make_index('1')
1227 index = CombinedGraphIndex([index1])1234 idx = index.CombinedGraphIndex([idx1])
1228 self.assertEqual([], list(index.iter_entries([('a', )])))1235 self.assertEqual([], list(idx.iter_entries([('a', )])))
12291236
1230 def test_iter_missing_entry_two_index(self):1237 def test_iter_missing_entry_two_index(self):
1231 index1 = self.make_index('1')1238 idx1 = self.make_index('1')
1232 index2 = self.make_index('2')1239 idx2 = self.make_index('2')
1233 index = CombinedGraphIndex([index1, index2])1240 idx = index.CombinedGraphIndex([idx1, idx2])
1234 self.assertEqual([], list(index.iter_entries([('a', )])))1241 self.assertEqual([], list(idx.iter_entries([('a', )])))
12351242
1236 def test_iter_entry_present_one_index_only(self):1243 def test_iter_entry_present_one_index_only(self):
1237 index1 = self.make_index('1', nodes=[(('key', ), '', ())])1244 idx1 = self.make_index('1', nodes=[(('key', ), '', ())])
1238 index2 = self.make_index('2', nodes=[])1245 idx2 = self.make_index('2', nodes=[])
1239 index = CombinedGraphIndex([index1, index2])1246 idx = index.CombinedGraphIndex([idx1, idx2])
1240 self.assertEqual([(index1, ('key', ), '')],1247 self.assertEqual([(idx1, ('key', ), '')],
1241 list(index.iter_entries([('key', )])))1248 list(idx.iter_entries([('key', )])))
1242 # and in the other direction1249 # and in the other direction
1243 index = CombinedGraphIndex([index2, index1])1250 idx = index.CombinedGraphIndex([idx2, idx1])
1244 self.assertEqual([(index1, ('key', ), '')],1251 self.assertEqual([(idx1, ('key', ), '')],
1245 list(index.iter_entries([('key', )])))1252 list(idx.iter_entries([('key', )])))
12461253
1247 def test_key_count_empty(self):1254 def test_key_count_empty(self):
1248 index1 = self.make_index('1', nodes=[])1255 idx1 = self.make_index('1', nodes=[])
1249 index2 = self.make_index('2', nodes=[])1256 idx2 = self.make_index('2', nodes=[])
1250 index = CombinedGraphIndex([index1, index2])1257 idx = index.CombinedGraphIndex([idx1, idx2])
1251 self.assertEqual(0, index.key_count())1258 self.assertEqual(0, idx.key_count())
12521259
1253 def test_key_count_sums_index_keys(self):1260 def test_key_count_sums_index_keys(self):
1254 index1 = self.make_index('1', nodes=[1261 idx1 = self.make_index('1', nodes=[
1255 (('1',), '', ()),1262 (('1',), '', ()),
1256 (('2',), '', ())])1263 (('2',), '', ())])
1257 index2 = self.make_index('2', nodes=[(('1',), '', ())])1264 idx2 = self.make_index('2', nodes=[(('1',), '', ())])
1258 index = CombinedGraphIndex([index1, index2])1265 idx = index.CombinedGraphIndex([idx1, idx2])
1259 self.assertEqual(3, index.key_count())1266 self.assertEqual(3, idx.key_count())
12601267
1261 def test_validate_bad_child_index_errors(self):1268 def test_validate_bad_child_index_errors(self):
1262 trans = self.get_transport()1269 trans = self.get_transport()
1263 trans.put_bytes('name', "not an index\n")1270 trans.put_bytes('name', "not an index\n")
1264 index1 = GraphIndex(trans, 'name', 13)1271 idx1 = index.GraphIndex(trans, 'name', 13)
1265 index = CombinedGraphIndex([index1])1272 idx = index.CombinedGraphIndex([idx1])
1266 self.assertRaises(errors.BadIndexFormatSignature, index.validate)1273 self.assertRaises(errors.BadIndexFormatSignature, idx.validate)
12671274
1268 def test_validate_empty(self):1275 def test_validate_empty(self):
1269 index = CombinedGraphIndex([])1276 idx = index.CombinedGraphIndex([])
1270 index.validate()1277 idx.validate()
12711278
1272 def test_key_count_reloads(self):1279 def test_key_count_reloads(self):
1273 index, reload_counter = self.make_combined_index_with_missing()1280 idx, reload_counter = self.make_combined_index_with_missing()
1274 self.assertEqual(2, index.key_count())1281 self.assertEqual(2, idx.key_count())
1275 self.assertEqual([1, 1, 0], reload_counter)1282 self.assertEqual([1, 1, 0], reload_counter)
12761283
1277 def test_key_count_no_reload(self):1284 def test_key_count_no_reload(self):
1278 index, reload_counter = self.make_combined_index_with_missing()1285 idx, reload_counter = self.make_combined_index_with_missing()
1279 index._reload_func = None1286 idx._reload_func = None
1280 # Without a _reload_func we just raise the exception1287 # Without a _reload_func we just raise the exception
1281 self.assertRaises(errors.NoSuchFile, index.key_count)1288 self.assertRaises(errors.NoSuchFile, idx.key_count)
12821289
1283 def test_key_count_reloads_and_fails(self):1290 def test_key_count_reloads_and_fails(self):
1284 # We have deleted all underlying indexes, so we will try to reload, but1291 # We have deleted all underlying indexes, so we will try to reload, but
1285 # still fail. This is mostly to test we don't get stuck in an infinite1292 # still fail. This is mostly to test we don't get stuck in an infinite
1286 # loop trying to reload1293 # loop trying to reload
1287 index, reload_counter = self.make_combined_index_with_missing(1294 idx, reload_counter = self.make_combined_index_with_missing(
1288 ['1', '2', '3'])1295 ['1', '2', '3'])
1289 self.assertRaises(errors.NoSuchFile, index.key_count)1296 self.assertRaises(errors.NoSuchFile, idx.key_count)
1290 self.assertEqual([2, 1, 1], reload_counter)1297 self.assertEqual([2, 1, 1], reload_counter)
12911298
1292 def test_iter_entries_reloads(self):1299 def test_iter_entries_reloads(self):
@@ -1392,27 +1399,27 @@
1392 return self.make_index('index-%s' % name, 0, nodes=nodes)1399 return self.make_index('index-%s' % name, 0, nodes=nodes)
13931400
1394 def test_reorder_after_iter_entries(self):1401 def test_reorder_after_iter_entries(self):
1395 # Four indices: [key1] in index1, [key2,key3] in index2, [] in index3,1402 # Four indices: [key1] in idx1, [key2,key3] in idx2, [] in idx3,
1396 # [key4] in index4.1403 # [key4] in idx4.
1397 index = CombinedGraphIndex([])1404 idx = index.CombinedGraphIndex([])
1398 index.insert_index(0, self.make_index_with_simple_nodes('1'), '1')1405 idx.insert_index(0, self.make_index_with_simple_nodes('1'), '1')
1399 index.insert_index(1, self.make_index_with_simple_nodes('2'), '2')1406 idx.insert_index(1, self.make_index_with_simple_nodes('2'), '2')
1400 index.insert_index(2, self.make_index_with_simple_nodes('3'), '3')1407 idx.insert_index(2, self.make_index_with_simple_nodes('3'), '3')
1401 index.insert_index(3, self.make_index_with_simple_nodes('4'), '4')1408 idx.insert_index(3, self.make_index_with_simple_nodes('4'), '4')
1402 index1, index2, index3, index4 = index._indices1409 idx1, idx2, idx3, idx4 = idx._indices
1403 # Query a key from index4 and index2.1410 # Query a key from idx4 and idx2.
1404 self.assertLength(2, list(index.iter_entries(1411 self.assertLength(2, list(idx.iter_entries(
1405 [('index-4-key-1',), ('index-2-key-1',)])))1412 [('index-4-key-1',), ('index-2-key-1',)])))
1406 # Now index2 and index4 should be moved to the front (and index1 should1413 # Now idx2 and idx4 should be moved to the front (and idx1 should
1407 # still be before index3).1414 # still be before idx3).
1408 self.assertEqual([index2, index4, index1, index3], index._indices)1415 self.assertEqual([idx2, idx4, idx1, idx3], idx._indices)
1409 self.assertEqual(['2', '4', '1', '3'], index._index_names)1416 self.assertEqual(['2', '4', '1', '3'], idx._index_names)
14101417
1411 def test_reorder_propagates_to_siblings(self):1418 def test_reorder_propagates_to_siblings(self):
1412 # Two CombinedGraphIndex objects, with the same number of indicies with1419 # Two CombinedGraphIndex objects, with the same number of indicies with
1413 # matching names.1420 # matching names.
1414 cgi1 = CombinedGraphIndex([])1421 cgi1 = index.CombinedGraphIndex([])
1415 cgi2 = CombinedGraphIndex([])1422 cgi2 = index.CombinedGraphIndex([])
1416 cgi1.insert_index(0, self.make_index_with_simple_nodes('1-1'), 'one')1423 cgi1.insert_index(0, self.make_index_with_simple_nodes('1-1'), 'one')
1417 cgi1.insert_index(1, self.make_index_with_simple_nodes('1-2'), 'two')1424 cgi1.insert_index(1, self.make_index_with_simple_nodes('1-2'), 'two')
1418 cgi2.insert_index(0, self.make_index_with_simple_nodes('2-1'), 'one')1425 cgi2.insert_index(0, self.make_index_with_simple_nodes('2-1'), 'one')
@@ -1425,23 +1432,23 @@
1425 self.assertEqual(['two', 'one'], cgi2._index_names)1432 self.assertEqual(['two', 'one'], cgi2._index_names)
14261433
1427 def test_validate_reloads(self):1434 def test_validate_reloads(self):
1428 index, reload_counter = self.make_combined_index_with_missing()1435 idx, reload_counter = self.make_combined_index_with_missing()
1429 index.validate()1436 idx.validate()
1430 self.assertEqual([1, 1, 0], reload_counter)1437 self.assertEqual([1, 1, 0], reload_counter)
14311438
1432 def test_validate_reloads_midway(self):1439 def test_validate_reloads_midway(self):
1433 index, reload_counter = self.make_combined_index_with_missing(['2'])1440 idx, reload_counter = self.make_combined_index_with_missing(['2'])
1434 index.validate()1441 idx.validate()
14351442
1436 def test_validate_no_reload(self):1443 def test_validate_no_reload(self):
1437 index, reload_counter = self.make_combined_index_with_missing()1444 idx, reload_counter = self.make_combined_index_with_missing()
1438 index._reload_func = None1445 idx._reload_func = None
1439 self.assertRaises(errors.NoSuchFile, index.validate)1446 self.assertRaises(errors.NoSuchFile, idx.validate)
14401447
1441 def test_validate_reloads_and_fails(self):1448 def test_validate_reloads_and_fails(self):
1442 index, reload_counter = self.make_combined_index_with_missing(1449 idx, reload_counter = self.make_combined_index_with_missing(
1443 ['1', '2', '3'])1450 ['1', '2', '3'])
1444 self.assertRaises(errors.NoSuchFile, index.validate)1451 self.assertRaises(errors.NoSuchFile, idx.validate)
14451452
1446 def test_find_ancestors_across_indexes(self):1453 def test_find_ancestors_across_indexes(self):
1447 key1 = ('key-1',)1454 key1 = ('key-1',)
@@ -1456,7 +1463,7 @@
1456 (key3, 'value', ([key2],)),1463 (key3, 'value', ([key2],)),
1457 (key4, 'value', ([key3],)),1464 (key4, 'value', ([key3],)),
1458 ])1465 ])
1459 c_index = CombinedGraphIndex([index1, index2])1466 c_index = index.CombinedGraphIndex([index1, index2])
1460 parent_map, missing_keys = c_index.find_ancestry([key1], 0)1467 parent_map, missing_keys = c_index.find_ancestry([key1], 0)
1461 self.assertEqual({key1: ()}, parent_map)1468 self.assertEqual({key1: ()}, parent_map)
1462 self.assertEqual(set(), missing_keys)1469 self.assertEqual(set(), missing_keys)
@@ -1479,7 +1486,7 @@
1479 index2 = self.make_index('34', ref_lists=1, nodes=[1486 index2 = self.make_index('34', ref_lists=1, nodes=[
1480 (key3, 'value', ([key2],)),1487 (key3, 'value', ([key2],)),
1481 ])1488 ])
1482 c_index = CombinedGraphIndex([index1, index2])1489 c_index = index.CombinedGraphIndex([index1, index2])
1483 # Searching for a key which is actually not present at all should1490 # Searching for a key which is actually not present at all should
1484 # eventually converge1491 # eventually converge
1485 parent_map, missing_keys = c_index.find_ancestry([key4], 0)1492 parent_map, missing_keys = c_index.find_ancestry([key4], 0)
@@ -1487,7 +1494,7 @@
1487 self.assertEqual(set([key4]), missing_keys)1494 self.assertEqual(set([key4]), missing_keys)
14881495
1489 def test_find_ancestors_no_indexes(self):1496 def test_find_ancestors_no_indexes(self):
1490 c_index = CombinedGraphIndex([])1497 c_index = index.CombinedGraphIndex([])
1491 key1 = ('key-1',)1498 key1 = ('key-1',)
1492 parent_map, missing_keys = c_index.find_ancestry([key1], 0)1499 parent_map, missing_keys = c_index.find_ancestry([key1], 0)
1493 self.assertEqual({}, parent_map)1500 self.assertEqual({}, parent_map)
@@ -1505,7 +1512,7 @@
1505 index2 = self.make_index('34', ref_lists=1, nodes=[1512 index2 = self.make_index('34', ref_lists=1, nodes=[
1506 (key4, 'value', ([key2, key3],)),1513 (key4, 'value', ([key2, key3],)),
1507 ])1514 ])
1508 c_index = CombinedGraphIndex([index1, index2])1515 c_index = index.CombinedGraphIndex([index1, index2])
1509 # Searching for a key which is actually not present at all should1516 # Searching for a key which is actually not present at all should
1510 # eventually converge1517 # eventually converge
1511 parent_map, missing_keys = c_index.find_ancestry([key4], 0)1518 parent_map, missing_keys = c_index.find_ancestry([key4], 0)
@@ -1514,20 +1521,20 @@
1514 self.assertEqual(set([key3]), missing_keys)1521 self.assertEqual(set([key3]), missing_keys)
15151522
1516 def test__find_ancestors_empty_index(self):1523 def test__find_ancestors_empty_index(self):
1517 index = self.make_index('test', ref_lists=1, key_elements=1, nodes=[])1524 idx = self.make_index('test', ref_lists=1, key_elements=1, nodes=[])
1518 parent_map = {}1525 parent_map = {}
1519 missing_keys = set()1526 missing_keys = set()
1520 search_keys = index._find_ancestors([('one',), ('two',)], 0, parent_map,1527 search_keys = idx._find_ancestors([('one',), ('two',)], 0, parent_map,
1521 missing_keys)1528 missing_keys)
1522 self.assertEqual(set(), search_keys)1529 self.assertEqual(set(), search_keys)
1523 self.assertEqual({}, parent_map)1530 self.assertEqual({}, parent_map)
1524 self.assertEqual(set([('one',), ('two',)]), missing_keys)1531 self.assertEqual(set([('one',), ('two',)]), missing_keys)
15251532
15261533
1527class TestInMemoryGraphIndex(TestCaseWithMemoryTransport):1534class TestInMemoryGraphIndex(tests.TestCaseWithMemoryTransport):
15281535
1529 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):1536 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):
1530 result = InMemoryGraphIndex(ref_lists, key_elements=key_elements)1537 result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)
1531 result.add_nodes(nodes)1538 result.add_nodes(nodes)
1532 return result1539 return result
15331540
@@ -1654,23 +1661,26 @@
1654 index.validate()1661 index.validate()
16551662
16561663
1657class TestGraphIndexPrefixAdapter(TestCaseWithMemoryTransport):1664class TestGraphIndexPrefixAdapter(tests.TestCaseWithMemoryTransport):
16581665
1659 def make_index(self, ref_lists=1, key_elements=2, nodes=[], add_callback=False):1666 def make_index(self, ref_lists=1, key_elements=2, nodes=[],
1660 result = InMemoryGraphIndex(ref_lists, key_elements=key_elements)1667 add_callback=False):
1668 result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)
1661 result.add_nodes(nodes)1669 result.add_nodes(nodes)
1662 if add_callback:1670 if add_callback:
1663 add_nodes_callback = result.add_nodes1671 add_nodes_callback = result.add_nodes
1664 else:1672 else:
1665 add_nodes_callback = None1673 add_nodes_callback = None
1666 adapter = GraphIndexPrefixAdapter(result, ('prefix', ), key_elements - 1,1674 adapter = index.GraphIndexPrefixAdapter(
1675 result, ('prefix', ), key_elements - 1,
1667 add_nodes_callback=add_nodes_callback)1676 add_nodes_callback=add_nodes_callback)
1668 return result, adapter1677 return result, adapter
16691678
1670 def test_add_node(self):1679 def test_add_node(self):
1671 index, adapter = self.make_index(add_callback=True)1680 index, adapter = self.make_index(add_callback=True)
1672 adapter.add_node(('key',), 'value', ((('ref',),),))1681 adapter.add_node(('key',), 'value', ((('ref',),),))
1673 self.assertEqual(set([(index, ('prefix', 'key'), 'value', ((('prefix', 'ref'),),))]),1682 self.assertEqual(set([(index, ('prefix', 'key'), 'value',
1683 ((('prefix', 'ref'),),))]),
1674 set(index.iter_all_entries()))1684 set(index.iter_all_entries()))
16751685
1676 def test_add_nodes(self):1686 def test_add_nodes(self):
@@ -1686,12 +1696,13 @@
1686 set(index.iter_all_entries()))1696 set(index.iter_all_entries()))
16871697
1688 def test_construct(self):1698 def test_construct(self):
1689 index = InMemoryGraphIndex()1699 idx = index.InMemoryGraphIndex()
1690 adapter = GraphIndexPrefixAdapter(index, ('prefix', ), 1)1700 adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1)
16911701
1692 def test_construct_with_callback(self):1702 def test_construct_with_callback(self):
1693 index = InMemoryGraphIndex()1703 idx = index.InMemoryGraphIndex()
1694 adapter = GraphIndexPrefixAdapter(index, ('prefix', ), 1, index.add_nodes)1704 adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1,
1705 idx.add_nodes)
16951706
1696 def test_iter_all_entries_cross_prefix_map_errors(self):1707 def test_iter_all_entries_cross_prefix_map_errors(self):
1697 index, adapter = self.make_index(nodes=[1708 index, adapter = self.make_index(nodes=[
16981709
=== modified file 'bzrlib/tests/test_knit.py'
--- bzrlib/tests/test_knit.py 2010-06-04 03:09:35 +0000
+++ bzrlib/tests/test_knit.py 2010-06-29 17:48:31 +0000
@@ -26,6 +26,7 @@
26 osutils,26 osutils,
27 pack,27 pack,
28 tests,28 tests,
29 transport,
29 tuned_gzip,30 tuned_gzip,
30 )31 )
31from bzrlib.errors import (32from bzrlib.errors import (
@@ -53,7 +54,6 @@
53 TestCaseWithTransport,54 TestCaseWithTransport,
54 TestNotApplicable,55 TestNotApplicable,
55 )56 )
56from bzrlib.transport import get_transport
57from bzrlib.versionedfile import (57from bzrlib.versionedfile import (
58 AbsentContentFactory,58 AbsentContentFactory,
59 ConstantMapper,59 ConstantMapper,
@@ -1571,13 +1571,13 @@
1571 # could leave an empty .kndx file, which bzr would later claim was a1571 # could leave an empty .kndx file, which bzr would later claim was a
1572 # corrupted file since the header was not present. In reality, the file1572 # corrupted file since the header was not present. In reality, the file
1573 # just wasn't created, so it should be ignored.1573 # just wasn't created, so it should be ignored.
1574 t = get_transport('.')1574 t = transport.get_transport('.')
1575 t.put_bytes('test.kndx', '')1575 t.put_bytes('test.kndx', '')
15761576
1577 knit = self.make_test_knit()1577 knit = self.make_test_knit()
15781578
1579 def test_knit_index_checks_header(self):1579 def test_knit_index_checks_header(self):
1580 t = get_transport('.')1580 t = transport.get_transport('.')
1581 t.put_bytes('test.kndx', '# not really a knit header\n\n')1581 t.put_bytes('test.kndx', '# not really a knit header\n\n')
1582 k = self.make_test_knit()1582 k = self.make_test_knit()
1583 self.assertRaises(KnitHeaderError, k.keys)1583 self.assertRaises(KnitHeaderError, k.keys)
15841584
=== modified file 'bzrlib/tests/test_lockable_files.py'
--- bzrlib/tests/test_lockable_files.py 2010-02-17 17:11:16 +0000
+++ bzrlib/tests/test_lockable_files.py 2010-06-29 17:48:31 +0000
@@ -21,6 +21,7 @@
21 errors,21 errors,
22 lockdir,22 lockdir,
23 osutils,23 osutils,
24 transport,
24 )25 )
25from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError26from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
26from bzrlib.lockable_files import LockableFiles, TransportLock27from bzrlib.lockable_files import LockableFiles, TransportLock
@@ -37,7 +38,6 @@
37 ReadOnlyTransaction,38 ReadOnlyTransaction,
38 WriteTransaction,39 WriteTransaction,
39 )40 )
40from bzrlib.transport import get_transport
4141
4242
43# these tests are applied in each parameterized suite for LockableFiles43# these tests are applied in each parameterized suite for LockableFiles
@@ -279,9 +279,9 @@
279279
280 def setUp(self):280 def setUp(self):
281 TestCaseInTempDir.setUp(self)281 TestCaseInTempDir.setUp(self)
282 transport = get_transport('.')282 t = transport.get_transport('.')
283 transport.mkdir('.bzr')283 t.mkdir('.bzr')
284 self.sub_transport = transport.clone('.bzr')284 self.sub_transport = t.clone('.bzr')
285 self.lockable = self.get_lockable()285 self.lockable = self.get_lockable()
286 self.lockable.create_lock()286 self.lockable.create_lock()
287287
@@ -304,7 +304,7 @@
304304
305 def setUp(self):305 def setUp(self):
306 TestCaseInTempDir.setUp(self)306 TestCaseInTempDir.setUp(self)
307 self.transport = get_transport('.')307 self.transport = transport.get_transport('.')
308 self.lockable = self.get_lockable()308 self.lockable = self.get_lockable()
309 # the lock creation here sets mode - test_permissions on branch309 # the lock creation here sets mode - test_permissions on branch
310 # tests that implicitly, but it might be a good idea to factor310 # tests that implicitly, but it might be a good idea to factor
@@ -347,7 +347,7 @@
347 # in test_remote and test_smart as usual.347 # in test_remote and test_smart as usual.
348 b = self.make_branch('foo')348 b = self.make_branch('foo')
349 self.addCleanup(b.bzrdir.transport.disconnect)349 self.addCleanup(b.bzrdir.transport.disconnect)
350 self.transport = get_transport('.')350 self.transport = transport.get_transport('.')
351 self.lockable = self.get_lockable()351 self.lockable = self.get_lockable()
352352
353 def get_lockable(self):353 def get_lockable(self):
354354
=== modified file 'bzrlib/tests/test_osutils.py'
--- bzrlib/tests/test_osutils.py 2010-06-08 01:45:09 +0000
+++ bzrlib/tests/test_osutils.py 2010-06-29 17:48:31 +0000
@@ -861,7 +861,7 @@
861 self.assertEqual('//HOST/path', osutils._win98_abspath('//HOST/path'))861 self.assertEqual('//HOST/path', osutils._win98_abspath('//HOST/path'))
862 # relative path862 # relative path
863 cwd = osutils.getcwd().rstrip('/')863 cwd = osutils.getcwd().rstrip('/')
864 drive = osutils._nt_splitdrive(cwd)[0]864 drive = osutils.ntpath.splitdrive(cwd)[0]
865 self.assertEqual(cwd+'/path', osutils._win98_abspath('path'))865 self.assertEqual(cwd+'/path', osutils._win98_abspath('path'))
866 self.assertEqual(drive+'/path', osutils._win98_abspath('/path'))866 self.assertEqual(drive+'/path', osutils._win98_abspath('/path'))
867 # unicode path867 # unicode path
868868
=== modified file 'bzrlib/tests/test_osutils_encodings.py'
--- bzrlib/tests/test_osutils_encodings.py 2010-06-25 20:34:05 +0000
+++ bzrlib/tests/test_osutils_encodings.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2006 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/tests/test_permissions.py'
--- bzrlib/tests/test_permissions.py 2009-09-07 08:46:00 +0000
+++ bzrlib/tests/test_permissions.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005 Canonical Ltd1# Copyright (C) 2005-2010 Canonical Ltd
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# This program is free software; you can redistribute it and/or modify4# This program is free software; you can redistribute it and/or modify
@@ -36,11 +36,11 @@
36from cStringIO import StringIO36from cStringIO import StringIO
37import urllib37import urllib
3838
39from bzrlib import transport
39from bzrlib.branch import Branch40from bzrlib.branch import Branch
40from bzrlib.bzrdir import BzrDir41from bzrlib.bzrdir import BzrDir
41from bzrlib.tests import TestCaseWithTransport, TestSkipped42from bzrlib.tests import TestCaseWithTransport, TestSkipped
42from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer43from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
43from bzrlib.transport import get_transport
44from bzrlib.workingtree import WorkingTree44from bzrlib.workingtree import WorkingTree
4545
4646
@@ -65,7 +65,7 @@
65 :param dir_mode: The mode for all directories65 :param dir_mode: The mode for all directories
66 :param include_base: If false, only check the subdirectories66 :param include_base: If false, only check the subdirectories
67 """67 """
68 t = get_transport(".")68 t = transport.get_transport(".")
69 if include_base:69 if include_base:
70 test.assertTransportMode(t, base, dir_mode)70 test.assertTransportMode(t, base, dir_mode)
71 for root, dirs, files in os.walk(base):71 for root, dirs, files in os.walk(base):
@@ -180,7 +180,7 @@
180180
181 # bodge around for stubsftpserver not letting use connect181 # bodge around for stubsftpserver not letting use connect
182 # more than once182 # more than once
183 _t = get_transport(self.get_url())183 _t = transport.get_transport(self.get_url())
184184
185 os.mkdir('local')185 os.mkdir('local')
186 t_local = self.make_branch_and_tree('local')186 t_local = self.make_branch_and_tree('local')
@@ -257,7 +257,7 @@
257 original_umask = os.umask(umask)257 original_umask = os.umask(umask)
258258
259 try:259 try:
260 t = get_transport(self.get_url())260 t = transport.get_transport(self.get_url())
261 # Direct access should be masked by umask261 # Direct access should be masked by umask
262 t._sftp_open_exclusive('a', mode=0666).write('foo\n')262 t._sftp_open_exclusive('a', mode=0666).write('foo\n')
263 self.assertTransportMode(t, 'a', 0666 &~umask)263 self.assertTransportMode(t, 'a', 0666 &~umask)
264264
=== modified file 'bzrlib/tests/test_reconcile.py'
--- bzrlib/tests/test_reconcile.py 2009-03-23 14:59:43 +0000
+++ bzrlib/tests/test_reconcile.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006, 2008, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -17,15 +17,18 @@
17"""Tests for reconiliation behaviour that is repository independent."""17"""Tests for reconiliation behaviour that is repository independent."""
1818
1919
20from bzrlib import bzrdir, errors, tests20from bzrlib import (
21 bzrdir,
22 errors,
23 tests,
24 )
21from bzrlib.reconcile import reconcile, Reconciler25from bzrlib.reconcile import reconcile, Reconciler
22from bzrlib.revision import Revision26from bzrlib.revision import Revision
23from bzrlib.tests.per_repository import TestCaseWithRepository27from bzrlib.tests import per_repository
24from bzrlib.transport import get_transport
25from bzrlib.workingtree import WorkingTree28from bzrlib.workingtree import WorkingTree
2629
2730
28class TestWorksWithSharedRepositories(TestCaseWithRepository):31class TestWorksWithSharedRepositories(per_repository.TestCaseWithRepository):
2932
30 def test_reweave_empty(self):33 def test_reweave_empty(self):
31 # we want a repo capable format34 # we want a repo capable format
3235
=== modified file 'bzrlib/tests/test_remote.py'
--- bzrlib/tests/test_remote.py 2010-05-20 18:23:17 +0000
+++ bzrlib/tests/test_remote.py 2010-06-29 17:48:31 +0000
@@ -38,6 +38,7 @@
38 remote,38 remote,
39 repository,39 repository,
40 tests,40 tests,
41 transport,
41 treebuilder,42 treebuilder,
42 urlutils,43 urlutils,
43 versionedfile,44 versionedfile,
@@ -63,7 +64,6 @@
63 multiply_tests,64 multiply_tests,
64 test_server,65 test_server,
65 )66 )
66from bzrlib.transport import get_transport
67from bzrlib.transport.memory import MemoryTransport67from bzrlib.transport.memory import MemoryTransport
68from bzrlib.transport.remote import (68from bzrlib.transport.remote import (
69 RemoteTransport,69 RemoteTransport,
@@ -359,8 +359,8 @@
359 a given client_base and transport_base.359 a given client_base and transport_base.
360 """360 """
361 client_medium = medium.SmartClientMedium(client_base)361 client_medium = medium.SmartClientMedium(client_base)
362 transport = get_transport(transport_base)362 t = transport.get_transport(transport_base)
363 result = client_medium.remote_path_from_transport(transport)363 result = client_medium.remote_path_from_transport(t)
364 self.assertEqual(expected, result)364 self.assertEqual(expected, result)
365365
366 def test_remote_path_from_transport(self):366 def test_remote_path_from_transport(self):
@@ -377,7 +377,7 @@
377 a given transport_base and relpath of that transport. (Note that377 a given transport_base and relpath of that transport. (Note that
378 HttpTransportBase is a subclass of SmartClientMedium)378 HttpTransportBase is a subclass of SmartClientMedium)
379 """379 """
380 base_transport = get_transport(transport_base)380 base_transport = transport.get_transport(transport_base)
381 client_medium = base_transport.get_smart_medium()381 client_medium = base_transport.get_smart_medium()
382 cloned_transport = base_transport.clone(relpath)382 cloned_transport = base_transport.clone(relpath)
383 result = client_medium.remote_path_from_transport(cloned_transport)383 result = client_medium.remote_path_from_transport(cloned_transport)
384384
=== modified file 'bzrlib/tests/test_selftest.py'
--- bzrlib/tests/test_selftest.py 2010-05-14 09:48:51 +0000
+++ bzrlib/tests/test_selftest.py 2010-06-29 17:48:31 +0000
@@ -622,7 +622,6 @@
622 """Tests for the convenience functions TestCaseWithTransport introduces."""622 """Tests for the convenience functions TestCaseWithTransport introduces."""
623623
624 def test_get_readonly_url_none(self):624 def test_get_readonly_url_none(self):
625 from bzrlib.transport import get_transport
626 from bzrlib.transport.readonly import ReadonlyTransportDecorator625 from bzrlib.transport.readonly import ReadonlyTransportDecorator
627 self.vfs_transport_factory = memory.MemoryServer626 self.vfs_transport_factory = memory.MemoryServer
628 self.transport_readonly_server = None627 self.transport_readonly_server = None
@@ -630,15 +629,14 @@
630 # for the server629 # for the server
631 url = self.get_readonly_url()630 url = self.get_readonly_url()
632 url2 = self.get_readonly_url('foo/bar')631 url2 = self.get_readonly_url('foo/bar')
633 t = get_transport(url)632 t = transport.get_transport(url)
634 t2 = get_transport(url2)633 t2 = transport.get_transport(url2)
635 self.failUnless(isinstance(t, ReadonlyTransportDecorator))634 self.failUnless(isinstance(t, ReadonlyTransportDecorator))
636 self.failUnless(isinstance(t2, ReadonlyTransportDecorator))635 self.failUnless(isinstance(t2, ReadonlyTransportDecorator))
637 self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))636 self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
638637
639 def test_get_readonly_url_http(self):638 def test_get_readonly_url_http(self):
640 from bzrlib.tests.http_server import HttpServer639 from bzrlib.tests.http_server import HttpServer
641 from bzrlib.transport import get_transport
642 from bzrlib.transport.http import HttpTransportBase640 from bzrlib.transport.http import HttpTransportBase
643 self.transport_server = test_server.LocalURLServer641 self.transport_server = test_server.LocalURLServer
644 self.transport_readonly_server = HttpServer642 self.transport_readonly_server = HttpServer
@@ -646,8 +644,8 @@
646 url = self.get_readonly_url()644 url = self.get_readonly_url()
647 url2 = self.get_readonly_url('foo/bar')645 url2 = self.get_readonly_url('foo/bar')
648 # the transport returned may be any HttpTransportBase subclass646 # the transport returned may be any HttpTransportBase subclass
649 t = get_transport(url)647 t = transport.get_transport(url)
650 t2 = get_transport(url2)648 t2 = transport.get_transport(url2)
651 self.failUnless(isinstance(t, HttpTransportBase))649 self.failUnless(isinstance(t, HttpTransportBase))
652 self.failUnless(isinstance(t2, HttpTransportBase))650 self.failUnless(isinstance(t2, HttpTransportBase))
653 self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))651 self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
@@ -691,8 +689,7 @@
691class TestChrootedTest(tests.ChrootedTestCase):689class TestChrootedTest(tests.ChrootedTestCase):
692690
693 def test_root_is_root(self):691 def test_root_is_root(self):
694 from bzrlib.transport import get_transport692 t = transport.get_transport(self.get_readonly_url())
695 t = get_transport(self.get_readonly_url())
696 url = t.base693 url = t.base
697 self.assertEqual(url, t.clone('..').base)694 self.assertEqual(url, t.clone('..').base)
698695
699696
=== modified file 'bzrlib/tests/test_sftp_transport.py'
--- bzrlib/tests/test_sftp_transport.py 2010-02-23 07:43:11 +0000
+++ bzrlib/tests/test_sftp_transport.py 2010-06-29 17:48:31 +0000
@@ -41,7 +41,6 @@
41 TestSkipped,41 TestSkipped,
42 )42 )
43from bzrlib.tests.http_server import HttpServer43from bzrlib.tests.http_server import HttpServer
44from bzrlib.transport import get_transport
45import bzrlib.transport.http44import bzrlib.transport.http
4645
47if features.paramiko.available():46if features.paramiko.available():
@@ -190,7 +189,7 @@
190 server = stub_sftp.SFTPSiblingAbsoluteServer()189 server = stub_sftp.SFTPSiblingAbsoluteServer()
191 server.start_server()190 server.start_server()
192 try:191 try:
193 transport = get_transport(server.get_url())192 transport = _mod_transport.get_transport(server.get_url())
194 self.assertFalse(transport.abspath('/').endswith('/~/'))193 self.assertFalse(transport.abspath('/').endswith('/~/'))
195 self.assertTrue(transport.abspath('/').endswith('/'))194 self.assertTrue(transport.abspath('/').endswith('/'))
196 del transport195 del transport
@@ -313,7 +312,7 @@
313 """Test that a real connection attempt raises the right error"""312 """Test that a real connection attempt raises the right error"""
314 from bzrlib.transport import ssh313 from bzrlib.transport import ssh
315 self.set_vendor(ssh.ParamikoVendor())314 self.set_vendor(ssh.ParamikoVendor())
316 t = bzrlib.transport.get_transport(self.bogus_url)315 t = _mod_transport.get_transport(self.bogus_url)
317 self.assertRaises(errors.ConnectionError, t.get, 'foobar')316 self.assertRaises(errors.ConnectionError, t.get, 'foobar')
318317
319 def test_bad_connection_ssh(self):318 def test_bad_connection_ssh(self):
@@ -324,7 +323,7 @@
324 # However, 'ssh' will create stipple on the output, so instead323 # However, 'ssh' will create stipple on the output, so instead
325 # I'm using run_bzr_subprocess, and parsing the output324 # I'm using run_bzr_subprocess, and parsing the output
326 # try:325 # try:
327 # t = bzrlib.transport.get_transport(self.bogus_url)326 # t = _mod_transport.get_transport(self.bogus_url)
328 # except errors.ConnectionError:327 # except errors.ConnectionError:
329 # # Correct error328 # # Correct error
330 # pass329 # pass
@@ -511,7 +510,7 @@
511 conf._get_config().update(510 conf._get_config().update(
512 {'sftptest': {'scheme': 'ssh', 'port': port, 'user': 'bar'}})511 {'sftptest': {'scheme': 'ssh', 'port': port, 'user': 'bar'}})
513 conf._save()512 conf._save()
514 t = get_transport('sftp://localhost:%d' % port)513 t = _mod_transport.get_transport('sftp://localhost:%d' % port)
515 # force a connection to be performed.514 # force a connection to be performed.
516 t.has('foo')515 t.has('foo')
517 return t516 return t
518517
=== modified file 'bzrlib/tests/test_smart_request.py'
--- bzrlib/tests/test_smart_request.py 2009-07-27 02:11:25 +0000
+++ bzrlib/tests/test_smart_request.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2009 Canonical Ltd1# Copyright (C) 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -18,11 +18,13 @@
1818
19import threading19import threading
2020
21from bzrlib import errors21from bzrlib import (
22 errors,
23 transport,
24 )
22from bzrlib.bzrdir import BzrDir25from bzrlib.bzrdir import BzrDir
23from bzrlib.smart import request26from bzrlib.smart import request
24from bzrlib.tests import TestCase, TestCaseWithMemoryTransport27from bzrlib.tests import TestCase, TestCaseWithMemoryTransport
25from bzrlib.transport import get_transport
2628
2729
28class NoBodyRequest(request.SmartServerRequest):30class NoBodyRequest(request.SmartServerRequest):
@@ -34,7 +36,7 @@
3436
35class DoErrorRequest(request.SmartServerRequest):37class DoErrorRequest(request.SmartServerRequest):
36 """A request that raises an error from self.do()."""38 """A request that raises an error from self.do()."""
37 39
38 def do(self):40 def do(self):
39 raise errors.NoSuchFile('xyzzy')41 raise errors.NoSuchFile('xyzzy')
4042
@@ -172,7 +174,7 @@
172174
173175
174class TestRequestJail(TestCaseWithMemoryTransport):176class TestRequestJail(TestCaseWithMemoryTransport):
175 177
176 def test_jail(self):178 def test_jail(self):
177 transport = self.get_transport('blah')179 transport = self.get_transport('blah')
178 req = request.SmartServerRequest(transport)180 req = request.SmartServerRequest(transport)
@@ -203,8 +205,8 @@
203 # A parent is not allowed205 # A parent is not allowed
204 self.assertRaises(errors.JailBreak, _pre_open_hook, t.clone('..'))206 self.assertRaises(errors.JailBreak, _pre_open_hook, t.clone('..'))
205 # A completely unrelated transport is not allowed207 # A completely unrelated transport is not allowed
206 self.assertRaises(208 self.assertRaises(errors.JailBreak, _pre_open_hook,
207 errors.JailBreak, _pre_open_hook, get_transport('http://host/'))209 transport.get_transport('http://host/'))
208210
209 def test_open_bzrdir_in_non_main_thread(self):211 def test_open_bzrdir_in_non_main_thread(self):
210 """Opening a bzrdir in a non-main thread should work ok.212 """Opening a bzrdir in a non-main thread should work ok.
211213
=== modified file 'bzrlib/tests/test_transport_log.py'
--- bzrlib/tests/test_transport_log.py 2010-02-17 17:11:16 +0000
+++ bzrlib/tests/test_transport_log.py 2010-06-29 17:48:31 +0000
@@ -20,10 +20,9 @@
2020
21import types21import types
2222
2323from bzrlib import transport
24from bzrlib.tests import TestCaseWithMemoryTransport24from bzrlib.tests import TestCaseWithMemoryTransport
25from bzrlib.trace import mutter25from bzrlib.trace import mutter
26from bzrlib.transport import get_transport
27from bzrlib.transport.log import TransportLogDecorator26from bzrlib.transport.log import TransportLogDecorator
2827
2928
@@ -31,7 +30,8 @@
3130
32 def test_log_transport(self):31 def test_log_transport(self):
33 base_transport = self.get_transport('')32 base_transport = self.get_transport('')
34 logging_transport = get_transport('log+' + base_transport.base)33 logging_transport = transport.get_transport(
34 'log+' + base_transport.base)
3535
36 # operations such as mkdir are logged36 # operations such as mkdir are logged
37 mutter('where are you?')37 mutter('where are you?')
3838
=== modified file 'bzrlib/tests/test_upgrade.py'
--- bzrlib/tests/test_upgrade.py 2010-02-15 10:46:49 +0000
+++ bzrlib/tests/test_upgrade.py 2010-06-29 17:48:31 +0000
@@ -31,13 +31,13 @@
31 bzrdir,31 bzrdir,
32 progress,32 progress,
33 repository,33 repository,
34 transport,
34 workingtree,35 workingtree,
35 workingtree_4,36 workingtree_4,
36 )37 )
37import bzrlib.branch38import bzrlib.branch
38from bzrlib.branch import Branch39from bzrlib.branch import Branch
39from bzrlib.tests import TestCaseWithTransport40from bzrlib.tests import TestCaseWithTransport
40from bzrlib.transport import get_transport
41from bzrlib.upgrade import upgrade41from bzrlib.upgrade import upgrade
4242
4343
@@ -80,27 +80,27 @@
80 rt.unlock()80 rt.unlock()
81 # check a backup was made:81 # check a backup was made:
82 backup_dir = 'backup.bzr.~1~'82 backup_dir = 'backup.bzr.~1~'
83 transport = get_transport(b.base)83 t = transport.get_transport(b.base)
84 transport.stat(backup_dir)84 t.stat(backup_dir)
85 transport.stat(backup_dir + '/README')85 t.stat(backup_dir + '/README')
86 transport.stat(backup_dir + '/branch-format')86 t.stat(backup_dir + '/branch-format')
87 transport.stat(backup_dir + '/revision-history')87 t.stat(backup_dir + '/revision-history')
88 transport.stat(backup_dir + '/merged-patches')88 t.stat(backup_dir + '/merged-patches')
89 transport.stat(backup_dir + '/pending-merged-patches')89 t.stat(backup_dir + '/pending-merged-patches')
90 transport.stat(backup_dir + '/pending-merges')90 t.stat(backup_dir + '/pending-merges')
91 transport.stat(backup_dir + '/branch-name')91 t.stat(backup_dir + '/branch-name')
92 transport.stat(backup_dir + '/branch-lock')92 t.stat(backup_dir + '/branch-lock')
93 transport.stat(backup_dir + '/inventory')93 t.stat(backup_dir + '/inventory')
94 transport.stat(backup_dir + '/stat-cache')94 t.stat(backup_dir + '/stat-cache')
95 transport.stat(backup_dir + '/text-store')95 t.stat(backup_dir + '/text-store')
96 transport.stat(backup_dir + '/text-store/foo-20051004035611-1591048e9dc7c2d4.gz')96 t.stat(backup_dir + '/text-store/foo-20051004035611-1591048e9dc7c2d4.gz')
97 transport.stat(backup_dir + '/text-store/foo-20051004035756-4081373d897c3453.gz')97 t.stat(backup_dir + '/text-store/foo-20051004035756-4081373d897c3453.gz')
98 transport.stat(backup_dir + '/inventory-store/')98 t.stat(backup_dir + '/inventory-store/')
99 transport.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')99 t.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
100 transport.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')100 t.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
101 transport.stat(backup_dir + '/revision-store/')101 t.stat(backup_dir + '/revision-store/')
102 transport.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')102 t.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
103 transport.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')103 t.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
104104
105 def test_upgrade_with_ghosts(self):105 def test_upgrade_with_ghosts(self):
106 """Upgrade v0.0.4 tree containing ghost references.106 """Upgrade v0.0.4 tree containing ghost references.
@@ -153,12 +153,12 @@
153 # such a branch to metadir must not setup a working tree.153 # such a branch to metadir must not setup a working tree.
154 self.build_tree_contents(_upgrade1_template)154 self.build_tree_contents(_upgrade1_template)
155 upgrade('.', bzrdir.BzrDirFormat6())155 upgrade('.', bzrdir.BzrDirFormat6())
156 transport = get_transport('.')156 t = transport.get_transport('.')
157 transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])157 t.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
158 self.assertFalse(transport.has('.bzr/stat-cache'))158 self.assertFalse(t.has('.bzr/stat-cache'))
159 # XXX: upgrade fails if a backup.bzr is already present159 # XXX: upgrade fails if a backup.bzr is already present
160 # -- David Allouche 2006-08-11160 # -- David Allouche 2006-08-11
161 transport.delete_tree('backup.bzr.~1~')161 t.delete_tree('backup.bzr.~1~')
162 # At this point, we have a format6 branch without checkout files.162 # At this point, we have a format6 branch without checkout files.
163 upgrade('.', bzrdir.BzrDirMetaFormat1())163 upgrade('.', bzrdir.BzrDirMetaFormat1())
164 # The upgrade should not have set up a working tree.164 # The upgrade should not have set up a working tree.
165165
=== modified file 'bzrlib/tests/test_workingtree.py'
--- bzrlib/tests/test_workingtree.py 2010-04-23 08:51:52 +0000
+++ bzrlib/tests/test_workingtree.py 2010-06-29 17:48:31 +0000
@@ -22,6 +22,7 @@
22 bzrdir,22 bzrdir,
23 conflicts,23 conflicts,
24 errors,24 errors,
25 transport,
25 workingtree,26 workingtree,
26 )27 )
27from bzrlib.branch import Branch28from bzrlib.branch import Branch
@@ -29,7 +30,6 @@
29from bzrlib.lockdir import LockDir30from bzrlib.lockdir import LockDir
30from bzrlib.mutabletree import needs_tree_write_lock31from bzrlib.mutabletree import needs_tree_write_lock
31from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped32from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
32from bzrlib.transport import get_transport
33from bzrlib.workingtree import (33from bzrlib.workingtree import (
34 TreeEntry,34 TreeEntry,
35 TreeDirectory,35 TreeDirectory,
@@ -138,7 +138,7 @@
138 dir.create_repository()138 dir.create_repository()
139 dir.create_branch()139 dir.create_branch()
140 format.initialize(dir)140 format.initialize(dir)
141 t = get_transport(url)141 t = transport.get_transport(url)
142 found_format = workingtree.WorkingTreeFormat.find_format(dir)142 found_format = workingtree.WorkingTreeFormat.find_format(dir)
143 self.failUnless(isinstance(found_format, format.__class__))143 self.failUnless(isinstance(found_format, format.__class__))
144 check_format(workingtree.WorkingTreeFormat3(), "bar")144 check_format(workingtree.WorkingTreeFormat3(), "bar")
145145
=== modified file 'bzrlib/textmerge.py'
--- bzrlib/textmerge.py 2010-06-04 03:09:35 +0000
+++ bzrlib/textmerge.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005, 2006 Canonical Ltd1# Copyright (C) 2006, 2009, 2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/transport/decorator.py'
--- bzrlib/transport/decorator.py 2010-02-23 07:43:11 +0000
+++ bzrlib/transport/decorator.py 2010-06-29 17:48:31 +0000
@@ -20,10 +20,10 @@
20stub functions to allow other decorators to be written easily.20stub functions to allow other decorators to be written easily.
21"""21"""
2222
23from bzrlib.transport import get_transport, Transport, Server23from bzrlib import transport
2424
2525
26class TransportDecorator(Transport):26class TransportDecorator(transport.Transport):
27 """A no-change decorator for Transports.27 """A no-change decorator for Transports.
2828
29 Subclasses of this are new transports that are based on an29 Subclasses of this are new transports that are based on an
@@ -50,7 +50,7 @@
50 (url, prefix))50 (url, prefix))
51 not_decorated_url = url[len(prefix):]51 not_decorated_url = url[len(prefix):]
52 if _decorated is None:52 if _decorated is None:
53 self._decorated = get_transport(not_decorated_url)53 self._decorated = transport.get_transport(not_decorated_url)
54 else:54 else:
55 self._decorated = _decorated55 self._decorated = _decorated
56 super(TransportDecorator, self).__init__(prefix + self._decorated.base)56 super(TransportDecorator, self).__init__(prefix + self._decorated.base)
5757
=== modified file 'bzrlib/transport/remote.py'
--- bzrlib/transport/remote.py 2010-06-16 05:47:02 +0000
+++ bzrlib/transport/remote.py 2010-06-29 17:48:31 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006 Canonical Ltd1# Copyright (C) 2006-2010 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
55
=== modified file 'bzrlib/workingtree.py'
--- bzrlib/workingtree.py 2010-05-25 17:27:52 +0000
+++ bzrlib/workingtree.py 2010-06-29 17:48:31 +0000
@@ -61,13 +61,12 @@
61 revisiontree,61 revisiontree,
62 trace,62 trace,
63 transform,63 transform,
64 transport,
64 ui,65 ui,
65 views,66 views,
66 xml5,67 xml5,
67 xml7,68 xml7,
68 )69 )
69import bzrlib.branch
70from bzrlib.transport import get_transport
71from bzrlib.workingtree_4 import (70from bzrlib.workingtree_4 import (
72 WorkingTreeFormat4,71 WorkingTreeFormat4,
73 WorkingTreeFormat5,72 WorkingTreeFormat5,
@@ -369,10 +368,10 @@
369 return True, None368 return True, None
370 else:369 else:
371 return True, tree370 return True, tree
372 transport = get_transport(location)371 t = transport.get_transport(location)
373 iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,372 iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
374 list_current=list_current)373 list_current=list_current)
375 return [t for t in iterator if t is not None]374 return [tr for tr in iterator if tr is not None]
376375
377 # should be deprecated - this is slow and in any case treating them as a376 # should be deprecated - this is slow and in any case treating them as a
378 # container is (we now know) bad style -- mbp 20070302377 # container is (we now know) bad style -- mbp 20070302