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