bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
1 |
# Copyright (C) 2006, 2007 Canonical Ltd
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
1752.2.39
by Martin Pool
[broken] implement upgrade apis on remote bzrdirs |
17 |
# TODO: At some point, handle upgrades by just passing the whole request
|
18 |
# across to run on the server.
|
|
19 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
20 |
from cStringIO import StringIO |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
21 |
|
|
2490.2.5
by Aaron Bentley
Use GraphWalker.unique_ancestor to determine merge base |
22 |
from bzrlib import ( |
23 |
branch, |
|
24 |
errors, |
|
25 |
lockdir, |
|
26 |
repository, |
|
27 |
)
|
|
|
2477.1.5
by Martin Pool
More cleanups of Branch.push to get the right behaviour with RemoteBranches |
28 |
from bzrlib.branch import Branch, BranchReferenceFormat |
|
2018.5.174
by Andrew Bennetts
Various nits discovered by pyflakes. |
29 |
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat |
|
2018.14.2
by Andrew Bennetts
All but one repository_implementation tests for RemoteRepository passing. |
30 |
from bzrlib.config import BranchConfig, TreeConfig |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
31 |
from bzrlib.decorators import needs_read_lock, needs_write_lock |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
32 |
from bzrlib.errors import NoSuchRevision |
|
2018.5.127
by Andrew Bennetts
Fix most of the lockable_files tests for RemoteBranchLockableFiles. |
33 |
from bzrlib.lockable_files import LockableFiles |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
34 |
from bzrlib.revision import NULL_REVISION |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
35 |
from bzrlib.smart import client, vfs |
|
2018.18.20
by Martin Pool
Route branch operations through remote copy_content_into |
36 |
from bzrlib.trace import note |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
37 |
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
38 |
# Note: RemoteBzrDirFormat is in bzrdir.py
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
39 |
|
40 |
class RemoteBzrDir(BzrDir): |
|
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
41 |
"""Control directory on a remote server, accessed via bzr:// or similar.""" |
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
42 |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
43 |
def __init__(self, transport, _client=None): |
44 |
"""Construct a RemoteBzrDir. |
|
45 |
||
46 |
:param _client: Private parameter for testing. Disables probing and the
|
|
47 |
use of a real bzrdir.
|
|
48 |
"""
|
|
|
1752.2.39
by Martin Pool
[broken] implement upgrade apis on remote bzrdirs |
49 |
BzrDir.__init__(self, transport, RemoteBzrDirFormat()) |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
50 |
# this object holds a delegated bzrdir that uses file-level operations
|
51 |
# to talk to the other side
|
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
52 |
self._real_bzrdir = None |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
53 |
|
54 |
if _client is None: |
|
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
55 |
self._shared_medium = transport.get_shared_medium() |
56 |
self._client = client._SmartClient(self._shared_medium) |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
57 |
else: |
58 |
self._client = _client |
|
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
59 |
self._shared_medium = None |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
60 |
return
|
61 |
||
62 |
path = self._path_for_remote_call(self._client) |
|
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
63 |
response = self._client.call('BzrDir.open', path) |
64 |
if response not in [('yes',), ('no',)]: |
|
65 |
raise errors.UnexpectedSmartServerResponse(response) |
|
|
2018.5.26
by Andrew Bennetts
Extract a simple SmartClient class from RemoteTransport, and a hack to avoid VFS operations when probing for a bzrdir over a smart transport. |
66 |
if response == ('no',): |
67 |
raise errors.NotBranchError(path=transport.base) |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
68 |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
69 |
def _ensure_real(self): |
70 |
"""Ensure that there is a _real_bzrdir set. |
|
71 |
||
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
72 |
Used before calls to self._real_bzrdir.
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
73 |
"""
|
74 |
if not self._real_bzrdir: |
|
|
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
75 |
self._real_bzrdir = BzrDir.open_from_transport( |
76 |
self.root_transport, _server_formats=False) |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
77 |
|
|
1752.2.39
by Martin Pool
[broken] implement upgrade apis on remote bzrdirs |
78 |
def create_repository(self, shared=False): |
|
2018.5.162
by Andrew Bennetts
Add some missing _ensure_real calls, and a missing import. |
79 |
self._ensure_real() |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
80 |
self._real_bzrdir.create_repository(shared=shared) |
81 |
return self.open_repository() |
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
82 |
|
83 |
def create_branch(self): |
|
|
2018.5.162
by Andrew Bennetts
Add some missing _ensure_real calls, and a missing import. |
84 |
self._ensure_real() |
|
1752.2.72
by Andrew Bennetts
Make Remote* classes in remote.py more consistent and remove some dead code. |
85 |
real_branch = self._real_bzrdir.create_branch() |
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
86 |
return RemoteBranch(self, self.find_repository(), real_branch) |
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
87 |
|
88 |
def create_workingtree(self, revision_id=None): |
|
|
2018.5.174
by Andrew Bennetts
Various nits discovered by pyflakes. |
89 |
raise errors.NotLocalUrl(self.transport.base) |
|
1752.2.39
by Martin Pool
[broken] implement upgrade apis on remote bzrdirs |
90 |
|
|
2018.5.124
by Robert Collins
Fix test_format_initialize_find_open by delegating Branch formt lookup to the BzrDir, where it should have stayed from the start. |
91 |
def find_branch_format(self): |
92 |
"""Find the branch 'format' for this bzrdir. |
|
93 |
||
94 |
This might be a synthetic object for e.g. RemoteBranch and SVN.
|
|
95 |
"""
|
|
96 |
b = self.open_branch() |
|
97 |
return b._format |
|
98 |
||
|
2018.5.132
by Robert Collins
Make all BzrDir implementation tests pass on RemoteBzrDir - fix some things, and remove the incomplete_with_basis tests as cruft. |
99 |
def get_branch_reference(self): |
100 |
"""See BzrDir.get_branch_reference().""" |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
101 |
path = self._path_for_remote_call(self._client) |
102 |
response = self._client.call('BzrDir.open_branch', path) |
|
103 |
if response[0] == 'ok': |
|
104 |
if response[1] == '': |
|
105 |
# branch at this location.
|
|
|
2018.5.132
by Robert Collins
Make all BzrDir implementation tests pass on RemoteBzrDir - fix some things, and remove the incomplete_with_basis tests as cruft. |
106 |
return None |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
107 |
else: |
108 |
# a branch reference, use the existing BranchReference logic.
|
|
|
2018.5.132
by Robert Collins
Make all BzrDir implementation tests pass on RemoteBzrDir - fix some things, and remove the incomplete_with_basis tests as cruft. |
109 |
return response[1] |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
110 |
elif response == ('nobranch',): |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
111 |
raise errors.NotBranchError(path=self.root_transport.base) |
112 |
else: |
|
|
2555.1.1
by Martin Pool
Remove use of 'assert False' to raise an exception unconditionally |
113 |
raise errors.UnexpectedSmartServerResponse(response) |
|
2018.5.132
by Robert Collins
Make all BzrDir implementation tests pass on RemoteBzrDir - fix some things, and remove the incomplete_with_basis tests as cruft. |
114 |
|
115 |
def open_branch(self, _unsupported=False): |
|
116 |
assert _unsupported == False, 'unsupported flag support not implemented yet.' |
|
117 |
reference_url = self.get_branch_reference() |
|
118 |
if reference_url is None: |
|
119 |
# branch at this location.
|
|
120 |
return RemoteBranch(self, self.find_repository()) |
|
121 |
else: |
|
122 |
# a branch reference, use the existing BranchReference logic.
|
|
123 |
format = BranchReferenceFormat() |
|
124 |
return format.open(self, _found=True, location=reference_url) |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
125 |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
126 |
def open_repository(self): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
127 |
path = self._path_for_remote_call(self._client) |
128 |
response = self._client.call('BzrDir.find_repository', path) |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
129 |
assert response[0] in ('ok', 'norepository'), \ |
|
2018.5.52
by Wouter van Heyst
Provide more information when encountering unexpected responses from a smart |
130 |
'unexpected response code %s' % (response,) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
131 |
if response[0] == 'norepository': |
132 |
raise errors.NoRepositoryPresent(self) |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
133 |
assert len(response) == 4, 'incorrect response length %s' % (response,) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
134 |
if response[1] == '': |
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
135 |
format = RemoteRepositoryFormat() |
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
136 |
format.rich_root_data = (response[2] == 'yes') |
137 |
format.supports_tree_reference = (response[3] == 'yes') |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
138 |
return RemoteRepository(self, format) |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
139 |
else: |
140 |
raise errors.NoRepositoryPresent(self) |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
141 |
|
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
142 |
def open_workingtree(self, recommend_upgrade=True): |
|
2445.1.1
by Andrew Bennetts
Make RemoteBzrDir.open_workingtree raise NoWorkingTree rather than NotLocalUrl |
143 |
self._ensure_real() |
144 |
if self._real_bzrdir.has_workingtree(): |
|
145 |
raise errors.NotLocalUrl(self.root_transport) |
|
146 |
else: |
|
147 |
raise errors.NoWorkingTree(self.root_transport.base) |
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
148 |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
149 |
def _path_for_remote_call(self, client): |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
150 |
"""Return the path to be used for this bzrdir in a remote call.""" |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
151 |
return client.remote_path_from_transport(self.root_transport) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
152 |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
153 |
def get_branch_transport(self, branch_format): |
|
2018.5.162
by Andrew Bennetts
Add some missing _ensure_real calls, and a missing import. |
154 |
self._ensure_real() |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
155 |
return self._real_bzrdir.get_branch_transport(branch_format) |
156 |
||
|
1752.2.43
by Andrew Bennetts
Fix get_{branch,repository,workingtree}_transport. |
157 |
def get_repository_transport(self, repository_format): |
|
2018.5.162
by Andrew Bennetts
Add some missing _ensure_real calls, and a missing import. |
158 |
self._ensure_real() |
|
1752.2.43
by Andrew Bennetts
Fix get_{branch,repository,workingtree}_transport. |
159 |
return self._real_bzrdir.get_repository_transport(repository_format) |
160 |
||
161 |
def get_workingtree_transport(self, workingtree_format): |
|
|
2018.5.162
by Andrew Bennetts
Add some missing _ensure_real calls, and a missing import. |
162 |
self._ensure_real() |
|
1752.2.43
by Andrew Bennetts
Fix get_{branch,repository,workingtree}_transport. |
163 |
return self._real_bzrdir.get_workingtree_transport(workingtree_format) |
164 |
||
|
1752.2.39
by Martin Pool
[broken] implement upgrade apis on remote bzrdirs |
165 |
def can_convert_format(self): |
166 |
"""Upgrading of remote bzrdirs is not supported yet.""" |
|
167 |
return False |
|
168 |
||
169 |
def needs_format_conversion(self, format=None): |
|
170 |
"""Upgrading of remote bzrdirs is not supported yet.""" |
|
171 |
return False |
|
172 |
||
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
173 |
def clone(self, url, revision_id=None, force_new_repo=False): |
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
174 |
self._ensure_real() |
175 |
return self._real_bzrdir.clone(url, revision_id=revision_id, |
|
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
176 |
force_new_repo=force_new_repo) |
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
177 |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
178 |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
179 |
class RemoteRepositoryFormat(repository.RepositoryFormat): |
|
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
180 |
"""Format for repositories accessed over a _SmartClient. |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
181 |
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
182 |
Instances of this repository are represented by RemoteRepository
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
183 |
instances.
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
184 |
|
185 |
The RemoteRepositoryFormat is parameterised during construction
|
|
186 |
to reflect the capabilities of the real, remote format. Specifically
|
|
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
187 |
the attributes rich_root_data and supports_tree_reference are set
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
188 |
on a per instance basis, and are not set (and should not be) at
|
189 |
the class level.
|
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
190 |
"""
|
191 |
||
192 |
_matchingbzrdir = RemoteBzrDirFormat |
|
193 |
||
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
194 |
def initialize(self, a_bzrdir, shared=False): |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
195 |
assert isinstance(a_bzrdir, RemoteBzrDir), \ |
196 |
'%r is not a RemoteBzrDir' % (a_bzrdir,) |
|
|
1752.2.72
by Andrew Bennetts
Make Remote* classes in remote.py more consistent and remove some dead code. |
197 |
return a_bzrdir.create_repository(shared=shared) |
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
198 |
|
199 |
def open(self, a_bzrdir): |
|
|
1752.2.72
by Andrew Bennetts
Make Remote* classes in remote.py more consistent and remove some dead code. |
200 |
assert isinstance(a_bzrdir, RemoteBzrDir) |
201 |
return a_bzrdir.open_repository() |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
202 |
|
203 |
def get_format_description(self): |
|
204 |
return 'bzr remote repository' |
|
205 |
||
206 |
def __eq__(self, other): |
|
|
1752.2.87
by Andrew Bennetts
Make tests pass. |
207 |
return self.__class__ == other.__class__ |
208 |
||
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
209 |
def check_conversion_target(self, target_format): |
210 |
if self.rich_root_data and not target_format.rich_root_data: |
|
211 |
raise errors.BadConversionTarget( |
|
212 |
'Does not support rich root data.', target_format) |
|
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
213 |
if (self.supports_tree_reference and |
214 |
not getattr(target_format, 'supports_tree_reference', False)): |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
215 |
raise errors.BadConversionTarget( |
216 |
'Does not support nested trees', target_format) |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
217 |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
218 |
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
219 |
class RemoteRepository(object): |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
220 |
"""Repository accessed over rpc. |
221 |
||
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
222 |
For the moment most operations are performed using local transport-backed
|
223 |
Repository objects.
|
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
224 |
"""
|
225 |
||
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
226 |
def __init__(self, remote_bzrdir, format, real_repository=None, _client=None): |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
227 |
"""Create a RemoteRepository instance. |
228 |
|
|
229 |
:param remote_bzrdir: The bzrdir hosting this repository.
|
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
230 |
:param format: The RemoteFormat object to use.
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
231 |
:param real_repository: If not None, a local implementation of the
|
232 |
repository logic for the repository, usually accessing the data
|
|
233 |
via the VFS.
|
|
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
234 |
:param _client: Private testing parameter - override the smart client
|
235 |
to be used by the repository.
|
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
236 |
"""
|
237 |
if real_repository: |
|
|
2018.5.36
by Andrew Bennetts
Fix typo, and clean up some ununsed import warnings from pyflakes at the same time. |
238 |
self._real_repository = real_repository |
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
239 |
else: |
240 |
self._real_repository = None |
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
241 |
self.bzrdir = remote_bzrdir |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
242 |
if _client is None: |
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
243 |
self._client = client._SmartClient(self.bzrdir._shared_medium) |
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
244 |
else: |
245 |
self._client = _client |
|
|
2018.5.118
by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference. |
246 |
self._format = format |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
247 |
self._lock_mode = None |
248 |
self._lock_token = None |
|
249 |
self._lock_count = 0 |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
250 |
self._leave_lock = False |
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
251 |
|
|
2671.1.1
by Andrew Bennetts
Add support for comparing Repositories with == and != operators. |
252 |
def __eq__(self, other): |
253 |
return (self.__class__ == other.__class__ and |
|
|
2671.1.2
by Andrew Bennetts
Compare URLs in RemoteRepository.__eq__, rather than '_client' attributes. |
254 |
self.bzrdir.transport.base == other.bzrdir.transport.base) |
|
2671.1.1
by Andrew Bennetts
Add support for comparing Repositories with == and != operators. |
255 |
|
256 |
def __ne__(self, other): |
|
257 |
return not self == other |
|
258 |
||
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
259 |
def _ensure_real(self): |
260 |
"""Ensure that there is a _real_repository set. |
|
261 |
||
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
262 |
Used before calls to self._real_repository.
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
263 |
"""
|
264 |
if not self._real_repository: |
|
265 |
self.bzrdir._ensure_real() |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
266 |
#self._real_repository = self.bzrdir._real_bzrdir.open_repository()
|
267 |
self._set_real_repository(self.bzrdir._real_bzrdir.open_repository()) |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
268 |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
269 |
def get_revision_graph(self, revision_id=None): |
270 |
"""See Repository.get_revision_graph().""" |
|
271 |
if revision_id is None: |
|
272 |
revision_id = '' |
|
273 |
elif revision_id == NULL_REVISION: |
|
274 |
return {} |
|
275 |
||
276 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
277 |
assert type(revision_id) is str |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
278 |
response = self._client.call_expecting_body( |
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
279 |
'Repository.get_revision_graph', path, revision_id) |
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
280 |
if response[0][0] not in ['ok', 'nosuchrevision']: |
281 |
raise errors.UnexpectedSmartServerResponse(response[0]) |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
282 |
if response[0][0] == 'ok': |
283 |
coded = response[1].read_body_bytes() |
|
|
2018.5.105
by Andrew Bennetts
Implement revision_history caching for RemoteBranch. |
284 |
if coded == '': |
285 |
# no revisions in this repository!
|
|
286 |
return {} |
|
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
287 |
lines = coded.split('\n') |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
288 |
revision_graph = {} |
289 |
for line in lines: |
|
|
2625.8.1
by Robert Collins
LIBRARY API BREAKS: |
290 |
d = tuple(line.split()) |
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
291 |
revision_graph[d[0]] = d[1:] |
292 |
||
293 |
return revision_graph |
|
294 |
else: |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
295 |
response_body = response[1].read_body_bytes() |
296 |
assert response_body == '' |
|
|
2018.5.67
by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins) |
297 |
raise NoSuchRevision(self, revision_id) |
298 |
||
|
2018.5.40
by Robert Collins
Implement a remote Repository.has_revision method. |
299 |
def has_revision(self, revision_id): |
300 |
"""See Repository.has_revision().""" |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
301 |
if revision_id is None: |
302 |
# The null revision is always present.
|
|
303 |
return True |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
304 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
305 |
response = self._client.call('Repository.has_revision', path, revision_id) |
|
2018.5.158
by Andrew Bennetts
Return 'yes'/'no' rather than 'ok'/'no' from the Repository.has_revision smart command. |
306 |
assert response[0] in ('yes', 'no'), 'unexpected response code %s' % (response,) |
307 |
return response[0] == 'yes' |
|
|
2018.5.40
by Robert Collins
Implement a remote Repository.has_revision method. |
308 |
|
|
2490.2.21
by Aaron Bentley
Rename graph to deprecated_graph |
309 |
def get_graph(self, other_repository=None): |
310 |
"""Return the graph for this repository format""" |
|
311 |
return self._real_repository.get_graph(other_repository) |
|
|
2490.2.5
by Aaron Bentley
Use GraphWalker.unique_ancestor to determine merge base |
312 |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
313 |
def gather_stats(self, revid=None, committers=None): |
|
2018.5.62
by Robert Collins
Stub out RemoteRepository.gather_stats while its implemented in parallel. |
314 |
"""See Repository.gather_stats().""" |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
315 |
path = self.bzrdir._path_for_remote_call(self._client) |
316 |
if revid in (None, NULL_REVISION): |
|
317 |
fmt_revid = '' |
|
318 |
else: |
|
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
319 |
fmt_revid = revid |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
320 |
if committers is None or not committers: |
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
321 |
fmt_committers = 'no' |
322 |
else: |
|
323 |
fmt_committers = 'yes' |
|
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
324 |
response = self._client.call_expecting_body( |
325 |
'Repository.gather_stats', path, fmt_revid, fmt_committers) |
|
|
2018.10.3
by v.ladeuil+lp at free
more tests for gather_stats |
326 |
assert response[0][0] == 'ok', \ |
327 |
'unexpected response code %s' % (response[0],) |
|
328 |
||
329 |
body = response[1].read_body_bytes() |
|
330 |
result = {} |
|
331 |
for line in body.split('\n'): |
|
332 |
if not line: |
|
333 |
continue
|
|
334 |
key, val_text = line.split(':') |
|
335 |
if key in ('revisions', 'size', 'committers'): |
|
336 |
result[key] = int(val_text) |
|
337 |
elif key in ('firstrev', 'latestrev'): |
|
338 |
values = val_text.split(' ')[1:] |
|
339 |
result[key] = (float(values[0]), long(values[1])) |
|
340 |
||
341 |
return result |
|
|
2018.5.62
by Robert Collins
Stub out RemoteRepository.gather_stats while its implemented in parallel. |
342 |
|
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
343 |
def get_physical_lock_status(self): |
344 |
"""See Repository.get_physical_lock_status().""" |
|
345 |
return False |
|
346 |
||
|
2018.5.57
by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil). |
347 |
def is_shared(self): |
348 |
"""See Repository.is_shared().""" |
|
349 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
350 |
response = self._client.call('Repository.is_shared', path) |
|
351 |
assert response[0] in ('yes', 'no'), 'unexpected response code %s' % (response,) |
|
352 |
return response[0] == 'yes' |
|
353 |
||
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
354 |
def lock_read(self): |
355 |
# wrong eventually - want a local lock cache context
|
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
356 |
if not self._lock_mode: |
357 |
self._lock_mode = 'r' |
|
358 |
self._lock_count = 1 |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
359 |
if self._real_repository is not None: |
360 |
self._real_repository.lock_read() |
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
361 |
else: |
362 |
self._lock_count += 1 |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
363 |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
364 |
def _remote_lock_write(self, token): |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
365 |
path = self.bzrdir._path_for_remote_call(self._client) |
366 |
if token is None: |
|
367 |
token = '' |
|
368 |
response = self._client.call('Repository.lock_write', path, token) |
|
369 |
if response[0] == 'ok': |
|
370 |
ok, token = response |
|
371 |
return token |
|
372 |
elif response[0] == 'LockContention': |
|
373 |
raise errors.LockContention('(remote lock)') |
|
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
374 |
elif response[0] == 'UnlockableTransport': |
375 |
raise errors.UnlockableTransport(self.bzrdir.root_transport) |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
376 |
else: |
|
2555.1.1
by Martin Pool
Remove use of 'assert False' to raise an exception unconditionally |
377 |
raise errors.UnexpectedSmartServerResponse(response) |
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
378 |
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
379 |
def lock_write(self, token=None): |
380 |
if not self._lock_mode: |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
381 |
self._lock_token = self._remote_lock_write(token) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
382 |
assert self._lock_token, 'Remote server did not return a token!' |
383 |
if self._real_repository is not None: |
|
384 |
self._real_repository.lock_write(token=self._lock_token) |
|
385 |
if token is not None: |
|
386 |
self._leave_lock = True |
|
387 |
else: |
|
388 |
self._leave_lock = False |
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
389 |
self._lock_mode = 'w' |
390 |
self._lock_count = 1 |
|
391 |
elif self._lock_mode == 'r': |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
392 |
raise errors.ReadOnlyError(self) |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
393 |
else: |
394 |
self._lock_count += 1 |
|
395 |
return self._lock_token |
|
396 |
||
397 |
def leave_lock_in_place(self): |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
398 |
self._leave_lock = True |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
399 |
|
400 |
def dont_leave_lock_in_place(self): |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
401 |
self._leave_lock = False |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
402 |
|
403 |
def _set_real_repository(self, repository): |
|
404 |
"""Set the _real_repository for this repository. |
|
405 |
||
406 |
:param repository: The repository to fallback to for non-hpss
|
|
407 |
implemented operations.
|
|
408 |
"""
|
|
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
409 |
assert not isinstance(repository, RemoteRepository) |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
410 |
self._real_repository = repository |
411 |
if self._lock_mode == 'w': |
|
412 |
# if we are already locked, the real repository must be able to
|
|
413 |
# acquire the lock with our token.
|
|
414 |
self._real_repository.lock_write(self._lock_token) |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
415 |
elif self._lock_mode == 'r': |
416 |
self._real_repository.lock_read() |
|
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
417 |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
418 |
def _unlock(self, token): |
419 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
420 |
response = self._client.call('Repository.unlock', path, token) |
|
421 |
if response == ('ok',): |
|
422 |
return
|
|
423 |
elif response[0] == 'TokenMismatch': |
|
424 |
raise errors.TokenMismatch(token, '(remote token)') |
|
425 |
else: |
|
|
2555.1.1
by Martin Pool
Remove use of 'assert False' to raise an exception unconditionally |
426 |
raise errors.UnexpectedSmartServerResponse(response) |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
427 |
|
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
428 |
def unlock(self): |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
429 |
self._lock_count -= 1 |
430 |
if not self._lock_count: |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
431 |
mode = self._lock_mode |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
432 |
self._lock_mode = None |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
433 |
if self._real_repository is not None: |
434 |
self._real_repository.unlock() |
|
435 |
if mode != 'w': |
|
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
436 |
# Only write-locked repositories need to make a remote method
|
437 |
# call to perfom the unlock.
|
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
438 |
return
|
439 |
assert self._lock_token, 'Locked, but no token!' |
|
440 |
token = self._lock_token |
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
441 |
self._lock_token = None |
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
442 |
if not self._leave_lock: |
443 |
self._unlock(token) |
|
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
444 |
|
445 |
def break_lock(self): |
|
|
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
446 |
# should hand off to the network
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
447 |
self._ensure_real() |
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
448 |
return self._real_repository.break_lock() |
449 |
||
|
2018.18.8
by Ian Clatworthy
Tarball proxy code & tests |
450 |
def _get_tarball(self, compression): |
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
451 |
"""Return a TemporaryFile containing a repository tarball""" |
452 |
import tempfile |
|
|
2018.18.8
by Ian Clatworthy
Tarball proxy code & tests |
453 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
2018.18.14
by Martin Pool
merge hpss again; restore incorrectly removed RemoteRepository.break_lock |
454 |
response, protocol = self._client.call_expecting_body( |
455 |
'Repository.tarball', path, compression) |
|
|
2018.18.8
by Ian Clatworthy
Tarball proxy code & tests |
456 |
assert response[0] in ('ok', 'failure'), \ |
457 |
'unexpected response code %s' % (response,) |
|
458 |
if response[0] == 'ok': |
|
459 |
# Extract the tarball and return it
|
|
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
460 |
t = tempfile.NamedTemporaryFile() |
461 |
# TODO: rpc layer should read directly into it...
|
|
462 |
t.write(protocol.read_body_bytes()) |
|
463 |
t.seek(0) |
|
464 |
return t |
|
|
2018.18.8
by Ian Clatworthy
Tarball proxy code & tests |
465 |
else: |
466 |
raise errors.SmartServerError(error_code=response) |
|
467 |
||
|
2440.1.1
by Martin Pool
Add new Repository.sprout, |
468 |
def sprout(self, to_bzrdir, revision_id=None): |
469 |
# TODO: Option to control what format is created?
|
|
470 |
to_repo = to_bzrdir.create_repository() |
|
|
2018.18.24
by Martin Pool
Merge Repository.sprout refactoring, and make that use Repository.tarball |
471 |
self._copy_repository_tarball(to_repo, revision_id) |
|
2440.1.1
by Martin Pool
Add new Repository.sprout, |
472 |
return to_repo |
473 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
474 |
### These methods are just thin shims to the VFS object for now.
|
475 |
||
476 |
def revision_tree(self, revision_id): |
|
477 |
self._ensure_real() |
|
478 |
return self._real_repository.revision_tree(revision_id) |
|
479 |
||
|
2520.4.113
by Aaron Bentley
Avoid peeking at Repository._serializer |
480 |
def get_serializer_format(self): |
481 |
self._ensure_real() |
|
482 |
return self._real_repository.get_serializer_format() |
|
483 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
484 |
def get_commit_builder(self, branch, parents, config, timestamp=None, |
485 |
timezone=None, committer=None, revprops=None, |
|
486 |
revision_id=None): |
|
487 |
# FIXME: It ought to be possible to call this without immediately
|
|
488 |
# triggering _ensure_real. For now it's the easiest thing to do.
|
|
489 |
self._ensure_real() |
|
490 |
builder = self._real_repository.get_commit_builder(branch, parents, |
|
491 |
config, timestamp=timestamp, timezone=timezone, |
|
492 |
committer=committer, revprops=revprops, revision_id=revision_id) |
|
493 |
# Make the builder use this RemoteRepository rather than the real one.
|
|
494 |
builder.repository = self |
|
495 |
return builder |
|
496 |
||
497 |
@needs_write_lock
|
|
498 |
def add_inventory(self, revid, inv, parents): |
|
499 |
self._ensure_real() |
|
500 |
return self._real_repository.add_inventory(revid, inv, parents) |
|
501 |
||
502 |
@needs_write_lock
|
|
503 |
def add_revision(self, rev_id, rev, inv=None, config=None): |
|
504 |
self._ensure_real() |
|
505 |
return self._real_repository.add_revision( |
|
506 |
rev_id, rev, inv=inv, config=config) |
|
507 |
||
508 |
@needs_read_lock
|
|
509 |
def get_inventory(self, revision_id): |
|
510 |
self._ensure_real() |
|
511 |
return self._real_repository.get_inventory(revision_id) |
|
512 |
||
513 |
@needs_read_lock
|
|
514 |
def get_revision(self, revision_id): |
|
515 |
self._ensure_real() |
|
516 |
return self._real_repository.get_revision(revision_id) |
|
517 |
||
518 |
@property
|
|
519 |
def weave_store(self): |
|
520 |
self._ensure_real() |
|
521 |
return self._real_repository.weave_store |
|
522 |
||
523 |
def get_transaction(self): |
|
524 |
self._ensure_real() |
|
525 |
return self._real_repository.get_transaction() |
|
526 |
||
527 |
@needs_read_lock
|
|
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
528 |
def clone(self, a_bzrdir, revision_id=None): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
529 |
self._ensure_real() |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
530 |
return self._real_repository.clone(a_bzrdir, revision_id=revision_id) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
531 |
|
532 |
def make_working_trees(self): |
|
|
2018.5.120
by Robert Collins
The Repository API ``make_working_trees`` is now permitted to return |
533 |
"""RemoteRepositories never create working trees by default.""" |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
534 |
return False |
535 |
||
536 |
def fetch(self, source, revision_id=None, pb=None): |
|
537 |
self._ensure_real() |
|
538 |
return self._real_repository.fetch( |
|
539 |
source, revision_id=revision_id, pb=pb) |
|
540 |
||
|
2520.4.54
by Aaron Bentley
Hang a create_bundle method off repository |
541 |
def create_bundle(self, target, base, fileobj, format=None): |
542 |
self._ensure_real() |
|
543 |
self._real_repository.create_bundle(target, base, fileobj, format) |
|
544 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
545 |
@property
|
546 |
def control_weaves(self): |
|
547 |
self._ensure_real() |
|
548 |
return self._real_repository.control_weaves |
|
549 |
||
550 |
@needs_read_lock
|
|
|
2530.1.1
by Aaron Bentley
Make topological sorting optional for get_ancestry |
551 |
def get_ancestry(self, revision_id, topo_sorted=True): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
552 |
self._ensure_real() |
|
2530.1.1
by Aaron Bentley
Make topological sorting optional for get_ancestry |
553 |
return self._real_repository.get_ancestry(revision_id, topo_sorted) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
554 |
|
555 |
@needs_read_lock
|
|
556 |
def get_inventory_weave(self): |
|
557 |
self._ensure_real() |
|
558 |
return self._real_repository.get_inventory_weave() |
|
559 |
||
560 |
def fileids_altered_by_revision_ids(self, revision_ids): |
|
561 |
self._ensure_real() |
|
562 |
return self._real_repository.fileids_altered_by_revision_ids(revision_ids) |
|
563 |
||
564 |
@needs_read_lock
|
|
565 |
def get_signature_text(self, revision_id): |
|
566 |
self._ensure_real() |
|
567 |
return self._real_repository.get_signature_text(revision_id) |
|
568 |
||
569 |
@needs_read_lock
|
|
570 |
def get_revision_graph_with_ghosts(self, revision_ids=None): |
|
571 |
self._ensure_real() |
|
572 |
return self._real_repository.get_revision_graph_with_ghosts( |
|
573 |
revision_ids=revision_ids) |
|
574 |
||
575 |
@needs_read_lock
|
|
576 |
def get_inventory_xml(self, revision_id): |
|
577 |
self._ensure_real() |
|
578 |
return self._real_repository.get_inventory_xml(revision_id) |
|
579 |
||
580 |
def deserialise_inventory(self, revision_id, xml): |
|
581 |
self._ensure_real() |
|
582 |
return self._real_repository.deserialise_inventory(revision_id, xml) |
|
583 |
||
584 |
def reconcile(self, other=None, thorough=False): |
|
585 |
self._ensure_real() |
|
586 |
return self._real_repository.reconcile(other=other, thorough=thorough) |
|
587 |
||
588 |
def all_revision_ids(self): |
|
589 |
self._ensure_real() |
|
590 |
return self._real_repository.all_revision_ids() |
|
591 |
||
592 |
@needs_read_lock
|
|
593 |
def get_deltas_for_revisions(self, revisions): |
|
594 |
self._ensure_real() |
|
595 |
return self._real_repository.get_deltas_for_revisions(revisions) |
|
596 |
||
597 |
@needs_read_lock
|
|
598 |
def get_revision_delta(self, revision_id): |
|
599 |
self._ensure_real() |
|
600 |
return self._real_repository.get_revision_delta(revision_id) |
|
601 |
||
602 |
@needs_read_lock
|
|
603 |
def revision_trees(self, revision_ids): |
|
604 |
self._ensure_real() |
|
605 |
return self._real_repository.revision_trees(revision_ids) |
|
606 |
||
607 |
@needs_read_lock
|
|
608 |
def get_revision_reconcile(self, revision_id): |
|
609 |
self._ensure_real() |
|
610 |
return self._real_repository.get_revision_reconcile(revision_id) |
|
611 |
||
612 |
@needs_read_lock
|
|
613 |
def check(self, revision_ids): |
|
614 |
self._ensure_real() |
|
615 |
return self._real_repository.check(revision_ids) |
|
616 |
||
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
617 |
def copy_content_into(self, destination, revision_id=None): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
618 |
self._ensure_real() |
619 |
return self._real_repository.copy_content_into( |
|
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
620 |
destination, revision_id=revision_id) |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
621 |
|
|
2018.18.24
by Martin Pool
Merge Repository.sprout refactoring, and make that use Repository.tarball |
622 |
def _copy_repository_tarball(self, destination, revision_id=None): |
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
623 |
# get a tarball of the remote repository, and copy from that into the
|
624 |
# destination
|
|
625 |
from bzrlib import osutils |
|
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
626 |
import tarfile |
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
627 |
import tempfile |
|
2018.18.9
by Martin Pool
remote Repository.tarball builds a temporary directory and tars that |
628 |
from StringIO import StringIO |
|
2018.18.20
by Martin Pool
Route branch operations through remote copy_content_into |
629 |
# TODO: Maybe a progress bar while streaming the tarball?
|
630 |
note("Copying repository content as tarball...") |
|
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
631 |
tar_file = self._get_tarball('bz2') |
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
632 |
try: |
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
633 |
tar = tarfile.open('repository', fileobj=tar_file, |
634 |
mode='r|bz2') |
|
635 |
tmpdir = tempfile.mkdtemp() |
|
636 |
try: |
|
637 |
_extract_tar(tar, tmpdir) |
|
638 |
tmp_bzrdir = BzrDir.open(tmpdir) |
|
639 |
tmp_repo = tmp_bzrdir.open_repository() |
|
640 |
tmp_repo.copy_content_into(destination, revision_id) |
|
641 |
finally: |
|
642 |
osutils.rmtree(tmpdir) |
|
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
643 |
finally: |
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
644 |
tar_file.close() |
|
2018.18.10
by Martin Pool
copy_content_into from Remote repositories by using temporary directories on both ends. |
645 |
# TODO: if the server doesn't support this operation, maybe do it the
|
646 |
# slow way using the _real_repository?
|
|
|
2018.18.23
by Martin Pool
review cleanups |
647 |
#
|
648 |
# TODO: Suggestion from john: using external tar is much faster than
|
|
649 |
# python's tarfile library, but it may not work on windows.
|
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
650 |
|
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
651 |
@needs_write_lock
|
652 |
def pack(self): |
|
653 |
"""Compress the data within the repository. |
|
654 |
||
655 |
This is not currently implemented within the smart server.
|
|
656 |
"""
|
|
657 |
self._ensure_real() |
|
658 |
return self._real_repository.pack() |
|
659 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
660 |
def set_make_working_trees(self, new_value): |
661 |
raise NotImplementedError(self.set_make_working_trees) |
|
662 |
||
663 |
@needs_write_lock
|
|
664 |
def sign_revision(self, revision_id, gpg_strategy): |
|
665 |
self._ensure_real() |
|
666 |
return self._real_repository.sign_revision(revision_id, gpg_strategy) |
|
667 |
||
668 |
@needs_read_lock
|
|
669 |
def get_revisions(self, revision_ids): |
|
670 |
self._ensure_real() |
|
671 |
return self._real_repository.get_revisions(revision_ids) |
|
672 |
||
673 |
def supports_rich_root(self): |
|
|
2018.5.84
by Andrew Bennetts
Merge in supports-rich-root, another test passing. |
674 |
self._ensure_real() |
675 |
return self._real_repository.supports_rich_root() |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
676 |
|
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
677 |
def iter_reverse_revision_history(self, revision_id): |
678 |
self._ensure_real() |
|
679 |
return self._real_repository.iter_reverse_revision_history(revision_id) |
|
680 |
||
|
2018.5.96
by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's |
681 |
@property
|
682 |
def _serializer(self): |
|
683 |
self._ensure_real() |
|
684 |
return self._real_repository._serializer |
|
685 |
||
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
686 |
def store_revision_signature(self, gpg_strategy, plaintext, revision_id): |
687 |
self._ensure_real() |
|
688 |
return self._real_repository.store_revision_signature( |
|
689 |
gpg_strategy, plaintext, revision_id) |
|
690 |
||
691 |
def has_signature_for_revision_id(self, revision_id): |
|
692 |
self._ensure_real() |
|
693 |
return self._real_repository.has_signature_for_revision_id(revision_id) |
|
694 |
||
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
695 |
|
|
2018.5.127
by Andrew Bennetts
Fix most of the lockable_files tests for RemoteBranchLockableFiles. |
696 |
class RemoteBranchLockableFiles(LockableFiles): |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
697 |
"""A 'LockableFiles' implementation that talks to a smart server. |
698 |
|
|
699 |
This is not a public interface class.
|
|
700 |
"""
|
|
701 |
||
702 |
def __init__(self, bzrdir, _client): |
|
703 |
self.bzrdir = bzrdir |
|
704 |
self._client = _client |
|
|
2018.5.135
by Andrew Bennetts
Prevent remote branch clients from determining the 'right' mode for control files, because we don't want clients setting the mode anyway. |
705 |
self._need_find_modes = True |
|
2018.5.133
by Andrew Bennetts
All TestLockableFiles_RemoteLockDir tests passing. |
706 |
LockableFiles.__init__( |
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
707 |
self, bzrdir.get_branch_transport(None), |
|
2018.5.133
by Andrew Bennetts
All TestLockableFiles_RemoteLockDir tests passing. |
708 |
'lock', lockdir.LockDir) |
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
709 |
|
|
2018.5.135
by Andrew Bennetts
Prevent remote branch clients from determining the 'right' mode for control files, because we don't want clients setting the mode anyway. |
710 |
def _find_modes(self): |
711 |
# RemoteBranches don't let the client set the mode of control files.
|
|
712 |
self._dir_mode = None |
|
713 |
self._file_mode = None |
|
714 |
||
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
715 |
def get(self, path): |
716 |
"""'get' a remote path as per the LockableFiles interface. |
|
717 |
||
718 |
:param path: the file to 'get'. If this is 'branch.conf', we do not
|
|
719 |
just retrieve a file, instead we ask the smart server to generate
|
|
720 |
a configuration for us - which is retrieved as an INI file.
|
|
721 |
"""
|
|
|
2018.5.133
by Andrew Bennetts
All TestLockableFiles_RemoteLockDir tests passing. |
722 |
if path == 'branch.conf': |
723 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
724 |
response = self._client.call_expecting_body( |
725 |
'Branch.get_config_file', path) |
|
|
2018.5.133
by Andrew Bennetts
All TestLockableFiles_RemoteLockDir tests passing. |
726 |
assert response[0][0] == 'ok', \ |
727 |
'unexpected response code %s' % (response[0],) |
|
728 |
return StringIO(response[1].read_body_bytes()) |
|
729 |
else: |
|
730 |
# VFS fallback.
|
|
731 |
return LockableFiles.get(self, path) |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
732 |
|
733 |
||
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
734 |
class RemoteBranchFormat(branch.BranchFormat): |
735 |
||
|
2018.5.124
by Robert Collins
Fix test_format_initialize_find_open by delegating Branch formt lookup to the BzrDir, where it should have stayed from the start. |
736 |
def __eq__(self, other): |
737 |
return (isinstance(other, RemoteBranchFormat) and |
|
738 |
self.__dict__ == other.__dict__) |
|
739 |
||
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
740 |
def get_format_description(self): |
741 |
return 'Remote BZR Branch' |
|
742 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
743 |
def get_format_string(self): |
744 |
return 'Remote BZR Branch' |
|
745 |
||
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
746 |
def open(self, a_bzrdir): |
|
1752.2.72
by Andrew Bennetts
Make Remote* classes in remote.py more consistent and remove some dead code. |
747 |
assert isinstance(a_bzrdir, RemoteBzrDir) |
748 |
return a_bzrdir.open_branch() |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
749 |
|
750 |
def initialize(self, a_bzrdir): |
|
751 |
assert isinstance(a_bzrdir, RemoteBzrDir) |
|
752 |
return a_bzrdir.create_branch() |
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
753 |
|
754 |
||
755 |
class RemoteBranch(branch.Branch): |
|
756 |
"""Branch stored on a server accessed by HPSS RPC. |
|
757 |
||
758 |
At the moment most operations are mapped down to simple file operations.
|
|
759 |
"""
|
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
760 |
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
761 |
def __init__(self, remote_bzrdir, remote_repository, real_branch=None, |
762 |
_client=None): |
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
763 |
"""Create a RemoteBranch instance. |
764 |
||
765 |
:param real_branch: An optional local implementation of the branch
|
|
766 |
format, usually accessing the data via the VFS.
|
|
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
767 |
:param _client: Private parameter for testing.
|
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
768 |
"""
|
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
769 |
# We intentionally don't call the parent class's __init__, because it
|
770 |
# will try to assign to self.tags, which is a property in this subclass.
|
|
771 |
# And the parent's __init__ doesn't do much anyway.
|
|
|
2018.5.105
by Andrew Bennetts
Implement revision_history caching for RemoteBranch. |
772 |
self._revision_history_cache = None |
|
1752.2.64
by Andrew Bennetts
Improve how RemoteBzrDir.open_branch works to handle references and not double-open repositories. |
773 |
self.bzrdir = remote_bzrdir |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
774 |
if _client is not None: |
775 |
self._client = _client |
|
776 |
else: |
|
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
777 |
self._client = client._SmartClient(self.bzrdir._shared_medium) |
|
1752.2.64
by Andrew Bennetts
Improve how RemoteBzrDir.open_branch works to handle references and not double-open repositories. |
778 |
self.repository = remote_repository |
|
2018.5.34
by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository. |
779 |
if real_branch is not None: |
780 |
self._real_branch = real_branch |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
781 |
# Give the remote repository the matching real repo.
|
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
782 |
real_repo = self._real_branch.repository |
783 |
if isinstance(real_repo, RemoteRepository): |
|
784 |
real_repo._ensure_real() |
|
785 |
real_repo = real_repo._real_repository |
|
786 |
self.repository._set_real_repository(real_repo) |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
787 |
# Give the branch the remote repository to let fast-pathing happen.
|
788 |
self._real_branch.repository = self.repository |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
789 |
else: |
790 |
self._real_branch = None |
|
|
2018.5.59
by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil). |
791 |
# Fill out expected attributes of branch for bzrlib api users.
|
|
1752.2.64
by Andrew Bennetts
Improve how RemoteBzrDir.open_branch works to handle references and not double-open repositories. |
792 |
self._format = RemoteBranchFormat() |
|
2018.5.55
by Robert Collins
Give RemoteBranch a base url in line with the Branch protocol. |
793 |
self.base = self.bzrdir.root_transport.base |
|
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
794 |
self._control_files = None |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
795 |
self._lock_mode = None |
796 |
self._lock_token = None |
|
797 |
self._lock_count = 0 |
|
798 |
self._leave_lock = False |
|
|
1752.2.64
by Andrew Bennetts
Improve how RemoteBzrDir.open_branch works to handle references and not double-open repositories. |
799 |
|
|
2477.1.1
by Martin Pool
Add RemoteBranch repr |
800 |
def __str__(self): |
801 |
return "%s(%s)" % (self.__class__.__name__, self.base) |
|
802 |
||
803 |
__repr__ = __str__ |
|
804 |
||
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
805 |
def _ensure_real(self): |
806 |
"""Ensure that there is a _real_branch set. |
|
807 |
||
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
808 |
Used before calls to self._real_branch.
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
809 |
"""
|
810 |
if not self._real_branch: |
|
811 |
assert vfs.vfs_enabled() |
|
812 |
self.bzrdir._ensure_real() |
|
813 |
self._real_branch = self.bzrdir._real_bzrdir.open_branch() |
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
814 |
# Give the remote repository the matching real repo.
|
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
815 |
real_repo = self._real_branch.repository |
816 |
if isinstance(real_repo, RemoteRepository): |
|
817 |
real_repo._ensure_real() |
|
818 |
real_repo = real_repo._real_repository |
|
819 |
self.repository._set_real_repository(real_repo) |
|
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
820 |
# Give the branch the remote repository to let fast-pathing happen.
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
821 |
self._real_branch.repository = self.repository |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
822 |
# XXX: deal with _lock_mode == 'w'
|
823 |
if self._lock_mode == 'r': |
|
824 |
self._real_branch.lock_read() |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
825 |
|
|
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
826 |
@property
|
827 |
def control_files(self): |
|
828 |
# Defer actually creating RemoteBranchLockableFiles until its needed,
|
|
829 |
# because it triggers an _ensure_real that we otherwise might not need.
|
|
830 |
if self._control_files is None: |
|
831 |
self._control_files = RemoteBranchLockableFiles( |
|
832 |
self.bzrdir, self._client) |
|
833 |
return self._control_files |
|
834 |
||
|
2018.5.166
by Andrew Bennetts
Small changes in response to Aaron's review. |
835 |
def _get_checkout_format(self): |
836 |
self._ensure_real() |
|
837 |
return self._real_branch._get_checkout_format() |
|
838 |
||
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
839 |
def get_physical_lock_status(self): |
840 |
"""See Branch.get_physical_lock_status().""" |
|
841 |
# should be an API call to the server, as branches must be lockable.
|
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
842 |
self._ensure_real() |
|
2018.5.60
by Robert Collins
More missing methods from RemoteBranch and RemoteRepository to let 'info' get further. |
843 |
return self._real_branch.get_physical_lock_status() |
844 |
||
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
845 |
def lock_read(self): |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
846 |
if not self._lock_mode: |
847 |
self._lock_mode = 'r' |
|
848 |
self._lock_count = 1 |
|
849 |
if self._real_branch is not None: |
|
850 |
self._real_branch.lock_read() |
|
851 |
else: |
|
852 |
self._lock_count += 1 |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
853 |
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
854 |
def _remote_lock_write(self, token): |
855 |
if token is None: |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
856 |
branch_token = repo_token = '' |
857 |
else: |
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
858 |
branch_token = token |
859 |
repo_token = self.repository.lock_write() |
|
860 |
self.repository.unlock() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
861 |
path = self.bzrdir._path_for_remote_call(self._client) |
862 |
response = self._client.call('Branch.lock_write', path, branch_token, |
|
863 |
repo_token) |
|
864 |
if response[0] == 'ok': |
|
865 |
ok, branch_token, repo_token = response |
|
866 |
return branch_token, repo_token |
|
867 |
elif response[0] == 'LockContention': |
|
868 |
raise errors.LockContention('(remote lock)') |
|
869 |
elif response[0] == 'TokenMismatch': |
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
870 |
raise errors.TokenMismatch(token, '(remote token)') |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
871 |
elif response[0] == 'UnlockableTransport': |
872 |
raise errors.UnlockableTransport(self.bzrdir.root_transport) |
|
|
2018.5.123
by Robert Collins
Translate ReadOnlyError in RemoteBranch._remote_lock_write. |
873 |
elif response[0] == 'ReadOnlyError': |
874 |
raise errors.ReadOnlyError(self) |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
875 |
else: |
|
2555.1.1
by Martin Pool
Remove use of 'assert False' to raise an exception unconditionally |
876 |
raise errors.UnexpectedSmartServerResponse(response) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
877 |
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
878 |
def lock_write(self, token=None): |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
879 |
if not self._lock_mode: |
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
880 |
remote_tokens = self._remote_lock_write(token) |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
881 |
self._lock_token, self._repo_lock_token = remote_tokens |
882 |
assert self._lock_token, 'Remote server did not return a token!' |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
883 |
# TODO: We really, really, really don't want to call _ensure_real
|
884 |
# here, but it's the easiest way to ensure coherency between the
|
|
885 |
# state of the RemoteBranch and RemoteRepository objects and the
|
|
886 |
# physical locks. If we don't materialise the real objects here,
|
|
887 |
# then getting everything in the right state later is complex, so
|
|
888 |
# for now we just do it the lazy way.
|
|
889 |
# -- Andrew Bennetts, 2007-02-22.
|
|
890 |
self._ensure_real() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
891 |
if self._real_branch is not None: |
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
892 |
self._real_branch.repository.lock_write( |
893 |
token=self._repo_lock_token) |
|
894 |
try: |
|
895 |
self._real_branch.lock_write(token=self._lock_token) |
|
896 |
finally: |
|
897 |
self._real_branch.repository.unlock() |
|
898 |
if token is not None: |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
899 |
self._leave_lock = True |
900 |
else: |
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
901 |
# XXX: this case seems to be unreachable; token cannot be None.
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
902 |
self._leave_lock = False |
903 |
self._lock_mode = 'w' |
|
904 |
self._lock_count = 1 |
|
905 |
elif self._lock_mode == 'r': |
|
906 |
raise errors.ReadOnlyTransaction |
|
907 |
else: |
|
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
908 |
if token is not None: |
909 |
# A token was given to lock_write, and we're relocking, so check
|
|
910 |
# that the given token actually matches the one we already have.
|
|
911 |
if token != self._lock_token: |
|
912 |
raise errors.TokenMismatch(token, self._lock_token) |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
913 |
self._lock_count += 1 |
|
2018.5.142
by Andrew Bennetts
Change Branch.lock_token to only accept and receive the branch lock token (rather than the branch and repo lock tokens). |
914 |
return self._lock_token |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
915 |
|
916 |
def _unlock(self, branch_token, repo_token): |
|
917 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
918 |
response = self._client.call('Branch.unlock', path, branch_token, |
|
919 |
repo_token) |
|
920 |
if response == ('ok',): |
|
921 |
return
|
|
922 |
elif response[0] == 'TokenMismatch': |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
923 |
raise errors.TokenMismatch( |
924 |
str((branch_token, repo_token)), '(remote tokens)') |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
925 |
else: |
|
2555.1.1
by Martin Pool
Remove use of 'assert False' to raise an exception unconditionally |
926 |
raise errors.UnexpectedSmartServerResponse(response) |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
927 |
|
928 |
def unlock(self): |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
929 |
self._lock_count -= 1 |
930 |
if not self._lock_count: |
|
|
2018.5.105
by Andrew Bennetts
Implement revision_history caching for RemoteBranch. |
931 |
self._clear_cached_state() |
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
932 |
mode = self._lock_mode |
933 |
self._lock_mode = None |
|
934 |
if self._real_branch is not None: |
|
|
2018.15.1
by Andrew Bennetts
All branch_implementations/test_locking tests passing. |
935 |
if not self._leave_lock: |
936 |
# If this RemoteBranch will remove the physical lock for the
|
|
937 |
# repository, make sure the _real_branch doesn't do it
|
|
938 |
# first. (Because the _real_branch's repository is set to
|
|
939 |
# be the RemoteRepository.)
|
|
940 |
self._real_branch.repository.leave_lock_in_place() |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
941 |
self._real_branch.unlock() |
942 |
if mode != 'w': |
|
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
943 |
# Only write-locked branched need to make a remote method call
|
944 |
# to perfom the unlock.
|
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
945 |
return
|
946 |
assert self._lock_token, 'Locked, but no token!' |
|
947 |
branch_token = self._lock_token |
|
948 |
repo_token = self._repo_lock_token |
|
949 |
self._lock_token = None |
|
950 |
self._repo_lock_token = None |
|
951 |
if not self._leave_lock: |
|
952 |
self._unlock(branch_token, repo_token) |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
953 |
|
954 |
def break_lock(self): |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
955 |
self._ensure_real() |
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
956 |
return self._real_branch.break_lock() |
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
957 |
|
|
2018.5.79
by Andrew Bennetts
Implement RemoteBranch.lock_write/unlock as smart operations. |
958 |
def leave_lock_in_place(self): |
959 |
self._leave_lock = True |
|
960 |
||
961 |
def dont_leave_lock_in_place(self): |
|
962 |
self._leave_lock = False |
|
963 |
||
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
964 |
def last_revision_info(self): |
965 |
"""See Branch.last_revision_info().""" |
|
966 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
967 |
response = self._client.call('Branch.last_revision_info', path) |
|
|
2018.5.52
by Wouter van Heyst
Provide more information when encountering unexpected responses from a smart |
968 |
assert response[0] == 'ok', 'unexpected response code %s' % (response,) |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
969 |
revno = int(response[1]) |
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
970 |
last_revision = response[2] |
|
2018.5.51
by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info() |
971 |
return (revno, last_revision) |
972 |
||
|
2018.5.105
by Andrew Bennetts
Implement revision_history caching for RemoteBranch. |
973 |
def _gen_revision_history(self): |
974 |
"""See Branch._gen_revision_history().""" |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
975 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
2018.5.153
by Andrew Bennetts
Rename call2 to call_expecting_body, and other small changes prompted by review. |
976 |
response = self._client.call_expecting_body( |
977 |
'Branch.revision_history', path) |
|
978 |
assert response[0][0] == 'ok', ('unexpected response code %s' |
|
979 |
% (response[0],)) |
|
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
980 |
result = response[1].read_body_bytes().split('\x00') |
|
2018.5.38
by Robert Collins
Implement RemoteBranch.revision_history(). |
981 |
if result == ['']: |
982 |
return [] |
|
983 |
return result |
|
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
984 |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
985 |
@needs_write_lock
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
986 |
def set_revision_history(self, rev_history): |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
987 |
# Send just the tip revision of the history; the server will generate
|
988 |
# the full history from that. If the revision doesn't exist in this
|
|
989 |
# branch, NoSuchRevision will be raised.
|
|
990 |
path = self.bzrdir._path_for_remote_call(self._client) |
|
991 |
if rev_history == []: |
|
|
2018.5.170
by Andrew Bennetts
Use 'null:' instead of '' to mean NULL_REVISION on the wire. |
992 |
rev_id = 'null:' |
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
993 |
else: |
994 |
rev_id = rev_history[-1] |
|
|
2418.5.12
by John Arbash Meinel
Move functions from BzrBranch to base Branch object. |
995 |
self._clear_cached_state() |
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
996 |
response = self._client.call('Branch.set_last_revision', |
997 |
path, self._lock_token, self._repo_lock_token, rev_id) |
|
|
2018.12.3
by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it. |
998 |
if response[0] == 'NoSuchRevision': |
999 |
raise NoSuchRevision(self, rev_id) |
|
1000 |
else: |
|
1001 |
assert response == ('ok',), ( |
|
1002 |
'unexpected response code %r' % (response,)) |
|
|
2018.5.105
by Andrew Bennetts
Implement revision_history caching for RemoteBranch. |
1003 |
self._cache_revision_history(rev_history) |
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
1004 |
|
1005 |
def get_parent(self): |
|
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
1006 |
self._ensure_real() |
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
1007 |
return self._real_branch.get_parent() |
1008 |
||
|
1752.2.63
by Andrew Bennetts
Delegate set_parent. |
1009 |
def set_parent(self, url): |
|
2018.5.70
by Robert Collins
Only try to get real repositories when an operation requires them. |
1010 |
self._ensure_real() |
|
1752.2.63
by Andrew Bennetts
Delegate set_parent. |
1011 |
return self._real_branch.set_parent(url) |
1012 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1013 |
def get_config(self): |
1014 |
return RemoteBranchConfig(self) |
|
1015 |
||
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
1016 |
def sprout(self, to_bzrdir, revision_id=None): |
1017 |
# Like Branch.sprout, except that it sprouts a branch in the default
|
|
1018 |
# format, because RemoteBranches can't be created at arbitrary URLs.
|
|
1019 |
# XXX: if to_bzrdir is a RemoteBranch, this should perhaps do
|
|
1020 |
# to_bzrdir.create_branch...
|
|
1021 |
result = branch.BranchFormat.get_default_format().initialize(to_bzrdir) |
|
|
2018.18.20
by Martin Pool
Route branch operations through remote copy_content_into |
1022 |
self.copy_content_into(result, revision_id=revision_id) |
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
1023 |
result.set_parent(self.bzrdir.root_transport.base) |
1024 |
return result |
|
1025 |
||
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1026 |
@needs_write_lock
|
1027 |
def append_revision(self, *revision_ids): |
|
1028 |
self._ensure_real() |
|
1029 |
return self._real_branch.append_revision(*revision_ids) |
|
1030 |
||
1031 |
@needs_write_lock
|
|
|
2477.1.2
by Martin Pool
Rename push/pull back to 'run_hooks' (jameinel) |
1032 |
def pull(self, source, overwrite=False, stop_revision=None, |
|
2477.1.9
by Martin Pool
Review cleanups from John, mostly docs |
1033 |
**kwargs): |
1034 |
# FIXME: This asks the real branch to run the hooks, which means
|
|
1035 |
# they're called with the wrong target branch parameter.
|
|
1036 |
# The test suite specifically allows this at present but it should be
|
|
1037 |
# fixed. It should get a _override_hook_target branch,
|
|
1038 |
# as push does. -- mbp 20070405
|
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1039 |
self._ensure_real() |
1040 |
self._real_branch.pull( |
|
|
2477.1.2
by Martin Pool
Rename push/pull back to 'run_hooks' (jameinel) |
1041 |
source, overwrite=overwrite, stop_revision=stop_revision, |
1042 |
**kwargs) |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1043 |
|
|
2018.14.3
by Andrew Bennetts
Make a couple more branch_implementations tests pass. |
1044 |
@needs_read_lock
|
1045 |
def push(self, target, overwrite=False, stop_revision=None): |
|
1046 |
self._ensure_real() |
|
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
1047 |
return self._real_branch.push( |
|
2477.1.5
by Martin Pool
More cleanups of Branch.push to get the right behaviour with RemoteBranches |
1048 |
target, overwrite=overwrite, stop_revision=stop_revision, |
1049 |
_override_hook_source_branch=self) |
|
|
2018.14.3
by Andrew Bennetts
Make a couple more branch_implementations tests pass. |
1050 |
|
1051 |
def is_locked(self): |
|
1052 |
return self._lock_count >= 1 |
|
1053 |
||
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
1054 |
def set_last_revision_info(self, revno, revision_id): |
1055 |
self._ensure_real() |
|
|
2018.5.105
by Andrew Bennetts
Implement revision_history caching for RemoteBranch. |
1056 |
self._clear_cached_state() |
|
2018.5.83
by Andrew Bennetts
Fix some test failures caused by the switch from unicode to UTF-8-encoded strs for revision IDs. |
1057 |
return self._real_branch.set_last_revision_info(revno, revision_id) |
1058 |
||
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
1059 |
def generate_revision_history(self, revision_id, last_rev=None, |
1060 |
other_branch=None): |
|
1061 |
self._ensure_real() |
|
1062 |
return self._real_branch.generate_revision_history( |
|
1063 |
revision_id, last_rev=last_rev, other_branch=other_branch) |
|
1064 |
||
|
2018.5.96
by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's |
1065 |
@property
|
1066 |
def tags(self): |
|
1067 |
self._ensure_real() |
|
1068 |
return self._real_branch.tags |
|
1069 |
||
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
1070 |
def set_push_location(self, location): |
1071 |
self._ensure_real() |
|
1072 |
return self._real_branch.set_push_location(location) |
|
1073 |
||
1074 |
def update_revisions(self, other, stop_revision=None): |
|
1075 |
self._ensure_real() |
|
1076 |
return self._real_branch.update_revisions( |
|
1077 |
other, stop_revision=stop_revision) |
|
1078 |
||
|
1752.2.30
by Martin Pool
Start adding a RemoteBzrDir, etc |
1079 |
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1080 |
class RemoteBranchConfig(BranchConfig): |
1081 |
||
1082 |
def username(self): |
|
1083 |
self.branch._ensure_real() |
|
1084 |
return self.branch._real_branch.get_config().username() |
|
1085 |
||
|
2018.14.2
by Andrew Bennetts
All but one repository_implementation tests for RemoteRepository passing. |
1086 |
def _get_branch_data_config(self): |
1087 |
self.branch._ensure_real() |
|
1088 |
if self._branch_data_config is None: |
|
1089 |
self._branch_data_config = TreeConfig(self.branch._real_branch) |
|
1090 |
return self._branch_data_config |
|
1091 |
||
|
2018.18.25
by Martin Pool
Repository.tarball fixes for python2.4 |
1092 |
|
1093 |
def _extract_tar(tar, to_dir): |
|
1094 |
"""Extract all the contents of a tarfile object. |
|
1095 |
||
1096 |
A replacement for extractall, which is not present in python2.4
|
|
1097 |
"""
|
|
1098 |
for tarinfo in tar: |
|
1099 |
tar.extract(tarinfo, to_dir) |