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