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
1=== modified file 'bzrlib/_annotator_py.py'
2--- bzrlib/_annotator_py.py 2010-06-04 03:09:35 +0000
3+++ bzrlib/_annotator_py.py 2010-06-29 17:48:31 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2009 Canonical Ltd
6+# Copyright (C) 2009, 2010 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10
11=== modified file 'bzrlib/add.py'
12--- bzrlib/add.py 2010-06-21 21:50:57 +0000
13+++ bzrlib/add.py 2010-06-29 17:48:31 +0000
14@@ -1,4 +1,4 @@
15-# Copyright (C) 2005, 2006 Canonical Ltd
16+# Copyright (C) 2005-2010 Canonical Ltd
17 #
18 # This program is free software; you can redistribute it and/or modify
19 # it under the terms of the GNU General Public License as published by
20
21=== modified file 'bzrlib/annotate.py'
22--- bzrlib/annotate.py 2010-06-04 03:09:35 +0000
23+++ bzrlib/annotate.py 2010-06-29 17:48:31 +0000
24@@ -1,4 +1,4 @@
25-# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Canonical Ltd
26+# Copyright (C) 2005-2010 Canonical Ltd
27 #
28 # This program is free software; you can redistribute it and/or modify
29 # it under the terms of the GNU General Public License as published by
30
31=== modified file 'bzrlib/benchmarks/bench_commit.py'
32--- bzrlib/benchmarks/bench_commit.py 2009-03-23 14:59:43 +0000
33+++ bzrlib/benchmarks/bench_commit.py 2010-06-29 17:48:31 +0000
34@@ -1,4 +1,4 @@
35-# Copyright (C) 2006 Canonical Ltd
36+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
37 #
38 # This program is free software; you can redistribute it and/or modify
39 # it under the terms of the GNU General Public License as published by
40@@ -20,7 +20,6 @@
41
42 from bzrlib.benchmarks import Benchmark
43 from bzrlib.transport.memory import MemoryServer
44-from bzrlib.transport import get_transport
45
46
47 class CommitBenchmark(Benchmark):
48
49=== modified file 'bzrlib/breakin.py'
50--- bzrlib/breakin.py 2010-06-02 04:50:35 +0000
51+++ bzrlib/breakin.py 2010-06-29 17:48:31 +0000
52@@ -1,4 +1,4 @@
53-# Copyright (C) 2006, 2007, 2009 Canonical Ltd
54+# Copyright (C) 2007, 2009, 2010 Canonical Ltd
55 #
56 # This program is free software; you can redistribute it and/or modify
57 # it under the terms of the GNU General Public License as published by
58
59=== modified file 'bzrlib/btree_index.py'
60--- bzrlib/btree_index.py 2010-03-25 12:32:24 +0000
61+++ bzrlib/btree_index.py 2010-06-29 17:48:31 +0000
62@@ -33,9 +33,9 @@
63 osutils,
64 static_tuple,
65 trace,
66+ transport,
67 )
68 from bzrlib.index import _OPTION_NODE_REFS, _OPTION_KEY_ELEMENTS, _OPTION_LEN
69-from bzrlib.transport import get_transport
70
71
72 _BTSIGNATURE = "B+Tree Graph Index 2\n"
73@@ -193,7 +193,8 @@
74 new_backing_file, size = self._spill_mem_keys_without_combining()
75 # Note: The transport here isn't strictly needed, because we will use
76 # direct access to the new_backing._file object
77- new_backing = BTreeGraphIndex(get_transport('.'), '<temp>', size)
78+ new_backing = BTreeGraphIndex(transport.get_transport('.'),
79+ '<temp>', size)
80 # GC will clean up the file
81 new_backing._file = new_backing_file
82 if self._combine_backing_indices:
83
84=== modified file 'bzrlib/builtins.py'
85--- bzrlib/builtins.py 2010-06-17 08:53:15 +0000
86+++ bzrlib/builtins.py 2010-06-29 17:48:31 +0000
87@@ -4920,17 +4920,17 @@
88
89 def run(self, port=None, inet=False, directory=None, allow_writes=False,
90 protocol=None):
91- from bzrlib.transport import get_transport, transport_server_registry
92+ from bzrlib import transport
93 if directory is None:
94 directory = os.getcwd()
95 if protocol is None:
96- protocol = transport_server_registry.get()
97+ protocol = transport.transport_server_registry.get()
98 host, port = self.get_host_and_port(port)
99 url = urlutils.local_path_to_url(directory)
100 if not allow_writes:
101 url = 'readonly+' + url
102- transport = get_transport(url)
103- protocol(transport, host, port, inet)
104+ t = transport.get_transport(url)
105+ protocol(t, host, port, inet)
106
107
108 class cmd_join(Command):
109
110=== modified file 'bzrlib/filters/eol.py'
111--- bzrlib/filters/eol.py 2010-06-02 04:56:07 +0000
112+++ bzrlib/filters/eol.py 2010-06-29 17:48:31 +0000
113@@ -1,4 +1,4 @@
114-# Copyright (C) 2009 Canonical Ltd
115+# Copyright (C) 2009, 2010 Canonical Ltd
116 #
117 # This program is free software; you can redistribute it and/or modify
118 # it under the terms of the GNU General Public License as published by
119
120=== modified file 'bzrlib/osutils.py'
121--- bzrlib/osutils.py 2010-06-25 20:34:05 +0000
122+++ bzrlib/osutils.py 2010-06-29 17:48:31 +0000
123@@ -18,7 +18,6 @@
124 import os
125 import re
126 import stat
127-from stat import S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE
128 import sys
129 import time
130 import codecs
131@@ -27,23 +26,18 @@
132 lazy_import(globals(), """
133 from datetime import datetime
134 import getpass
135-from ntpath import (abspath as _nt_abspath,
136- join as _nt_join,
137- normpath as _nt_normpath,
138- realpath as _nt_realpath,
139- splitdrive as _nt_splitdrive,
140- )
141+import ntpath
142 import posixpath
143+# We need to import both shutil and rmtree as we export the later on posix
144+# and need the former on windows
145 import shutil
146-from shutil import (
147- rmtree,
148- )
149+from shutil import rmtree
150 import socket
151 import subprocess
152+# We need to import both tempfile and mkdtemp as we export the later on posix
153+# and need the former on windows
154 import tempfile
155-from tempfile import (
156- mkdtemp,
157- )
158+from tempfile import mkdtemp
159 import unicodedata
160
161 from bzrlib import (
162@@ -304,13 +298,13 @@
163 running python.exe under cmd.exe return capital C:\\
164 running win32 python inside a cygwin shell returns lowercase c:\\
165 """
166- drive, path = _nt_splitdrive(path)
167+ drive, path = ntpath.splitdrive(path)
168 return drive.upper() + path
169
170
171 def _win32_abspath(path):
172- # Real _nt_abspath doesn't have a problem with a unicode cwd
173- return _win32_fixdrive(_nt_abspath(unicode(path)).replace('\\', '/'))
174+ # Real ntpath.abspath doesn't have a problem with a unicode cwd
175+ return _win32_fixdrive(ntpath.abspath(unicode(path)).replace('\\', '/'))
176
177
178 def _win98_abspath(path):
179@@ -327,30 +321,30 @@
180 # /path => C:/path
181 path = unicode(path)
182 # check for absolute path
183- drive = _nt_splitdrive(path)[0]
184+ drive = ntpath.splitdrive(path)[0]
185 if drive == '' and path[:2] not in('//','\\\\'):
186 cwd = os.getcwdu()
187 # we cannot simply os.path.join cwd and path
188 # because os.path.join('C:','/path') produce '/path'
189 # and this is incorrect
190 if path[:1] in ('/','\\'):
191- cwd = _nt_splitdrive(cwd)[0]
192+ cwd = ntpath.splitdrive(cwd)[0]
193 path = path[1:]
194 path = cwd + '\\' + path
195- return _win32_fixdrive(_nt_normpath(path).replace('\\', '/'))
196+ return _win32_fixdrive(ntpath.normpath(path).replace('\\', '/'))
197
198
199 def _win32_realpath(path):
200- # Real _nt_realpath doesn't have a problem with a unicode cwd
201- return _win32_fixdrive(_nt_realpath(unicode(path)).replace('\\', '/'))
202+ # Real ntpath.realpath doesn't have a problem with a unicode cwd
203+ return _win32_fixdrive(ntpath.realpath(unicode(path)).replace('\\', '/'))
204
205
206 def _win32_pathjoin(*args):
207- return _nt_join(*args).replace('\\', '/')
208+ return ntpath.join(*args).replace('\\', '/')
209
210
211 def _win32_normpath(path):
212- return _win32_fixdrive(_nt_normpath(unicode(path)).replace('\\', '/'))
213+ return _win32_fixdrive(ntpath.normpath(unicode(path)).replace('\\', '/'))
214
215
216 def _win32_getcwd():
217@@ -358,7 +352,7 @@
218
219
220 def _win32_mkdtemp(*args, **kwargs):
221- return _win32_fixdrive(tempfile.mkdtemp(*args, **kwargs).replace('\\', '/'))
222+ return _win32_fixdrive(mkdtemp(*args, **kwargs).replace('\\', '/'))
223
224
225 def _win32_rename(old, new):
226@@ -395,7 +389,7 @@
227 basename = os.path.basename
228 split = os.path.split
229 splitext = os.path.splitext
230-# These were already imported into local scope
231+# These were already lazily imported into local scope
232 # mkdtemp = tempfile.mkdtemp
233 # rmtree = shutil.rmtree
234
235@@ -509,7 +503,7 @@
236 def isdir(f):
237 """True if f is an accessible directory."""
238 try:
239- return S_ISDIR(os.lstat(f)[ST_MODE])
240+ return stat.S_ISDIR(os.lstat(f)[stat.ST_MODE])
241 except OSError:
242 return False
243
244@@ -517,14 +511,14 @@
245 def isfile(f):
246 """True if f is a regular file."""
247 try:
248- return S_ISREG(os.lstat(f)[ST_MODE])
249+ return stat.S_ISREG(os.lstat(f)[stat.ST_MODE])
250 except OSError:
251 return False
252
253 def islink(f):
254 """True if f is a symlink."""
255 try:
256- return S_ISLNK(os.lstat(f)[ST_MODE])
257+ return stat.S_ISLNK(os.lstat(f)[stat.ST_MODE])
258 except OSError:
259 return False
260
261@@ -870,7 +864,7 @@
262
263 def filesize(f):
264 """Return size of given open file."""
265- return os.fstat(f.fileno())[ST_SIZE]
266+ return os.fstat(f.fileno())[stat.ST_SIZE]
267
268
269 # Define rand_bytes based on platform.
270
271=== modified file 'bzrlib/plugins/launchpad/account.py'
272--- bzrlib/plugins/launchpad/account.py 2009-04-27 16:10:10 +0000
273+++ bzrlib/plugins/launchpad/account.py 2010-06-29 17:48:31 +0000
274@@ -1,4 +1,4 @@
275-# Copyright (C) 2007, 2008 Canonical Ltd
276+# Copyright (C) 2007-2010 Canonical Ltd
277 #
278 # This program is free software; you can redistribute it and/or modify
279 # it under the terms of the GNU General Public License as published by
280@@ -20,9 +20,12 @@
281 than once for each place that needs to take it into account.
282 """
283
284-from bzrlib import errors, trace
285+from bzrlib import (
286+ errors,
287+ trace,
288+ transport,
289+ )
290 from bzrlib.config import AuthenticationConfig, GlobalConfig
291-from bzrlib.transport import get_transport
292
293
294 LAUNCHPAD_BASE = 'https://launchpad.net/'
295@@ -97,7 +100,7 @@
296 uploaded SSH keys.
297 """
298 if _transport is None:
299- _transport = get_transport(LAUNCHPAD_BASE)
300+ _transport = transport.get_transport(LAUNCHPAD_BASE)
301
302 try:
303 data = _transport.get_bytes('~%s/+sshkeys' % username)
304
305=== modified file 'bzrlib/plugins/launchpad/test_lp_directory.py'
306--- bzrlib/plugins/launchpad/test_lp_directory.py 2010-05-20 18:23:10 +0000
307+++ bzrlib/plugins/launchpad/test_lp_directory.py 2010-06-29 17:48:31 +0000
308@@ -22,6 +22,7 @@
309 from bzrlib import (
310 errors,
311 tests,
312+ transport,
313 )
314 from bzrlib.branch import Branch
315 from bzrlib.directory_service import directories
316@@ -29,7 +30,6 @@
317 TestCaseInTempDir,
318 TestCaseWithMemoryTransport
319 )
320-from bzrlib.transport import get_transport
321 from bzrlib.plugins.launchpad import (
322 _register_directory,
323 lp_registration,
324@@ -217,8 +217,8 @@
325 directories.register('lp:', FooService, 'Map lp URLs to local urls')
326 self.addCleanup(_register_directory)
327 self.addCleanup(directories.remove, 'lp:')
328- transport = get_transport('lp:///apt')
329- branch = Branch.open_from_transport(transport)
330+ t = transport.get_transport('lp:///apt')
331+ branch = Branch.open_from_transport(t)
332 self.assertEqual(target_branch.base, branch.base)
333
334
335
336=== modified file 'bzrlib/symbol_versioning.py'
337--- bzrlib/symbol_versioning.py 2010-06-25 06:11:21 +0000
338+++ bzrlib/symbol_versioning.py 2010-06-29 17:48:31 +0000
339@@ -1,4 +1,4 @@
340-# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
341+# Copyright (C) 2006-2010 Canonical Ltd
342 #
343 # This program is free software; you can redistribute it and/or modify
344 # it under the terms of the GNU General Public License as published by
345
346=== modified file 'bzrlib/tests/__init__.py'
347--- bzrlib/tests/__init__.py 2010-06-25 06:12:56 +0000
348+++ bzrlib/tests/__init__.py 2010-06-29 17:48:31 +0000
349@@ -29,7 +29,7 @@
350
351 import atexit
352 import codecs
353-from copy import copy
354+import copy
355 from cStringIO import StringIO
356 import difflib
357 import doctest
358@@ -37,12 +37,12 @@
359 import logging
360 import math
361 import os
362-from pprint import pformat
363+import pprint
364 import random
365 import re
366 import shlex
367 import stat
368-from subprocess import Popen, PIPE, STDOUT
369+import subprocess
370 import sys
371 import tempfile
372 import threading
373@@ -74,6 +74,7 @@
374 ui,
375 urlutils,
376 registry,
377+ transport as _mod_transport,
378 workingtree,
379 )
380 import bzrlib.branch
381@@ -103,11 +104,9 @@
382 )
383 import bzrlib.trace
384 from bzrlib.transport import (
385- get_transport,
386 memory,
387 pathfilter,
388 )
389-import bzrlib.transport
390 from bzrlib.trace import mutter, note
391 from bzrlib.tests import (
392 test_server,
393@@ -943,7 +942,7 @@
394
395 def permit_dir(self, name):
396 """Permit a directory to be used by this test. See permit_url."""
397- name_transport = get_transport(name)
398+ name_transport = _mod_transport.get_transport(name)
399 self.permit_url(name)
400 self.permit_url(name_transport.base)
401
402@@ -1028,7 +1027,7 @@
403 self.addCleanup(transport_server.stop_server)
404 # Obtain a real transport because if the server supplies a password, it
405 # will be hidden from the base on the client side.
406- t = get_transport(transport_server.get_url())
407+ t = _mod_transport.get_transport(transport_server.get_url())
408 # Some transport servers effectively chroot the backing transport;
409 # others like SFTPServer don't - users of the transport can walk up the
410 # transport to read the entire backing transport. This wouldn't matter
411@@ -1095,7 +1094,7 @@
412 message += '\n'
413 raise AssertionError("%snot equal:\na = %s\nb = %s\n"
414 % (message,
415- pformat(a), pformat(b)))
416+ pprint.pformat(a), pprint.pformat(b)))
417
418 assertEquals = assertEqual
419
420@@ -1986,7 +1985,9 @@
421 if not allow_plugins:
422 command.append('--no-plugins')
423 command.extend(process_args)
424- process = self._popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
425+ process = self._popen(command, stdin=subprocess.PIPE,
426+ stdout=subprocess.PIPE,
427+ stderr=subprocess.PIPE)
428 finally:
429 restore_environment()
430 if cwd is not None:
431@@ -2000,7 +2001,7 @@
432 Allows tests to override this method to intercept the calls made to
433 Popen for introspection.
434 """
435- return Popen(*args, **kwargs)
436+ return subprocess.Popen(*args, **kwargs)
437
438 def get_source_path(self):
439 """Return the path of the directory containing bzrlib."""
440@@ -2186,7 +2187,7 @@
441
442 :param relpath: a path relative to the base url.
443 """
444- t = get_transport(self.get_url(relpath))
445+ t = _mod_transport.get_transport(self.get_url(relpath))
446 self.assertFalse(t.is_readonly())
447 return t
448
449@@ -2198,7 +2199,7 @@
450
451 :param relpath: a path relative to the base url.
452 """
453- t = get_transport(self.get_readonly_url(relpath))
454+ t = _mod_transport.get_transport(self.get_readonly_url(relpath))
455 self.assertTrue(t.is_readonly())
456 return t
457
458@@ -2334,7 +2335,7 @@
459 propagating. This method ensures than a test did not leaked.
460 """
461 root = TestCaseWithMemoryTransport.TEST_ROOT
462- self.permit_url(get_transport(root).base)
463+ self.permit_url(_mod_transport.get_transport(root).base)
464 wt = workingtree.WorkingTree.open(root)
465 last_rev = wt.last_revision()
466 if last_rev != 'null:':
467@@ -2385,7 +2386,7 @@
468 # might be a relative or absolute path
469 maybe_a_url = self.get_url(relpath)
470 segments = maybe_a_url.rsplit('/', 1)
471- t = get_transport(maybe_a_url)
472+ t = _mod_transport.get_transport(maybe_a_url)
473 if len(segments) > 1 and segments[-1] not in ('', '.'):
474 t.ensure_base()
475 if format is None:
476@@ -2413,7 +2414,8 @@
477 backing_server = self.get_server()
478 smart_server = test_server.SmartTCPServer_for_testing()
479 self.start_server(smart_server, backing_server)
480- remote_transport = get_transport(smart_server.get_url()).clone(path)
481+ remote_transport = _mod_transport.get_transport(smart_server.get_url()
482+ ).clone(path)
483 return remote_transport
484
485 def make_branch_and_memory_tree(self, relpath, format=None):
486@@ -2568,7 +2570,7 @@
487 "a list or a tuple. Got %r instead" % (shape,))
488 # It's OK to just create them using forward slashes on windows.
489 if transport is None or transport.is_readonly():
490- transport = get_transport(".")
491+ transport = _mod_transport.get_transport(".")
492 for name in shape:
493 self.assertIsInstance(name, basestring)
494 if name[-1] == '/':
495@@ -3315,10 +3317,12 @@
496 '--subunit']
497 if '--no-plugins' in sys.argv:
498 argv.append('--no-plugins')
499- # stderr=STDOUT would be ideal, but until we prevent noise on
500- # stderr it can interrupt the subunit protocol.
501- process = Popen(argv, stdin=PIPE, stdout=PIPE, stderr=PIPE,
502- bufsize=1)
503+ # stderr=subprocess.STDOUT would be ideal, but until we prevent
504+ # noise on stderr it can interrupt the subunit protocol.
505+ process = subprocess.Popen(argv, stdin=subprocess.PIPE,
506+ stdout=subprocess.PIPE,
507+ stderr=subprocess.PIPE,
508+ bufsize=1)
509 test = TestInSubprocess(process, test_list_file_name)
510 result.append(test)
511 except:
512@@ -4043,7 +4047,7 @@
513 :param new_id: The id to assign to it.
514 :return: The new test.
515 """
516- new_test = copy(test)
517+ new_test = copy.copy(test)
518 new_test.id = lambda: new_id
519 return new_test
520
521
522=== modified file 'bzrlib/tests/blackbox/__init__.py'
523--- bzrlib/tests/blackbox/__init__.py 2010-06-20 22:38:35 +0000
524+++ bzrlib/tests/blackbox/__init__.py 2010-06-29 17:48:31 +0000
525@@ -1,4 +1,4 @@
526-# Copyright (C) 2005-2007, 2010 Canonical Ltd
527+# Copyright (C) 2005-2010 Canonical Ltd
528 #
529 # This program is free software; you can redistribute it and/or modify
530 # it under the terms of the GNU General Public License as published by
531
532=== modified file 'bzrlib/tests/blackbox/test_alias.py'
533--- bzrlib/tests/blackbox/test_alias.py 2010-06-11 07:32:12 +0000
534+++ bzrlib/tests/blackbox/test_alias.py 2010-06-29 17:48:31 +0000
535@@ -1,4 +1,4 @@
536-# Copyright (C) 2005, 2006, 2007 Canonical Ltd
537+# Copyright (C) 2008, 2009, 2010 Canonical Ltd
538 #
539 # This program is free software; you can redistribute it and/or modify
540 # it under the terms of the GNU General Public License as published by
541
542=== modified file 'bzrlib/tests/blackbox/test_aliases.py'
543--- bzrlib/tests/blackbox/test_aliases.py 2010-06-11 07:32:12 +0000
544+++ bzrlib/tests/blackbox/test_aliases.py 2010-06-29 17:48:31 +0000
545@@ -1,4 +1,4 @@
546-# Copyright (C) 2005, 2006 Canonical Ltd
547+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
548 #
549 # This program is free software; you can redistribute it and/or modify
550 # it under the terms of the GNU General Public License as published by
551
552=== modified file 'bzrlib/tests/blackbox/test_cat_revision.py'
553--- bzrlib/tests/blackbox/test_cat_revision.py 2010-06-11 06:52:28 +0000
554+++ bzrlib/tests/blackbox/test_cat_revision.py 2010-06-29 17:48:31 +0000
555@@ -1,4 +1,4 @@
556-# Copyright (C) 2004-2010 Canonical Ltd
557+# Copyright (C) 2007-2010 Canonical Ltd
558 #
559 # This program is free software; you can redistribute it and/or modify
560 # it under the terms of the GNU General Public License as published by
561
562=== modified file 'bzrlib/tests/blackbox/test_check.py'
563--- bzrlib/tests/blackbox/test_check.py 2010-06-11 07:32:12 +0000
564+++ bzrlib/tests/blackbox/test_check.py 2010-06-29 17:48:31 +0000
565@@ -1,4 +1,4 @@
566-# Copyright (C) 2007, 2009 Canonical Ltd
567+# Copyright (C) 2007-2010 Canonical Ltd
568 #
569 # This program is free software; you can redistribute it and/or modify
570 # it under the terms of the GNU General Public License as published by
571
572=== modified file 'bzrlib/tests/blackbox/test_dpush.py'
573--- bzrlib/tests/blackbox/test_dpush.py 2010-06-20 22:38:35 +0000
574+++ bzrlib/tests/blackbox/test_dpush.py 2010-06-29 17:48:31 +0000
575@@ -1,4 +1,4 @@
576-# Copyright (C) 2005, 2007-2010 Canonical Ltd
577+# Copyright (C) 2009, 2010 Canonical Ltd
578 #
579 # This program is free software; you can redistribute it and/or modify
580 # it under the terms of the GNU General Public License as published by
581
582=== modified file 'bzrlib/tests/blackbox/test_filesystem_cicp.py'
583--- bzrlib/tests/blackbox/test_filesystem_cicp.py 2010-06-11 07:23:10 +0000
584+++ bzrlib/tests/blackbox/test_filesystem_cicp.py 2010-06-29 17:48:31 +0000
585@@ -1,4 +1,4 @@
586-# Copyright (C) 2008, 2010 Canonical Ltd
587+# Copyright (C) 2008, 2009, 2010 Canonical Ltd
588 #
589 # This program is free software; you can redistribute it and/or modify
590 # it under the terms of the GNU General Public License as published by
591
592=== modified file 'bzrlib/tests/blackbox/test_find_merge_base.py'
593--- bzrlib/tests/blackbox/test_find_merge_base.py 2010-06-11 07:32:12 +0000
594+++ bzrlib/tests/blackbox/test_find_merge_base.py 2010-06-29 17:48:31 +0000
595@@ -1,4 +1,4 @@
596-# Copyright (C) 2005 Canonical Ltd
597+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
598 # -*- coding: utf-8 -*-
599 #
600 # This program is free software; you can redistribute it and/or modify
601
602=== modified file 'bzrlib/tests/blackbox/test_ignored.py'
603--- bzrlib/tests/blackbox/test_ignored.py 2010-06-11 07:32:12 +0000
604+++ bzrlib/tests/blackbox/test_ignored.py 2010-06-29 17:48:31 +0000
605@@ -1,4 +1,4 @@
606-# Copyright (C) 2006-2010 Canonical Ltd
607+# Copyright (C) 2006, 2009, 2010 Canonical Ltd
608 #
609 # This program is free software; you can redistribute it and/or modify
610 # it under the terms of the GNU General Public License as published by
611
612=== modified file 'bzrlib/tests/blackbox/test_merge_directive.py'
613--- bzrlib/tests/blackbox/test_merge_directive.py 2010-05-28 14:15:28 +0000
614+++ bzrlib/tests/blackbox/test_merge_directive.py 2010-06-29 17:48:31 +0000
615@@ -1,4 +1,4 @@
616-# Copyright (C) 2007 Canonical Ltd
617+# Copyright (C) 2007, 2009, 2010 Canonical Ltd
618 #
619 # This program is free software; you can redistribute it and/or modify
620 # it under the terms of the GNU General Public License as published by
621
622=== modified file 'bzrlib/tests/blackbox/test_missing.py'
623--- bzrlib/tests/blackbox/test_missing.py 2010-05-28 14:15:28 +0000
624+++ bzrlib/tests/blackbox/test_missing.py 2010-06-29 17:48:31 +0000
625@@ -1,4 +1,4 @@
626-# Copyright (C) 2005, 2008 Canonical Ltd
627+# Copyright (C) 2005-2010 Canonical Ltd
628 #
629 # This program is free software; you can redistribute it and/or modify
630 # it under the terms of the GNU General Public License as published by
631
632=== modified file 'bzrlib/tests/blackbox/test_modified.py'
633--- bzrlib/tests/blackbox/test_modified.py 2010-06-11 07:32:12 +0000
634+++ bzrlib/tests/blackbox/test_modified.py 2010-06-29 17:48:31 +0000
635@@ -1,4 +1,4 @@
636-# Copyright (C) 2006-2010 Canonical Ltd
637+# Copyright (C) 2008, 2009, 2010 Canonical Ltd
638 # -*- coding: utf-8 -*-
639 #
640 # This program is free software; you can redistribute it and/or modify
641
642=== modified file 'bzrlib/tests/blackbox/test_nick.py'
643--- bzrlib/tests/blackbox/test_nick.py 2010-06-11 07:32:12 +0000
644+++ bzrlib/tests/blackbox/test_nick.py 2010-06-29 17:48:31 +0000
645@@ -1,4 +1,4 @@
646-# Copyright (C) 2005-2010 Canonical Ltd
647+# Copyright (C) 2006-2010 Canonical Ltd
648 #
649 # This program is free software; you can redistribute it and/or modify
650 # it under the terms of the GNU General Public License as published by
651
652=== modified file 'bzrlib/tests/blackbox/test_remove.py'
653--- bzrlib/tests/blackbox/test_remove.py 2010-06-11 07:32:12 +0000
654+++ bzrlib/tests/blackbox/test_remove.py 2010-06-29 17:48:31 +0000
655@@ -1,4 +1,4 @@
656-# Copyright (C) 2005, 2006 Canonical Ltd
657+# Copyright (C) 2006-2010 Canonical Ltd
658 #
659 # This program is free software; you can redistribute it and/or modify
660 # it under the terms of the GNU General Public License as published by
661
662=== modified file 'bzrlib/tests/blackbox/test_remove_tree.py'
663--- bzrlib/tests/blackbox/test_remove_tree.py 2010-06-11 07:32:12 +0000
664+++ bzrlib/tests/blackbox/test_remove_tree.py 2010-06-29 17:48:31 +0000
665@@ -1,4 +1,4 @@
666-# Copyright (C) 2006 Canonical Ltd
667+# Copyright (C) 2006-2010 Canonical Ltd
668 #
669 # This program is free software; you can redistribute it and/or modify
670 # it under the terms of the GNU General Public License as published by
671
672=== modified file 'bzrlib/tests/blackbox/test_revert.py'
673--- bzrlib/tests/blackbox/test_revert.py 2010-06-11 07:32:12 +0000
674+++ bzrlib/tests/blackbox/test_revert.py 2010-06-29 17:48:31 +0000
675@@ -1,4 +1,4 @@
676-# Copyright (C) 2005, 2007 Canonical Ltd
677+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
678 #
679 # This program is free software; you can redistribute it and/or modify
680 # it under the terms of the GNU General Public License as published by
681
682=== modified file 'bzrlib/tests/blackbox/test_revision_info.py'
683--- bzrlib/tests/blackbox/test_revision_info.py 2010-06-20 22:38:35 +0000
684+++ bzrlib/tests/blackbox/test_revision_info.py 2010-06-29 17:48:31 +0000
685@@ -1,4 +1,4 @@
686-# Copyright (C) 2004-2005, 2009-2010 Canonical Ltd
687+# Copyright (C) 2005-2010 Canonical Ltd
688 #
689 # This program is free software; you can redistribute it and/or modify
690 # it under the terms of the GNU General Public License as published by
691
692=== modified file 'bzrlib/tests/blackbox/test_serve.py'
693--- bzrlib/tests/blackbox/test_serve.py 2010-02-17 17:11:16 +0000
694+++ bzrlib/tests/blackbox/test_serve.py 2010-06-29 17:48:31 +0000
695@@ -31,6 +31,7 @@
696 errors,
697 osutils,
698 revision as _mod_revision,
699+ transport,
700 urlutils,
701 )
702 from bzrlib.branch import Branch
703@@ -43,7 +44,7 @@
704 TestSkipped,
705 )
706 from bzrlib.trace import mutter
707-from bzrlib.transport import get_transport, remote
708+from bzrlib.transport import remote
709
710
711 class TestBzrServeBase(TestCaseWithTransport):
712@@ -192,8 +193,8 @@
713 def test_bzr_serve_port_readonly(self):
714 """bzr server should provide a read only filesystem by default."""
715 process, url = self.start_server_port()
716- transport = get_transport(url)
717- self.assertRaises(errors.TransportNotPossible, transport.mkdir, 'adir')
718+ t = transport.get_transport(url)
719+ self.assertRaises(errors.TransportNotPossible, t.mkdir, 'adir')
720 self.assertServerFinishesCleanly(process)
721
722 def test_bzr_serve_port_readwrite(self):
723
724=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
725--- bzrlib/tests/blackbox/test_upgrade.py 2010-04-16 07:56:51 +0000
726+++ bzrlib/tests/blackbox/test_upgrade.py 2010-06-29 17:48:31 +0000
727@@ -21,6 +21,7 @@
728 from bzrlib import (
729 bzrdir,
730 repository,
731+ transport,
732 )
733 from bzrlib.tests import (
734 features,
735@@ -28,7 +29,6 @@
736 TestCaseWithTransport,
737 )
738 from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
739-from bzrlib.transport import get_transport
740 from bzrlib.repofmt.knitrepo import (
741 RepositoryFormatKnit1,
742 )
743@@ -79,7 +79,8 @@
744 (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
745 self.assertEqual("This is a checkout. The branch (%s) needs to be "
746 "upgraded separately.\n"
747- % get_transport(self.get_url('current_format_branch')).base,
748+ % transport.get_transport(
749+ self.get_url('current_format_branch')).base,
750 out)
751 self.assertEqualDiff("bzr: ERROR: The branch format Meta "
752 "directory format 1 is already at the most "
753@@ -101,7 +102,7 @@
754 def test_upgrade_explicit_metaformat(self):
755 # users can force an upgrade to metadir format.
756 self.make_format_5_branch()
757- url = get_transport(self.get_url('format_5_branch')).base
758+ url = transport.get_transport(self.get_url('format_5_branch')).base
759 # check --format takes effect
760 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
761 backup_dir = 'backup.bzr.~1~'
762@@ -125,7 +126,7 @@
763 # users can force an upgrade to knit format from a metadir weave
764 # branch
765 self.make_metadir_weave_branch()
766- url = get_transport(self.get_url('metadir_weave_branch')).base
767+ url = transport.get_transport(self.get_url('metadir_weave_branch')).base
768 # check --format takes effect
769 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
770 backup_dir = 'backup.bzr.~1~'
771@@ -163,14 +164,14 @@
772
773 def test_upgrade_with_existing_backup_dir(self):
774 self.make_format_5_branch()
775- transport = get_transport(self.get_url('format_5_branch'))
776- url = transport.base
777+ t = transport.get_transport(self.get_url('format_5_branch'))
778+ url = t.base
779 bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
780 backup_dir1 = 'backup.bzr.~1~'
781 backup_dir2 = 'backup.bzr.~2~'
782 # explicitly create backup_dir1. bzr should create the .~2~ directory
783 # as backup
784- transport.mkdir(backup_dir1)
785+ t.mkdir(backup_dir1)
786 (out, err) = self.run_bzr(
787 ['upgrade', '--format=metaweave', url])
788 self.assertEqualDiff("""starting upgrade of %s
789@@ -186,14 +187,14 @@
790 self.assertTrue(isinstance(
791 bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
792 bzrdir.BzrDirMetaFormat1))
793- self.assertTrue(transport.has(backup_dir2))
794+ self.assertTrue(t.has(backup_dir2))
795
796 class SFTPTests(TestCaseWithSFTPServer):
797 """Tests for upgrade over sftp."""
798
799 def test_upgrade_url(self):
800 self.run_bzr('init --format=weave')
801- t = get_transport(self.get_url())
802+ t = transport.get_transport(self.get_url())
803 url = t.base
804 out, err = self.run_bzr(['upgrade', '--format=knit', url])
805 backup_dir = 'backup.bzr.~1~'
806
807=== modified file 'bzrlib/tests/blackbox/test_whoami.py'
808--- bzrlib/tests/blackbox/test_whoami.py 2010-06-20 22:54:30 +0000
809+++ bzrlib/tests/blackbox/test_whoami.py 2010-06-29 17:48:31 +0000
810@@ -1,4 +1,4 @@
811-# Copyright (C) 2006 Canonical Ltd
812+# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
813 #
814 # This program is free software; you can redistribute it and/or modify
815 # it under the terms of the GNU General Public License as published by
816
817=== modified file 'bzrlib/tests/http_utils.py'
818--- bzrlib/tests/http_utils.py 2010-02-17 17:11:16 +0000
819+++ bzrlib/tests/http_utils.py 2010-06-29 17:48:31 +0000
820@@ -106,10 +106,20 @@
821 one. This will currently fail if the primary transport is not
822 backed by regular disk files.
823 """
824+
825+ # This can be overriden or parametrized by daughter clasess if needed, but
826+ # it must exist so that the create_transport_readonly_server() method can
827+ # propagate it.
828+ _protocol_version = None
829+
830 def setUp(self):
831 super(TestCaseWithWebserver, self).setUp()
832 self.transport_readonly_server = http_server.HttpServer
833
834+ def create_transport_readonly_server(self):
835+ return self.transport_readonly_server(
836+ protocol_version=self._protocol_version)
837+
838
839 class TestCaseWithTwoWebservers(TestCaseWithWebserver):
840 """A support class providing readonly urls on two servers that are http://.
841@@ -127,7 +137,8 @@
842
843 This is mostly a hook for daughter classes.
844 """
845- return self.transport_secondary_server()
846+ return self.transport_secondary_server(
847+ protocol_version=self._protocol_version)
848
849 def get_secondary_server(self):
850 """Get the server instance for the secondary transport."""
851@@ -218,7 +229,8 @@
852 def create_transport_secondary_server(self):
853 """Create the secondary server redirecting to the primary server"""
854 new = self.get_readonly_server()
855- redirecting = HTTPServerRedirecting()
856+ redirecting = HTTPServerRedirecting(
857+ protocol_version=self._protocol_version)
858 redirecting.redirect_to(new.host, new.port)
859 return redirecting
860
861
862=== modified file 'bzrlib/tests/per_branch/test_bound_sftp.py'
863--- bzrlib/tests/per_branch/test_bound_sftp.py 2010-02-11 09:27:55 +0000
864+++ bzrlib/tests/per_branch/test_bound_sftp.py 2010-06-29 17:48:31 +0000
865@@ -144,13 +144,13 @@
866 wt_child2.commit, 'child2', rev_id='r@d-2')
867
868 def test_unbinding(self):
869- from bzrlib.transport import get_transport
870+ from bzrlib import transport
871 b_base, wt_child = self.create_branches()
872
873 # TestCaseWithSFTPServer only allows you to connect one time
874 # to the SFTP server. So we have to create a connection and
875 # keep it around, so that it can be reused
876- __unused_t = get_transport(self.get_url('.'))
877+ __unused_t = transport.get_transport(self.get_url('.'))
878
879 wt_base = b_base.bzrdir.open_workingtree()
880 open('base/a', 'wb').write('new base contents\n')
881
882=== modified file 'bzrlib/tests/per_branch/test_permissions.py'
883--- bzrlib/tests/per_branch/test_permissions.py 2009-09-07 08:46:00 +0000
884+++ bzrlib/tests/per_branch/test_permissions.py 2010-06-29 17:48:31 +0000
885@@ -1,4 +1,4 @@
886-# Copyright (C) 2005, 2008 Canonical Ltd
887+# Copyright (C) 2006-2010 Canonical Ltd
888 #
889 # This program is free software; you can redistribute it and/or modify
890 # it under the terms of the GNU General Public License as published by
891@@ -38,7 +38,6 @@
892 from bzrlib.remote import RemoteBranchFormat
893 from bzrlib.tests.test_permissions import chmod_r, check_mode_r
894 from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
895-from bzrlib.transport import get_transport
896 from bzrlib.workingtree import WorkingTree
897
898
899
900=== modified file 'bzrlib/tests/per_branch/test_stacking.py'
901--- bzrlib/tests/per_branch/test_stacking.py 2009-08-20 04:09:58 +0000
902+++ bzrlib/tests/per_branch/test_stacking.py 2010-06-29 17:48:31 +0000
903@@ -1,4 +1,4 @@
904-# Copyright (C) 2008 Canonical Ltd
905+# Copyright (C) 2008, 2009, 2010 Canonical Ltd
906 #
907 # This program is free software; you can redistribute it and/or modify
908 # it under the terms of the GNU General Public License as published by
909@@ -26,7 +26,6 @@
910 from bzrlib.smart import server
911 from bzrlib.tests import TestNotApplicable, KnownFailure, transport_util
912 from bzrlib.tests.per_branch import TestCaseWithBranch
913-from bzrlib.transport import get_transport
914
915
916 unstackable_format_errors = (
917
918=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
919--- bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-06-24 06:29:40 +0000
920+++ bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-06-29 17:48:31 +0000
921@@ -55,7 +55,6 @@
922 )
923 from bzrlib.tests.per_bzrdir import TestCaseWithBzrDir
924 from bzrlib.trace import mutter
925-from bzrlib.transport import get_transport
926 from bzrlib.transport.local import LocalTransport
927 from bzrlib.ui import (
928 CannedInputUIFactory,
929@@ -202,7 +201,7 @@
930 A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
931 TestSkipped. Returns the newly sprouted bzrdir.
932 """
933- to_transport = get_transport(to_url)
934+ to_transport = transport.get_transport(to_url)
935 if not isinstance(to_transport, LocalTransport):
936 raise TestSkipped('Cannot sprout to remote bzrdirs.')
937 target = from_bzrdir.sprout(to_url, revision_id=revision_id,
938@@ -1206,8 +1205,8 @@
939 '_network_name', None),
940 None)
941 # supported formats must be able to init and open
942- t = get_transport(self.get_url())
943- readonly_t = get_transport(self.get_readonly_url())
944+ t = transport.get_transport(self.get_url())
945+ readonly_t = transport.get_transport(self.get_readonly_url())
946 made_control = self.bzrdir_format.initialize(t.base)
947 self.failUnless(isinstance(made_control, bzrdir.BzrDir))
948 self.assertEqual(self.bzrdir_format,
949@@ -1417,7 +1416,7 @@
950 # test the formats specific behaviour for no-content or similar dirs.
951 self.assertRaises(NotBranchError,
952 self.bzrdir_format.open,
953- get_transport(self.get_readonly_url()))
954+ transport.get_transport(self.get_readonly_url()))
955
956 def test_create_branch(self):
957 # a bzrdir can construct a branch and repository for itself.
958@@ -1426,7 +1425,7 @@
959 # because the default open will not open them and
960 # they may not be initializable.
961 return
962- t = get_transport(self.get_url())
963+ t = transport.get_transport(self.get_url())
964 made_control = self.bzrdir_format.initialize(t.base)
965 made_repo = made_control.create_repository()
966 made_branch = made_control.create_branch()
967@@ -1439,7 +1438,7 @@
968 # because the default open will not open them and
969 # they may not be initializable.
970 return
971- t = get_transport(self.get_url())
972+ t = transport.get_transport(self.get_url())
973 made_control = self.bzrdir_format.initialize(t.base)
974 made_repo = made_control.create_repository()
975 made_branch = made_control.create_branch()
976@@ -1454,7 +1453,7 @@
977 # because the default open will not open them and
978 # they may not be initializable.
979 return
980- t = get_transport(self.get_url())
981+ t = transport.get_transport(self.get_url())
982 made_control = self.bzrdir_format.initialize(t.base)
983 made_repo = made_control.create_repository()
984 made_branch = made_control.create_branch()
985@@ -1475,7 +1474,7 @@
986 # because the default open will not open them and
987 # they may not be initializable.
988 return
989- t = get_transport(self.get_url())
990+ t = transport.get_transport(self.get_url())
991 made_control = self.bzrdir_format.initialize(t.base)
992 made_repo = made_control.create_repository()
993 # Check that we have a repository object.
994@@ -1490,7 +1489,7 @@
995 # because the default open will not open them and
996 # they may not be initializable.
997 return
998- t = get_transport(self.get_url())
999+ t = transport.get_transport(self.get_url())
1000 made_control = self.bzrdir_format.initialize(t.base)
1001 try:
1002 made_repo = made_control.create_repository(shared=True)
1003@@ -1507,7 +1506,7 @@
1004 # because the default open will not open them and
1005 # they may not be initializable.
1006 return
1007- t = get_transport(self.get_url())
1008+ t = transport.get_transport(self.get_url())
1009 made_control = self.bzrdir_format.initialize(t.base)
1010 made_repo = made_control.create_repository(shared=False)
1011 self.assertFalse(made_repo.is_shared())
1012@@ -1518,7 +1517,7 @@
1013 # because the default open will not open them and
1014 # they may not be initializable.
1015 return
1016- t = get_transport(self.get_url())
1017+ t = transport.get_transport(self.get_url())
1018 made_control = self.bzrdir_format.initialize(t.base)
1019 made_repo = made_control.create_repository()
1020 opened_repo = made_control.open_repository()
1021@@ -1646,7 +1645,7 @@
1022 def test_root_transport(self):
1023 dir = self.make_bzrdir('.')
1024 self.assertEqual(dir.root_transport.base,
1025- get_transport(self.get_url('.')).base)
1026+ transport.get_transport(self.get_url('.')).base)
1027
1028 def test_find_repository_no_repo_under_standalone_branch(self):
1029 # finding a repo stops at standalone branches even if there is a
1030@@ -1657,8 +1656,8 @@
1031 # need a shared repository to test this.
1032 return
1033 url = self.get_url('intermediate')
1034- get_transport(self.get_url()).mkdir('intermediate')
1035- get_transport(self.get_url()).mkdir('intermediate/child')
1036+ transport.get_transport(self.get_url()).mkdir('intermediate')
1037+ transport.get_transport(self.get_url()).mkdir('intermediate/child')
1038 made_control = self.bzrdir_format.initialize(url)
1039 made_control.create_repository()
1040 innermost_control = self.bzrdir_format.initialize(
1041@@ -1682,7 +1681,7 @@
1042 # need a shared repository to test this.
1043 return
1044 url = self.get_url('childbzrdir')
1045- get_transport(self.get_url()).mkdir('childbzrdir')
1046+ transport.get_transport(self.get_url()).mkdir('childbzrdir')
1047 made_control = self.bzrdir_format.initialize(url)
1048 try:
1049 child_repo = made_control.open_repository()
1050@@ -1716,7 +1715,7 @@
1051 # need a shared repository to test this.
1052 return
1053 url = self.get_url('childrepo')
1054- get_transport(self.get_url()).mkdir('childrepo')
1055+ transport.get_transport(self.get_url()).mkdir('childrepo')
1056 child_control = self.bzrdir_format.initialize(url)
1057 child_repo = child_control.create_repository(shared=True)
1058 opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
1059@@ -1735,8 +1734,8 @@
1060 # need a shared repository to test this.
1061 return
1062 url = self.get_url('intermediate')
1063- get_transport(self.get_url()).mkdir('intermediate')
1064- get_transport(self.get_url()).mkdir('intermediate/child')
1065+ transport.get_transport(self.get_url()).mkdir('intermediate')
1066+ transport.get_transport(self.get_url()).mkdir('intermediate/child')
1067 made_control = self.bzrdir_format.initialize(url)
1068 try:
1069 child_repo = made_control.open_repository()
1070@@ -1981,7 +1980,7 @@
1071 # - do the vfs initialisation over the basic vfs transport
1072 # XXX: TODO this should become a 'bzrdirlocation' api call.
1073 url = self.get_vfs_only_url('subdir')
1074- get_transport(self.get_vfs_only_url()).mkdir('subdir')
1075+ transport.get_transport(self.get_vfs_only_url()).mkdir('subdir')
1076 made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1077 try:
1078 repo = made_control.open_repository()
1079@@ -1997,7 +1996,7 @@
1080
1081 class TestBzrDirControlComponent(TestCaseWithBzrDir):
1082 """BzrDir implementations adequately implement ControlComponent."""
1083-
1084+
1085 def test_urls(self):
1086 bd = self.make_bzrdir('bd')
1087 self.assertIsInstance(bd.user_url, str)
1088
1089=== modified file 'bzrlib/tests/per_interbranch/__init__.py'
1090--- bzrlib/tests/per_interbranch/__init__.py 2010-06-16 08:17:50 +0000
1091+++ bzrlib/tests/per_interbranch/__init__.py 2010-06-29 17:48:31 +0000
1092@@ -1,4 +1,4 @@
1093-# Copyright (C) 2009 Canonical Ltd
1094+# Copyright (C) 2009, 2010 Canonical Ltd
1095 # -*- coding: utf-8 -*-
1096 #
1097 # This program is free software; you can redistribute it and/or modify
1098@@ -46,7 +46,6 @@
1099 TestCaseWithTransport,
1100 multiply_tests,
1101 )
1102-from bzrlib.transport import get_transport
1103
1104
1105 def make_scenarios(test_list):
1106
1107=== modified file 'bzrlib/tests/per_interbranch/test_pull.py'
1108--- bzrlib/tests/per_interbranch/test_pull.py 2010-06-14 06:37:11 +0000
1109+++ bzrlib/tests/per_interbranch/test_pull.py 2010-06-29 17:48:31 +0000
1110@@ -1,4 +1,4 @@
1111-# Copyright (C) 2004, 2005, 2007, 2009 Canonical Ltd
1112+# Copyright (C) 2009, 2010 Canonical Ltd
1113 #
1114 # This program is free software; you can redistribute it and/or modify
1115 # it under the terms of the GNU General Public License as published by
1116
1117=== modified file 'bzrlib/tests/per_interbranch/test_push.py'
1118--- bzrlib/tests/per_interbranch/test_push.py 2010-06-24 08:16:36 +0000
1119+++ bzrlib/tests/per_interbranch/test_push.py 2010-06-29 17:48:31 +0000
1120@@ -44,7 +44,6 @@
1121 from bzrlib.tests.per_interbranch import (
1122 TestCaseWithInterBranch,
1123 )
1124-from bzrlib.transport import get_transport
1125 from bzrlib.tests import test_server
1126
1127
1128
1129=== modified file 'bzrlib/tests/per_interbranch/test_update_revisions.py'
1130--- bzrlib/tests/per_interbranch/test_update_revisions.py 2010-06-17 06:30:22 +0000
1131+++ bzrlib/tests/per_interbranch/test_update_revisions.py 2010-06-29 17:48:31 +0000
1132@@ -1,4 +1,4 @@
1133-# Copyright (C) 2009 Canonical Ltd
1134+# Copyright (C) 2009, 2010 Canonical Ltd
1135 #
1136 # This program is free software; you can redistribute it and/or modify
1137 # it under the terms of the GNU General Public License as published by
1138
1139=== modified file 'bzrlib/tests/per_interrepository/__init__.py'
1140--- bzrlib/tests/per_interrepository/__init__.py 2009-08-14 01:07:44 +0000
1141+++ bzrlib/tests/per_interrepository/__init__.py 2010-06-29 17:48:31 +0000
1142@@ -1,4 +1,4 @@
1143-# Copyright (C) 2006 Canonical Ltd
1144+# Copyright (C) 2006-2010 Canonical Ltd
1145 # Authors: Robert Collins <robert.collins@canonical.com>
1146 # -*- coding: utf-8 -*-
1147 #
1148@@ -26,6 +26,7 @@
1149 """
1150
1151
1152+from bzrlib import transport
1153 from bzrlib.errors import (
1154 FileExists,
1155 UninitializableFormat,
1156@@ -39,7 +40,6 @@
1157 multiply_tests,
1158 )
1159 from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
1160-from bzrlib.transport import get_transport
1161
1162
1163 def make_scenarios(transport_server, transport_readonly_server, formats):
1164@@ -143,7 +143,7 @@
1165 segments = url.split('/')
1166 if segments and segments[-1] not in ('', '.'):
1167 parent = '/'.join(segments[:-1])
1168- t = get_transport(parent)
1169+ t = transport.get_transport(parent)
1170 try:
1171 t.mkdir(segments[-1])
1172 except FileExists:
1173
1174=== modified file 'bzrlib/tests/per_intertree/__init__.py'
1175--- bzrlib/tests/per_intertree/__init__.py 2010-02-17 17:11:16 +0000
1176+++ bzrlib/tests/per_intertree/__init__.py 2010-06-29 17:48:31 +0000
1177@@ -28,7 +28,6 @@
1178 revisiontree,
1179 tests,
1180 )
1181-from bzrlib.transport import get_transport
1182 from bzrlib.transform import TransformPreview
1183 from bzrlib.tests import (
1184 default_transport,
1185
1186=== modified file 'bzrlib/tests/per_repository/test_fetch.py'
1187--- bzrlib/tests/per_repository/test_fetch.py 2009-08-05 02:12:22 +0000
1188+++ bzrlib/tests/per_repository/test_fetch.py 2010-06-29 17:48:31 +0000
1189@@ -1,4 +1,4 @@
1190-# Copyright (C) 2007 Canonical Ltd
1191+# Copyright (C) 2007-2010 Canonical Ltd
1192 #
1193 # This program is free software; you can redistribute it and/or modify
1194 # it under the terms of the GNU General Public License as published by
1195@@ -28,7 +28,6 @@
1196 from bzrlib.inventory import ROOT_ID
1197 from bzrlib.tests import TestSkipped
1198 from bzrlib.tests.per_repository import TestCaseWithRepository
1199-from bzrlib.transport import get_transport
1200
1201
1202 class TestFetchSameRepository(TestCaseWithRepository):
1203
1204=== modified file 'bzrlib/tests/per_repository/test_has_same_location.py'
1205--- bzrlib/tests/per_repository/test_has_same_location.py 2009-03-23 14:59:43 +0000
1206+++ bzrlib/tests/per_repository/test_has_same_location.py 2010-06-29 17:48:31 +0000
1207@@ -1,4 +1,4 @@
1208-# Copyright (C) 2007, 2008 Canonical Ltd
1209+# Copyright (C) 2007-2010 Canonical Ltd
1210 #
1211 # This program is free software; you can redistribute it and/or modify
1212 # it under the terms of the GNU General Public License as published by
1213@@ -16,12 +16,14 @@
1214
1215 """Tests for implementations of Repository.has_same_location."""
1216
1217-from bzrlib import bzrdir
1218+from bzrlib import (
1219+ bzrdir,
1220+ transport,
1221+ )
1222 from bzrlib.tests import (
1223 TestNotApplicable,
1224 )
1225 from bzrlib.tests.per_repository import TestCaseWithRepository
1226-from bzrlib.transport import get_transport
1227
1228
1229 class TestHasSameLocation(TestCaseWithRepository):
1230@@ -112,7 +114,8 @@
1231 if repo._format == other_repo._format:
1232 # We're testing the default format! So we have to use a non-default
1233 # format for other_repo.
1234- get_transport(self.get_vfs_only_url()).delete_tree('other')
1235+ transport.get_transport(self.get_vfs_only_url()
1236+ ).delete_tree('other')
1237 other_repo = self.make_repository('other', format='metaweave')
1238 # Make sure the other_repo is not a RemoteRepository.
1239 other_bzrdir = bzrdir.BzrDir.open(self.get_vfs_only_url('other'))
1240
1241=== modified file 'bzrlib/tests/per_repository/test_reconcile.py'
1242--- bzrlib/tests/per_repository/test_reconcile.py 2009-09-08 11:32:53 +0000
1243+++ bzrlib/tests/per_repository/test_reconcile.py 2010-06-29 17:48:31 +0000
1244@@ -1,4 +1,4 @@
1245-# Copyright (C) 2006 Canonical Ltd
1246+# Copyright (C) 2006-2010 Canonical Ltd
1247 #
1248 # This program is free software; you can redistribute it and/or modify
1249 # it under the terms of the GNU General Public License as published by
1250@@ -18,7 +18,10 @@
1251
1252
1253 import bzrlib
1254-import bzrlib.errors as errors
1255+from bzrlib import (
1256+ errors,
1257+ transport,
1258+ )
1259 from bzrlib.inventory import Inventory
1260 from bzrlib.reconcile import reconcile, Reconciler
1261 from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
1262@@ -30,7 +33,6 @@
1263 from bzrlib.tests.per_repository import (
1264 TestCaseWithRepository,
1265 )
1266-from bzrlib.transport import get_transport
1267 from bzrlib.uncommit import uncommit
1268
1269
1270@@ -59,7 +61,7 @@
1271 def setUp(self):
1272 super(TestsNeedingReweave, self).setUp()
1273
1274- t = get_transport(self.get_url())
1275+ t = transport.get_transport(self.get_url())
1276 # an empty inventory with no revision for testing with.
1277 repo = self.make_repository('inventory_without_revision')
1278 repo.lock_write()
1279@@ -310,7 +312,7 @@
1280 self.reduceLockdirTimeout()
1281 super(TestReconcileWithIncorrectRevisionCache, self).setUp()
1282
1283- t = get_transport(self.get_url())
1284+ t = transport.get_transport(self.get_url())
1285 # we need a revision with two parents in the wrong order
1286 # which should trigger reinsertion.
1287 # and another with the first one correct but the other two not
1288@@ -379,7 +381,7 @@
1289
1290 def test_reconcile_wrong_order(self):
1291 # a wrong order in primary parents is optionally correctable
1292- t = get_transport(self.get_url()).clone('wrong-first-parent')
1293+ t = transport.get_transport(self.get_url()).clone('wrong-first-parent')
1294 d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
1295 repo = d.open_repository()
1296 repo.lock_read()
1297@@ -408,7 +410,8 @@
1298
1299 def test_reconcile_wrong_order_secondary_inventory(self):
1300 # a wrong order in the parents for inventories is ignored.
1301- t = get_transport(self.get_url()).clone('reversed-secondary-parents')
1302+ t = transport.get_transport(self.get_url()
1303+ ).clone('reversed-secondary-parents')
1304 d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
1305 repo = d.open_repository()
1306 self.checkUnreconciled(d, repo.reconcile())
1307
1308=== modified file 'bzrlib/tests/per_versionedfile.py'
1309--- bzrlib/tests/per_versionedfile.py 2010-05-14 14:29:28 +0000
1310+++ bzrlib/tests/per_versionedfile.py 2010-06-29 17:48:31 +0000
1311@@ -31,6 +31,7 @@
1312 knit as _mod_knit,
1313 osutils,
1314 progress,
1315+ transport,
1316 ui,
1317 )
1318 from bzrlib.errors import (
1319@@ -56,7 +57,6 @@
1320 )
1321 from bzrlib.tests.http_utils import TestCaseWithWebserver
1322 from bzrlib.trace import mutter
1323-from bzrlib.transport import get_transport
1324 from bzrlib.transport.memory import MemoryTransport
1325 from bzrlib.tsort import topo_sort
1326 from bzrlib.tuned_gzip import GzipFile
1327@@ -849,10 +849,10 @@
1328 self.assertEquals(('references_ghost', 'line_c\n'), origins[2])
1329
1330 def test_readonly_mode(self):
1331- transport = get_transport(self.get_url('.'))
1332+ t = transport.get_transport(self.get_url('.'))
1333 factory = self.get_factory()
1334- vf = factory('id', transport, 0777, create=True, access_mode='w')
1335- vf = factory('id', transport, access_mode='r')
1336+ vf = factory('id', t, 0777, create=True, access_mode='w')
1337+ vf = factory('id', t, access_mode='r')
1338 self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'base', [], [])
1339 self.assertRaises(errors.ReadOnlyError,
1340 vf.add_lines_with_ghosts,
1341@@ -880,12 +880,14 @@
1342 class TestWeave(TestCaseWithMemoryTransport, VersionedFileTestMixIn):
1343
1344 def get_file(self, name='foo'):
1345- return WeaveFile(name, get_transport(self.get_url('.')), create=True,
1346- get_scope=self.get_transaction)
1347+ return WeaveFile(name, transport.get_transport(self.get_url('.')),
1348+ create=True,
1349+ get_scope=self.get_transaction)
1350
1351 def get_file_corrupted_text(self):
1352- w = WeaveFile('foo', get_transport(self.get_url('.')), create=True,
1353- get_scope=self.get_transaction)
1354+ w = WeaveFile('foo', transport.get_transport(self.get_url('.')),
1355+ create=True,
1356+ get_scope=self.get_transaction)
1357 w.add_lines('v1', [], ['hello\n'])
1358 w.add_lines('v2', ['v1'], ['hello\n', 'there\n'])
1359
1360@@ -919,14 +921,15 @@
1361 return w
1362
1363 def reopen_file(self, name='foo', create=False):
1364- return WeaveFile(name, get_transport(self.get_url('.')), create=create,
1365- get_scope=self.get_transaction)
1366+ return WeaveFile(name, transport.get_transport(self.get_url('.')),
1367+ create=create,
1368+ get_scope=self.get_transaction)
1369
1370 def test_no_implicit_create(self):
1371 self.assertRaises(errors.NoSuchFile,
1372 WeaveFile,
1373 'foo',
1374- get_transport(self.get_url('.')),
1375+ transport.get_transport(self.get_url('.')),
1376 get_scope=self.get_transaction)
1377
1378 def get_factory(self):
1379@@ -999,7 +1002,7 @@
1380 # we should be able to read from http with a versioned file.
1381 vf = self.get_file()
1382 # try an empty file access
1383- readonly_vf = self.get_factory()('foo', get_transport(
1384+ readonly_vf = self.get_factory()('foo', transport.get_transport(
1385 self.get_readonly_url('.')))
1386 self.assertEqual([], readonly_vf.versions())
1387
1388@@ -1009,7 +1012,7 @@
1389 # now with feeling.
1390 vf.add_lines('1', [], ['a\n'])
1391 vf.add_lines('2', ['1'], ['b\n', 'a\n'])
1392- readonly_vf = self.get_factory()('foo', get_transport(
1393+ readonly_vf = self.get_factory()('foo', transport.get_transport(
1394 self.get_readonly_url('.')))
1395 self.assertEqual(['1', '2'], vf.versions())
1396 self.assertEqual(['1', '2'], readonly_vf.versions())
1397@@ -1020,8 +1023,9 @@
1398 class TestWeaveHTTP(TestCaseWithWebserver, TestReadonlyHttpMixin):
1399
1400 def get_file(self):
1401- return WeaveFile('foo', get_transport(self.get_url('.')), create=True,
1402- get_scope=self.get_transaction)
1403+ return WeaveFile('foo', transport.get_transport(self.get_url('.')),
1404+ create=True,
1405+ get_scope=self.get_transaction)
1406
1407 def get_factory(self):
1408 return WeaveFile
1409@@ -1271,7 +1275,8 @@
1410 class TestWeaveMerge(TestCaseWithMemoryTransport, MergeCasesMixin):
1411
1412 def get_file(self, name='foo'):
1413- return WeaveFile(name, get_transport(self.get_url('.')), create=True)
1414+ return WeaveFile(name, transport.get_transport(self.get_url('.')),
1415+ create=True)
1416
1417 def log_contents(self, w):
1418 self.log('weave is:')
1419
1420=== modified file 'bzrlib/tests/per_workingtree/test_pull.py'
1421--- bzrlib/tests/per_workingtree/test_pull.py 2010-01-11 23:02:32 +0000
1422+++ bzrlib/tests/per_workingtree/test_pull.py 2010-06-29 17:48:31 +0000
1423@@ -23,7 +23,6 @@
1424 from bzrlib.osutils import basename
1425 from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
1426 from bzrlib.trace import mutter
1427-from bzrlib.transport import get_transport
1428
1429
1430 class TestPull(TestCaseWithWorkingTree):
1431
1432=== modified file 'bzrlib/tests/test_btree_index.py'
1433--- bzrlib/tests/test_btree_index.py 2010-03-25 17:09:53 +0000
1434+++ bzrlib/tests/test_btree_index.py 2010-06-29 17:48:31 +0000
1435@@ -27,6 +27,7 @@
1436 lru_cache,
1437 osutils,
1438 tests,
1439+ transport,
1440 )
1441 from bzrlib.tests import (
1442 TestCaseWithTransport,
1443@@ -34,7 +35,6 @@
1444 multiply_tests,
1445 split_suite_by_condition,
1446 )
1447-from bzrlib.transport import get_transport
1448
1449
1450 def load_tests(standard_tests, module, loader):
1451@@ -280,10 +280,10 @@
1452
1453 for node in nodes:
1454 builder.add_node(*node)
1455- transport = get_transport('trace+' + self.get_url(''))
1456- size = transport.put_file('index', self.time(builder.finish))
1457+ t = transport.get_transport('trace+' + self.get_url(''))
1458+ size = t.put_file('index', self.time(builder.finish))
1459 del builder
1460- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1461+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1462 # Seed the metadata, we're using internal calls now.
1463 index.key_count()
1464 self.assertEqual(3, len(index._row_lengths),
1465@@ -409,9 +409,9 @@
1466 self.assertEqual(None, builder._backing_indices[2])
1467 self.assertEqual(16, builder._backing_indices[3].key_count())
1468 # Now finish, and check we got a correctly ordered tree
1469- transport = self.get_transport('')
1470- size = transport.put_file('index', builder.finish())
1471- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1472+ t = self.get_transport('')
1473+ size = t.put_file('index', builder.finish())
1474+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1475 nodes = list(index.iter_all_entries())
1476 self.assertEqual(sorted(nodes), nodes)
1477 self.assertEqual(16, len(nodes))
1478@@ -607,7 +607,7 @@
1479 for key, value, references in nodes:
1480 builder.add_node(key, value, references)
1481 stream = builder.finish()
1482- trans = get_transport('trace+' + self.get_url())
1483+ trans = transport.get_transport('trace+' + self.get_url())
1484 size = trans.put_file('index', stream)
1485 return btree_index.BTreeGraphIndex(trans, 'index', size)
1486
1487@@ -648,57 +648,57 @@
1488 self.assertEqual(0, len(index._leaf_node_cache))
1489
1490 def test_trivial_constructor(self):
1491- transport = get_transport('trace+' + self.get_url(''))
1492- index = btree_index.BTreeGraphIndex(transport, 'index', None)
1493+ t = transport.get_transport('trace+' + self.get_url(''))
1494+ index = btree_index.BTreeGraphIndex(t, 'index', None)
1495 # Checks the page size at load, but that isn't logged yet.
1496- self.assertEqual([], transport._activity)
1497+ self.assertEqual([], t._activity)
1498
1499 def test_with_size_constructor(self):
1500- transport = get_transport('trace+' + self.get_url(''))
1501- index = btree_index.BTreeGraphIndex(transport, 'index', 1)
1502+ t = transport.get_transport('trace+' + self.get_url(''))
1503+ index = btree_index.BTreeGraphIndex(t, 'index', 1)
1504 # Checks the page size at load, but that isn't logged yet.
1505- self.assertEqual([], transport._activity)
1506+ self.assertEqual([], t._activity)
1507
1508 def test_empty_key_count_no_size(self):
1509 builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)
1510- transport = get_transport('trace+' + self.get_url(''))
1511- transport.put_file('index', builder.finish())
1512- index = btree_index.BTreeGraphIndex(transport, 'index', None)
1513- del transport._activity[:]
1514- self.assertEqual([], transport._activity)
1515+ t = transport.get_transport('trace+' + self.get_url(''))
1516+ t.put_file('index', builder.finish())
1517+ index = btree_index.BTreeGraphIndex(t, 'index', None)
1518+ del t._activity[:]
1519+ self.assertEqual([], t._activity)
1520 self.assertEqual(0, index.key_count())
1521 # The entire index should have been requested (as we generally have the
1522 # size available, and doing many small readvs is inappropriate).
1523 # We can't tell how much was actually read here, but - check the code.
1524- self.assertEqual([('get', 'index')], transport._activity)
1525+ self.assertEqual([('get', 'index')], t._activity)
1526
1527 def test_empty_key_count(self):
1528 builder = btree_index.BTreeBuilder(key_elements=1, reference_lists=0)
1529- transport = get_transport('trace+' + self.get_url(''))
1530- size = transport.put_file('index', builder.finish())
1531+ t = transport.get_transport('trace+' + self.get_url(''))
1532+ size = t.put_file('index', builder.finish())
1533 self.assertEqual(72, size)
1534- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1535- del transport._activity[:]
1536- self.assertEqual([], transport._activity)
1537+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1538+ del t._activity[:]
1539+ self.assertEqual([], t._activity)
1540 self.assertEqual(0, index.key_count())
1541 # The entire index should have been read, as 4K > size
1542 self.assertEqual([('readv', 'index', [(0, 72)], False, None)],
1543- transport._activity)
1544+ t._activity)
1545
1546 def test_non_empty_key_count_2_2(self):
1547 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
1548 nodes = self.make_nodes(35, 2, 2)
1549 for node in nodes:
1550 builder.add_node(*node)
1551- transport = get_transport('trace+' + self.get_url(''))
1552- size = transport.put_file('index', builder.finish())
1553- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1554- del transport._activity[:]
1555- self.assertEqual([], transport._activity)
1556+ t = transport.get_transport('trace+' + self.get_url(''))
1557+ size = t.put_file('index', builder.finish())
1558+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1559+ del t._activity[:]
1560+ self.assertEqual([], t._activity)
1561 self.assertEqual(70, index.key_count())
1562 # The entire index should have been read, as it is one page long.
1563 self.assertEqual([('readv', 'index', [(0, size)], False, None)],
1564- transport._activity)
1565+ t._activity)
1566 self.assertEqual(1173, size)
1567
1568 def test_with_offset_no_size(self):
1569@@ -722,7 +722,7 @@
1570
1571 def test__read_nodes_no_size_one_page_reads_once(self):
1572 self.make_index(nodes=[(('key',), 'value', ())])
1573- trans = get_transport('trace+' + self.get_url())
1574+ trans = transport.get_transport('trace+' + self.get_url())
1575 index = btree_index.BTreeGraphIndex(trans, 'index', None)
1576 del trans._activity[:]
1577 nodes = dict(index._read_nodes([0]))
1578@@ -736,7 +736,7 @@
1579 index.key_count()
1580 num_pages = index._row_offsets[-1]
1581 # Reopen with a traced transport and no size
1582- trans = get_transport('trace+' + self.get_url())
1583+ trans = transport.get_transport('trace+' + self.get_url())
1584 index = btree_index.BTreeGraphIndex(trans, 'index', None)
1585 del trans._activity[:]
1586 nodes = dict(index._read_nodes([0]))
1587@@ -747,31 +747,31 @@
1588 nodes = self.make_nodes(160, 2, 2)
1589 for node in nodes:
1590 builder.add_node(*node)
1591- transport = get_transport('trace+' + self.get_url(''))
1592- size = transport.put_file('index', builder.finish())
1593+ t = transport.get_transport('trace+' + self.get_url(''))
1594+ size = t.put_file('index', builder.finish())
1595 self.assertEqual(17692, size)
1596- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1597- del transport._activity[:]
1598- self.assertEqual([], transport._activity)
1599+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1600+ del t._activity[:]
1601+ self.assertEqual([], t._activity)
1602 self.assertEqual(320, index.key_count())
1603 # The entire index should not have been read.
1604 self.assertEqual([('readv', 'index', [(0, 4096)], False, None)],
1605- transport._activity)
1606+ t._activity)
1607
1608 def test_validate_one_page(self):
1609 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
1610 nodes = self.make_nodes(45, 2, 2)
1611 for node in nodes:
1612 builder.add_node(*node)
1613- transport = get_transport('trace+' + self.get_url(''))
1614- size = transport.put_file('index', builder.finish())
1615- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1616- del transport._activity[:]
1617- self.assertEqual([], transport._activity)
1618+ t = transport.get_transport('trace+' + self.get_url(''))
1619+ size = t.put_file('index', builder.finish())
1620+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1621+ del t._activity[:]
1622+ self.assertEqual([], t._activity)
1623 index.validate()
1624 # The entire index should have been read linearly.
1625 self.assertEqual([('readv', 'index', [(0, size)], False, None)],
1626- transport._activity)
1627+ t._activity)
1628 self.assertEqual(1488, size)
1629
1630 def test_validate_two_pages(self):
1631@@ -779,64 +779,65 @@
1632 nodes = self.make_nodes(80, 2, 2)
1633 for node in nodes:
1634 builder.add_node(*node)
1635- transport = get_transport('trace+' + self.get_url(''))
1636- size = transport.put_file('index', builder.finish())
1637+ t = transport.get_transport('trace+' + self.get_url(''))
1638+ size = t.put_file('index', builder.finish())
1639 # Root page, 2 leaf pages
1640 self.assertEqual(9339, size)
1641- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1642- del transport._activity[:]
1643- self.assertEqual([], transport._activity)
1644+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1645+ del t._activity[:]
1646+ self.assertEqual([], t._activity)
1647 index.validate()
1648 # The entire index should have been read linearly.
1649- self.assertEqual([('readv', 'index', [(0, 4096)], False, None),
1650- ('readv', 'index', [(4096, 4096), (8192, 1147)], False, None)],
1651- transport._activity)
1652+ self.assertEqual(
1653+ [('readv', 'index', [(0, 4096)], False, None),
1654+ ('readv', 'index', [(4096, 4096), (8192, 1147)], False, None)],
1655+ t._activity)
1656 # XXX: TODO: write some badly-ordered nodes, and some pointers-to-wrong
1657 # node and make validate find them.
1658
1659 def test_eq_ne(self):
1660 # two indices are equal when constructed with the same parameters:
1661- transport1 = get_transport('trace+' + self.get_url(''))
1662- transport2 = get_transport(self.get_url(''))
1663- self.assertTrue(
1664- btree_index.BTreeGraphIndex(transport1, 'index', None) ==
1665- btree_index.BTreeGraphIndex(transport1, 'index', None))
1666- self.assertTrue(
1667- btree_index.BTreeGraphIndex(transport1, 'index', 20) ==
1668- btree_index.BTreeGraphIndex(transport1, 'index', 20))
1669- self.assertFalse(
1670- btree_index.BTreeGraphIndex(transport1, 'index', 20) ==
1671- btree_index.BTreeGraphIndex(transport2, 'index', 20))
1672- self.assertFalse(
1673- btree_index.BTreeGraphIndex(transport1, 'inde1', 20) ==
1674- btree_index.BTreeGraphIndex(transport1, 'inde2', 20))
1675- self.assertFalse(
1676- btree_index.BTreeGraphIndex(transport1, 'index', 10) ==
1677- btree_index.BTreeGraphIndex(transport1, 'index', 20))
1678- self.assertFalse(
1679- btree_index.BTreeGraphIndex(transport1, 'index', None) !=
1680- btree_index.BTreeGraphIndex(transport1, 'index', None))
1681- self.assertFalse(
1682- btree_index.BTreeGraphIndex(transport1, 'index', 20) !=
1683- btree_index.BTreeGraphIndex(transport1, 'index', 20))
1684- self.assertTrue(
1685- btree_index.BTreeGraphIndex(transport1, 'index', 20) !=
1686- btree_index.BTreeGraphIndex(transport2, 'index', 20))
1687- self.assertTrue(
1688- btree_index.BTreeGraphIndex(transport1, 'inde1', 20) !=
1689- btree_index.BTreeGraphIndex(transport1, 'inde2', 20))
1690- self.assertTrue(
1691- btree_index.BTreeGraphIndex(transport1, 'index', 10) !=
1692- btree_index.BTreeGraphIndex(transport1, 'index', 20))
1693+ t1 = transport.get_transport('trace+' + self.get_url(''))
1694+ t2 = transport.get_transport(self.get_url(''))
1695+ self.assertTrue(
1696+ btree_index.BTreeGraphIndex(t1, 'index', None) ==
1697+ btree_index.BTreeGraphIndex(t1, 'index', None))
1698+ self.assertTrue(
1699+ btree_index.BTreeGraphIndex(t1, 'index', 20) ==
1700+ btree_index.BTreeGraphIndex(t1, 'index', 20))
1701+ self.assertFalse(
1702+ btree_index.BTreeGraphIndex(t1, 'index', 20) ==
1703+ btree_index.BTreeGraphIndex(t2, 'index', 20))
1704+ self.assertFalse(
1705+ btree_index.BTreeGraphIndex(t1, 'inde1', 20) ==
1706+ btree_index.BTreeGraphIndex(t1, 'inde2', 20))
1707+ self.assertFalse(
1708+ btree_index.BTreeGraphIndex(t1, 'index', 10) ==
1709+ btree_index.BTreeGraphIndex(t1, 'index', 20))
1710+ self.assertFalse(
1711+ btree_index.BTreeGraphIndex(t1, 'index', None) !=
1712+ btree_index.BTreeGraphIndex(t1, 'index', None))
1713+ self.assertFalse(
1714+ btree_index.BTreeGraphIndex(t1, 'index', 20) !=
1715+ btree_index.BTreeGraphIndex(t1, 'index', 20))
1716+ self.assertTrue(
1717+ btree_index.BTreeGraphIndex(t1, 'index', 20) !=
1718+ btree_index.BTreeGraphIndex(t2, 'index', 20))
1719+ self.assertTrue(
1720+ btree_index.BTreeGraphIndex(t1, 'inde1', 20) !=
1721+ btree_index.BTreeGraphIndex(t1, 'inde2', 20))
1722+ self.assertTrue(
1723+ btree_index.BTreeGraphIndex(t1, 'index', 10) !=
1724+ btree_index.BTreeGraphIndex(t1, 'index', 20))
1725
1726 def test_iter_all_only_root_no_size(self):
1727 self.make_index(nodes=[(('key',), 'value', ())])
1728- trans = get_transport('trace+' + self.get_url(''))
1729- index = btree_index.BTreeGraphIndex(trans, 'index', None)
1730- del trans._activity[:]
1731+ t = transport.get_transport('trace+' + self.get_url(''))
1732+ index = btree_index.BTreeGraphIndex(t, 'index', None)
1733+ del t._activity[:]
1734 self.assertEqual([(('key',), 'value')],
1735 [x[1:] for x in index.iter_all_entries()])
1736- self.assertEqual([('get', 'index')], trans._activity)
1737+ self.assertEqual([('get', 'index')], t._activity)
1738
1739 def test_iter_all_entries_reads(self):
1740 # iterating all entries reads the header, then does a linear
1741@@ -848,15 +849,15 @@
1742 nodes = self.make_nodes(10000, 2, 2)
1743 for node in nodes:
1744 builder.add_node(*node)
1745- transport = get_transport('trace+' + self.get_url(''))
1746- size = transport.put_file('index', builder.finish())
1747+ t = transport.get_transport('trace+' + self.get_url(''))
1748+ size = t.put_file('index', builder.finish())
1749 self.assertEqual(1303220, size, 'number of expected bytes in the'
1750 ' output changed')
1751 page_size = btree_index._PAGE_SIZE
1752 del builder
1753- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1754- del transport._activity[:]
1755- self.assertEqual([], transport._activity)
1756+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1757+ del t._activity[:]
1758+ self.assertEqual([], t._activity)
1759 found_nodes = self.time(list, index.iter_all_entries())
1760 bare_nodes = []
1761 for node in found_nodes:
1762@@ -883,7 +884,7 @@
1763 readv_request[-1] = (readv_request[-1][0], 1303220 % page_size)
1764 expected = [('readv', 'index', [(0, page_size)], False, None),
1765 ('readv', 'index', readv_request, False, None)]
1766- if expected != transport._activity:
1767+ if expected != t._activity:
1768 self.assertEqualDiff(pprint.pformat(expected),
1769 pprint.pformat(transport._activity))
1770
1771@@ -903,12 +904,12 @@
1772 nodes = self.make_nodes(160, 2, 2)
1773 for node in nodes:
1774 builder.add_node(*node)
1775- transport = get_transport('trace+' + self.get_url(''))
1776- size = transport.put_file('index', builder.finish())
1777+ t = transport.get_transport('trace+' + self.get_url(''))
1778+ size = t.put_file('index', builder.finish())
1779 del builder
1780- index = btree_index.BTreeGraphIndex(transport, 'index', size)
1781- del transport._activity[:]
1782- self.assertEqual([], transport._activity)
1783+ index = btree_index.BTreeGraphIndex(t, 'index', size)
1784+ del t._activity[:]
1785+ self.assertEqual([], t._activity)
1786 # search for one key
1787 found_nodes = list(index.iter_entries([nodes[30][0]]))
1788 bare_nodes = []
1789@@ -922,7 +923,7 @@
1790 # Should have read the root node, then one leaf page:
1791 self.assertEqual([('readv', 'index', [(0, 4096)], False, None),
1792 ('readv', 'index', [(8192, 4096), ], False, None)],
1793- transport._activity)
1794+ t._activity)
1795
1796 def test_iter_key_prefix_1_element_key_None(self):
1797 index = self.make_index()
1798@@ -1152,7 +1153,7 @@
1799 for node in nodes:
1800 builder.add_node(*node)
1801 stream = builder.finish()
1802- trans = get_transport(self.get_url())
1803+ trans = transport.get_transport(self.get_url())
1804 size = trans.put_file('index', stream)
1805 index = btree_index.BTreeGraphIndex(trans, 'index', size)
1806 self.assertEqual(500, index.key_count())
1807@@ -1349,8 +1350,8 @@
1808 This doesn't actually create anything on disk, it just primes a
1809 BTreeGraphIndex with the recommended information.
1810 """
1811- index = btree_index.BTreeGraphIndex(get_transport('memory:///'),
1812- 'test-index', size=size)
1813+ index = btree_index.BTreeGraphIndex(
1814+ transport.get_transport('memory:///'), 'test-index', size=size)
1815 if recommended_pages is not None:
1816 index._recommended_pages = recommended_pages
1817 return index
1818
1819=== modified file 'bzrlib/tests/test_bzrdir.py'
1820--- bzrlib/tests/test_bzrdir.py 2010-06-25 04:49:54 +0000
1821+++ bzrlib/tests/test_bzrdir.py 2010-06-29 17:48:31 +0000
1822@@ -1159,9 +1159,11 @@
1823 """
1824
1825 def create_transport_readonly_server(self):
1826+ # We don't set the http protocol version, relying on the default
1827 return http_utils.HTTPServerRedirecting()
1828
1829 def create_transport_secondary_server(self):
1830+ # We don't set the http protocol version, relying on the default
1831 return http_utils.HTTPServerRedirecting()
1832
1833 def setUp(self):
1834
1835=== modified file 'bzrlib/tests/test_debug.py'
1836--- bzrlib/tests/test_debug.py 2009-03-23 14:59:43 +0000
1837+++ bzrlib/tests/test_debug.py 2010-06-29 17:48:31 +0000
1838@@ -1,4 +1,4 @@
1839-# Copyright (C) 2009 Canonical Ltd
1840+# Copyright (C) 2009, 2010 Canonical Ltd
1841 #
1842 # This program is free software; you can redistribute it and/or modify
1843 # it under the terms of the GNU General Public License as published by
1844@@ -20,13 +20,14 @@
1845 import os
1846
1847
1848-from bzrlib import debug
1849+from bzrlib import (
1850+ debug,
1851+ tests,
1852+ )
1853 from bzrlib.config import config_filename, ensure_config_dir_exists
1854-from bzrlib.transport import get_transport
1855-from bzrlib.tests import TestCaseInTempDir
1856-
1857-
1858-class TestDebugFlags(TestCaseInTempDir):
1859+
1860+
1861+class TestDebugFlags(tests.TestCaseInTempDir):
1862
1863 def test_set_debug_flags_from_config(self):
1864 # test both combinations because configobject automatically splits up
1865
1866=== modified file 'bzrlib/tests/test_directory_service.py'
1867--- bzrlib/tests/test_directory_service.py 2010-06-02 04:50:35 +0000
1868+++ bzrlib/tests/test_directory_service.py 2010-06-29 17:48:31 +0000
1869@@ -18,11 +18,11 @@
1870
1871 from bzrlib import (
1872 errors,
1873+ transport,
1874 urlutils,
1875 )
1876 from bzrlib.directory_service import DirectoryServiceRegistry, directories
1877 from bzrlib.tests import TestCase, TestCaseWithTransport
1878-from bzrlib.transport import get_transport
1879
1880
1881 class FooService(object):
1882@@ -56,7 +56,7 @@
1883 directories.register('foo:', FooService, 'Map foo URLs to http urls')
1884 self.addCleanup(directories.remove, 'foo:')
1885 self.assertEqual(FooService.base + 'bar/',
1886- get_transport('foo:bar').base)
1887+ transport.get_transport('foo:bar').base)
1888
1889
1890 class TestAliasDirectory(TestCaseWithTransport):
1891
1892=== modified file 'bzrlib/tests/test_http.py'
1893--- bzrlib/tests/test_http.py 2010-03-18 23:11:15 +0000
1894+++ bzrlib/tests/test_http.py 2010-06-29 17:48:31 +0000
1895@@ -89,6 +89,18 @@
1896 _qualified_prefix='http+pycurl',)))
1897 tests.multiply_tests(t_tests, transport_scenarios, result)
1898
1899+ protocol_scenarios = [
1900+ ('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
1901+ ('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
1902+ ]
1903+
1904+ # some tests are parametrized by the protocol version only
1905+ p_tests, remaining_tests = tests.split_suite_by_condition(
1906+ remaining_tests, tests.condition_isinstance((
1907+ TestAuthOnRedirected,
1908+ )))
1909+ tests.multiply_tests(p_tests, protocol_scenarios, result)
1910+
1911 # each implementation tested with each HTTP version
1912 tp_tests, remaining_tests = tests.split_suite_by_condition(
1913 remaining_tests, tests.condition_isinstance((
1914@@ -103,10 +115,6 @@
1915 TestRanges,
1916 TestSpecificRequestHandler,
1917 )))
1918- protocol_scenarios = [
1919- ('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
1920- ('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
1921- ]
1922 tp_scenarios = tests.multiply_scenarios(transport_scenarios,
1923 protocol_scenarios)
1924 tests.multiply_tests(tp_tests, tp_scenarios, result)
1925@@ -2156,13 +2164,14 @@
1926 _transport = _urllib.HttpTransport_urllib
1927
1928 def create_transport_readonly_server(self):
1929- return self._auth_server()
1930+ return self._auth_server(protocol_version=self._protocol_version)
1931
1932 def create_transport_secondary_server(self):
1933 """Create the secondary server redirecting to the primary server"""
1934 new = self.get_readonly_server()
1935
1936- redirecting = http_utils.HTTPServerRedirecting()
1937+ redirecting = http_utils.HTTPServerRedirecting(
1938+ protocol_version=self._protocol_version)
1939 redirecting.redirect_to(new.host, new.port)
1940 return redirecting
1941
1942
1943=== modified file 'bzrlib/tests/test_index.py'
1944--- bzrlib/tests/test_index.py 2010-04-08 07:01:10 +0000
1945+++ bzrlib/tests/test_index.py 2010-06-29 17:48:31 +0000
1946@@ -16,16 +16,18 @@
1947
1948 """Tests for indices."""
1949
1950-from bzrlib import errors
1951-from bzrlib.index import *
1952-from bzrlib.tests import TestCaseWithMemoryTransport
1953-from bzrlib.transport import get_transport
1954-
1955-
1956-class TestGraphIndexBuilder(TestCaseWithMemoryTransport):
1957+from bzrlib import (
1958+ errors,
1959+ index,
1960+ tests,
1961+ transport,
1962+ )
1963+
1964+
1965+class TestGraphIndexBuilder(tests.TestCaseWithMemoryTransport):
1966
1967 def test_build_index_empty(self):
1968- builder = GraphIndexBuilder()
1969+ builder = index.GraphIndexBuilder()
1970 stream = builder.finish()
1971 contents = stream.read()
1972 self.assertEqual(
1973@@ -33,7 +35,7 @@
1974 contents)
1975
1976 def test_build_index_empty_two_element_keys(self):
1977- builder = GraphIndexBuilder(key_elements=2)
1978+ builder = index.GraphIndexBuilder(key_elements=2)
1979 stream = builder.finish()
1980 contents = stream.read()
1981 self.assertEqual(
1982@@ -41,7 +43,7 @@
1983 contents)
1984
1985 def test_build_index_one_reference_list_empty(self):
1986- builder = GraphIndexBuilder(reference_lists=1)
1987+ builder = index.GraphIndexBuilder(reference_lists=1)
1988 stream = builder.finish()
1989 contents = stream.read()
1990 self.assertEqual(
1991@@ -49,7 +51,7 @@
1992 contents)
1993
1994 def test_build_index_two_reference_list_empty(self):
1995- builder = GraphIndexBuilder(reference_lists=2)
1996+ builder = index.GraphIndexBuilder(reference_lists=2)
1997 stream = builder.finish()
1998 contents = stream.read()
1999 self.assertEqual(
2000@@ -57,7 +59,7 @@
2001 contents)
2002
2003 def test_build_index_one_node_no_refs(self):
2004- builder = GraphIndexBuilder()
2005+ builder = index.GraphIndexBuilder()
2006 builder.add_node(('akey', ), 'data')
2007 stream = builder.finish()
2008 contents = stream.read()
2009@@ -66,7 +68,7 @@
2010 "akey\x00\x00\x00data\n\n", contents)
2011
2012 def test_build_index_one_node_no_refs_accepts_empty_reflist(self):
2013- builder = GraphIndexBuilder()
2014+ builder = index.GraphIndexBuilder()
2015 builder.add_node(('akey', ), 'data', ())
2016 stream = builder.finish()
2017 contents = stream.read()
2018@@ -78,7 +80,7 @@
2019 # multipart keys are separated by \x00 - because they are fixed length,
2020 # not variable this does not cause any issues, and seems clearer to the
2021 # author.
2022- builder = GraphIndexBuilder(key_elements=2)
2023+ builder = index.GraphIndexBuilder(key_elements=2)
2024 builder.add_node(('akey', 'secondpart'), 'data')
2025 stream = builder.finish()
2026 contents = stream.read()
2027@@ -87,7 +89,7 @@
2028 "akey\x00secondpart\x00\x00\x00data\n\n", contents)
2029
2030 def test_add_node_empty_value(self):
2031- builder = GraphIndexBuilder()
2032+ builder = index.GraphIndexBuilder()
2033 builder.add_node(('akey', ), '')
2034 stream = builder.finish()
2035 contents = stream.read()
2036@@ -97,7 +99,7 @@
2037
2038 def test_build_index_nodes_sorted(self):
2039 # the highest sorted node comes first.
2040- builder = GraphIndexBuilder()
2041+ builder = index.GraphIndexBuilder()
2042 # use three to have a good chance of glitching dictionary hash
2043 # lookups etc. Insert in randomish order that is not correct
2044 # and not the reverse of the correct order.
2045@@ -115,7 +117,7 @@
2046
2047 def test_build_index_2_element_key_nodes_sorted(self):
2048 # multiple element keys are sorted first-key, second-key.
2049- builder = GraphIndexBuilder(key_elements=2)
2050+ builder = index.GraphIndexBuilder(key_elements=2)
2051 # use three values of each key element, to have a good chance of
2052 # glitching dictionary hash lookups etc. Insert in randomish order that
2053 # is not correct and not the reverse of the correct order.
2054@@ -144,7 +146,7 @@
2055 "\n", contents)
2056
2057 def test_build_index_reference_lists_are_included_one(self):
2058- builder = GraphIndexBuilder(reference_lists=1)
2059+ builder = index.GraphIndexBuilder(reference_lists=1)
2060 builder.add_node(('key', ), 'data', ([], ))
2061 stream = builder.finish()
2062 contents = stream.read()
2063@@ -154,7 +156,7 @@
2064 "\n", contents)
2065
2066 def test_build_index_reference_lists_with_2_element_keys(self):
2067- builder = GraphIndexBuilder(reference_lists=1, key_elements=2)
2068+ builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)
2069 builder.add_node(('key', 'key2'), 'data', ([], ))
2070 stream = builder.finish()
2071 contents = stream.read()
2072@@ -164,7 +166,7 @@
2073 "\n", contents)
2074
2075 def test_build_index_reference_lists_are_included_two(self):
2076- builder = GraphIndexBuilder(reference_lists=2)
2077+ builder = index.GraphIndexBuilder(reference_lists=2)
2078 builder.add_node(('key', ), 'data', ([], []))
2079 stream = builder.finish()
2080 contents = stream.read()
2081@@ -174,12 +176,12 @@
2082 "\n", contents)
2083
2084 def test_clear_cache(self):
2085- builder = GraphIndexBuilder(reference_lists=2)
2086+ builder = index.GraphIndexBuilder(reference_lists=2)
2087 # This is a no-op, but the api should exist
2088 builder.clear_cache()
2089
2090 def test_node_references_are_byte_offsets(self):
2091- builder = GraphIndexBuilder(reference_lists=1)
2092+ builder = index.GraphIndexBuilder(reference_lists=1)
2093 builder.add_node(('reference', ), 'data', ([], ))
2094 builder.add_node(('key', ), 'data', ([('reference', )], ))
2095 stream = builder.finish()
2096@@ -191,10 +193,11 @@
2097 "\n", contents)
2098
2099 def test_node_references_are_cr_delimited(self):
2100- builder = GraphIndexBuilder(reference_lists=1)
2101+ builder = index.GraphIndexBuilder(reference_lists=1)
2102 builder.add_node(('reference', ), 'data', ([], ))
2103 builder.add_node(('reference2', ), 'data', ([], ))
2104- builder.add_node(('key', ), 'data', ([('reference', ), ('reference2', )], ))
2105+ builder.add_node(('key', ), 'data',
2106+ ([('reference', ), ('reference2', )], ))
2107 stream = builder.finish()
2108 contents = stream.read()
2109 self.assertEqual(
2110@@ -205,9 +208,10 @@
2111 "\n", contents)
2112
2113 def test_multiple_reference_lists_are_tab_delimited(self):
2114- builder = GraphIndexBuilder(reference_lists=2)
2115+ builder = index.GraphIndexBuilder(reference_lists=2)
2116 builder.add_node(('keference', ), 'data', ([], []))
2117- builder.add_node(('rey', ), 'data', ([('keference', )], [('keference', )]))
2118+ builder.add_node(('rey', ), 'data',
2119+ ([('keference', )], [('keference', )]))
2120 stream = builder.finish()
2121 contents = stream.read()
2122 self.assertEqual(
2123@@ -217,8 +221,9 @@
2124 "\n", contents)
2125
2126 def test_add_node_referencing_missing_key_makes_absent(self):
2127- builder = GraphIndexBuilder(reference_lists=1)
2128- builder.add_node(('rey', ), 'data', ([('beference', ), ('aeference2', )], ))
2129+ builder = index.GraphIndexBuilder(reference_lists=1)
2130+ builder.add_node(('rey', ), 'data',
2131+ ([('beference', ), ('aeference2', )], ))
2132 stream = builder.finish()
2133 contents = stream.read()
2134 self.assertEqual(
2135@@ -230,7 +235,7 @@
2136
2137 def test_node_references_three_digits(self):
2138 # test the node digit expands as needed.
2139- builder = GraphIndexBuilder(reference_lists=1)
2140+ builder = index.GraphIndexBuilder(reference_lists=1)
2141 references = [(str(val), ) for val in reversed(range(9))]
2142 builder.add_node(('2-key', ), '', (references, ))
2143 stream = builder.finish()
2144@@ -252,7 +257,7 @@
2145 def test_absent_has_no_reference_overhead(self):
2146 # the offsets after an absent record should be correct when there are
2147 # >1 reference lists.
2148- builder = GraphIndexBuilder(reference_lists=2)
2149+ builder = index.GraphIndexBuilder(reference_lists=2)
2150 builder.add_node(('parent', ), '', ([('aail', ), ('zther', )], []))
2151 stream = builder.finish()
2152 contents = stream.read()
2153@@ -264,7 +269,7 @@
2154 "\n", contents)
2155
2156 def test_add_node_bad_key(self):
2157- builder = GraphIndexBuilder()
2158+ builder = index.GraphIndexBuilder()
2159 for bad_char in '\t\n\x0b\x0c\r\x00 ':
2160 self.assertRaises(errors.BadIndexKey, builder.add_node,
2161 ('a%skey' % bad_char, ), 'data')
2162@@ -279,30 +284,30 @@
2163 self.assertRaises(errors.BadIndexKey, builder.add_node,
2164 ('primary', 'secondary'), 'data')
2165 # secondary key elements get checked too:
2166- builder = GraphIndexBuilder(key_elements=2)
2167+ builder = index.GraphIndexBuilder(key_elements=2)
2168 for bad_char in '\t\n\x0b\x0c\r\x00 ':
2169 self.assertRaises(errors.BadIndexKey, builder.add_node,
2170 ('prefix', 'a%skey' % bad_char), 'data')
2171
2172 def test_add_node_bad_data(self):
2173- builder = GraphIndexBuilder()
2174+ builder = index.GraphIndexBuilder()
2175 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2176 'data\naa')
2177 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2178 'data\x00aa')
2179
2180 def test_add_node_bad_mismatched_ref_lists_length(self):
2181- builder = GraphIndexBuilder()
2182+ builder = index.GraphIndexBuilder()
2183 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2184 'data aa', ([], ))
2185- builder = GraphIndexBuilder(reference_lists=1)
2186+ builder = index.GraphIndexBuilder(reference_lists=1)
2187 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2188 'data aa')
2189 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2190 'data aa', (), )
2191 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2192 'data aa', ([], []))
2193- builder = GraphIndexBuilder(reference_lists=2)
2194+ builder = index.GraphIndexBuilder(reference_lists=2)
2195 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2196 'data aa')
2197 self.assertRaises(errors.BadIndexValue, builder.add_node, ('akey', ),
2198@@ -312,7 +317,7 @@
2199
2200 def test_add_node_bad_key_in_reference_lists(self):
2201 # first list, first key - trivial
2202- builder = GraphIndexBuilder(reference_lists=1)
2203+ builder = index.GraphIndexBuilder(reference_lists=1)
2204 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),
2205 'data aa', ([('a key', )], ))
2206 # references keys must be tuples too
2207@@ -329,41 +334,41 @@
2208 'data aa', ([('agoodkey', ), ('that is a bad key', )], ))
2209 # and if there is more than one list it should be getting checked
2210 # too
2211- builder = GraphIndexBuilder(reference_lists=2)
2212+ builder = index.GraphIndexBuilder(reference_lists=2)
2213 self.assertRaises(errors.BadIndexKey, builder.add_node, ('akey', ),
2214 'data aa', ([], ['a bad key']))
2215
2216 def test_add_duplicate_key(self):
2217- builder = GraphIndexBuilder()
2218+ builder = index.GraphIndexBuilder()
2219 builder.add_node(('key', ), 'data')
2220- self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node, ('key', ),
2221- 'data')
2222+ self.assertRaises(errors.BadIndexDuplicateKey,
2223+ builder.add_node, ('key', ), 'data')
2224
2225 def test_add_duplicate_key_2_elements(self):
2226- builder = GraphIndexBuilder(key_elements=2)
2227+ builder = index.GraphIndexBuilder(key_elements=2)
2228 builder.add_node(('key', 'key'), 'data')
2229 self.assertRaises(errors.BadIndexDuplicateKey, builder.add_node,
2230 ('key', 'key'), 'data')
2231
2232 def test_add_key_after_referencing_key(self):
2233- builder = GraphIndexBuilder(reference_lists=1)
2234+ builder = index.GraphIndexBuilder(reference_lists=1)
2235 builder.add_node(('key', ), 'data', ([('reference', )], ))
2236 builder.add_node(('reference', ), 'data', ([],))
2237
2238 def test_add_key_after_referencing_key_2_elements(self):
2239- builder = GraphIndexBuilder(reference_lists=1, key_elements=2)
2240+ builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)
2241 builder.add_node(('k', 'ey'), 'data', ([('reference', 'tokey')], ))
2242 builder.add_node(('reference', 'tokey'), 'data', ([],))
2243
2244 def test_set_optimize(self):
2245- builder = GraphIndexBuilder(reference_lists=1, key_elements=2)
2246+ builder = index.GraphIndexBuilder(reference_lists=1, key_elements=2)
2247 builder.set_optimize(for_size=True)
2248 self.assertTrue(builder._optimize_for_size)
2249 builder.set_optimize(for_size=False)
2250 self.assertFalse(builder._optimize_for_size)
2251
2252
2253-class TestGraphIndex(TestCaseWithMemoryTransport):
2254+class TestGraphIndex(tests.TestCaseWithMemoryTransport):
2255
2256 def make_key(self, number):
2257 return (str(number) + 'X'*100,)
2258@@ -380,24 +385,24 @@
2259 return nodes
2260
2261 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):
2262- builder = GraphIndexBuilder(ref_lists, key_elements=key_elements)
2263+ builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
2264 for key, value, references in nodes:
2265 builder.add_node(key, value, references)
2266 stream = builder.finish()
2267- trans = get_transport('trace+' + self.get_url())
2268+ trans = transport.get_transport('trace+' + self.get_url())
2269 size = trans.put_file('index', stream)
2270- return GraphIndex(trans, 'index', size)
2271+ return index.GraphIndex(trans, 'index', size)
2272
2273 def make_index_with_offset(self, ref_lists=0, key_elements=1, nodes=[],
2274 offset=0):
2275- builder = GraphIndexBuilder(ref_lists, key_elements=key_elements)
2276+ builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
2277 for key, value, references in nodes:
2278 builder.add_node(key, value, references)
2279 content = builder.finish().read()
2280 size = len(content)
2281 trans = self.get_transport()
2282 trans.put_bytes('index', (' '*offset) + content)
2283- return GraphIndex(trans, 'index', size, offset=offset)
2284+ return index.GraphIndex(trans, 'index', size, offset=offset)
2285
2286 def test_clear_cache(self):
2287 index = self.make_index()
2288@@ -408,18 +413,18 @@
2289 def test_open_bad_index_no_error(self):
2290 trans = self.get_transport()
2291 trans.put_bytes('name', "not an index\n")
2292- index = GraphIndex(trans, 'name', 13)
2293+ idx = index.GraphIndex(trans, 'name', 13)
2294
2295 def test_with_offset(self):
2296 nodes = self.make_nodes(200)
2297- index = self.make_index_with_offset(offset=1234567, nodes=nodes)
2298- self.assertEqual(200, index.key_count())
2299+ idx = self.make_index_with_offset(offset=1234567, nodes=nodes)
2300+ self.assertEqual(200, idx.key_count())
2301
2302 def test_buffer_all_with_offset(self):
2303 nodes = self.make_nodes(200)
2304- index = self.make_index_with_offset(offset=1234567, nodes=nodes)
2305- index._buffer_all()
2306- self.assertEqual(200, index.key_count())
2307+ idx = self.make_index_with_offset(offset=1234567, nodes=nodes)
2308+ idx._buffer_all()
2309+ self.assertEqual(200, idx.key_count())
2310
2311 def test_side_effect_buffering_with_offset(self):
2312 nodes = self.make_nodes(20)
2313@@ -830,9 +835,9 @@
2314 self.assertEqual([], list(index.iter_entries([('a', )])))
2315
2316 def test_iter_missing_entry_empty_no_size(self):
2317- index = self.make_index()
2318- index = GraphIndex(index._transport, 'index', None)
2319- self.assertEqual([], list(index.iter_entries([('a', )])))
2320+ idx = self.make_index()
2321+ idx = index.GraphIndex(idx._transport, 'index', None)
2322+ self.assertEqual([], list(idx.iter_entries([('a', )])))
2323
2324 def test_iter_key_prefix_1_element_key_None(self):
2325 index = self.make_index()
2326@@ -928,17 +933,17 @@
2327 def test_validate_bad_index_errors(self):
2328 trans = self.get_transport()
2329 trans.put_bytes('name', "not an index\n")
2330- index = GraphIndex(trans, 'name', 13)
2331- self.assertRaises(errors.BadIndexFormatSignature, index.validate)
2332+ idx = index.GraphIndex(trans, 'name', 13)
2333+ self.assertRaises(errors.BadIndexFormatSignature, idx.validate)
2334
2335 def test_validate_bad_node_refs(self):
2336- index = self.make_index(2)
2337+ idx = self.make_index(2)
2338 trans = self.get_transport()
2339 content = trans.get_bytes('index')
2340 # change the options line to end with a rather than a parseable number
2341 new_content = content[:-2] + 'a\n\n'
2342 trans.put_bytes('index', new_content)
2343- self.assertRaises(errors.BadIndexOptions, index.validate)
2344+ self.assertRaises(errors.BadIndexOptions, idx.validate)
2345
2346 def test_validate_missing_end_line_empty(self):
2347 index = self.make_index(2)
2348@@ -1049,25 +1054,25 @@
2349 self.assertEqual(set(), search_keys)
2350
2351 def test_supports_unlimited_cache(self):
2352- builder = GraphIndexBuilder(0, key_elements=1)
2353+ builder = index.GraphIndexBuilder(0, key_elements=1)
2354 stream = builder.finish()
2355- trans = get_transport(self.get_url())
2356+ trans = transport.get_transport(self.get_url())
2357 size = trans.put_file('index', stream)
2358 # It doesn't matter what unlimited_cache does here, just that it can be
2359 # passed
2360- index = GraphIndex(trans, 'index', size, unlimited_cache=True)
2361-
2362-
2363-class TestCombinedGraphIndex(TestCaseWithMemoryTransport):
2364+ idx = index.GraphIndex(trans, 'index', size, unlimited_cache=True)
2365+
2366+
2367+class TestCombinedGraphIndex(tests.TestCaseWithMemoryTransport):
2368
2369 def make_index(self, name, ref_lists=0, key_elements=1, nodes=[]):
2370- builder = GraphIndexBuilder(ref_lists, key_elements=key_elements)
2371+ builder = index.GraphIndexBuilder(ref_lists, key_elements=key_elements)
2372 for key, value, references in nodes:
2373 builder.add_node(key, value, references)
2374 stream = builder.finish()
2375 trans = self.get_transport()
2376 size = trans.put_file(name, stream)
2377- return GraphIndex(trans, name, size)
2378+ return index.GraphIndex(trans, name, size)
2379
2380 def make_combined_index_with_missing(self, missing=['1', '2']):
2381 """Create a CombinedGraphIndex which will have missing indexes.
2382@@ -1079,9 +1084,9 @@
2383 :param missing: The underlying indexes to delete
2384 :return: (CombinedGraphIndex, reload_counter)
2385 """
2386- index1 = self.make_index('1', nodes=[(('1',), '', ())])
2387- index2 = self.make_index('2', nodes=[(('2',), '', ())])
2388- index3 = self.make_index('3', nodes=[
2389+ idx1 = self.make_index('1', nodes=[(('1',), '', ())])
2390+ idx2 = self.make_index('2', nodes=[(('2',), '', ())])
2391+ idx3 = self.make_index('3', nodes=[
2392 (('1',), '', ()),
2393 (('2',), '', ())])
2394
2395@@ -1089,29 +1094,30 @@
2396 reload_counter = [0, 0, 0]
2397 def reload():
2398 reload_counter[0] += 1
2399- new_indices = [index3]
2400- if index._indices == new_indices:
2401+ new_indices = [idx3]
2402+ if idx._indices == new_indices:
2403 reload_counter[2] += 1
2404 return False
2405 reload_counter[1] += 1
2406- index._indices[:] = new_indices
2407+ idx._indices[:] = new_indices
2408 return True
2409- index = CombinedGraphIndex([index1, index2], reload_func=reload)
2410+ idx = index.CombinedGraphIndex([idx1, idx2], reload_func=reload)
2411 trans = self.get_transport()
2412 for fname in missing:
2413 trans.delete(fname)
2414- return index, reload_counter
2415+ return idx, reload_counter
2416
2417 def test_open_missing_index_no_error(self):
2418 trans = self.get_transport()
2419- index1 = GraphIndex(trans, 'missing', 100)
2420- index = CombinedGraphIndex([index1])
2421+ idx1 = index.GraphIndex(trans, 'missing', 100)
2422+ idx = index.CombinedGraphIndex([idx1])
2423
2424 def test_add_index(self):
2425- index = CombinedGraphIndex([])
2426- index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
2427- index.insert_index(0, index1)
2428- self.assertEqual([(index1, ('key', ), '')], list(index.iter_all_entries()))
2429+ idx = index.CombinedGraphIndex([])
2430+ idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
2431+ idx.insert_index(0, idx1)
2432+ self.assertEqual([(idx1, ('key', ), '')],
2433+ list(idx.iter_all_entries()))
2434
2435 def test_clear_cache(self):
2436 log = []
2437@@ -1128,165 +1134,166 @@
2438 log.append(self._index)
2439 return self._index.clear_cache()
2440
2441- index = CombinedGraphIndex([])
2442- index1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
2443- index.insert_index(0, ClearCacheProxy(index1))
2444- index2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
2445- index.insert_index(1, ClearCacheProxy(index2))
2446+ idx = index.CombinedGraphIndex([])
2447+ idx1 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
2448+ idx.insert_index(0, ClearCacheProxy(idx1))
2449+ idx2 = self.make_index('name', 0, nodes=[(('key', ), '', ())])
2450+ idx.insert_index(1, ClearCacheProxy(idx2))
2451 # CombinedGraphIndex should call 'clear_cache()' on all children
2452- index.clear_cache()
2453- self.assertEqual(sorted([index1, index2]), sorted(log))
2454+ idx.clear_cache()
2455+ self.assertEqual(sorted([idx1, idx2]), sorted(log))
2456
2457 def test_iter_all_entries_empty(self):
2458- index = CombinedGraphIndex([])
2459- self.assertEqual([], list(index.iter_all_entries()))
2460+ idx = index.CombinedGraphIndex([])
2461+ self.assertEqual([], list(idx.iter_all_entries()))
2462
2463 def test_iter_all_entries_children_empty(self):
2464- index1 = self.make_index('name')
2465- index = CombinedGraphIndex([index1])
2466- self.assertEqual([], list(index.iter_all_entries()))
2467+ idx1 = self.make_index('name')
2468+ idx = index.CombinedGraphIndex([idx1])
2469+ self.assertEqual([], list(idx.iter_all_entries()))
2470
2471 def test_iter_all_entries_simple(self):
2472- index1 = self.make_index('name', nodes=[(('name', ), 'data', ())])
2473- index = CombinedGraphIndex([index1])
2474- self.assertEqual([(index1, ('name', ), 'data')],
2475- list(index.iter_all_entries()))
2476+ idx1 = self.make_index('name', nodes=[(('name', ), 'data', ())])
2477+ idx = index.CombinedGraphIndex([idx1])
2478+ self.assertEqual([(idx1, ('name', ), 'data')],
2479+ list(idx.iter_all_entries()))
2480
2481 def test_iter_all_entries_two_indices(self):
2482- index1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
2483- index2 = self.make_index('name2', nodes=[(('2', ), '', ())])
2484- index = CombinedGraphIndex([index1, index2])
2485- self.assertEqual([(index1, ('name', ), 'data'),
2486- (index2, ('2', ), '')],
2487- list(index.iter_all_entries()))
2488+ idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
2489+ idx2 = self.make_index('name2', nodes=[(('2', ), '', ())])
2490+ idx = index.CombinedGraphIndex([idx1, idx2])
2491+ self.assertEqual([(idx1, ('name', ), 'data'),
2492+ (idx2, ('2', ), '')],
2493+ list(idx.iter_all_entries()))
2494
2495 def test_iter_entries_two_indices_dup_key(self):
2496- index1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
2497- index2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
2498- index = CombinedGraphIndex([index1, index2])
2499- self.assertEqual([(index1, ('name', ), 'data')],
2500- list(index.iter_entries([('name', )])))
2501+ idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
2502+ idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
2503+ idx = index.CombinedGraphIndex([idx1, idx2])
2504+ self.assertEqual([(idx1, ('name', ), 'data')],
2505+ list(idx.iter_entries([('name', )])))
2506
2507 def test_iter_all_entries_two_indices_dup_key(self):
2508- index1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
2509- index2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
2510- index = CombinedGraphIndex([index1, index2])
2511- self.assertEqual([(index1, ('name', ), 'data')],
2512- list(index.iter_all_entries()))
2513+ idx1 = self.make_index('name1', nodes=[(('name', ), 'data', ())])
2514+ idx2 = self.make_index('name2', nodes=[(('name', ), 'data', ())])
2515+ idx = index.CombinedGraphIndex([idx1, idx2])
2516+ self.assertEqual([(idx1, ('name', ), 'data')],
2517+ list(idx.iter_all_entries()))
2518
2519 def test_iter_key_prefix_2_key_element_refs(self):
2520- index1 = self.make_index('1', 1, key_elements=2, nodes=[
2521- (('name', 'fin1'), 'data', ([('ref', 'erence')], ))])
2522- index2 = self.make_index('2', 1, key_elements=2, nodes=[
2523- (('name', 'fin2'), 'beta', ([], )),
2524- (('ref', 'erence'), 'refdata', ([], ))])
2525- index = CombinedGraphIndex([index1, index2])
2526- self.assertEqual(set([(index1, ('name', 'fin1'), 'data', ((('ref', 'erence'),),)),
2527- (index2, ('ref', 'erence'), 'refdata', ((), ))]),
2528- set(index.iter_entries_prefix([('name', 'fin1'), ('ref', 'erence')])))
2529- self.assertEqual(set([(index1, ('name', 'fin1'), 'data', ((('ref', 'erence'),),)),
2530- (index2, ('name', 'fin2'), 'beta', ((), ))]),
2531- set(index.iter_entries_prefix([('name', None)])))
2532+ idx1 = self.make_index('1', 1, key_elements=2, nodes=[
2533+ (('name', 'fin1'), 'data', ([('ref', 'erence')], ))])
2534+ idx2 = self.make_index('2', 1, key_elements=2, nodes=[
2535+ (('name', 'fin2'), 'beta', ([], )),
2536+ (('ref', 'erence'), 'refdata', ([], ))])
2537+ idx = index.CombinedGraphIndex([idx1, idx2])
2538+ self.assertEqual(set([(idx1, ('name', 'fin1'), 'data',
2539+ ((('ref', 'erence'),),)),
2540+ (idx2, ('ref', 'erence'), 'refdata', ((), ))]),
2541+ set(idx.iter_entries_prefix([('name', 'fin1'),
2542+ ('ref', 'erence')])))
2543+ self.assertEqual(set([(idx1, ('name', 'fin1'), 'data',
2544+ ((('ref', 'erence'),),)),
2545+ (idx2, ('name', 'fin2'), 'beta', ((), ))]),
2546+ set(idx.iter_entries_prefix([('name', None)])))
2547
2548 def test_iter_nothing_empty(self):
2549- index = CombinedGraphIndex([])
2550- self.assertEqual([], list(index.iter_entries([])))
2551+ idx = index.CombinedGraphIndex([])
2552+ self.assertEqual([], list(idx.iter_entries([])))
2553
2554 def test_iter_nothing_children_empty(self):
2555- index1 = self.make_index('name')
2556- index = CombinedGraphIndex([index1])
2557- self.assertEqual([], list(index.iter_entries([])))
2558+ idx1 = self.make_index('name')
2559+ idx = index.CombinedGraphIndex([idx1])
2560+ self.assertEqual([], list(idx.iter_entries([])))
2561
2562 def test_iter_all_keys(self):
2563- index1 = self.make_index('1', 1, nodes=[
2564- (('name', ), 'data', ([('ref', )], ))])
2565- index2 = self.make_index('2', 1, nodes=[
2566- (('ref', ), 'refdata', ((), ))])
2567- index = CombinedGraphIndex([index1, index2])
2568- self.assertEqual(set([(index1, ('name', ), 'data', ((('ref', ), ), )),
2569- (index2, ('ref', ), 'refdata', ((), ))]),
2570- set(index.iter_entries([('name', ), ('ref', )])))
2571+ idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data',
2572+ ([('ref', )], ))])
2573+ idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ((), ))])
2574+ idx = index.CombinedGraphIndex([idx1, idx2])
2575+ self.assertEqual(set([(idx1, ('name', ), 'data', ((('ref', ), ), )),
2576+ (idx2, ('ref', ), 'refdata', ((), ))]),
2577+ set(idx.iter_entries([('name', ), ('ref', )])))
2578
2579 def test_iter_all_keys_dup_entry(self):
2580- index1 = self.make_index('1', 1, nodes=[
2581- (('name', ), 'data', ([('ref', )], )),
2582- (('ref', ), 'refdata', ([], ))])
2583- index2 = self.make_index('2', 1, nodes=[
2584- (('ref', ), 'refdata', ([], ))])
2585- index = CombinedGraphIndex([index1, index2])
2586- self.assertEqual(set([(index1, ('name', ), 'data', ((('ref',),),)),
2587- (index1, ('ref', ), 'refdata', ((), ))]),
2588- set(index.iter_entries([('name', ), ('ref', )])))
2589+ idx1 = self.make_index('1', 1, nodes=[(('name', ), 'data',
2590+ ([('ref', )], )),
2591+ (('ref', ), 'refdata', ([], ))])
2592+ idx2 = self.make_index('2', 1, nodes=[(('ref', ), 'refdata', ([], ))])
2593+ idx = index.CombinedGraphIndex([idx1, idx2])
2594+ self.assertEqual(set([(idx1, ('name', ), 'data', ((('ref',),),)),
2595+ (idx1, ('ref', ), 'refdata', ((), ))]),
2596+ set(idx.iter_entries([('name', ), ('ref', )])))
2597
2598 def test_iter_missing_entry_empty(self):
2599- index = CombinedGraphIndex([])
2600- self.assertEqual([], list(index.iter_entries([('a', )])))
2601+ idx = index.CombinedGraphIndex([])
2602+ self.assertEqual([], list(idx.iter_entries([('a', )])))
2603
2604 def test_iter_missing_entry_one_index(self):
2605- index1 = self.make_index('1')
2606- index = CombinedGraphIndex([index1])
2607- self.assertEqual([], list(index.iter_entries([('a', )])))
2608+ idx1 = self.make_index('1')
2609+ idx = index.CombinedGraphIndex([idx1])
2610+ self.assertEqual([], list(idx.iter_entries([('a', )])))
2611
2612 def test_iter_missing_entry_two_index(self):
2613- index1 = self.make_index('1')
2614- index2 = self.make_index('2')
2615- index = CombinedGraphIndex([index1, index2])
2616- self.assertEqual([], list(index.iter_entries([('a', )])))
2617+ idx1 = self.make_index('1')
2618+ idx2 = self.make_index('2')
2619+ idx = index.CombinedGraphIndex([idx1, idx2])
2620+ self.assertEqual([], list(idx.iter_entries([('a', )])))
2621
2622 def test_iter_entry_present_one_index_only(self):
2623- index1 = self.make_index('1', nodes=[(('key', ), '', ())])
2624- index2 = self.make_index('2', nodes=[])
2625- index = CombinedGraphIndex([index1, index2])
2626- self.assertEqual([(index1, ('key', ), '')],
2627- list(index.iter_entries([('key', )])))
2628+ idx1 = self.make_index('1', nodes=[(('key', ), '', ())])
2629+ idx2 = self.make_index('2', nodes=[])
2630+ idx = index.CombinedGraphIndex([idx1, idx2])
2631+ self.assertEqual([(idx1, ('key', ), '')],
2632+ list(idx.iter_entries([('key', )])))
2633 # and in the other direction
2634- index = CombinedGraphIndex([index2, index1])
2635- self.assertEqual([(index1, ('key', ), '')],
2636- list(index.iter_entries([('key', )])))
2637+ idx = index.CombinedGraphIndex([idx2, idx1])
2638+ self.assertEqual([(idx1, ('key', ), '')],
2639+ list(idx.iter_entries([('key', )])))
2640
2641 def test_key_count_empty(self):
2642- index1 = self.make_index('1', nodes=[])
2643- index2 = self.make_index('2', nodes=[])
2644- index = CombinedGraphIndex([index1, index2])
2645- self.assertEqual(0, index.key_count())
2646+ idx1 = self.make_index('1', nodes=[])
2647+ idx2 = self.make_index('2', nodes=[])
2648+ idx = index.CombinedGraphIndex([idx1, idx2])
2649+ self.assertEqual(0, idx.key_count())
2650
2651 def test_key_count_sums_index_keys(self):
2652- index1 = self.make_index('1', nodes=[
2653+ idx1 = self.make_index('1', nodes=[
2654 (('1',), '', ()),
2655 (('2',), '', ())])
2656- index2 = self.make_index('2', nodes=[(('1',), '', ())])
2657- index = CombinedGraphIndex([index1, index2])
2658- self.assertEqual(3, index.key_count())
2659+ idx2 = self.make_index('2', nodes=[(('1',), '', ())])
2660+ idx = index.CombinedGraphIndex([idx1, idx2])
2661+ self.assertEqual(3, idx.key_count())
2662
2663 def test_validate_bad_child_index_errors(self):
2664 trans = self.get_transport()
2665 trans.put_bytes('name', "not an index\n")
2666- index1 = GraphIndex(trans, 'name', 13)
2667- index = CombinedGraphIndex([index1])
2668- self.assertRaises(errors.BadIndexFormatSignature, index.validate)
2669+ idx1 = index.GraphIndex(trans, 'name', 13)
2670+ idx = index.CombinedGraphIndex([idx1])
2671+ self.assertRaises(errors.BadIndexFormatSignature, idx.validate)
2672
2673 def test_validate_empty(self):
2674- index = CombinedGraphIndex([])
2675- index.validate()
2676+ idx = index.CombinedGraphIndex([])
2677+ idx.validate()
2678
2679 def test_key_count_reloads(self):
2680- index, reload_counter = self.make_combined_index_with_missing()
2681- self.assertEqual(2, index.key_count())
2682+ idx, reload_counter = self.make_combined_index_with_missing()
2683+ self.assertEqual(2, idx.key_count())
2684 self.assertEqual([1, 1, 0], reload_counter)
2685
2686 def test_key_count_no_reload(self):
2687- index, reload_counter = self.make_combined_index_with_missing()
2688- index._reload_func = None
2689+ idx, reload_counter = self.make_combined_index_with_missing()
2690+ idx._reload_func = None
2691 # Without a _reload_func we just raise the exception
2692- self.assertRaises(errors.NoSuchFile, index.key_count)
2693+ self.assertRaises(errors.NoSuchFile, idx.key_count)
2694
2695 def test_key_count_reloads_and_fails(self):
2696 # We have deleted all underlying indexes, so we will try to reload, but
2697 # still fail. This is mostly to test we don't get stuck in an infinite
2698 # loop trying to reload
2699- index, reload_counter = self.make_combined_index_with_missing(
2700- ['1', '2', '3'])
2701- self.assertRaises(errors.NoSuchFile, index.key_count)
2702+ idx, reload_counter = self.make_combined_index_with_missing(
2703+ ['1', '2', '3'])
2704+ self.assertRaises(errors.NoSuchFile, idx.key_count)
2705 self.assertEqual([2, 1, 1], reload_counter)
2706
2707 def test_iter_entries_reloads(self):
2708@@ -1392,27 +1399,27 @@
2709 return self.make_index('index-%s' % name, 0, nodes=nodes)
2710
2711 def test_reorder_after_iter_entries(self):
2712- # Four indices: [key1] in index1, [key2,key3] in index2, [] in index3,
2713- # [key4] in index4.
2714- index = CombinedGraphIndex([])
2715- index.insert_index(0, self.make_index_with_simple_nodes('1'), '1')
2716- index.insert_index(1, self.make_index_with_simple_nodes('2'), '2')
2717- index.insert_index(2, self.make_index_with_simple_nodes('3'), '3')
2718- index.insert_index(3, self.make_index_with_simple_nodes('4'), '4')
2719- index1, index2, index3, index4 = index._indices
2720- # Query a key from index4 and index2.
2721- self.assertLength(2, list(index.iter_entries(
2722+ # Four indices: [key1] in idx1, [key2,key3] in idx2, [] in idx3,
2723+ # [key4] in idx4.
2724+ idx = index.CombinedGraphIndex([])
2725+ idx.insert_index(0, self.make_index_with_simple_nodes('1'), '1')
2726+ idx.insert_index(1, self.make_index_with_simple_nodes('2'), '2')
2727+ idx.insert_index(2, self.make_index_with_simple_nodes('3'), '3')
2728+ idx.insert_index(3, self.make_index_with_simple_nodes('4'), '4')
2729+ idx1, idx2, idx3, idx4 = idx._indices
2730+ # Query a key from idx4 and idx2.
2731+ self.assertLength(2, list(idx.iter_entries(
2732 [('index-4-key-1',), ('index-2-key-1',)])))
2733- # Now index2 and index4 should be moved to the front (and index1 should
2734- # still be before index3).
2735- self.assertEqual([index2, index4, index1, index3], index._indices)
2736- self.assertEqual(['2', '4', '1', '3'], index._index_names)
2737+ # Now idx2 and idx4 should be moved to the front (and idx1 should
2738+ # still be before idx3).
2739+ self.assertEqual([idx2, idx4, idx1, idx3], idx._indices)
2740+ self.assertEqual(['2', '4', '1', '3'], idx._index_names)
2741
2742 def test_reorder_propagates_to_siblings(self):
2743 # Two CombinedGraphIndex objects, with the same number of indicies with
2744 # matching names.
2745- cgi1 = CombinedGraphIndex([])
2746- cgi2 = CombinedGraphIndex([])
2747+ cgi1 = index.CombinedGraphIndex([])
2748+ cgi2 = index.CombinedGraphIndex([])
2749 cgi1.insert_index(0, self.make_index_with_simple_nodes('1-1'), 'one')
2750 cgi1.insert_index(1, self.make_index_with_simple_nodes('1-2'), 'two')
2751 cgi2.insert_index(0, self.make_index_with_simple_nodes('2-1'), 'one')
2752@@ -1425,23 +1432,23 @@
2753 self.assertEqual(['two', 'one'], cgi2._index_names)
2754
2755 def test_validate_reloads(self):
2756- index, reload_counter = self.make_combined_index_with_missing()
2757- index.validate()
2758+ idx, reload_counter = self.make_combined_index_with_missing()
2759+ idx.validate()
2760 self.assertEqual([1, 1, 0], reload_counter)
2761
2762 def test_validate_reloads_midway(self):
2763- index, reload_counter = self.make_combined_index_with_missing(['2'])
2764- index.validate()
2765+ idx, reload_counter = self.make_combined_index_with_missing(['2'])
2766+ idx.validate()
2767
2768 def test_validate_no_reload(self):
2769- index, reload_counter = self.make_combined_index_with_missing()
2770- index._reload_func = None
2771- self.assertRaises(errors.NoSuchFile, index.validate)
2772+ idx, reload_counter = self.make_combined_index_with_missing()
2773+ idx._reload_func = None
2774+ self.assertRaises(errors.NoSuchFile, idx.validate)
2775
2776 def test_validate_reloads_and_fails(self):
2777- index, reload_counter = self.make_combined_index_with_missing(
2778- ['1', '2', '3'])
2779- self.assertRaises(errors.NoSuchFile, index.validate)
2780+ idx, reload_counter = self.make_combined_index_with_missing(
2781+ ['1', '2', '3'])
2782+ self.assertRaises(errors.NoSuchFile, idx.validate)
2783
2784 def test_find_ancestors_across_indexes(self):
2785 key1 = ('key-1',)
2786@@ -1456,7 +1463,7 @@
2787 (key3, 'value', ([key2],)),
2788 (key4, 'value', ([key3],)),
2789 ])
2790- c_index = CombinedGraphIndex([index1, index2])
2791+ c_index = index.CombinedGraphIndex([index1, index2])
2792 parent_map, missing_keys = c_index.find_ancestry([key1], 0)
2793 self.assertEqual({key1: ()}, parent_map)
2794 self.assertEqual(set(), missing_keys)
2795@@ -1479,7 +1486,7 @@
2796 index2 = self.make_index('34', ref_lists=1, nodes=[
2797 (key3, 'value', ([key2],)),
2798 ])
2799- c_index = CombinedGraphIndex([index1, index2])
2800+ c_index = index.CombinedGraphIndex([index1, index2])
2801 # Searching for a key which is actually not present at all should
2802 # eventually converge
2803 parent_map, missing_keys = c_index.find_ancestry([key4], 0)
2804@@ -1487,7 +1494,7 @@
2805 self.assertEqual(set([key4]), missing_keys)
2806
2807 def test_find_ancestors_no_indexes(self):
2808- c_index = CombinedGraphIndex([])
2809+ c_index = index.CombinedGraphIndex([])
2810 key1 = ('key-1',)
2811 parent_map, missing_keys = c_index.find_ancestry([key1], 0)
2812 self.assertEqual({}, parent_map)
2813@@ -1505,7 +1512,7 @@
2814 index2 = self.make_index('34', ref_lists=1, nodes=[
2815 (key4, 'value', ([key2, key3],)),
2816 ])
2817- c_index = CombinedGraphIndex([index1, index2])
2818+ c_index = index.CombinedGraphIndex([index1, index2])
2819 # Searching for a key which is actually not present at all should
2820 # eventually converge
2821 parent_map, missing_keys = c_index.find_ancestry([key4], 0)
2822@@ -1514,20 +1521,20 @@
2823 self.assertEqual(set([key3]), missing_keys)
2824
2825 def test__find_ancestors_empty_index(self):
2826- index = self.make_index('test', ref_lists=1, key_elements=1, nodes=[])
2827+ idx = self.make_index('test', ref_lists=1, key_elements=1, nodes=[])
2828 parent_map = {}
2829 missing_keys = set()
2830- search_keys = index._find_ancestors([('one',), ('two',)], 0, parent_map,
2831- missing_keys)
2832+ search_keys = idx._find_ancestors([('one',), ('two',)], 0, parent_map,
2833+ missing_keys)
2834 self.assertEqual(set(), search_keys)
2835 self.assertEqual({}, parent_map)
2836 self.assertEqual(set([('one',), ('two',)]), missing_keys)
2837
2838
2839-class TestInMemoryGraphIndex(TestCaseWithMemoryTransport):
2840+class TestInMemoryGraphIndex(tests.TestCaseWithMemoryTransport):
2841
2842 def make_index(self, ref_lists=0, key_elements=1, nodes=[]):
2843- result = InMemoryGraphIndex(ref_lists, key_elements=key_elements)
2844+ result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)
2845 result.add_nodes(nodes)
2846 return result
2847
2848@@ -1654,23 +1661,26 @@
2849 index.validate()
2850
2851
2852-class TestGraphIndexPrefixAdapter(TestCaseWithMemoryTransport):
2853+class TestGraphIndexPrefixAdapter(tests.TestCaseWithMemoryTransport):
2854
2855- def make_index(self, ref_lists=1, key_elements=2, nodes=[], add_callback=False):
2856- result = InMemoryGraphIndex(ref_lists, key_elements=key_elements)
2857+ def make_index(self, ref_lists=1, key_elements=2, nodes=[],
2858+ add_callback=False):
2859+ result = index.InMemoryGraphIndex(ref_lists, key_elements=key_elements)
2860 result.add_nodes(nodes)
2861 if add_callback:
2862 add_nodes_callback = result.add_nodes
2863 else:
2864 add_nodes_callback = None
2865- adapter = GraphIndexPrefixAdapter(result, ('prefix', ), key_elements - 1,
2866+ adapter = index.GraphIndexPrefixAdapter(
2867+ result, ('prefix', ), key_elements - 1,
2868 add_nodes_callback=add_nodes_callback)
2869 return result, adapter
2870
2871 def test_add_node(self):
2872 index, adapter = self.make_index(add_callback=True)
2873 adapter.add_node(('key',), 'value', ((('ref',),),))
2874- self.assertEqual(set([(index, ('prefix', 'key'), 'value', ((('prefix', 'ref'),),))]),
2875+ self.assertEqual(set([(index, ('prefix', 'key'), 'value',
2876+ ((('prefix', 'ref'),),))]),
2877 set(index.iter_all_entries()))
2878
2879 def test_add_nodes(self):
2880@@ -1686,12 +1696,13 @@
2881 set(index.iter_all_entries()))
2882
2883 def test_construct(self):
2884- index = InMemoryGraphIndex()
2885- adapter = GraphIndexPrefixAdapter(index, ('prefix', ), 1)
2886+ idx = index.InMemoryGraphIndex()
2887+ adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1)
2888
2889 def test_construct_with_callback(self):
2890- index = InMemoryGraphIndex()
2891- adapter = GraphIndexPrefixAdapter(index, ('prefix', ), 1, index.add_nodes)
2892+ idx = index.InMemoryGraphIndex()
2893+ adapter = index.GraphIndexPrefixAdapter(idx, ('prefix', ), 1,
2894+ idx.add_nodes)
2895
2896 def test_iter_all_entries_cross_prefix_map_errors(self):
2897 index, adapter = self.make_index(nodes=[
2898
2899=== modified file 'bzrlib/tests/test_knit.py'
2900--- bzrlib/tests/test_knit.py 2010-06-04 03:09:35 +0000
2901+++ bzrlib/tests/test_knit.py 2010-06-29 17:48:31 +0000
2902@@ -26,6 +26,7 @@
2903 osutils,
2904 pack,
2905 tests,
2906+ transport,
2907 tuned_gzip,
2908 )
2909 from bzrlib.errors import (
2910@@ -53,7 +54,6 @@
2911 TestCaseWithTransport,
2912 TestNotApplicable,
2913 )
2914-from bzrlib.transport import get_transport
2915 from bzrlib.versionedfile import (
2916 AbsentContentFactory,
2917 ConstantMapper,
2918@@ -1571,13 +1571,13 @@
2919 # could leave an empty .kndx file, which bzr would later claim was a
2920 # corrupted file since the header was not present. In reality, the file
2921 # just wasn't created, so it should be ignored.
2922- t = get_transport('.')
2923+ t = transport.get_transport('.')
2924 t.put_bytes('test.kndx', '')
2925
2926 knit = self.make_test_knit()
2927
2928 def test_knit_index_checks_header(self):
2929- t = get_transport('.')
2930+ t = transport.get_transport('.')
2931 t.put_bytes('test.kndx', '# not really a knit header\n\n')
2932 k = self.make_test_knit()
2933 self.assertRaises(KnitHeaderError, k.keys)
2934
2935=== modified file 'bzrlib/tests/test_lockable_files.py'
2936--- bzrlib/tests/test_lockable_files.py 2010-02-17 17:11:16 +0000
2937+++ bzrlib/tests/test_lockable_files.py 2010-06-29 17:48:31 +0000
2938@@ -21,6 +21,7 @@
2939 errors,
2940 lockdir,
2941 osutils,
2942+ transport,
2943 )
2944 from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
2945 from bzrlib.lockable_files import LockableFiles, TransportLock
2946@@ -37,7 +38,6 @@
2947 ReadOnlyTransaction,
2948 WriteTransaction,
2949 )
2950-from bzrlib.transport import get_transport
2951
2952
2953 # these tests are applied in each parameterized suite for LockableFiles
2954@@ -279,9 +279,9 @@
2955
2956 def setUp(self):
2957 TestCaseInTempDir.setUp(self)
2958- transport = get_transport('.')
2959- transport.mkdir('.bzr')
2960- self.sub_transport = transport.clone('.bzr')
2961+ t = transport.get_transport('.')
2962+ t.mkdir('.bzr')
2963+ self.sub_transport = t.clone('.bzr')
2964 self.lockable = self.get_lockable()
2965 self.lockable.create_lock()
2966
2967@@ -304,7 +304,7 @@
2968
2969 def setUp(self):
2970 TestCaseInTempDir.setUp(self)
2971- self.transport = get_transport('.')
2972+ self.transport = transport.get_transport('.')
2973 self.lockable = self.get_lockable()
2974 # the lock creation here sets mode - test_permissions on branch
2975 # tests that implicitly, but it might be a good idea to factor
2976@@ -347,7 +347,7 @@
2977 # in test_remote and test_smart as usual.
2978 b = self.make_branch('foo')
2979 self.addCleanup(b.bzrdir.transport.disconnect)
2980- self.transport = get_transport('.')
2981+ self.transport = transport.get_transport('.')
2982 self.lockable = self.get_lockable()
2983
2984 def get_lockable(self):
2985
2986=== modified file 'bzrlib/tests/test_osutils.py'
2987--- bzrlib/tests/test_osutils.py 2010-06-08 01:45:09 +0000
2988+++ bzrlib/tests/test_osutils.py 2010-06-29 17:48:31 +0000
2989@@ -861,7 +861,7 @@
2990 self.assertEqual('//HOST/path', osutils._win98_abspath('//HOST/path'))
2991 # relative path
2992 cwd = osutils.getcwd().rstrip('/')
2993- drive = osutils._nt_splitdrive(cwd)[0]
2994+ drive = osutils.ntpath.splitdrive(cwd)[0]
2995 self.assertEqual(cwd+'/path', osutils._win98_abspath('path'))
2996 self.assertEqual(drive+'/path', osutils._win98_abspath('/path'))
2997 # unicode path
2998
2999=== modified file 'bzrlib/tests/test_osutils_encodings.py'
3000--- bzrlib/tests/test_osutils_encodings.py 2010-06-25 20:34:05 +0000
3001+++ bzrlib/tests/test_osutils_encodings.py 2010-06-29 17:48:31 +0000
3002@@ -1,4 +1,4 @@
3003-# Copyright (C) 2005, 2006 Canonical Ltd
3004+# Copyright (C) 2006-2010 Canonical Ltd
3005 #
3006 # This program is free software; you can redistribute it and/or modify
3007 # it under the terms of the GNU General Public License as published by
3008
3009=== modified file 'bzrlib/tests/test_permissions.py'
3010--- bzrlib/tests/test_permissions.py 2009-09-07 08:46:00 +0000
3011+++ bzrlib/tests/test_permissions.py 2010-06-29 17:48:31 +0000
3012@@ -1,4 +1,4 @@
3013-# Copyright (C) 2005 Canonical Ltd
3014+# Copyright (C) 2005-2010 Canonical Ltd
3015 # -*- coding: utf-8 -*-
3016 #
3017 # This program is free software; you can redistribute it and/or modify
3018@@ -36,11 +36,11 @@
3019 from cStringIO import StringIO
3020 import urllib
3021
3022+from bzrlib import transport
3023 from bzrlib.branch import Branch
3024 from bzrlib.bzrdir import BzrDir
3025 from bzrlib.tests import TestCaseWithTransport, TestSkipped
3026 from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
3027-from bzrlib.transport import get_transport
3028 from bzrlib.workingtree import WorkingTree
3029
3030
3031@@ -65,7 +65,7 @@
3032 :param dir_mode: The mode for all directories
3033 :param include_base: If false, only check the subdirectories
3034 """
3035- t = get_transport(".")
3036+ t = transport.get_transport(".")
3037 if include_base:
3038 test.assertTransportMode(t, base, dir_mode)
3039 for root, dirs, files in os.walk(base):
3040@@ -180,7 +180,7 @@
3041
3042 # bodge around for stubsftpserver not letting use connect
3043 # more than once
3044- _t = get_transport(self.get_url())
3045+ _t = transport.get_transport(self.get_url())
3046
3047 os.mkdir('local')
3048 t_local = self.make_branch_and_tree('local')
3049@@ -257,7 +257,7 @@
3050 original_umask = os.umask(umask)
3051
3052 try:
3053- t = get_transport(self.get_url())
3054+ t = transport.get_transport(self.get_url())
3055 # Direct access should be masked by umask
3056 t._sftp_open_exclusive('a', mode=0666).write('foo\n')
3057 self.assertTransportMode(t, 'a', 0666 &~umask)
3058
3059=== modified file 'bzrlib/tests/test_reconcile.py'
3060--- bzrlib/tests/test_reconcile.py 2009-03-23 14:59:43 +0000
3061+++ bzrlib/tests/test_reconcile.py 2010-06-29 17:48:31 +0000
3062@@ -1,4 +1,4 @@
3063-# Copyright (C) 2006 Canonical Ltd
3064+# Copyright (C) 2006, 2008, 2009, 2010 Canonical Ltd
3065 #
3066 # This program is free software; you can redistribute it and/or modify
3067 # it under the terms of the GNU General Public License as published by
3068@@ -17,15 +17,18 @@
3069 """Tests for reconiliation behaviour that is repository independent."""
3070
3071
3072-from bzrlib import bzrdir, errors, tests
3073+from bzrlib import (
3074+ bzrdir,
3075+ errors,
3076+ tests,
3077+ )
3078 from bzrlib.reconcile import reconcile, Reconciler
3079 from bzrlib.revision import Revision
3080-from bzrlib.tests.per_repository import TestCaseWithRepository
3081-from bzrlib.transport import get_transport
3082+from bzrlib.tests import per_repository
3083 from bzrlib.workingtree import WorkingTree
3084
3085
3086-class TestWorksWithSharedRepositories(TestCaseWithRepository):
3087+class TestWorksWithSharedRepositories(per_repository.TestCaseWithRepository):
3088
3089 def test_reweave_empty(self):
3090 # we want a repo capable format
3091
3092=== modified file 'bzrlib/tests/test_remote.py'
3093--- bzrlib/tests/test_remote.py 2010-05-20 18:23:17 +0000
3094+++ bzrlib/tests/test_remote.py 2010-06-29 17:48:31 +0000
3095@@ -38,6 +38,7 @@
3096 remote,
3097 repository,
3098 tests,
3099+ transport,
3100 treebuilder,
3101 urlutils,
3102 versionedfile,
3103@@ -63,7 +64,6 @@
3104 multiply_tests,
3105 test_server,
3106 )
3107-from bzrlib.transport import get_transport
3108 from bzrlib.transport.memory import MemoryTransport
3109 from bzrlib.transport.remote import (
3110 RemoteTransport,
3111@@ -359,8 +359,8 @@
3112 a given client_base and transport_base.
3113 """
3114 client_medium = medium.SmartClientMedium(client_base)
3115- transport = get_transport(transport_base)
3116- result = client_medium.remote_path_from_transport(transport)
3117+ t = transport.get_transport(transport_base)
3118+ result = client_medium.remote_path_from_transport(t)
3119 self.assertEqual(expected, result)
3120
3121 def test_remote_path_from_transport(self):
3122@@ -377,7 +377,7 @@
3123 a given transport_base and relpath of that transport. (Note that
3124 HttpTransportBase is a subclass of SmartClientMedium)
3125 """
3126- base_transport = get_transport(transport_base)
3127+ base_transport = transport.get_transport(transport_base)
3128 client_medium = base_transport.get_smart_medium()
3129 cloned_transport = base_transport.clone(relpath)
3130 result = client_medium.remote_path_from_transport(cloned_transport)
3131
3132=== modified file 'bzrlib/tests/test_selftest.py'
3133--- bzrlib/tests/test_selftest.py 2010-05-14 09:48:51 +0000
3134+++ bzrlib/tests/test_selftest.py 2010-06-29 17:48:31 +0000
3135@@ -622,7 +622,6 @@
3136 """Tests for the convenience functions TestCaseWithTransport introduces."""
3137
3138 def test_get_readonly_url_none(self):
3139- from bzrlib.transport import get_transport
3140 from bzrlib.transport.readonly import ReadonlyTransportDecorator
3141 self.vfs_transport_factory = memory.MemoryServer
3142 self.transport_readonly_server = None
3143@@ -630,15 +629,14 @@
3144 # for the server
3145 url = self.get_readonly_url()
3146 url2 = self.get_readonly_url('foo/bar')
3147- t = get_transport(url)
3148- t2 = get_transport(url2)
3149+ t = transport.get_transport(url)
3150+ t2 = transport.get_transport(url2)
3151 self.failUnless(isinstance(t, ReadonlyTransportDecorator))
3152 self.failUnless(isinstance(t2, ReadonlyTransportDecorator))
3153 self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
3154
3155 def test_get_readonly_url_http(self):
3156 from bzrlib.tests.http_server import HttpServer
3157- from bzrlib.transport import get_transport
3158 from bzrlib.transport.http import HttpTransportBase
3159 self.transport_server = test_server.LocalURLServer
3160 self.transport_readonly_server = HttpServer
3161@@ -646,8 +644,8 @@
3162 url = self.get_readonly_url()
3163 url2 = self.get_readonly_url('foo/bar')
3164 # the transport returned may be any HttpTransportBase subclass
3165- t = get_transport(url)
3166- t2 = get_transport(url2)
3167+ t = transport.get_transport(url)
3168+ t2 = transport.get_transport(url2)
3169 self.failUnless(isinstance(t, HttpTransportBase))
3170 self.failUnless(isinstance(t2, HttpTransportBase))
3171 self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
3172@@ -691,8 +689,7 @@
3173 class TestChrootedTest(tests.ChrootedTestCase):
3174
3175 def test_root_is_root(self):
3176- from bzrlib.transport import get_transport
3177- t = get_transport(self.get_readonly_url())
3178+ t = transport.get_transport(self.get_readonly_url())
3179 url = t.base
3180 self.assertEqual(url, t.clone('..').base)
3181
3182
3183=== modified file 'bzrlib/tests/test_sftp_transport.py'
3184--- bzrlib/tests/test_sftp_transport.py 2010-02-23 07:43:11 +0000
3185+++ bzrlib/tests/test_sftp_transport.py 2010-06-29 17:48:31 +0000
3186@@ -41,7 +41,6 @@
3187 TestSkipped,
3188 )
3189 from bzrlib.tests.http_server import HttpServer
3190-from bzrlib.transport import get_transport
3191 import bzrlib.transport.http
3192
3193 if features.paramiko.available():
3194@@ -190,7 +189,7 @@
3195 server = stub_sftp.SFTPSiblingAbsoluteServer()
3196 server.start_server()
3197 try:
3198- transport = get_transport(server.get_url())
3199+ transport = _mod_transport.get_transport(server.get_url())
3200 self.assertFalse(transport.abspath('/').endswith('/~/'))
3201 self.assertTrue(transport.abspath('/').endswith('/'))
3202 del transport
3203@@ -313,7 +312,7 @@
3204 """Test that a real connection attempt raises the right error"""
3205 from bzrlib.transport import ssh
3206 self.set_vendor(ssh.ParamikoVendor())
3207- t = bzrlib.transport.get_transport(self.bogus_url)
3208+ t = _mod_transport.get_transport(self.bogus_url)
3209 self.assertRaises(errors.ConnectionError, t.get, 'foobar')
3210
3211 def test_bad_connection_ssh(self):
3212@@ -324,7 +323,7 @@
3213 # However, 'ssh' will create stipple on the output, so instead
3214 # I'm using run_bzr_subprocess, and parsing the output
3215 # try:
3216- # t = bzrlib.transport.get_transport(self.bogus_url)
3217+ # t = _mod_transport.get_transport(self.bogus_url)
3218 # except errors.ConnectionError:
3219 # # Correct error
3220 # pass
3221@@ -511,7 +510,7 @@
3222 conf._get_config().update(
3223 {'sftptest': {'scheme': 'ssh', 'port': port, 'user': 'bar'}})
3224 conf._save()
3225- t = get_transport('sftp://localhost:%d' % port)
3226+ t = _mod_transport.get_transport('sftp://localhost:%d' % port)
3227 # force a connection to be performed.
3228 t.has('foo')
3229 return t
3230
3231=== modified file 'bzrlib/tests/test_smart_request.py'
3232--- bzrlib/tests/test_smart_request.py 2009-07-27 02:11:25 +0000
3233+++ bzrlib/tests/test_smart_request.py 2010-06-29 17:48:31 +0000
3234@@ -1,4 +1,4 @@
3235-# Copyright (C) 2009 Canonical Ltd
3236+# Copyright (C) 2009, 2010 Canonical Ltd
3237 #
3238 # This program is free software; you can redistribute it and/or modify
3239 # it under the terms of the GNU General Public License as published by
3240@@ -18,11 +18,13 @@
3241
3242 import threading
3243
3244-from bzrlib import errors
3245+from bzrlib import (
3246+ errors,
3247+ transport,
3248+ )
3249 from bzrlib.bzrdir import BzrDir
3250 from bzrlib.smart import request
3251 from bzrlib.tests import TestCase, TestCaseWithMemoryTransport
3252-from bzrlib.transport import get_transport
3253
3254
3255 class NoBodyRequest(request.SmartServerRequest):
3256@@ -34,7 +36,7 @@
3257
3258 class DoErrorRequest(request.SmartServerRequest):
3259 """A request that raises an error from self.do()."""
3260-
3261+
3262 def do(self):
3263 raise errors.NoSuchFile('xyzzy')
3264
3265@@ -172,7 +174,7 @@
3266
3267
3268 class TestRequestJail(TestCaseWithMemoryTransport):
3269-
3270+
3271 def test_jail(self):
3272 transport = self.get_transport('blah')
3273 req = request.SmartServerRequest(transport)
3274@@ -203,8 +205,8 @@
3275 # A parent is not allowed
3276 self.assertRaises(errors.JailBreak, _pre_open_hook, t.clone('..'))
3277 # A completely unrelated transport is not allowed
3278- self.assertRaises(
3279- errors.JailBreak, _pre_open_hook, get_transport('http://host/'))
3280+ self.assertRaises(errors.JailBreak, _pre_open_hook,
3281+ transport.get_transport('http://host/'))
3282
3283 def test_open_bzrdir_in_non_main_thread(self):
3284 """Opening a bzrdir in a non-main thread should work ok.
3285
3286=== modified file 'bzrlib/tests/test_transport_log.py'
3287--- bzrlib/tests/test_transport_log.py 2010-02-17 17:11:16 +0000
3288+++ bzrlib/tests/test_transport_log.py 2010-06-29 17:48:31 +0000
3289@@ -20,10 +20,9 @@
3290
3291 import types
3292
3293-
3294+from bzrlib import transport
3295 from bzrlib.tests import TestCaseWithMemoryTransport
3296 from bzrlib.trace import mutter
3297-from bzrlib.transport import get_transport
3298 from bzrlib.transport.log import TransportLogDecorator
3299
3300
3301@@ -31,7 +30,8 @@
3302
3303 def test_log_transport(self):
3304 base_transport = self.get_transport('')
3305- logging_transport = get_transport('log+' + base_transport.base)
3306+ logging_transport = transport.get_transport(
3307+ 'log+' + base_transport.base)
3308
3309 # operations such as mkdir are logged
3310 mutter('where are you?')
3311
3312=== modified file 'bzrlib/tests/test_upgrade.py'
3313--- bzrlib/tests/test_upgrade.py 2010-02-15 10:46:49 +0000
3314+++ bzrlib/tests/test_upgrade.py 2010-06-29 17:48:31 +0000
3315@@ -31,13 +31,13 @@
3316 bzrdir,
3317 progress,
3318 repository,
3319+ transport,
3320 workingtree,
3321 workingtree_4,
3322 )
3323 import bzrlib.branch
3324 from bzrlib.branch import Branch
3325 from bzrlib.tests import TestCaseWithTransport
3326-from bzrlib.transport import get_transport
3327 from bzrlib.upgrade import upgrade
3328
3329
3330@@ -80,27 +80,27 @@
3331 rt.unlock()
3332 # check a backup was made:
3333 backup_dir = 'backup.bzr.~1~'
3334- transport = get_transport(b.base)
3335- transport.stat(backup_dir)
3336- transport.stat(backup_dir + '/README')
3337- transport.stat(backup_dir + '/branch-format')
3338- transport.stat(backup_dir + '/revision-history')
3339- transport.stat(backup_dir + '/merged-patches')
3340- transport.stat(backup_dir + '/pending-merged-patches')
3341- transport.stat(backup_dir + '/pending-merges')
3342- transport.stat(backup_dir + '/branch-name')
3343- transport.stat(backup_dir + '/branch-lock')
3344- transport.stat(backup_dir + '/inventory')
3345- transport.stat(backup_dir + '/stat-cache')
3346- transport.stat(backup_dir + '/text-store')
3347- transport.stat(backup_dir + '/text-store/foo-20051004035611-1591048e9dc7c2d4.gz')
3348- transport.stat(backup_dir + '/text-store/foo-20051004035756-4081373d897c3453.gz')
3349- transport.stat(backup_dir + '/inventory-store/')
3350- transport.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
3351- transport.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
3352- transport.stat(backup_dir + '/revision-store/')
3353- transport.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
3354- transport.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
3355+ t = transport.get_transport(b.base)
3356+ t.stat(backup_dir)
3357+ t.stat(backup_dir + '/README')
3358+ t.stat(backup_dir + '/branch-format')
3359+ t.stat(backup_dir + '/revision-history')
3360+ t.stat(backup_dir + '/merged-patches')
3361+ t.stat(backup_dir + '/pending-merged-patches')
3362+ t.stat(backup_dir + '/pending-merges')
3363+ t.stat(backup_dir + '/branch-name')
3364+ t.stat(backup_dir + '/branch-lock')
3365+ t.stat(backup_dir + '/inventory')
3366+ t.stat(backup_dir + '/stat-cache')
3367+ t.stat(backup_dir + '/text-store')
3368+ t.stat(backup_dir + '/text-store/foo-20051004035611-1591048e9dc7c2d4.gz')
3369+ t.stat(backup_dir + '/text-store/foo-20051004035756-4081373d897c3453.gz')
3370+ t.stat(backup_dir + '/inventory-store/')
3371+ t.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
3372+ t.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
3373+ t.stat(backup_dir + '/revision-store/')
3374+ t.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
3375+ t.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
3376
3377 def test_upgrade_with_ghosts(self):
3378 """Upgrade v0.0.4 tree containing ghost references.
3379@@ -153,12 +153,12 @@
3380 # such a branch to metadir must not setup a working tree.
3381 self.build_tree_contents(_upgrade1_template)
3382 upgrade('.', bzrdir.BzrDirFormat6())
3383- transport = get_transport('.')
3384- transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
3385- self.assertFalse(transport.has('.bzr/stat-cache'))
3386+ t = transport.get_transport('.')
3387+ t.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
3388+ self.assertFalse(t.has('.bzr/stat-cache'))
3389 # XXX: upgrade fails if a backup.bzr is already present
3390 # -- David Allouche 2006-08-11
3391- transport.delete_tree('backup.bzr.~1~')
3392+ t.delete_tree('backup.bzr.~1~')
3393 # At this point, we have a format6 branch without checkout files.
3394 upgrade('.', bzrdir.BzrDirMetaFormat1())
3395 # The upgrade should not have set up a working tree.
3396
3397=== modified file 'bzrlib/tests/test_workingtree.py'
3398--- bzrlib/tests/test_workingtree.py 2010-04-23 08:51:52 +0000
3399+++ bzrlib/tests/test_workingtree.py 2010-06-29 17:48:31 +0000
3400@@ -22,6 +22,7 @@
3401 bzrdir,
3402 conflicts,
3403 errors,
3404+ transport,
3405 workingtree,
3406 )
3407 from bzrlib.branch import Branch
3408@@ -29,7 +30,6 @@
3409 from bzrlib.lockdir import LockDir
3410 from bzrlib.mutabletree import needs_tree_write_lock
3411 from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
3412-from bzrlib.transport import get_transport
3413 from bzrlib.workingtree import (
3414 TreeEntry,
3415 TreeDirectory,
3416@@ -138,7 +138,7 @@
3417 dir.create_repository()
3418 dir.create_branch()
3419 format.initialize(dir)
3420- t = get_transport(url)
3421+ t = transport.get_transport(url)
3422 found_format = workingtree.WorkingTreeFormat.find_format(dir)
3423 self.failUnless(isinstance(found_format, format.__class__))
3424 check_format(workingtree.WorkingTreeFormat3(), "bar")
3425
3426=== modified file 'bzrlib/textmerge.py'
3427--- bzrlib/textmerge.py 2010-06-04 03:09:35 +0000
3428+++ bzrlib/textmerge.py 2010-06-29 17:48:31 +0000
3429@@ -1,4 +1,4 @@
3430-# Copyright (C) 2005, 2006 Canonical Ltd
3431+# Copyright (C) 2006, 2009, 2010 Canonical Ltd
3432 #
3433 # This program is free software; you can redistribute it and/or modify
3434 # it under the terms of the GNU General Public License as published by
3435
3436=== modified file 'bzrlib/transport/decorator.py'
3437--- bzrlib/transport/decorator.py 2010-02-23 07:43:11 +0000
3438+++ bzrlib/transport/decorator.py 2010-06-29 17:48:31 +0000
3439@@ -20,10 +20,10 @@
3440 stub functions to allow other decorators to be written easily.
3441 """
3442
3443-from bzrlib.transport import get_transport, Transport, Server
3444-
3445-
3446-class TransportDecorator(Transport):
3447+from bzrlib import transport
3448+
3449+
3450+class TransportDecorator(transport.Transport):
3451 """A no-change decorator for Transports.
3452
3453 Subclasses of this are new transports that are based on an
3454@@ -50,7 +50,7 @@
3455 (url, prefix))
3456 not_decorated_url = url[len(prefix):]
3457 if _decorated is None:
3458- self._decorated = get_transport(not_decorated_url)
3459+ self._decorated = transport.get_transport(not_decorated_url)
3460 else:
3461 self._decorated = _decorated
3462 super(TransportDecorator, self).__init__(prefix + self._decorated.base)
3463
3464=== modified file 'bzrlib/transport/remote.py'
3465--- bzrlib/transport/remote.py 2010-06-16 05:47:02 +0000
3466+++ bzrlib/transport/remote.py 2010-06-29 17:48:31 +0000
3467@@ -1,4 +1,4 @@
3468-# Copyright (C) 2006 Canonical Ltd
3469+# Copyright (C) 2006-2010 Canonical Ltd
3470 #
3471 # This program is free software; you can redistribute it and/or modify
3472 # it under the terms of the GNU General Public License as published by
3473
3474=== modified file 'bzrlib/workingtree.py'
3475--- bzrlib/workingtree.py 2010-05-25 17:27:52 +0000
3476+++ bzrlib/workingtree.py 2010-06-29 17:48:31 +0000
3477@@ -61,13 +61,12 @@
3478 revisiontree,
3479 trace,
3480 transform,
3481+ transport,
3482 ui,
3483 views,
3484 xml5,
3485 xml7,
3486 )
3487-import bzrlib.branch
3488-from bzrlib.transport import get_transport
3489 from bzrlib.workingtree_4 import (
3490 WorkingTreeFormat4,
3491 WorkingTreeFormat5,
3492@@ -369,10 +368,10 @@
3493 return True, None
3494 else:
3495 return True, tree
3496- transport = get_transport(location)
3497- iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,
3498+ t = transport.get_transport(location)
3499+ iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
3500 list_current=list_current)
3501- return [t for t in iterator if t is not None]
3502+ return [tr for tr in iterator if tr is not None]
3503
3504 # should be deprecated - this is slow and in any case treating them as a
3505 # container is (we now know) bad style -- mbp 20070302