bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.1014
by Jelmer Vernooij
Fix tests. |
1 |
# Copyright (C) 2007-2010 Jelmer Vernooij <jelmer@samba.org>
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
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 |
||
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
17 |
from bzrlib import ( |
|
0.200.596
by Jelmer Vernooij
Import RemoteGitBranch._get_config(). |
18 |
config, |
|
0.200.707
by Jelmer Vernooij
Add debug routines. |
19 |
debug, |
|
0.200.586
by Jelmer Vernooij
Fix issues pointed out by pyflakes. |
20 |
trace, |
|
0.200.333
by Jelmer Vernooij
Support progress reporting when creating index. |
21 |
ui, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
22 |
urlutils, |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
23 |
version_info as bzrlib_version, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
24 |
)
|
25 |
from bzrlib.errors import ( |
|
26 |
BzrError, |
|
|
0.200.1412
by Jelmer Vernooij
Implement GitControlDirFormat.supports_transport. |
27 |
InProcessTransport, |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
28 |
InvalidRevisionId, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
29 |
NoSuchFile, |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
30 |
NoSuchRevision, |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
31 |
NotBranchError, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
32 |
NotLocalUrl, |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
33 |
UninitializableFormat, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
34 |
)
|
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
35 |
from bzrlib.transport import ( |
36 |
Transport, |
|
37 |
)
|
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
38 |
|
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
39 |
from bzrlib.plugins.git import ( |
40 |
lazy_check_versions, |
|
41 |
)
|
|
|
0.200.200
by Jelmer Vernooij
Register lazily where possible. |
42 |
lazy_check_versions() |
43 |
||
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
44 |
from bzrlib.plugins.git.branch import ( |
45 |
GitBranch, |
|
|
0.200.1064
by Jelmer Vernooij
Use common base class for tags. |
46 |
GitTags, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
47 |
)
|
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
48 |
from bzrlib.plugins.git.dir import ( |
49 |
GitControlDirFormat, |
|
50 |
GitDir, |
|
51 |
)
|
|
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
52 |
from bzrlib.plugins.git.errors import ( |
|
0.200.319
by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server. |
53 |
GitSmartRemoteNotSupported, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
54 |
NoSuchRef, |
55 |
)
|
|
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
56 |
from bzrlib.plugins.git.mapping import ( |
57 |
mapping_registry, |
|
58 |
)
|
|
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
59 |
from bzrlib.plugins.git.repository import ( |
60 |
GitRepository, |
|
61 |
)
|
|
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
62 |
from bzrlib.plugins.git.refs import ( |
63 |
branch_name_to_ref, |
|
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
64 |
is_peeled, |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
65 |
)
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
66 |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
67 |
import dulwich |
68 |
import dulwich.client |
|
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
69 |
from dulwich.errors import ( |
70 |
GitProtocolError, |
|
71 |
)
|
|
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
72 |
from dulwich.pack import ( |
73 |
Pack, |
|
|
0.200.1298
by Jelmer Vernooij
Fix compatibility with newer versions of dulwich. |
74 |
PackData, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
75 |
)
|
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
76 |
from dulwich.repo import DictRefsContainer |
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
77 |
import os |
78 |
import tempfile |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
79 |
import urllib |
80 |
import urlparse |
|
|
0.200.741
by Jelmer Vernooij
Cope with older versions of Python by adding git and git+ssh to the list of known schemes. |
81 |
urlparse.uses_netloc.extend(['git', 'git+ssh']) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
82 |
|
|
0.200.586
by Jelmer Vernooij
Fix issues pointed out by pyflakes. |
83 |
from dulwich.pack import load_pack_index |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
84 |
|
|
0.200.143
by Jelmer Vernooij
Reoncile InterGitRepository objects. |
85 |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
86 |
# Don't run any tests on GitSmartTransport as it is not intended to be
|
|
0.200.181
by Jelmer Vernooij
Support setting tags. |
87 |
# a full implementation of Transport
|
88 |
def get_test_permutations(): |
|
89 |
return [] |
|
90 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
91 |
|
|
0.200.708
by Jelmer Vernooij
Factor out URL parsing. |
92 |
def split_git_url(url): |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
93 |
"""Split a Git URL. |
94 |
||
95 |
:param url: Git URL
|
|
96 |
:return: Tuple with host, port, username, path.
|
|
97 |
"""
|
|
|
0.200.743
by Jelmer Vernooij
Fix URL parsing. |
98 |
(scheme, netloc, loc, _, _) = urlparse.urlsplit(url) |
99 |
path = urllib.unquote(loc) |
|
|
0.246.2
by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories. |
100 |
if path.startswith("/~"): |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
101 |
path = path[1:] |
|
0.200.743
by Jelmer Vernooij
Fix URL parsing. |
102 |
(username, hostport) = urllib.splituser(netloc) |
|
0.200.708
by Jelmer Vernooij
Factor out URL parsing. |
103 |
(host, port) = urllib.splitnport(hostport, None) |
104 |
return (host, port, username, path) |
|
105 |
||
106 |
||
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
107 |
def parse_git_error(url, message): |
108 |
"""Parse a remote git server error and return a bzr exception. |
|
109 |
||
110 |
:param url: URL of the remote repository
|
|
111 |
:param message: Message sent by the remote git server
|
|
112 |
"""
|
|
113 |
message = str(message).strip() |
|
114 |
if message.startswith("Could not find Repository "): |
|
115 |
return NotBranchError(url, message) |
|
116 |
# Don't know, just return it to the user as-is
|
|
117 |
return BzrError(message) |
|
118 |
||
119 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
120 |
class GitSmartTransport(Transport): |
121 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
122 |
def __init__(self, url, _client=None): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
123 |
Transport.__init__(self, url) |
|
0.200.708
by Jelmer Vernooij
Factor out URL parsing. |
124 |
(self._host, self._port, self._username, self._path) = \ |
125 |
split_git_url(url) |
|
|
0.200.707
by Jelmer Vernooij
Add debug routines. |
126 |
if 'transport' in debug.debug_flags: |
127 |
trace.mutter('host: %r, user: %r, port: %r, path: %r', |
|
128 |
self._host, self._username, self._port, self._path) |
|
|
0.200.166
by Jelmer Vernooij
don't reuse client objects. |
129 |
self._client = _client |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
130 |
if "," in self._path and bzrlib_version < (2, 5, 0): |
131 |
trace.warning( |
|
132 |
"ignoring parameters %r, not supported in bzr < 2.5.", |
|
133 |
self._path.rsplit(",", 1)[1]) |
|
134 |
self._stripped_path = self._path.rsplit(",", 1)[0] |
|
|
0.200.166
by Jelmer Vernooij
don't reuse client objects. |
135 |
|
|
0.200.543
by Jelmer Vernooij
Implement GitSmartTransport.external_url(). |
136 |
def external_url(self): |
137 |
return self.base |
|
138 |
||
|
0.200.238
by Jelmer Vernooij
Import Transport.has(). |
139 |
def has(self, relpath): |
140 |
return False |
|
141 |
||
|
0.200.567
by Jelmer Vernooij
Pass along thin pack settings. |
142 |
def _get_client(self, thin_packs): |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
143 |
raise NotImplementedError(self._get_client) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
144 |
|
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
145 |
def _get_path(self): |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
146 |
return self._stripped_path |
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
147 |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
148 |
def get(self, path): |
149 |
raise NoSuchFile(path) |
|
150 |
||
|
0.200.160
by Jelmer Vernooij
Implement abspath. |
151 |
def abspath(self, relpath): |
152 |
return urlutils.join(self.base, relpath) |
|
153 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
154 |
def clone(self, offset=None): |
155 |
"""See Transport.clone().""" |
|
156 |
if offset is None: |
|
157 |
newurl = self.base |
|
158 |
else: |
|
159 |
newurl = urlutils.join(self.base, offset) |
|
160 |
||
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
161 |
return self.__class__(newurl, self._client) |
162 |
||
163 |
||
164 |
class TCPGitSmartTransport(GitSmartTransport): |
|
165 |
||
|
0.200.332
by Jelmer Vernooij
Support activity reporting. |
166 |
_scheme = 'git' |
167 |
||
|
0.200.567
by Jelmer Vernooij
Pass along thin pack settings. |
168 |
def _get_client(self, thin_packs): |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
169 |
if self._client is not None: |
170 |
ret = self._client |
|
171 |
self._client = None |
|
172 |
return ret |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
173 |
return dulwich.client.TCPGitClient(self._host, self._port, |
|
0.200.859
by Jelmer Vernooij
Trivial cleanups. |
174 |
thin_packs=thin_packs, report_activity=self._report_activity) |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
175 |
|
176 |
||
177 |
class SSHGitSmartTransport(GitSmartTransport): |
|
178 |
||
|
0.200.332
by Jelmer Vernooij
Support activity reporting. |
179 |
_scheme = 'git+ssh' |
180 |
||
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
181 |
def _get_path(self): |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
182 |
path = self._stripped_path |
|
0.200.1318
by Jelmer Vernooij
Strip segment parameters where necessary. |
183 |
if path.startswith("/~/"): |
184 |
return path[3:] |
|
185 |
return path |
|
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
186 |
|
|
0.200.567
by Jelmer Vernooij
Pass along thin pack settings. |
187 |
def _get_client(self, thin_packs): |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
188 |
if self._client is not None: |
189 |
ret = self._client |
|
190 |
self._client = None |
|
191 |
return ret |
|
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
192 |
location_config = config.LocationConfig(self.base) |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
193 |
client = dulwich.client.SSHGitClient(self._host, self._port, self._username, |
|
0.200.567
by Jelmer Vernooij
Pass along thin pack settings. |
194 |
thin_packs=thin_packs, report_activity=self._report_activity) |
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
195 |
# Set up alternate pack program paths
|
196 |
upload_pack = location_config.get_user_option('git_upload_pack') |
|
197 |
if upload_pack: |
|
|
0.200.949
by Jelmer Vernooij
merge support for specifying alternative paths for git executables. |
198 |
client.alternative_paths["upload-pack"] = upload_pack |
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
199 |
receive_pack = location_config.get_user_option('git_receive_pack') |
200 |
if receive_pack: |
|
|
0.200.949
by Jelmer Vernooij
merge support for specifying alternative paths for git executables. |
201 |
client.alternative_paths["receive-pack"] = receive_pack |
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
202 |
return client |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
203 |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
204 |
|
|
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
205 |
class RemoteGitDir(GitDir): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
206 |
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
207 |
def __init__(self, transport, format, get_client, client_path): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
208 |
self._format = format |
209 |
self.root_transport = transport |
|
210 |
self.transport = transport |
|
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
211 |
self._mode_check_done = None |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
212 |
self._get_client = get_client |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
213 |
self._client_path = client_path |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
214 |
self.base = self.root_transport.base |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
215 |
self._refs = None |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
216 |
|
217 |
def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None): |
|
218 |
if progress is None: |
|
219 |
def progress(text): |
|
220 |
trace.info("git: %s" % text) |
|
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
221 |
def wrap_determine_wants(refs_dict): |
222 |
return determine_wants(remote_refs_dict_to_container(refs_dict)) |
|
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
223 |
client = self._get_client(thin_packs=False) |
224 |
try: |
|
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
225 |
refs_dict = client.fetch_pack(self._client_path, wrap_determine_wants, |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
226 |
graph_walker, pack_data, progress) |
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
227 |
self._refs = remote_refs_dict_to_container(refs_dict) |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
228 |
return refs_dict |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
229 |
except GitProtocolError, e: |
230 |
raise parse_git_error(self.transport.external_url(), e) |
|
231 |
||
232 |
def send_pack(self, get_changed_refs, generate_pack_contents): |
|
233 |
client = self._get_client(thin_packs=False) |
|
234 |
try: |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
235 |
return client.send_pack(self._client_path, get_changed_refs, |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
236 |
generate_pack_contents) |
237 |
except GitProtocolError, e: |
|
238 |
raise parse_git_error(self.transport.external_url(), e) |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
239 |
|
|
0.200.1393
by Jelmer Vernooij
Implement removal of remote branches. |
240 |
def destroy_branch(self, name=None): |
241 |
refname = self._get_selected_ref(name) |
|
242 |
if refname is None: |
|
243 |
refname = "HEAD" |
|
244 |
def get_changed_refs(old_refs): |
|
245 |
ret = dict(old_refs) |
|
246 |
if not refname in ret: |
|
|
0.200.1395
by Jelmer Vernooij
Fix error reporting. |
247 |
raise NotBranchError(self.user_url) |
|
0.200.1393
by Jelmer Vernooij
Implement removal of remote branches. |
248 |
ret[refname] = "00" * 20 |
249 |
return ret |
|
250 |
self.send_pack(get_changed_refs, lambda have, want: []) |
|
251 |
||
|
0.200.1068
by Jelmer Vernooij
Implement user_url/control_url. |
252 |
@property
|
253 |
def user_url(self): |
|
254 |
return self.control_url |
|
255 |
||
|
0.200.1314
by Jelmer Vernooij
Provide RemoteGitDir.user_transport. |
256 |
@property
|
257 |
def user_transport(self): |
|
258 |
return self.root_transport |
|
259 |
||
|
0.200.1395
by Jelmer Vernooij
Fix error reporting. |
260 |
@property
|
261 |
def control_url(self): |
|
262 |
return self.control_transport.base |
|
263 |
||
264 |
@property
|
|
265 |
def control_transport(self): |
|
266 |
return self.root_transport |
|
267 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
268 |
def open_repository(self): |
|
0.200.1415
by Jelmer Vernooij
Fix lock files for remote directories. |
269 |
return RemoteGitRepository(self) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
270 |
|
|
0.200.1310
by Jelmer Vernooij
Add _get_selected_ref method. |
271 |
def open_branch(self, name=None, unsupported=False, |
|
0.200.1473
by Jelmer Vernooij
Support possible_transports argument to .open_branch. |
272 |
ignore_fallbacks=False, ref=None, possible_transports=None): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
273 |
repo = self.open_repository() |
|
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
274 |
refname = self._get_selected_ref(name, ref) |
|
0.200.1415
by Jelmer Vernooij
Fix lock files for remote directories. |
275 |
return RemoteGitBranch(self, repo, refname) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
276 |
|
|
0.200.662
by Jelmer Vernooij
Deal with recommend_upgrade argument to open_workingtree. |
277 |
def open_workingtree(self, recommend_upgrade=False): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
278 |
raise NotLocalUrl(self.transport.base) |
279 |
||
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
280 |
def get_peeled(self, name): |
281 |
return self.get_refs_container().get_peeled(name) |
|
282 |
||
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
283 |
def get_refs_container(self): |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
284 |
if self._refs is not None: |
285 |
return self._refs |
|
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
286 |
refs_dict = self.fetch_pack(lambda x: [], None, |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
287 |
lambda x: None, lambda x: trace.mutter("git: %s" % x)) |
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
288 |
self._refs = remote_refs_dict_to_container(refs_dict) |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
289 |
return self._refs |
290 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
291 |
|
|
0.225.2
by Jelmer Vernooij
Handle situation when repository is already up to date during pull. |
292 |
class EmptyObjectStoreIterator(dict): |
293 |
||
294 |
def iterobjects(self): |
|
295 |
return [] |
|
296 |
||
297 |
||
|
0.200.218
by Jelmer Vernooij
Simplify TemporaryPack implementation. |
298 |
class TemporaryPackIterator(Pack): |
299 |
||
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
300 |
def __init__(self, path, resolve_ext_ref): |
|
0.200.310
by Jelmer Vernooij
Fix pull from remote branches. |
301 |
super(TemporaryPackIterator, self).__init__(path) |
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
302 |
self.resolve_ext_ref = resolve_ext_ref |
303 |
||
|
0.200.218
by Jelmer Vernooij
Simplify TemporaryPack implementation. |
304 |
@property
|
|
0.200.604
by Jelmer Vernooij
Fix fetching of remote repositories on Windows. |
305 |
def data(self): |
306 |
if self._data is None: |
|
|
0.200.1298
by Jelmer Vernooij
Fix compatibility with newer versions of dulwich. |
307 |
self._data = PackData(self._data_path) |
|
0.200.604
by Jelmer Vernooij
Fix fetching of remote repositories on Windows. |
308 |
return self._data |
309 |
||
310 |
@property
|
|
|
0.200.458
by Jelmer Vernooij
Fix index. |
311 |
def index(self): |
|
0.200.218
by Jelmer Vernooij
Simplify TemporaryPack implementation. |
312 |
if self._idx is None: |
|
0.200.562
by Jelmer Vernooij
Only create pack index if it doesn't exist yet. |
313 |
if not os.path.exists(self._idx_path): |
314 |
pb = ui.ui_factory.nested_progress_bar() |
|
315 |
try: |
|
316 |
def report_progress(cur, total): |
|
317 |
pb.update("generating index", cur, total) |
|
|
0.200.900
by Jelmer Vernooij
Fix compatibility with newer versions of Dulwich. |
318 |
self.data.create_index(self._idx_path, |
|
0.200.562
by Jelmer Vernooij
Only create pack index if it doesn't exist yet. |
319 |
progress=report_progress) |
320 |
finally: |
|
321 |
pb.finished() |
|
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
322 |
self._idx = load_pack_index(self._idx_path) |
|
0.200.218
by Jelmer Vernooij
Simplify TemporaryPack implementation. |
323 |
return self._idx |
|
0.200.205
by Jelmer Vernooij
Fix remote fetching. |
324 |
|
325 |
def __del__(self): |
|
|
0.200.611
by Jelmer Vernooij
Merge warning fix from Naoki. |
326 |
if self._idx is not None: |
|
0.241.1
by Naoki INADA
Fix can't delete tempfile on Windows |
327 |
self._idx.close() |
328 |
os.remove(self._idx_path) |
|
|
0.200.611
by Jelmer Vernooij
Merge warning fix from Naoki. |
329 |
if self._data is not None: |
|
0.241.1
by Naoki INADA
Fix can't delete tempfile on Windows |
330 |
self._data.close() |
331 |
os.remove(self._data_path) |
|
|
0.200.205
by Jelmer Vernooij
Fix remote fetching. |
332 |
|
333 |
||
|
0.200.1337
by Jelmer Vernooij
Re-use http connection if possible. |
334 |
class BzrGitHttpClient(dulwich.client.HttpGitClient): |
335 |
||
336 |
def __init__(self, transport, *args, **kwargs): |
|
337 |
self.transport = transport |
|
338 |
super(BzrGitHttpClient, self).__init__(transport.external_url(), *args, **kwargs) |
|
339 |
import urllib2 |
|
340 |
self._http_perform = getattr(self.transport, "_perform", urllib2.urlopen) |
|
341 |
||
342 |
def _perform(self, req): |
|
343 |
req.accepted_errors = (200, 404) |
|
344 |
req.follow_redirections = True |
|
345 |
req.redirected_to = None |
|
346 |
return self._http_perform(req) |
|
347 |
||
348 |
||
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
349 |
class RemoteGitControlDirFormat(GitControlDirFormat): |
350 |
"""The .git directory control format.""" |
|
351 |
||
352 |
supports_workingtrees = False |
|
353 |
||
354 |
@classmethod
|
|
355 |
def _known_formats(self): |
|
356 |
return set([RemoteGitControlDirFormat()]) |
|
357 |
||
|
0.200.1413
by Jelmer Vernooij
Fix is_initializable() |
358 |
def is_initializable(self): |
359 |
return False |
|
360 |
||
361 |
def is_supported(self): |
|
362 |
return True |
|
363 |
||
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
364 |
def open(self, transport, _found=None): |
365 |
"""Open this directory. |
|
366 |
||
367 |
"""
|
|
368 |
# we dont grok readonly - git isn't integrated with transport.
|
|
369 |
url = transport.base |
|
370 |
if url.startswith('readonly+'): |
|
371 |
url = url[len('readonly+'):] |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
372 |
if isinstance(transport, GitSmartTransport): |
373 |
get_client = transport._get_client |
|
374 |
client_path = transport._get_path() |
|
375 |
elif urlparse.urlsplit(transport.external_url())[0] in ("http", "https"): |
|
376 |
def get_client(thin_packs=False): |
|
|
0.200.1337
by Jelmer Vernooij
Re-use http connection if possible. |
377 |
return BzrGitHttpClient(transport, thin_packs=thin_packs) |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
378 |
client_path = transport._path |
379 |
else: |
|
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
380 |
raise NotBranchError(transport.base) |
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
381 |
return RemoteGitDir(transport, self, get_client, client_path) |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
382 |
|
383 |
def get_format_description(self): |
|
384 |
return "Remote Git Repository" |
|
385 |
||
386 |
def initialize_on_transport(self, transport): |
|
387 |
raise UninitializableFormat(self) |
|
388 |
||
|
0.200.1412
by Jelmer Vernooij
Implement GitControlDirFormat.supports_transport. |
389 |
def supports_transport(self, transport): |
390 |
try: |
|
391 |
external_url = transport.external_url() |
|
392 |
except InProcessTransport: |
|
393 |
raise NotBranchError(path=transport.base) |
|
394 |
return (external_url.startswith("http:") or |
|
395 |
external_url.startswith("https:") or |
|
396 |
external_url.startswith("git+") or |
|
397 |
external_url.startswith("git:")) |
|
398 |
||
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
399 |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
400 |
class RemoteGitRepository(GitRepository): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
401 |
|
|
0.200.319
by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server. |
402 |
@property
|
|
0.200.1068
by Jelmer Vernooij
Implement user_url/control_url. |
403 |
def user_url(self): |
404 |
return self.control_url |
|
405 |
||
|
0.200.1288
by Jelmer Vernooij
Properly raise GitRemoteNotSupported from RemoteGitRepository. |
406 |
def get_parent_map(self, revids): |
|
0.200.1398
by Jelmer Vernooij
Make GitSmartRemoteNotSupported derive from UnsupportedOperation. |
407 |
raise GitSmartRemoteNotSupported(self.get_parent_map, self) |
|
0.200.319
by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server. |
408 |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
409 |
def fetch_pack(self, determine_wants, graph_walker, pack_data, |
|
0.200.155
by Jelmer Vernooij
Fix formatting, remove catch-all for exceptions when opening local repositories. |
410 |
progress=None): |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
411 |
return self.bzrdir.fetch_pack(determine_wants, graph_walker, |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
412 |
pack_data, progress) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
413 |
|
|
0.200.427
by Jelmer Vernooij
make send_pack accessible. |
414 |
def send_pack(self, get_changed_refs, generate_pack_contents): |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
415 |
return self.bzrdir.send_pack(get_changed_refs, generate_pack_contents) |
|
0.200.427
by Jelmer Vernooij
make send_pack accessible. |
416 |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
417 |
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref, |
418 |
progress=None): |
|
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
419 |
fd, path = tempfile.mkstemp(suffix=".pack") |
|
0.200.1299
by Jelmer Vernooij
Make sure file gets closed. |
420 |
try: |
421 |
self.fetch_pack(determine_wants, graph_walker, |
|
422 |
lambda x: os.write(fd, x), progress) |
|
423 |
finally: |
|
424 |
os.close(fd) |
|
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
425 |
if os.path.getsize(path) == 0: |
|
0.225.2
by Jelmer Vernooij
Handle situation when repository is already up to date during pull. |
426 |
return EmptyObjectStoreIterator() |
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
427 |
return TemporaryPackIterator(path[:-len(".pack")], resolve_ext_ref) |
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
428 |
|
|
0.200.650
by Jelmer Vernooij
Use standard names for lookup functions. |
429 |
def lookup_bzr_revision_id(self, bzr_revid): |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
430 |
# This won't work for any round-tripped bzr revisions, but it's a start..
|
431 |
try: |
|
432 |
return mapping_registry.revision_id_bzr_to_foreign(bzr_revid) |
|
433 |
except InvalidRevisionId: |
|
434 |
raise NoSuchRevision(self, bzr_revid) |
|
435 |
||
|
0.252.48
by Jelmer Vernooij
Implement lookup_foreign_revision for remote branches. |
436 |
def lookup_foreign_revision_id(self, foreign_revid, mapping=None): |
437 |
"""Lookup a revision id. |
|
438 |
||
439 |
"""
|
|
440 |
if mapping is None: |
|
441 |
mapping = self.get_mapping() |
|
442 |
# Not really an easy way to parse foreign revids here..
|
|
443 |
return mapping.revision_id_foreign_to_bzr(foreign_revid) |
|
444 |
||
|
0.200.1446
by Jelmer Vernooij
Add stub for RemoteGitRepository.revision_tree. |
445 |
def revision_tree(self, revid): |
446 |
raise GitSmartRemoteNotSupported(self.revision_tree, self) |
|
447 |
||
|
0.200.1481
by Jelmer Vernooij
'Implement' RemoteGitRepository.get_revisions. |
448 |
def get_revisions(self, revids): |
449 |
raise GitSmartRemoteNotSupported(self.get_revisions, self) |
|
450 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
451 |
|
|
0.200.1064
by Jelmer Vernooij
Use common base class for tags. |
452 |
class RemoteGitTagDict(GitTags): |
|
0.228.3
by Jelmer Vernooij
Fix tags when fetching from remotes. |
453 |
|
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
454 |
def get_refs_container(self): |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
455 |
return self.repository.bzrdir.get_refs_container() |
|
0.228.3
by Jelmer Vernooij
Fix tags when fetching from remotes. |
456 |
|
457 |
def set_tag(self, name, revid): |
|
458 |
# FIXME: Not supported yet, should do a push of a new ref
|
|
459 |
raise NotImplementedError(self.set_tag) |
|
460 |
||
461 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
462 |
class RemoteGitBranch(GitBranch): |
463 |
||
|
0.200.1415
by Jelmer Vernooij
Fix lock files for remote directories. |
464 |
def __init__(self, bzrdir, repository, name): |
|
0.200.919
by Jelmer Vernooij
Simplify ref handling in remote.py. |
465 |
self._sha = None |
|
0.200.1415
by Jelmer Vernooij
Fix lock files for remote directories. |
466 |
super(RemoteGitBranch, self).__init__(bzrdir, repository, name) |
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
467 |
|
|
0.200.1317
by Jelmer Vernooij
Avoid NotImplementedError. |
468 |
def last_revision_info(self): |
|
0.200.1398
by Jelmer Vernooij
Make GitSmartRemoteNotSupported derive from UnsupportedOperation. |
469 |
raise GitSmartRemoteNotSupported(self.last_revision_info, self) |
|
0.200.1317
by Jelmer Vernooij
Avoid NotImplementedError. |
470 |
|
|
0.200.1068
by Jelmer Vernooij
Implement user_url/control_url. |
471 |
@property
|
472 |
def user_url(self): |
|
473 |
return self.control_url |
|
474 |
||
475 |
@property
|
|
476 |
def control_url(self): |
|
477 |
return self.base |
|
478 |
||
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
479 |
def revision_history(self): |
|
0.200.1436
by Jelmer Vernooij
Raise UnsupportedOperation for `Branch.revision_id_to_dotted_revno`, |
480 |
raise GitSmartRemoteNotSupported(self.revision_history, self) |
481 |
||
482 |
def revision_id_to_revno(self, revision_id): |
|
483 |
raise GitSmartRemoteNotSupported(self.revision_id_to_revno, self) |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
484 |
|
485 |
def last_revision(self): |
|
|
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
486 |
return self.lookup_foreign_revision_id(self.head) |
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
487 |
|
488 |
@property
|
|
489 |
def head(self): |
|
|
0.200.919
by Jelmer Vernooij
Simplify ref handling in remote.py. |
490 |
if self._sha is not None: |
491 |
return self._sha |
|
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
492 |
refs = self.bzrdir.get_refs() |
|
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
493 |
name = branch_name_to_ref(self.name, "HEAD") |
|
0.200.1386
by Jelmer Vernooij
Friendlier message if HEAD is not found. |
494 |
try: |
495 |
self._sha = refs[name] |
|
496 |
except KeyError: |
|
497 |
raise NoSuchRef(name, self.repository.user_url, refs) |
|
|
0.200.919
by Jelmer Vernooij
Simplify ref handling in remote.py. |
498 |
return self._sha |
|
0.200.141
by Jelmer Vernooij
Separate out local and remote fetching. |
499 |
|
|
0.200.169
by Jelmer Vernooij
Fix branch cloning. |
500 |
def _synchronize_history(self, destination, revision_id): |
501 |
"""See Branch._synchronize_history().""" |
|
502 |
destination.generate_revision_history(self.last_revision()) |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
503 |
|
|
0.200.499
by Jelmer Vernooij
Implement RemoteBranch.{get,set}_push_location. |
504 |
def get_push_location(self): |
505 |
return None |
|
506 |
||
507 |
def set_push_location(self, url): |
|
508 |
pass
|
|
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
509 |
|
510 |
||
511 |
def remote_refs_dict_to_container(refs_dict): |
|
512 |
base = {} |
|
513 |
peeled = {} |
|
514 |
for k, v in refs_dict.iteritems(): |
|
515 |
if is_peeled(k): |
|
516 |
peeled[k[:-3]] = v |
|
517 |
else: |
|
518 |
base[k] = v |
|
519 |
peeled[k] = v |
|
520 |
ret = DictRefsContainer(base) |
|
521 |
ret._peeled = peeled |
|
522 |
return ret |