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