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