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