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