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