bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2007-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
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
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
16 |
|
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
17 |
"""Remote dirs, repositories and branches."""
|
18 |
||
|
0.200.1594
by Jelmer Vernooij
Use absolute_import everywhere. |
19 |
from __future__ import absolute_import |
20 |
||
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
21 |
import re |
22 |
||
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
23 |
from ... import ( |
|
0.200.596
by Jelmer Vernooij
Import RemoteGitBranch._get_config(). |
24 |
config, |
|
0.200.707
by Jelmer Vernooij
Add debug routines. |
25 |
debug, |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
26 |
errors, |
|
0.200.586
by Jelmer Vernooij
Fix issues pointed out by pyflakes. |
27 |
trace, |
|
0.200.333
by Jelmer Vernooij
Support progress reporting when creating index. |
28 |
ui, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
29 |
urlutils, |
30 |
)
|
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
31 |
from ...push import ( |
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
32 |
PushResult, |
33 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
34 |
from ...errors import ( |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
35 |
AlreadyBranchError, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
36 |
BzrError, |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
37 |
DivergedBranches, |
|
0.200.1412
by Jelmer Vernooij
Implement GitControlDirFormat.supports_transport. |
38 |
InProcessTransport, |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
39 |
InvalidRevisionId, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
40 |
NoSuchFile, |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
41 |
NoSuchRevision, |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
42 |
NoSuchTag, |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
43 |
NotBranchError, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
44 |
NotLocalUrl, |
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
45 |
NoWorkingTree, |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
46 |
UninitializableFormat, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
47 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
48 |
from ...transport import ( |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
49 |
Transport, |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
50 |
register_urlparse_netloc_protocol, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
51 |
)
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
52 |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
53 |
from . import ( |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
54 |
lazy_check_versions, |
|
0.409.2
by Jelmer Vernooij
call out to HTTP transport rather than creating new connection. |
55 |
user_agent_for_github, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
56 |
)
|
|
0.200.200
by Jelmer Vernooij
Register lazily where possible. |
57 |
lazy_check_versions() |
58 |
||
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
59 |
from .branch import ( |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
60 |
GitBranch, |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
61 |
GitBranchFormat, |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
62 |
GitBranchPushResult, |
|
0.200.1064
by Jelmer Vernooij
Use common base class for tags. |
63 |
GitTags, |
|
0.406.2
by Jelmer Vernooij
Add tests. |
64 |
_quick_lookup_revno, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
65 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
66 |
from .dir import ( |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
67 |
GitControlDirFormat, |
68 |
GitDir, |
|
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
69 |
BareLocalGitControlDirFormat, |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
70 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
71 |
from .errors import ( |
|
0.200.319
by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server. |
72 |
GitSmartRemoteNotSupported, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
73 |
NoSuchRef, |
74 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
75 |
from .mapping import ( |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
76 |
mapping_registry, |
77 |
)
|
|
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
78 |
from .object_store import ( |
79 |
get_object_store, |
|
80 |
)
|
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
81 |
from .push import ( |
82 |
remote_divergence, |
|
83 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
84 |
from .repository import ( |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
85 |
GitRepository, |
86 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
87 |
from .refs import ( |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
88 |
branch_name_to_ref, |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
89 |
is_peeled, |
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
90 |
ref_to_tag_name, |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
91 |
tag_name_to_ref, |
|
0.200.872
by Jelmer Vernooij
Move refs code to separate module. |
92 |
)
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
93 |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
94 |
import dulwich |
95 |
import dulwich.client |
|
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
96 |
from dulwich.errors import ( |
97 |
GitProtocolError, |
|
98 |
)
|
|
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
99 |
from dulwich.pack import ( |
100 |
Pack, |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
101 |
pack_objects_to_data, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
102 |
)
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
103 |
from dulwich.protocol import ZERO_SHA |
|
0.409.2
by Jelmer Vernooij
call out to HTTP transport rather than creating new connection. |
104 |
from dulwich.refs import ( |
105 |
DictRefsContainer, |
|
106 |
SYMREF, |
|
107 |
)
|
|
108 |
from dulwich.repo import ( |
|
109 |
NotGitRepository, |
|
110 |
)
|
|
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
111 |
import os |
|
0.200.1624
by Jelmer Vernooij
Add ssh vendor for dulwich that uses the bzr ssh vendor. |
112 |
import select |
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
113 |
import tempfile |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
114 |
import urllib |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
115 |
|
116 |
try: |
|
117 |
import urllib.parse as urlparse |
|
118 |
from urllib.parse import splituser, splitnport |
|
119 |
except ImportError: |
|
120 |
import urlparse |
|
121 |
from urllib import splituser, splitnport |
|
|
0.200.1555
by Jelmer Vernooij
Remove segment parameters for http smart transports. |
122 |
|
123 |
# urlparse only supports a limited number of schemes by default
|
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
124 |
register_urlparse_netloc_protocol('git') |
125 |
register_urlparse_netloc_protocol('git+ssh') |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
126 |
|
|
0.200.586
by Jelmer Vernooij
Fix issues pointed out by pyflakes. |
127 |
from dulwich.pack import load_pack_index |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
128 |
|
|
0.200.143
by Jelmer Vernooij
Reoncile InterGitRepository objects. |
129 |
|
|
0.406.1
by Jelmer Vernooij
Properly lookup revnos for brz-git push result. |
130 |
class GitPushResult(PushResult): |
131 |
||
132 |
def _lookup_revno(self, revid): |
|
|
0.406.2
by Jelmer Vernooij
Add tests. |
133 |
try: |
134 |
return _quick_lookup_revno(self.source_branch, self.target_branch, |
|
135 |
revid) |
|
136 |
except GitSmartRemoteNotSupported: |
|
137 |
return None |
|
|
0.406.1
by Jelmer Vernooij
Properly lookup revnos for brz-git push result. |
138 |
|
139 |
@property
|
|
140 |
def old_revno(self): |
|
141 |
return self._lookup_revno(self.old_revid) |
|
142 |
||
143 |
@property
|
|
144 |
def new_revno(self): |
|
145 |
return self._lookup_revno(self.new_revid) |
|
146 |
||
147 |
||
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
148 |
# Don't run any tests on GitSmartTransport as it is not intended to be
|
|
0.200.181
by Jelmer Vernooij
Support setting tags. |
149 |
# a full implementation of Transport
|
150 |
def get_test_permutations(): |
|
151 |
return [] |
|
152 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
153 |
|
|
0.200.708
by Jelmer Vernooij
Factor out URL parsing. |
154 |
def split_git_url(url): |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
155 |
"""Split a Git URL. |
156 |
||
157 |
:param url: Git URL
|
|
158 |
:return: Tuple with host, port, username, path.
|
|
159 |
"""
|
|
|
0.200.743
by Jelmer Vernooij
Fix URL parsing. |
160 |
(scheme, netloc, loc, _, _) = urlparse.urlsplit(url) |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
161 |
path = urlparse.unquote(loc) |
|
0.246.2
by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories. |
162 |
if path.startswith("/~"): |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
163 |
path = path[1:] |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
164 |
(username, hostport) = splituser(netloc) |
165 |
(host, port) = splitnport(hostport, None) |
|
|
0.200.708
by Jelmer Vernooij
Factor out URL parsing. |
166 |
return (host, port, username, path) |
167 |
||
168 |
||
|
0.200.1562
by Jelmer Vernooij
Add separate exception for remote errors. |
169 |
class RemoteGitError(BzrError): |
170 |
||
|
0.290.1
by Jelmer Vernooij
Avoid 'message' argument in RemoteGitError; apparently it breaks some versions of Python. |
171 |
_fmt = "Remote server error: %(msg)s" |
|
0.200.1562
by Jelmer Vernooij
Add separate exception for remote errors. |
172 |
|
173 |
||
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
174 |
def parse_git_error(url, message): |
175 |
"""Parse a remote git server error and return a bzr exception. |
|
176 |
||
177 |
:param url: URL of the remote repository
|
|
178 |
:param message: Message sent by the remote git server
|
|
179 |
"""
|
|
180 |
message = str(message).strip() |
|
181 |
if message.startswith("Could not find Repository "): |
|
182 |
return NotBranchError(url, message) |
|
|
0.200.1563
by Jelmer Vernooij
Improve error message. |
183 |
if message == "HEAD failed to update": |
184 |
base_url, _ = urlutils.split_segment_parameters(url) |
|
185 |
raise BzrError( |
|
186 |
("Unable to update remote HEAD branch. To update the master " |
|
187 |
"branch, specify the URL %s,branch=master.") % base_url) |
|
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
188 |
# Don't know, just return it to the user as-is
|
|
0.200.1562
by Jelmer Vernooij
Add separate exception for remote errors. |
189 |
return RemoteGitError(message) |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
190 |
|
191 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
192 |
class GitSmartTransport(Transport): |
193 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
194 |
def __init__(self, url, _client=None): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
195 |
Transport.__init__(self, url) |
|
0.200.708
by Jelmer Vernooij
Factor out URL parsing. |
196 |
(self._host, self._port, self._username, self._path) = \ |
197 |
split_git_url(url) |
|
|
0.200.707
by Jelmer Vernooij
Add debug routines. |
198 |
if 'transport' in debug.debug_flags: |
199 |
trace.mutter('host: %r, user: %r, port: %r, path: %r', |
|
200 |
self._host, self._username, self._port, self._path) |
|
|
0.200.166
by Jelmer Vernooij
don't reuse client objects. |
201 |
self._client = _client |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
202 |
self._stripped_path = self._path.rsplit(",", 1)[0] |
|
0.200.166
by Jelmer Vernooij
don't reuse client objects. |
203 |
|
|
0.200.543
by Jelmer Vernooij
Implement GitSmartTransport.external_url(). |
204 |
def external_url(self): |
205 |
return self.base |
|
206 |
||
|
0.200.238
by Jelmer Vernooij
Import Transport.has(). |
207 |
def has(self, relpath): |
208 |
return False |
|
209 |
||
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
210 |
def _get_client(self): |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
211 |
raise NotImplementedError(self._get_client) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
212 |
|
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
213 |
def _get_path(self): |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
214 |
return self._stripped_path |
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
215 |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
216 |
def get(self, path): |
217 |
raise NoSuchFile(path) |
|
218 |
||
|
0.200.160
by Jelmer Vernooij
Implement abspath. |
219 |
def abspath(self, relpath): |
220 |
return urlutils.join(self.base, relpath) |
|
221 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
222 |
def clone(self, offset=None): |
223 |
"""See Transport.clone().""" |
|
224 |
if offset is None: |
|
225 |
newurl = self.base |
|
226 |
else: |
|
227 |
newurl = urlutils.join(self.base, offset) |
|
228 |
||
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
229 |
return self.__class__(newurl, self._client) |
230 |
||
231 |
||
232 |
class TCPGitSmartTransport(GitSmartTransport): |
|
233 |
||
|
0.200.332
by Jelmer Vernooij
Support activity reporting. |
234 |
_scheme = 'git' |
235 |
||
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
236 |
def _get_client(self): |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
237 |
if self._client is not None: |
238 |
ret = self._client |
|
239 |
self._client = None |
|
240 |
return ret |
|
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
241 |
if self._host == '': |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
242 |
# return dulwich.client.LocalGitClient()
|
243 |
return dulwich.client.SubprocessGitClient() |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
244 |
return dulwich.client.TCPGitClient(self._host, self._port, |
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
245 |
report_activity=self._report_activity) |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
246 |
|
247 |
||
|
0.200.1624
by Jelmer Vernooij
Add ssh vendor for dulwich that uses the bzr ssh vendor. |
248 |
class SSHSocketWrapper(object): |
249 |
||
250 |
def __init__(self, sock): |
|
251 |
self.sock = sock |
|
252 |
||
253 |
def read(self, len=None): |
|
254 |
return self.sock.recv(len) |
|
255 |
||
256 |
def write(self, data): |
|
257 |
return self.sock.write(data) |
|
258 |
||
259 |
def can_read(self): |
|
260 |
return len(select.select([self.sock.fileno()], [], [], 0)[0]) > 0 |
|
261 |
||
262 |
||
263 |
class DulwichSSHVendor(dulwich.client.SSHVendor): |
|
264 |
||
265 |
def __init__(self): |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
266 |
from ...transport import ssh |
|
0.200.1624
by Jelmer Vernooij
Add ssh vendor for dulwich that uses the bzr ssh vendor. |
267 |
self.bzr_ssh_vendor = ssh._get_ssh_vendor() |
268 |
||
269 |
def run_command(self, host, command, username=None, port=None): |
|
270 |
connection = self.bzr_ssh_vendor.connect_ssh(username=username, |
|
271 |
password=None, port=port, host=host, command=command) |
|
272 |
(kind, io_object) = connection.get_sock_or_pipes() |
|
273 |
if kind == 'socket': |
|
274 |
return SSHSocketWrapper(io_object) |
|
275 |
else: |
|
276 |
raise AssertionError("Unknown io object kind %r'" % kind) |
|
277 |
||
278 |
||
279 |
#dulwich.client.get_ssh_vendor = DulwichSSHVendor
|
|
280 |
||
281 |
||
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
282 |
class SSHGitSmartTransport(GitSmartTransport): |
283 |
||
|
0.200.332
by Jelmer Vernooij
Support activity reporting. |
284 |
_scheme = 'git+ssh' |
285 |
||
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
286 |
def _get_path(self): |
|
0.200.1464
by Jelmer Vernooij
Warn about ignoring path segment parameters when using bzr 2.4. |
287 |
path = self._stripped_path |
|
0.200.1318
by Jelmer Vernooij
Strip segment parameters where necessary. |
288 |
if path.startswith("/~/"): |
289 |
return path[3:] |
|
290 |
return path |
|
|
0.200.470
by Jelmer Vernooij
Properly parse username in URLs. |
291 |
|
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
292 |
def _get_client(self): |
|
0.200.307
by Jelmer Vernooij
Support git+ssh. |
293 |
if self._client is not None: |
294 |
ret = self._client |
|
295 |
self._client = None |
|
296 |
return ret |
|
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
297 |
location_config = config.LocationConfig(self.base) |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
298 |
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. |
299 |
report_activity=self._report_activity) |
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
300 |
# Set up alternate pack program paths
|
301 |
upload_pack = location_config.get_user_option('git_upload_pack') |
|
302 |
if upload_pack: |
|
|
0.200.949
by Jelmer Vernooij
merge support for specifying alternative paths for git executables. |
303 |
client.alternative_paths["upload-pack"] = upload_pack |
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
304 |
receive_pack = location_config.get_user_option('git_receive_pack') |
305 |
if receive_pack: |
|
|
0.200.949
by Jelmer Vernooij
merge support for specifying alternative paths for git executables. |
306 |
client.alternative_paths["receive-pack"] = receive_pack |
|
0.253.1
by Ross Light
Added configuration options for git-upload-pack and git-receive-pack |
307 |
return client |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
308 |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
309 |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
310 |
class RemoteGitBranchFormat(GitBranchFormat): |
311 |
||
312 |
def get_format_description(self): |
|
313 |
return 'Remote Git Branch' |
|
314 |
||
315 |
@property
|
|
316 |
def _matchingcontroldir(self): |
|
317 |
return RemoteGitControlDirFormat() |
|
318 |
||
|
0.295.2
by Jelmer Vernooij
Make RemoteGitBranchFormat uninitializeable. |
319 |
def initialize(self, a_controldir, name=None, repository=None, |
320 |
append_revisions_only=None): |
|
321 |
raise UninitializableFormat(self) |
|
322 |
||
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
323 |
|
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
324 |
class DefaultProgressReporter(object): |
325 |
||
326 |
_GIT_PROGRESS_PARTIAL_RE = re.compile(r"(.*?): +(\d+)% \((\d+)/(\d+)\)") |
|
327 |
_GIT_PROGRESS_TOTAL_RE = re.compile(r"(.*?): (\d+)") |
|
328 |
||
329 |
def __init__(self, pb): |
|
330 |
self.pb = pb |
|
331 |
||
332 |
def progress(self, text): |
|
333 |
text = text.rstrip("\r\n") |
|
334 |
if text.startswith('error: '): |
|
335 |
trace.show_error('git: %s', text[len('error: '):]) |
|
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
336 |
else: |
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
337 |
trace.mutter("git: %s", text) |
338 |
g = self._GIT_PROGRESS_PARTIAL_RE.match(text) |
|
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
339 |
if g is not None: |
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
340 |
(text, pct, current, total) = g.groups() |
341 |
self.pb.update(text, int(current), int(total)) |
|
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
342 |
else: |
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
343 |
g = self._GIT_PROGRESS_TOTAL_RE.match(text) |
344 |
if g is not None: |
|
345 |
(text, total) = g.groups() |
|
346 |
self.pb.update(text, None, int(total)) |
|
347 |
else: |
|
348 |
trace.note("%s", text) |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
349 |
|
350 |
||
|
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
351 |
class RemoteGitDir(GitDir): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
352 |
|
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
353 |
def __init__(self, transport, format, client, client_path): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
354 |
self._format = format |
355 |
self.root_transport = transport |
|
356 |
self.transport = transport |
|
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
357 |
self._mode_check_done = None |
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
358 |
self._client = client |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
359 |
self._client_path = client_path |
|
0.200.1396
by Jelmer Vernooij
Support updating tags in remote branches during pull. |
360 |
self.base = self.root_transport.base |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
361 |
self._refs = None |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
362 |
|
|
0.322.1
by Jelmer Vernooij
Fix access of remote git branches. |
363 |
@property
|
364 |
def _gitrepository_class(self): |
|
365 |
return RemoteGitRepository |
|
366 |
||
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
367 |
def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None): |
368 |
if progress is None: |
|
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
369 |
pb = ui.ui_factory.nested_progress_bar() |
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
370 |
progress = DefaultProgressReporter(pb).progress |
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
371 |
else: |
372 |
pb = None |
|
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
373 |
try: |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
374 |
result = self._client.fetch_pack(self._client_path, determine_wants, |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
375 |
graph_walker, pack_data, progress) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
376 |
if result.refs is None: |
377 |
result.refs = {} |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
378 |
self._refs = remote_refs_dict_to_container(result.refs, result.symrefs) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
379 |
return result |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
380 |
except GitProtocolError as e: |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
381 |
raise parse_git_error(self.transport.external_url(), e) |
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
382 |
finally: |
383 |
if pb is not None: |
|
384 |
pb.finished() |
|
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
385 |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
386 |
def send_pack(self, get_changed_refs, generate_pack_data, progress=None): |
387 |
if progress is None: |
|
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
388 |
pb = ui.ui_factory.nested_progress_bar() |
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
389 |
progress = DefaultProgressReporter(pb).progress |
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
390 |
else: |
391 |
pb = None |
|
|
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
392 |
def get_changed_refs_wrapper(refs): |
393 |
# TODO(jelmer): This drops symref information
|
|
394 |
self._refs = remote_refs_dict_to_container(refs) |
|
395 |
return get_changed_refs(refs) |
|
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
396 |
try: |
|
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
397 |
return self._client.send_pack(self._client_path, |
398 |
get_changed_refs_wrapper, generate_pack_data, progress) |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
399 |
except GitProtocolError as e: |
|
0.200.1335
by Jelmer Vernooij
Move _get_client. |
400 |
raise parse_git_error(self.transport.external_url(), e) |
|
0.405.1
by Jelmer Vernooij
Use same logic for interpreting progress reports everywhere. |
401 |
finally: |
402 |
if pb is not None: |
|
403 |
pb.finished() |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
404 |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
405 |
def create_branch(self, name=None, repository=None, |
406 |
append_revisions_only=None, ref=None): |
|
407 |
refname = self._get_selected_ref(name, ref) |
|
408 |
if refname != b'HEAD' and refname in self.get_refs_container(): |
|
409 |
raise AlreadyBranchError(self.user_url) |
|
410 |
if refname in self.get_refs_container(): |
|
411 |
ref_chain, unused_sha = self.get_refs_container().follow(self._get_selected_ref(None)) |
|
412 |
if ref_chain[0] == b'HEAD': |
|
413 |
refname = ref_chain[1] |
|
414 |
repo = self.open_repository() |
|
415 |
return RemoteGitBranch(self, repo, refname) |
|
416 |
||
|
0.200.1393
by Jelmer Vernooij
Implement removal of remote branches. |
417 |
def destroy_branch(self, name=None): |
418 |
refname = self._get_selected_ref(name) |
|
419 |
def get_changed_refs(old_refs): |
|
420 |
ret = dict(old_refs) |
|
421 |
if not refname in ret: |
|
|
0.200.1395
by Jelmer Vernooij
Fix error reporting. |
422 |
raise NotBranchError(self.user_url) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
423 |
ret[refname] = dulwich.client.ZERO_SHA |
|
0.200.1393
by Jelmer Vernooij
Implement removal of remote branches. |
424 |
return ret |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
425 |
def generate_pack_data(have, want, ofs_delta=False): |
426 |
return pack_objects_to_data([]) |
|
427 |
self.send_pack(get_changed_refs, generate_pack_data) |
|
|
0.200.1393
by Jelmer Vernooij
Implement removal of remote branches. |
428 |
|
|
0.200.1068
by Jelmer Vernooij
Implement user_url/control_url. |
429 |
@property
|
430 |
def user_url(self): |
|
431 |
return self.control_url |
|
432 |
||
|
0.200.1314
by Jelmer Vernooij
Provide RemoteGitDir.user_transport. |
433 |
@property
|
434 |
def user_transport(self): |
|
435 |
return self.root_transport |
|
436 |
||
|
0.200.1395
by Jelmer Vernooij
Fix error reporting. |
437 |
@property
|
438 |
def control_url(self): |
|
439 |
return self.control_transport.base |
|
440 |
||
441 |
@property
|
|
442 |
def control_transport(self): |
|
443 |
return self.root_transport |
|
444 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
445 |
def open_repository(self): |
|
0.200.1415
by Jelmer Vernooij
Fix lock files for remote directories. |
446 |
return RemoteGitRepository(self) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
447 |
|
|
0.200.1310
by Jelmer Vernooij
Add _get_selected_ref method. |
448 |
def open_branch(self, name=None, unsupported=False, |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
449 |
ignore_fallbacks=False, ref=None, possible_transports=None, |
450 |
nascent_ok=False): |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
451 |
repo = self.open_repository() |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
452 |
ref = self._get_selected_ref(name, ref) |
453 |
if not nascent_ok and ref not in self.get_refs_container(): |
|
454 |
raise NotBranchError(self.root_transport.base, |
|
455 |
controldir=self) |
|
456 |
ref_chain, unused_sha = self.get_refs_container().follow(ref) |
|
457 |
return RemoteGitBranch(self, repo, ref_chain[-1]) |
|
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
458 |
|
|
0.200.662
by Jelmer Vernooij
Deal with recommend_upgrade argument to open_workingtree. |
459 |
def open_workingtree(self, recommend_upgrade=False): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
460 |
raise NotLocalUrl(self.transport.base) |
461 |
||
|
0.310.4
by Jelmer Vernooij
Implement RemoteControlDir.has_workingtree. |
462 |
def has_workingtree(self): |
463 |
return False |
|
464 |
||
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
465 |
def get_peeled(self, name): |
466 |
return self.get_refs_container().get_peeled(name) |
|
467 |
||
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
468 |
def get_refs_container(self): |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
469 |
if self._refs is not None: |
470 |
return self._refs |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
471 |
result = self.fetch_pack(lambda x: None, None, |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
472 |
lambda x: None, lambda x: trace.mutter("git: %s" % x)) |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
473 |
self._refs = remote_refs_dict_to_container( |
474 |
result.refs, result.symrefs) |
|
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
475 |
return self._refs |
476 |
||
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
477 |
def push_branch(self, source, revision_id=None, overwrite=False, |
478 |
remember=False, create_prefix=False, lossy=False, |
|
479 |
name=None): |
|
480 |
"""Push the source branch into this ControlDir.""" |
|
481 |
if revision_id is None: |
|
482 |
# No revision supplied by the user, default to the branch
|
|
483 |
# revision
|
|
484 |
revision_id = source.last_revision() |
|
485 |
||
|
0.406.1
by Jelmer Vernooij
Properly lookup revnos for brz-git push result. |
486 |
push_result = GitPushResult() |
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
487 |
push_result.workingtree_updated = None |
488 |
push_result.master_branch = None |
|
489 |
push_result.source_branch = source |
|
490 |
push_result.stacked_on = None |
|
491 |
push_result.branch_push_result = None |
|
492 |
repo = self.find_repository() |
|
493 |
refname = self._get_selected_ref(name) |
|
|
0.407.1
by Jelmer Vernooij
Improve progress reporting. |
494 |
if isinstance(source, GitBranch) and lossy: |
495 |
raise errors.LossyPushToSameVCS(source.controldir, self) |
|
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
496 |
source_store = get_object_store(source.repository) |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
497 |
with source_store.lock_read(): |
498 |
def get_changed_refs(refs): |
|
499 |
self._refs = remote_refs_dict_to_container(refs) |
|
500 |
ret = dict(refs) |
|
501 |
# TODO(jelmer): Unpeel if necessary
|
|
|
0.406.4
by Jelmer Vernooij
Fall back to local branch for revno. |
502 |
push_result.new_original_revid = revision_id |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
503 |
if lossy: |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
504 |
new_sha = source_store._lookup_revision_sha1(revision_id) |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
505 |
else: |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
506 |
new_sha = repo.lookup_bzr_revision_id(revision_id)[0] |
507 |
if not overwrite: |
|
508 |
if remote_divergence(ret.get(refname), new_sha, source_store): |
|
509 |
raise DivergedBranches( |
|
510 |
source, self.open_branch(name, nascent_ok=True)) |
|
511 |
ret[refname] = new_sha |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
512 |
return ret |
513 |
if lossy: |
|
514 |
generate_pack_data = source_store.generate_lossy_pack_data |
|
515 |
else: |
|
516 |
generate_pack_data = source_store.generate_pack_data |
|
517 |
new_refs = self.send_pack(get_changed_refs, generate_pack_data) |
|
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
518 |
push_result.new_revid = repo.lookup_foreign_revision_id( |
519 |
new_refs[refname]) |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
520 |
try: |
521 |
old_remote = self._refs[refname] |
|
522 |
except KeyError: |
|
523 |
old_remote = ZERO_SHA |
|
524 |
push_result.old_revid = repo.lookup_foreign_revision_id(old_remote) |
|
525 |
self._refs = remote_refs_dict_to_container(new_refs) |
|
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
526 |
push_result.target_branch = self.open_branch(name) |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
527 |
if old_remote != ZERO_SHA: |
528 |
push_result.branch_push_result = GitBranchPushResult() |
|
529 |
push_result.branch_push_result.source_branch = source |
|
530 |
push_result.branch_push_result.target_branch = push_result.target_branch |
|
531 |
push_result.branch_push_result.local_branch = None |
|
532 |
push_result.branch_push_result.master_branch = push_result.target_branch |
|
533 |
push_result.branch_push_result.old_revid = push_result.old_revid |
|
534 |
push_result.branch_push_result.new_revid = push_result.new_revid |
|
|
0.406.4
by Jelmer Vernooij
Fall back to local branch for revno. |
535 |
push_result.branch_push_result.new_original_revid = push_result.new_original_revid |
|
0.401.4
by Jelmer Vernooij
Implement RemoteGitDir.push_branch. |
536 |
if source.get_push_location() is None or remember: |
537 |
source.set_push_location(push_result.target_branch.base) |
|
538 |
return push_result |
|
539 |
||
|
0.409.1
by Jelmer Vernooij
Don't probe for commondir over remote transport. |
540 |
def _find_commondir(self): |
541 |
# There is no way to find the commondir, if there is any.
|
|
542 |
return self |
|
543 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
544 |
|
|
0.225.2
by Jelmer Vernooij
Handle situation when repository is already up to date during pull. |
545 |
class EmptyObjectStoreIterator(dict): |
546 |
||
547 |
def iterobjects(self): |
|
548 |
return [] |
|
549 |
||
550 |
||
|
0.200.218
by Jelmer Vernooij
Simplify TemporaryPack implementation. |
551 |
class TemporaryPackIterator(Pack): |
552 |
||
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
553 |
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. |
554 |
super(TemporaryPackIterator, self).__init__( |
555 |
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. |
556 |
self._idx_load = lambda: self._idx_load_or_generate(self._idx_path) |
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
557 |
|
|
0.278.2
by William Grant
Also override _idx_load rather than index, to be a bit cleaner. |
558 |
def _idx_load_or_generate(self, path): |
559 |
if not os.path.exists(path): |
|
560 |
pb = ui.ui_factory.nested_progress_bar() |
|
561 |
try: |
|
562 |
def report_progress(cur, total): |
|
563 |
pb.update("generating index", cur, total) |
|
564 |
self.data.create_index(path, |
|
565 |
progress=report_progress) |
|
566 |
finally: |
|
567 |
pb.finished() |
|
568 |
return load_pack_index(path) |
|
|
0.200.205
by Jelmer Vernooij
Fix remote fetching. |
569 |
|
570 |
def __del__(self): |
|
|
0.200.611
by Jelmer Vernooij
Merge warning fix from Naoki. |
571 |
if self._idx is not None: |
|
0.241.1
by Naoki INADA
Fix can't delete tempfile on Windows |
572 |
self._idx.close() |
573 |
os.remove(self._idx_path) |
|
|
0.200.611
by Jelmer Vernooij
Merge warning fix from Naoki. |
574 |
if self._data is not None: |
|
0.241.1
by Naoki INADA
Fix can't delete tempfile on Windows |
575 |
self._data.close() |
576 |
os.remove(self._data_path) |
|
|
0.200.205
by Jelmer Vernooij
Fix remote fetching. |
577 |
|
578 |
||
|
0.200.1337
by Jelmer Vernooij
Re-use http connection if possible. |
579 |
class BzrGitHttpClient(dulwich.client.HttpGitClient): |
580 |
||
581 |
def __init__(self, transport, *args, **kwargs): |
|
582 |
self.transport = transport |
|
583 |
super(BzrGitHttpClient, self).__init__(transport.external_url(), *args, **kwargs) |
|
|
0.409.2
by Jelmer Vernooij
call out to HTTP transport rather than creating new connection. |
584 |
|
585 |
def _http_request(self, url, headers=None, data=None, |
|
586 |
allow_compression=False): |
|
587 |
"""Perform HTTP request. |
|
588 |
||
589 |
:param url: Request URL.
|
|
590 |
:param headers: Optional custom headers to override defaults.
|
|
591 |
:param data: Request data.
|
|
592 |
:param allow_compression: Allow GZipped communication.
|
|
593 |
:return: Tuple (`response`, `read`), where response is an `urllib3`
|
|
594 |
response object with additional `content_type` and
|
|
595 |
`redirect_location` properties, and `read` is a consumable read
|
|
596 |
method for the response data.
|
|
597 |
"""
|
|
598 |
from breezy.transport.http._urllib2_wrappers import Request |
|
599 |
headers['User-agent'] = user_agent_for_github() |
|
600 |
headers["Pragma"] = "no-cache" |
|
601 |
if allow_compression: |
|
602 |
headers["Accept-Encoding"] = "gzip" |
|
603 |
else: |
|
604 |
headers["Accept-Encoding"] = "identity" |
|
605 |
||
606 |
request = Request( |
|
607 |
('GET' if data is None else 'POST'), |
|
608 |
url, data, headers, |
|
609 |
accepted_errors=[200, 404]) |
|
610 |
||
611 |
response = self.transport._perform(request) |
|
612 |
||
613 |
if response.code == 404: |
|
614 |
raise NotGitRepository() |
|
615 |
elif response.code != 200: |
|
616 |
raise GitProtocolError("unexpected http resp %d for %s" % |
|
617 |
(response.code, url)) |
|
618 |
||
619 |
# TODO: Optimization available by adding `preload_content=False` to the
|
|
620 |
# request and just passing the `read` method on instead of going via
|
|
621 |
# `BytesIO`, if we can guarantee that the entire response is consumed
|
|
622 |
# before issuing the next to still allow for connection reuse from the
|
|
623 |
# pool.
|
|
624 |
if response.getheader("Content-Encoding") == "gzip": |
|
625 |
read = gzip.GzipFile(fileobj=response).read |
|
626 |
else: |
|
627 |
read = response.read |
|
628 |
||
629 |
class WrapResponse(object): |
|
630 |
||
631 |
def __init__(self, response): |
|
632 |
self._response = response |
|
633 |
self.status = response.code |
|
634 |
self.content_type = response.getheader("Content-Type") |
|
635 |
self.redirect_location = response.geturl() |
|
636 |
||
637 |
def close(self): |
|
638 |
self._response.close() |
|
639 |
||
640 |
return WrapResponse(response), read |
|
|
0.200.1337
by Jelmer Vernooij
Re-use http connection if possible. |
641 |
|
642 |
||
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
643 |
class RemoteGitControlDirFormat(GitControlDirFormat): |
644 |
"""The .git directory control format.""" |
|
645 |
||
646 |
supports_workingtrees = False |
|
647 |
||
648 |
@classmethod
|
|
649 |
def _known_formats(self): |
|
650 |
return set([RemoteGitControlDirFormat()]) |
|
651 |
||
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
652 |
def get_branch_format(self): |
653 |
return RemoteGitBranchFormat() |
|
654 |
||
|
0.200.1413
by Jelmer Vernooij
Fix is_initializable() |
655 |
def is_initializable(self): |
656 |
return False |
|
657 |
||
658 |
def is_supported(self): |
|
659 |
return True |
|
660 |
||
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
661 |
def open(self, transport, _found=None): |
662 |
"""Open this directory. |
|
663 |
||
664 |
"""
|
|
665 |
# we dont grok readonly - git isn't integrated with transport.
|
|
666 |
url = transport.base |
|
667 |
if url.startswith('readonly+'): |
|
668 |
url = url[len('readonly+'):] |
|
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
669 |
scheme = urlparse.urlsplit(transport.external_url())[0] |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
670 |
if isinstance(transport, GitSmartTransport): |
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
671 |
client = transport._get_client() |
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
672 |
client_path = transport._get_path() |
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
673 |
elif scheme in ("http", "https"): |
674 |
client = BzrGitHttpClient(transport) |
|
|
0.200.1555
by Jelmer Vernooij
Remove segment parameters for http smart transports. |
675 |
client_path, _ = urlutils.split_segment_parameters(transport._path) |
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
676 |
elif scheme == 'file': |
677 |
client = dulwich.client.LocalGitClient() |
|
678 |
client_path = transport.local_abspath('.') |
|
|
0.200.1336
by Jelmer Vernooij
Support the git smart server http protocol. |
679 |
else: |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
680 |
raise NotBranchError(transport.base) |
|
0.344.1
by Jelmer Vernooij
Allow using local git executable by accessing git:///some/path. |
681 |
if not _found: |
682 |
pass # TODO(jelmer): Actually probe for something |
|
683 |
return RemoteGitDir(transport, self, client, client_path) |
|
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
684 |
|
685 |
def get_format_description(self): |
|
686 |
return "Remote Git Repository" |
|
687 |
||
688 |
def initialize_on_transport(self, transport): |
|
689 |
raise UninitializableFormat(self) |
|
690 |
||
|
0.200.1412
by Jelmer Vernooij
Implement GitControlDirFormat.supports_transport. |
691 |
def supports_transport(self, transport): |
692 |
try: |
|
693 |
external_url = transport.external_url() |
|
694 |
except InProcessTransport: |
|
695 |
raise NotBranchError(path=transport.base) |
|
696 |
return (external_url.startswith("http:") or |
|
697 |
external_url.startswith("https:") or |
|
698 |
external_url.startswith("git+") or |
|
699 |
external_url.startswith("git:")) |
|
700 |
||
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
701 |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
702 |
class RemoteGitRepository(GitRepository): |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
703 |
|
|
0.200.319
by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server. |
704 |
@property
|
|
0.200.1068
by Jelmer Vernooij
Implement user_url/control_url. |
705 |
def user_url(self): |
706 |
return self.control_url |
|
707 |
||
|
0.200.1288
by Jelmer Vernooij
Properly raise GitRemoteNotSupported from RemoteGitRepository. |
708 |
def get_parent_map(self, revids): |
|
0.200.1398
by Jelmer Vernooij
Make GitSmartRemoteNotSupported derive from UnsupportedOperation. |
709 |
raise GitSmartRemoteNotSupported(self.get_parent_map, self) |
|
0.200.319
by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server. |
710 |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
711 |
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. |
712 |
progress=None): |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
713 |
return self.controldir.fetch_pack(determine_wants, graph_walker, |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
714 |
pack_data, progress) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
715 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
716 |
def send_pack(self, get_changed_refs, generate_pack_data): |
717 |
return self.controldir.send_pack(get_changed_refs, generate_pack_data) |
|
|
0.200.427
by Jelmer Vernooij
make send_pack accessible. |
718 |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
719 |
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref, |
720 |
progress=None): |
|
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
721 |
fd, path = tempfile.mkstemp(suffix=".pack") |
|
0.200.1299
by Jelmer Vernooij
Make sure file gets closed. |
722 |
try: |
723 |
self.fetch_pack(determine_wants, graph_walker, |
|
724 |
lambda x: os.write(fd, x), progress) |
|
725 |
finally: |
|
726 |
os.close(fd) |
|
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
727 |
if os.path.getsize(path) == 0: |
|
0.225.2
by Jelmer Vernooij
Handle situation when repository is already up to date during pull. |
728 |
return EmptyObjectStoreIterator() |
|
0.200.226
by Jelmer Vernooij
Merge thin-pack work. |
729 |
return TemporaryPackIterator(path[:-len(".pack")], resolve_ext_ref) |
|
0.200.167
by Jelmer Vernooij
Implement fetch_objects properly. |
730 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
731 |
def lookup_bzr_revision_id(self, bzr_revid, mapping=None): |
|
0.200.415
by Jelmer Vernooij
make 'bzr pull --revision' work for remote repositories. |
732 |
# This won't work for any round-tripped bzr revisions, but it's a start..
|
733 |
try: |
|
734 |
return mapping_registry.revision_id_bzr_to_foreign(bzr_revid) |
|
735 |
except InvalidRevisionId: |
|
736 |
raise NoSuchRevision(self, bzr_revid) |
|
737 |
||
|
0.252.48
by Jelmer Vernooij
Implement lookup_foreign_revision for remote branches. |
738 |
def lookup_foreign_revision_id(self, foreign_revid, mapping=None): |
739 |
"""Lookup a revision id. |
|
740 |
||
741 |
"""
|
|
742 |
if mapping is None: |
|
743 |
mapping = self.get_mapping() |
|
744 |
# Not really an easy way to parse foreign revids here..
|
|
745 |
return mapping.revision_id_foreign_to_bzr(foreign_revid) |
|
746 |
||
|
0.200.1446
by Jelmer Vernooij
Add stub for RemoteGitRepository.revision_tree. |
747 |
def revision_tree(self, revid): |
748 |
raise GitSmartRemoteNotSupported(self.revision_tree, self) |
|
749 |
||
|
0.200.1481
by Jelmer Vernooij
'Implement' RemoteGitRepository.get_revisions. |
750 |
def get_revisions(self, revids): |
751 |
raise GitSmartRemoteNotSupported(self.get_revisions, self) |
|
752 |
||
|
0.200.1557
by Jelmer Vernooij
Implement RemoteGitRepository.has_revisions. |
753 |
def has_revisions(self, revids): |
754 |
raise GitSmartRemoteNotSupported(self.get_revisions, self) |
|
755 |
||
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
756 |
|
|
0.200.1064
by Jelmer Vernooij
Use common base class for tags. |
757 |
class RemoteGitTagDict(GitTags): |
|
0.228.3
by Jelmer Vernooij
Fix tags when fetching from remotes. |
758 |
|
759 |
def set_tag(self, name, revid): |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
760 |
sha = self.branch.lookup_bzr_revision_id(revid)[0] |
761 |
self._set_ref(name, sha) |
|
762 |
||
763 |
def delete_tag(self, name): |
|
764 |
self._set_ref(name, dulwich.client.ZERO_SHA) |
|
765 |
||
766 |
def _set_ref(self, name, sha): |
|
767 |
ref = tag_name_to_ref(name) |
|
768 |
def get_changed_refs(old_refs): |
|
769 |
ret = dict(old_refs) |
|
770 |
if sha == dulwich.client.ZERO_SHA and ref not in ret: |
|
771 |
raise NoSuchTag(name) |
|
772 |
ret[ref] = sha |
|
773 |
return ret |
|
774 |
def generate_pack_data(have, want, ofs_delta=False): |
|
775 |
return pack_objects_to_data([]) |
|
776 |
self.repository.send_pack(get_changed_refs, generate_pack_data) |
|
|
0.228.3
by Jelmer Vernooij
Fix tags when fetching from remotes. |
777 |
|
778 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
779 |
class RemoteGitBranch(GitBranch): |
780 |
||
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
781 |
def __init__(self, controldir, repository, name): |
|
0.200.919
by Jelmer Vernooij
Simplify ref handling in remote.py. |
782 |
self._sha = None |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
783 |
super(RemoteGitBranch, self).__init__(controldir, repository, name, |
784 |
RemoteGitBranchFormat()) |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
785 |
|
|
0.200.1317
by Jelmer Vernooij
Avoid NotImplementedError. |
786 |
def last_revision_info(self): |
|
0.200.1398
by Jelmer Vernooij
Make GitSmartRemoteNotSupported derive from UnsupportedOperation. |
787 |
raise GitSmartRemoteNotSupported(self.last_revision_info, self) |
|
0.200.1317
by Jelmer Vernooij
Avoid NotImplementedError. |
788 |
|
|
0.200.1068
by Jelmer Vernooij
Implement user_url/control_url. |
789 |
@property
|
790 |
def user_url(self): |
|
791 |
return self.control_url |
|
792 |
||
793 |
@property
|
|
794 |
def control_url(self): |
|
795 |
return self.base |
|
796 |
||
|
0.200.1436
by Jelmer Vernooij
Raise UnsupportedOperation for `Branch.revision_id_to_dotted_revno`, |
797 |
def revision_id_to_revno(self, revision_id): |
798 |
raise GitSmartRemoteNotSupported(self.revision_id_to_revno, self) |
|
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
799 |
|
800 |
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. |
801 |
return self.lookup_foreign_revision_id(self.head) |
|
0.200.461
by Jelmer Vernooij
Reduce number of round trips when fetching from Git. |
802 |
|
803 |
@property
|
|
804 |
def head(self): |
|
|
0.200.919
by Jelmer Vernooij
Simplify ref handling in remote.py. |
805 |
if self._sha is not None: |
806 |
return self._sha |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
807 |
refs = self.controldir.get_refs_container() |
|
0.200.1561
by Jelmer Vernooij
Some fixes for colocated branch handling. |
808 |
name = branch_name_to_ref(self.name) |
|
0.200.1386
by Jelmer Vernooij
Friendlier message if HEAD is not found. |
809 |
try: |
810 |
self._sha = refs[name] |
|
811 |
except KeyError: |
|
812 |
raise NoSuchRef(name, self.repository.user_url, refs) |
|
|
0.200.919
by Jelmer Vernooij
Simplify ref handling in remote.py. |
813 |
return self._sha |
|
0.200.141
by Jelmer Vernooij
Separate out local and remote fetching. |
814 |
|
|
0.200.169
by Jelmer Vernooij
Fix branch cloning. |
815 |
def _synchronize_history(self, destination, revision_id): |
816 |
"""See Branch._synchronize_history().""" |
|
817 |
destination.generate_revision_history(self.last_revision()) |
|
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
818 |
|
|
0.289.1
by Jelmer Vernooij
No parent location for remote repos. |
819 |
def _get_parent_location(self): |
820 |
return None |
|
821 |
||
|
0.200.499
by Jelmer Vernooij
Implement RemoteBranch.{get,set}_push_location. |
822 |
def get_push_location(self): |
823 |
return None |
|
824 |
||
825 |
def set_push_location(self, url): |
|
826 |
pass
|
|
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
827 |
|
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
828 |
def _iter_tag_refs(self): |
829 |
"""Iterate over the tag refs. |
|
830 |
||
831 |
:param refs: Refs dictionary (name -> git sha1)
|
|
832 |
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
|
|
833 |
"""
|
|
834 |
refs = self.controldir.get_refs_container() |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
835 |
for ref_name, unpeeled in refs.as_dict().items(): |
|
0.375.1
by Jelmer Vernooij
Fix remote tests, warn when fetching git->bzr and bzr->git. |
836 |
try: |
837 |
tag_name = ref_to_tag_name(ref_name) |
|
838 |
except (ValueError, UnicodeDecodeError): |
|
839 |
continue
|
|
840 |
peeled = refs.get_peeled(ref_name) |
|
841 |
if peeled is None: |
|
842 |
try: |
|
843 |
peeled = refs.peel_sha(unpeeled).id |
|
844 |
except KeyError: |
|
845 |
# Let's just hope it's a commit
|
|
846 |
peeled = unpeeled |
|
847 |
if type(tag_name) is not unicode: |
|
848 |
raise TypeError(tag_name) |
|
849 |
yield (ref_name, tag_name, peeled, unpeeled) |
|
850 |
||
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
851 |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
852 |
def remote_refs_dict_to_container(refs_dict, symrefs_dict={}): |
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
853 |
base = {} |
854 |
peeled = {} |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
855 |
for k, v in refs_dict.items(): |
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
856 |
if is_peeled(k): |
857 |
peeled[k[:-3]] = v |
|
858 |
else: |
|
859 |
base[k] = v |
|
860 |
peeled[k] = v |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
861 |
for name, target in symrefs_dict.items(): |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
862 |
base[name] = SYMREF + target |
|
0.200.1488
by Jelmer Vernooij
Factor out remote_refs_dict_to_container. |
863 |
ret = DictRefsContainer(base) |
864 |
ret._peeled = peeled |
|
865 |
return ret |