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