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

Proposed by Vincent Ladeuil
Status: Superseded
Proposed branch: lp:~vila/bzr/cleanup
Merge into: lp:bzr
Diff against target: 3473 lines (+645/-610)
70 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 (+17/-30)
bzrlib/plugins/launchpad/account.py (+7/-4)
bzrlib/plugins/launchpad/test_lp_directory.py (+3/-3)
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_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
bzr-core Pending
Review via email: mp+28306@code.launchpad.net

This proposal has been superseded by a proposal from 2010-06-23.

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 :

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

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