bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
1 |
# Copyright (C) 2007 Canonical Ltd
|
|
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
2 |
# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
18 |
"""An adapter between a Git Repository and a Bazaar Branch"""
|
|
19 |
||
20 |
from bzrlib import ( |
|
|
0.200.1244
by Jelmer Vernooij
Implement GitRepository.check. |
21 |
check, |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
22 |
errors, |
|
0.200.1281
by Jelmer Vernooij
Provide Repository.get_known_graph_ancestry. |
23 |
graph as _mod_graph, |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
24 |
inventory, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
25 |
repository, |
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
26 |
revision, |
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
27 |
transactions, |
|
0.200.1427
by Jelmer Vernooij
fix 2.3 and 2.4 compatibility. |
28 |
version_info as bzrlib_version, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
29 |
)
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
30 |
from bzrlib.decorators import only_raises |
|
0.200.1186
by Jelmer Vernooij
Cope with InventoryRevisionTree. |
31 |
try: |
32 |
from bzrlib.revisiontree import InventoryRevisionTree |
|
33 |
except ImportError: # bzr < 2.4 |
|
34 |
from bzrlib.revisiontree import RevisionTree as InventoryRevisionTree |
|
|
0.200.115
by Jelmer Vernooij
Pass mapping object. |
35 |
from bzrlib.foreign import ( |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
36 |
ForeignRepository, |
37 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
38 |
|
|
0.200.387
by Jelmer Vernooij
Initial work on supporting commit in git trees. |
39 |
from bzrlib.plugins.git.commit import ( |
40 |
GitCommitBuilder, |
|
41 |
)
|
|
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
42 |
from bzrlib.plugins.git.errors import ( |
43 |
NotCommitError, |
|
44 |
)
|
|
|
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
45 |
from bzrlib.plugins.git.filegraph import ( |
46 |
GitFileLastChangeScanner, |
|
47 |
GitFileParentProvider, |
|
48 |
)
|
|
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
49 |
from bzrlib.plugins.git.mapping import ( |
50 |
default_mapping, |
|
|
0.200.1263
by Jelmer Vernooij
Fix foreign_vcs_git. |
51 |
foreign_vcs_git, |
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
52 |
mapping_registry, |
53 |
)
|
|
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
54 |
from bzrlib.plugins.git.tree import ( |
55 |
GitRevisionTree, |
|
56 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
57 |
|
58 |
||
|
0.252.21
by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions. |
59 |
from dulwich.objects import ( |
60 |
Commit, |
|
|
0.200.1080
by Jelmer Vernooij
Fix handling of annotated tags when cloning from local repo. |
61 |
Tag, |
|
0.200.1153
by Jelmer Vernooij
Import ZERO_SHA from dulwich.objects. |
62 |
ZERO_SHA, |
|
0.252.21
by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions. |
63 |
)
|
|
0.200.1233
by Jelmer Vernooij
Implement Repository.iter_files_bytes. |
64 |
from dulwich.object_store import ( |
65 |
tree_lookup_path, |
|
66 |
)
|
|
|
0.252.21
by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions. |
67 |
|
68 |
||
|
0.200.1246
by Jelmer Vernooij
Provide GitRepository.reconcile. |
69 |
class RepoReconciler(object): |
70 |
"""Reconciler that reconciles a repository. |
|
71 |
||
72 |
"""
|
|
73 |
||
74 |
def __init__(self, repo, other=None, thorough=False): |
|
75 |
"""Construct a RepoReconciler. |
|
76 |
||
77 |
:param thorough: perform a thorough check which may take longer but
|
|
78 |
will correct non-data loss issues such as incorrect
|
|
79 |
cached data.
|
|
80 |
"""
|
|
81 |
self.repo = repo |
|
82 |
||
83 |
def reconcile(self): |
|
84 |
"""Perform reconciliation. |
|
85 |
||
86 |
After reconciliation the following attributes document found issues:
|
|
87 |
inconsistent_parents: The number of revisions in the repository whose
|
|
88 |
ancestry was being reported incorrectly.
|
|
89 |
garbage_inventories: The number of inventory objects without revisions
|
|
90 |
that were garbage collected.
|
|
91 |
"""
|
|
92 |
||
93 |
||
|
0.200.1244
by Jelmer Vernooij
Implement GitRepository.check. |
94 |
class GitCheck(check.Check): |
95 |
||
96 |
def __init__(self, repository, check_repo=True): |
|
97 |
self.repository = repository |
|
98 |
self.checked_rev_cnt = 0 |
|
99 |
||
100 |
def check(self, callback_refs=None, check_repo=True): |
|
101 |
if callback_refs is None: |
|
102 |
callback_refs = {} |
|
103 |
self.repository.lock_read() |
|
104 |
self.repository.unlock() |
|
105 |
||
106 |
def report_results(self, verbose): |
|
107 |
pass
|
|
108 |
||
109 |
||
|
0.200.1447
by Jelmer Vernooij
Load optimisers at most once. |
110 |
_optimisers_loaded = False |
111 |
||
112 |
def lazy_load_optimisers(): |
|
113 |
global _optimisers_loaded |
|
114 |
if _optimisers_loaded: |
|
115 |
return
|
|
116 |
from bzrlib.plugins.git import fetch, push |
|
117 |
for optimiser in [fetch.InterRemoteGitNonGitRepository, |
|
118 |
fetch.InterLocalGitNonGitRepository, |
|
119 |
fetch.InterGitGitRepository, |
|
120 |
push.InterToLocalGitRepository, |
|
121 |
push.InterToRemoteGitRepository]: |
|
122 |
repository.InterRepository.register_optimiser(optimiser) |
|
123 |
_optimisers_loaded = True |
|
124 |
||
125 |
||
|
0.200.115
by Jelmer Vernooij
Pass mapping object. |
126 |
class GitRepository(ForeignRepository): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
127 |
"""An adapter to git repositories for bzr.""" |
128 |
||
|
0.200.41
by David Allouche
Define _serializer = None in GitRepository. |
129 |
_serializer = None |
|
0.200.1263
by Jelmer Vernooij
Fix foreign_vcs_git. |
130 |
vcs = foreign_vcs_git |
|
0.200.1086
by Jelmer Vernooij
Provide chk_bytes attribute. |
131 |
chk_bytes = None |
|
0.200.41
by David Allouche
Define _serializer = None in GitRepository. |
132 |
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
133 |
def __init__(self, gitdir): |
|
0.200.1427
by Jelmer Vernooij
fix 2.3 and 2.4 compatibility. |
134 |
if bzrlib_version >= (2, 5): |
135 |
control_files = None |
|
136 |
else: |
|
137 |
class DummyControlFiles(object): |
|
138 |
def __init__(self): |
|
139 |
self._transport = gitdir.root_transport |
|
140 |
control_files = DummyControlFiles() |
|
|
0.200.1447
by Jelmer Vernooij
Load optimisers at most once. |
141 |
self._transport = gitdir.root_transport |
|
0.200.1307
by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions. |
142 |
super(GitRepository, self).__init__(GitRepositoryFormat(), |
|
0.200.1427
by Jelmer Vernooij
fix 2.3 and 2.4 compatibility. |
143 |
gitdir, control_files) |
|
0.200.1449
by Jelmer Vernooij
Fix compatibility with bzr < 2.5 when used with remote repositories. |
144 |
self.base = gitdir.root_transport.base |
|
0.200.1447
by Jelmer Vernooij
Load optimisers at most once. |
145 |
lazy_load_optimisers() |
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
146 |
self._lock_mode = None |
147 |
self._lock_count = 0 |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
148 |
|
|
0.200.1231
by Jelmer Vernooij
Implement GitRepository.add_fallback_repository. |
149 |
def add_fallback_repository(self, basis_url): |
|
0.200.1307
by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions. |
150 |
raise errors.UnstackableRepositoryFormat(self._format, |
151 |
self.control_transport.base) |
|
|
0.200.1231
by Jelmer Vernooij
Implement GitRepository.add_fallback_repository. |
152 |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
153 |
def is_shared(self): |
|
0.200.886
by Jelmer Vernooij
Git repositories are not shared. |
154 |
return False |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
155 |
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
156 |
def get_physical_lock_status(self): |
157 |
return False |
|
158 |
||
159 |
def lock_write(self): |
|
160 |
"""See Branch.lock_write().""" |
|
161 |
if self._lock_mode: |
|
162 |
assert self._lock_mode == 'w' |
|
163 |
self._lock_count += 1 |
|
164 |
else: |
|
165 |
self._lock_mode = 'w' |
|
166 |
self._lock_count = 1 |
|
167 |
return GitRepositoryLock(self) |
|
168 |
||
|
0.200.1454
by Jelmer Vernooij
Provide Repository.break_lock. |
169 |
def break_lock(self): |
170 |
raise NotImplementedError(self.break_lock) |
|
171 |
||
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
172 |
def dont_leave_lock_in_place(self): |
173 |
raise NotImplementedError(self.dont_leave_lock_in_place) |
|
174 |
||
175 |
def leave_lock_in_place(self): |
|
176 |
raise NotImplementedError(self.leave_lock_in_place) |
|
177 |
||
178 |
def lock_read(self): |
|
179 |
if self._lock_mode: |
|
180 |
assert self._lock_mode in ('r', 'w') |
|
181 |
self._lock_count += 1 |
|
182 |
else: |
|
183 |
self._lock_mode = 'r' |
|
184 |
self._lock_count = 1 |
|
185 |
return self |
|
186 |
||
187 |
@only_raises(errors.LockNotHeld, errors.LockBroken) |
|
188 |
def unlock(self): |
|
189 |
if self._lock_count == 0: |
|
190 |
raise errors.LockNotHeld(self) |
|
191 |
if self._lock_count == 1 and self._lock_mode == 'w': |
|
192 |
if self._write_group is not None: |
|
193 |
self.abort_write_group() |
|
194 |
self._lock_count -= 1 |
|
195 |
self._lock_mode = None |
|
196 |
raise errors.BzrError( |
|
197 |
'Must end write groups before releasing write locks.') |
|
198 |
self._lock_count -= 1 |
|
199 |
if self._lock_count == 0: |
|
200 |
self._lock_mode = None |
|
201 |
||
202 |
def is_write_locked(self): |
|
203 |
return (self._lock_mode == 'w') |
|
204 |
||
205 |
def is_locked(self): |
|
206 |
return (self._lock_mode is not None) |
|
207 |
||
208 |
def get_transaction(self): |
|
209 |
"""See Repository.get_transaction().""" |
|
210 |
if self._write_group is None: |
|
211 |
return transactions.PassThroughTransaction() |
|
212 |
else: |
|
213 |
return self._write_group |
|
214 |
||
|
0.200.1246
by Jelmer Vernooij
Provide GitRepository.reconcile. |
215 |
def reconcile(self, other=None, thorough=False): |
216 |
"""Reconcile this repository.""" |
|
217 |
reconciler = RepoReconciler(self, thorough=thorough) |
|
218 |
reconciler.reconcile() |
|
219 |
return reconciler |
|
220 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
221 |
def supports_rich_root(self): |
222 |
return True |
|
223 |
||
|
0.200.1111
by Jelmer Vernooij
Drop support for Bazaar < 2.3. |
224 |
def _warn_if_deprecated(self, branch=None): # for bzr < 2.4 |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
225 |
# This class isn't deprecated
|
226 |
pass
|
|
227 |
||
228 |
def get_mapping(self): |
|
229 |
return default_mapping |
|
230 |
||
|
0.200.147
by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though. |
231 |
def make_working_trees(self): |
|
0.200.1033
by Jelmer Vernooij
Don't claim to support working trees for bare repositories. |
232 |
return not self._git.bare |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
233 |
|
|
0.200.557
by Jelmer Vernooij
Implement GitRepository.revision_graph_can_have_wrong_parents(). |
234 |
def revision_graph_can_have_wrong_parents(self): |
235 |
return False |
|
236 |
||
|
0.200.1158
by Jelmer Vernooij
Implement stub Repositor.add_signature_text. |
237 |
def add_signature_text(self, revid, signature): |
238 |
raise errors.UnsupportedOperation(self.add_signature_text, self) |
|
239 |
||
|
0.200.1467
by Jelmer Vernooij
Implement GitRepository.sign_revision. |
240 |
def sign_revision(self, revision_id, gpg_strategy): |
241 |
raise errors.UnsupportedOperation(self.add_signature_text, self) |
|
242 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
243 |
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
244 |
class GitRepositoryLock(object): |
245 |
"""Subversion lock.""" |
|
246 |
||
247 |
def __init__(self, repository): |
|
248 |
self.repository_token = None |
|
249 |
self.repository = repository |
|
250 |
||
251 |
def unlock(self): |
|
252 |
self.repository.unlock() |
|
253 |
||
254 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
255 |
class LocalGitRepository(GitRepository): |
|
0.200.276
by Jelmer Vernooij
Improve formatting. |
256 |
"""Git repository on the file system.""" |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
257 |
|
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
258 |
def __init__(self, gitdir): |
259 |
GitRepository.__init__(self, gitdir) |
|
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
260 |
self._git = gitdir._git |
|
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
261 |
self._file_change_scanner = GitFileLastChangeScanner(self) |
|
0.200.45
by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers. |
262 |
|
|
0.200.1224
by Jelmer Vernooij
provide explicit GitRepository.get_commit_builder. |
263 |
def get_commit_builder(self, branch, parents, config, timestamp=None, |
264 |
timezone=None, committer=None, revprops=None, |
|
265 |
revision_id=None, lossy=False): |
|
266 |
"""Obtain a CommitBuilder for this repository. |
|
267 |
||
268 |
:param branch: Branch to commit to.
|
|
269 |
:param parents: Revision ids of the parents of the new revision.
|
|
270 |
:param config: Configuration to use.
|
|
271 |
:param timestamp: Optional timestamp recorded for commit.
|
|
272 |
:param timezone: Optional timezone for timestamp.
|
|
273 |
:param committer: Optional committer to set for commit.
|
|
274 |
:param revprops: Optional dictionary of revision properties.
|
|
275 |
:param revision_id: Optional revision id.
|
|
276 |
:param lossy: Whether to discard data that can not be natively
|
|
277 |
represented, when pushing to a foreign VCS
|
|
278 |
"""
|
|
|
0.200.1229
by Jelmer Vernooij
Provide CommitBuilder.any_changes. |
279 |
self.start_write_group() |
|
0.200.1224
by Jelmer Vernooij
provide explicit GitRepository.get_commit_builder. |
280 |
return GitCommitBuilder(self, parents, config, |
281 |
timestamp, timezone, committer, revprops, revision_id, |
|
282 |
lossy) |
|
283 |
||
|
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
284 |
def get_file_graph(self): |
|
0.200.1307
by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions. |
285 |
return _mod_graph.Graph(GitFileParentProvider( |
286 |
self._file_change_scanner)) |
|
|
0.200.1283
by Jelmer Vernooij
Provide Repository.get_file_graph() and Tree.get_file_revision(). |
287 |
|
|
0.200.1233
by Jelmer Vernooij
Implement Repository.iter_files_bytes. |
288 |
def iter_files_bytes(self, desired_files): |
289 |
"""Iterate through file versions. |
|
290 |
||
291 |
Files will not necessarily be returned in the order they occur in
|
|
292 |
desired_files. No specific order is guaranteed.
|
|
293 |
||
294 |
Yields pairs of identifier, bytes_iterator. identifier is an opaque
|
|
295 |
value supplied by the caller as part of desired_files. It should
|
|
296 |
uniquely identify the file version in the caller's context. (Examples:
|
|
297 |
an index number or a TreeTransform trans_id.)
|
|
298 |
||
299 |
bytes_iterator is an iterable of bytestrings for the file. The
|
|
300 |
kind of iterable and length of the bytestrings are unspecified, but for
|
|
301 |
this implementation, it is a list of bytes produced by
|
|
302 |
VersionedFile.get_record_stream().
|
|
303 |
||
304 |
:param desired_files: a list of (file_id, revision_id, identifier)
|
|
305 |
triples
|
|
306 |
"""
|
|
307 |
per_revision = {} |
|
308 |
for (file_id, revision_id, identifier) in desired_files: |
|
|
0.200.1307
by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions. |
309 |
per_revision.setdefault(revision_id, []).append( |
310 |
(file_id, identifier)) |
|
|
0.200.1233
by Jelmer Vernooij
Implement Repository.iter_files_bytes. |
311 |
for revid, files in per_revision.iteritems(): |
312 |
(commit_id, mapping) = self.lookup_bzr_revision_id(revid) |
|
313 |
try: |
|
314 |
commit = self._git.object_store[commit_id] |
|
315 |
except KeyError: |
|
316 |
raise errors.RevisionNotPresent(revid, self) |
|
317 |
root_tree = commit.tree |
|
318 |
for fileid, identifier in files: |
|
319 |
path = mapping.parse_file_id(fileid) |
|
320 |
try: |
|
321 |
obj = tree_lookup_path( |
|
322 |
self._git.object_store.__getitem__, root_tree, path) |
|
323 |
if isinstance(obj, tuple): |
|
324 |
(mode, item_id) = obj |
|
325 |
obj = self._git.object_store[item_id] |
|
326 |
except KeyError: |
|
327 |
raise errors.RevisionNotPresent((fileid, revid), self) |
|
328 |
else: |
|
329 |
if obj.type_name == "tree": |
|
330 |
yield (identifier, []) |
|
331 |
elif obj.type_name == "blob": |
|
332 |
yield (identifier, obj.chunked) |
|
333 |
else: |
|
334 |
raise AssertionError("file text resolved to %r" % obj) |
|
335 |
||
|
0.252.46
by Jelmer Vernooij
Generate refs/bzr/* if not set yet. |
336 |
def _iter_revision_ids(self): |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
337 |
mapping = self.get_mapping() |
|
0.252.21
by Jelmer Vernooij
Fix GitRepository.all_revision_ids() to find all revisions. |
338 |
for sha in self._git.object_store: |
339 |
o = self._git.object_store[sha] |
|
340 |
if not isinstance(o, Commit): |
|
341 |
continue
|
|
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
342 |
rev, roundtrip_revid, verifiers = mapping.import_commit(o, |
|
0.261.6
by Jelmer Vernooij
Use mapping.revision_id_foreign_to_bzr to find parents everywhere. |
343 |
mapping.revision_id_foreign_to_bzr) |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
344 |
yield o.id, rev.revision_id, roundtrip_revid |
|
0.252.46
by Jelmer Vernooij
Generate refs/bzr/* if not set yet. |
345 |
|
346 |
def all_revision_ids(self): |
|
347 |
ret = set([]) |
|
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
348 |
for git_sha, revid, roundtrip_revid in self._iter_revision_ids(): |
349 |
if roundtrip_revid: |
|
350 |
ret.add(roundtrip_revid) |
|
|
0.200.1325
by Jelmer Vernooij
More test fixes. |
351 |
else: |
352 |
ret.add(revid) |
|
|
0.200.74
by Jelmer Vernooij
Implement Repository.all_revision_ids(). |
353 |
return ret |
354 |
||
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
355 |
def _get_parents(self, revid): |
356 |
if type(revid) != str: |
|
357 |
raise ValueError |
|
358 |
try: |
|
|
0.200.1343
by Jelmer Vernooij
Update docstrings. |
359 |
(hexsha, mapping) = self.lookup_bzr_revision_id(revid) |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
360 |
except errors.NoSuchRevision: |
361 |
return None |
|
362 |
try: |
|
363 |
commit = self._git[hexsha] |
|
364 |
except KeyError: |
|
365 |
return None |
|
366 |
return [ |
|
367 |
self.lookup_foreign_revision_id(p, mapping) |
|
368 |
for p in commit.parents] |
|
369 |
||
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
370 |
def get_parent_map(self, revids): |
371 |
parent_map = {} |
|
372 |
for revision_id in revids: |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
373 |
parents = self._get_parents(revision_id) |
|
0.200.1329
by Jelmer Vernooij
Fix more tests. |
374 |
if revision_id == revision.NULL_REVISION: |
375 |
parent_map[revision_id] = () |
|
376 |
continue
|
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
377 |
if parents is None: |
378 |
continue
|
|
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
379 |
if len(parents) == 0: |
|
0.200.1094
by Jelmer Vernooij
Fix test_get_no_parents. |
380 |
parents = [revision.NULL_REVISION] |
381 |
parent_map[revision_id] = tuple(parents) |
|
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
382 |
return parent_map |
383 |
||
|
0.200.1281
by Jelmer Vernooij
Provide Repository.get_known_graph_ancestry. |
384 |
def get_known_graph_ancestry(self, revision_ids): |
385 |
"""Return the known graph for a set of revision ids and their ancestors. |
|
386 |
"""
|
|
387 |
pending = set(revision_ids) |
|
388 |
parent_map = {} |
|
389 |
while pending: |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
390 |
this_parent_map = {} |
391 |
for revid in pending: |
|
392 |
if revid == revision.NULL_REVISION: |
|
393 |
continue
|
|
394 |
parents = self._get_parents(revid) |
|
395 |
if parents is not None: |
|
396 |
this_parent_map[revid] = parents |
|
|
0.200.1281
by Jelmer Vernooij
Provide Repository.get_known_graph_ancestry. |
397 |
parent_map.update(this_parent_map) |
398 |
pending = set() |
|
399 |
map(pending.update, this_parent_map.itervalues()) |
|
400 |
pending = pending.difference(parent_map) |
|
401 |
return _mod_graph.KnownGraph(parent_map) |
|
402 |
||
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
403 |
def get_signature_text(self, revision_id): |
404 |
raise errors.NoSuchRevision(self, revision_id) |
|
405 |
||
|
0.200.1244
by Jelmer Vernooij
Implement GitRepository.check. |
406 |
def check(self, revision_ids=None, callback_refs=None, check_repo=True): |
407 |
result = GitCheck(self, check_repo=check_repo) |
|
408 |
result.check(callback_refs) |
|
409 |
return result |
|
410 |
||
|
0.257.1
by Jelmer Vernooij
use transport repo objects even for local access. |
411 |
def pack(self, hint=None, clean_obsolete_packs=False): |
412 |
self._git.object_store.pack_loose_objects() |
|
413 |
||
|
0.200.650
by Jelmer Vernooij
Use standard names for lookup functions. |
414 |
def lookup_foreign_revision_id(self, foreign_revid, mapping=None): |
|
0.200.124
by Jelmer Vernooij
Add lookup_revision_id stub. |
415 |
"""Lookup a revision id. |
|
0.200.676
by Jelmer Vernooij
Avoid iterating over all keys in the tdb database. |
416 |
|
|
0.200.124
by Jelmer Vernooij
Add lookup_revision_id stub. |
417 |
"""
|
|
0.200.1033
by Jelmer Vernooij
Don't claim to support working trees for bare repositories. |
418 |
assert type(foreign_revid) is str |
|
0.200.649
by Jelmer Vernooij
Make GitRevisions VF implementation behave as the interface expects. |
419 |
if mapping is None: |
420 |
mapping = self.get_mapping() |
|
|
0.200.914
by Jelmer Vernooij
Fix tests. |
421 |
if foreign_revid == ZERO_SHA: |
422 |
return revision.NULL_REVISION |
|
|
0.200.1268
by Jelmer Vernooij
Look in object store directly when something can't be a ref. |
423 |
commit = self._git.object_store[foreign_revid] |
|
0.200.1080
by Jelmer Vernooij
Fix handling of annotated tags when cloning from local repo. |
424 |
while isinstance(commit, Tag): |
425 |
commit = self._git[commit.object[1]] |
|
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
426 |
if not isinstance(commit, Commit): |
427 |
raise NotCommitError(commit.id) |
|
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
428 |
rev, roundtrip_revid, verifiers = mapping.import_commit(commit, |
|
0.261.6
by Jelmer Vernooij
Use mapping.revision_id_foreign_to_bzr to find parents everywhere. |
429 |
mapping.revision_id_foreign_to_bzr) |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
430 |
# FIXME: check testament before doing this?
|
431 |
if roundtrip_revid: |
|
432 |
return roundtrip_revid |
|
433 |
else: |
|
434 |
return rev.revision_id |
|
|
0.200.124
by Jelmer Vernooij
Add lookup_revision_id stub. |
435 |
|
|
0.200.60
by Jelmer Vernooij
Support signature functions. |
436 |
def has_signature_for_revision_id(self, revision_id): |
|
0.200.1343
by Jelmer Vernooij
Update docstrings. |
437 |
"""Check whether a GPG signature is present for this revision. |
438 |
||
439 |
This is never the case for Git repositories.
|
|
440 |
"""
|
|
|
0.200.60
by Jelmer Vernooij
Support signature functions. |
441 |
return False |
442 |
||
|
0.200.913
by Jelmer Vernooij
Fix tests. |
443 |
def lookup_bzr_revision_id(self, bzr_revid, mapping=None): |
|
0.200.1343
by Jelmer Vernooij
Update docstrings. |
444 |
"""Lookup a bzr revision id in a Git repository. |
445 |
||
446 |
:param bzr_revid: Bazaar revision id
|
|
447 |
:param mapping: Optional mapping to use
|
|
448 |
:return: Tuple with git commit id, mapping that was used and supplement
|
|
449 |
details
|
|
450 |
"""
|
|
|
0.200.105
by Jelmer Vernooij
Add common function for finding git commit by bzr revid. |
451 |
try: |
|
0.200.1343
by Jelmer Vernooij
Update docstrings. |
452 |
(git_sha, mapping) = mapping_registry.revision_id_bzr_to_foreign(bzr_revid) |
|
0.200.105
by Jelmer Vernooij
Add common function for finding git commit by bzr revid. |
453 |
except errors.InvalidRevisionId: |
|
0.200.913
by Jelmer Vernooij
Fix tests. |
454 |
if mapping is None: |
455 |
mapping = self.get_mapping() |
|
|
0.252.6
by Jelmer Vernooij
Roundtripping support for revision ids works. |
456 |
try: |
|
0.200.1307
by Jelmer Vernooij
Formatting fixes, specify path to a couple more functions. |
457 |
return (self._git.refs[mapping.revid_as_refname(bzr_revid)], |
458 |
mapping) |
|
|
0.252.6
by Jelmer Vernooij
Roundtripping support for revision ids works. |
459 |
except KeyError: |
|
0.252.46
by Jelmer Vernooij
Generate refs/bzr/* if not set yet. |
460 |
# Update refs from Git commit objects
|
461 |
# FIXME: Hitting this a lot will be very inefficient...
|
|
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
462 |
for git_sha, revid, roundtrip_revid in self._iter_revision_ids(): |
463 |
if not roundtrip_revid: |
|
464 |
continue
|
|
|
0.200.1022
by Jelmer Vernooij
Fix formatting. |
465 |
refname = mapping.revid_as_refname(roundtrip_revid) |
466 |
self._git.refs[refname] = git_sha |
|
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
467 |
if roundtrip_revid == bzr_revid: |
|
0.200.913
by Jelmer Vernooij
Fix tests. |
468 |
return git_sha, mapping |
469 |
raise errors.NoSuchRevision(self, bzr_revid) |
|
|
0.200.1343
by Jelmer Vernooij
Update docstrings. |
470 |
else: |
471 |
return (git_sha, mapping) |
|
|
0.200.105
by Jelmer Vernooij
Add common function for finding git commit by bzr revid. |
472 |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
473 |
def get_revision(self, revision_id): |
|
0.200.1101
by Jelmer Vernooij
Raise InvalidRevisionId on invalid type being specified to Repository.get_revision. |
474 |
if not isinstance(revision_id, str): |
475 |
raise errors.InvalidRevisionId(revision_id, self) |
|
|
0.200.650
by Jelmer Vernooij
Use standard names for lookup functions. |
476 |
git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id) |
|
0.200.147
by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though. |
477 |
try: |
|
0.200.832
by Jelmer Vernooij
Update to newer version of Dulwich, saner branch names. |
478 |
commit = self._git[git_commit_id] |
|
0.200.147
by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though. |
479 |
except KeyError: |
480 |
raise errors.NoSuchRevision(self, revision_id) |
|
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
481 |
revision, roundtrip_revid, verifiers = mapping.import_commit( |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
482 |
commit, self.lookup_foreign_revision_id) |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
483 |
assert revision is not None |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
484 |
# FIXME: check verifiers ?
|
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
485 |
if roundtrip_revid: |
486 |
revision.revision_id = roundtrip_revid |
|
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
487 |
return revision |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
488 |
|
489 |
def has_revision(self, revision_id): |
|
|
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
490 |
"""See Repository.has_revision.""" |
|
0.200.1122
by Jelmer Vernooij
has_revision(null:) should always return True. |
491 |
if revision_id == revision.NULL_REVISION: |
492 |
return True |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
493 |
try: |
|
0.200.902
by Jelmer Vernooij
Fix Repository.has_revision{s,}. |
494 |
git_commit_id, mapping = self.lookup_bzr_revision_id(revision_id) |
|
0.200.130
by Jelmer Vernooij
Make most tree inspection tests succeed. |
495 |
except errors.NoSuchRevision: |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
496 |
return False |
|
0.200.902
by Jelmer Vernooij
Fix Repository.has_revision{s,}. |
497 |
return (git_commit_id in self._git) |
498 |
||
499 |
def has_revisions(self, revision_ids): |
|
|
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
500 |
"""See Repository.has_revisions.""" |
|
0.200.913
by Jelmer Vernooij
Fix tests. |
501 |
return set(filter(self.has_revision, revision_ids)) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
502 |
|
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
503 |
def get_revisions(self, revids): |
|
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
504 |
"""See Repository.get_revisions.""" |
|
0.200.134
by Jelmer Vernooij
Fix get_revisions(). |
505 |
return [self.get_revision(r) for r in revids] |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
506 |
|
507 |
def revision_trees(self, revids): |
|
|
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
508 |
"""See Repository.revision_trees.""" |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
509 |
for revid in revids: |
510 |
yield self.revision_tree(revid) |
|
511 |
||
512 |
def revision_tree(self, revision_id): |
|
|
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
513 |
"""See Repository.revision_tree.""" |
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
514 |
revision_id = revision.ensure_null(revision_id) |
515 |
if revision_id == revision.NULL_REVISION: |
|
516 |
inv = inventory.Inventory(root_id=None) |
|
517 |
inv.revision_id = revision_id |
|
|
0.200.1186
by Jelmer Vernooij
Cope with InventoryRevisionTree. |
518 |
return InventoryRevisionTree(self, inv, revision_id) |
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
519 |
return GitRevisionTree(self, revision_id) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
520 |
|
521 |
def get_inventory(self, revision_id): |
|
|
0.264.4
by Jelmer Vernooij
No longer implement Repository.get_inventory. |
522 |
raise NotImplementedError(self.get_inventory) |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
523 |
|
|
0.200.108
by Jelmer Vernooij
Support bzr init --git. |
524 |
def set_make_working_trees(self, trees): |
|
0.200.1321
by Jelmer Vernooij
More fixes for compatibility with bzr.dev testsuite. |
525 |
raise errors.UnsupportedOperation(self.set_make_working_trees, self) |
|
0.200.1216
by Jelmer Vernooij
Add note about set_make_working_trees. |
526 |
# TODO: Set bare= in the configuration bug=777065
|
|
0.200.108
by Jelmer Vernooij
Support bzr init --git. |
527 |
|
|
0.200.276
by Jelmer Vernooij
Improve formatting. |
528 |
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref, |
529 |
progress=None): |
|
|
0.200.146
by Jelmer Vernooij
Merge dulwich. |
530 |
return self._git.fetch_objects(determine_wants, graph_walker, progress) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
531 |
|
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
532 |
|
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
533 |
class GitRepositoryFormat(repository.RepositoryFormat): |
|
0.200.429
by Jelmer Vernooij
get remote dpush to a point where we now what to send. |
534 |
"""Git repository format.""" |
|
0.203.1
by Aaron Bentley
Make checkouts work |
535 |
|
|
0.200.1294
by Jelmer Vernooij
Mark as not supporting versioned directories. |
536 |
supports_versioned_directories = False |
|
0.203.1
by Aaron Bentley
Make checkouts work |
537 |
supports_tree_reference = False |
|
0.200.133
by Jelmer Vernooij
Unmark as deprecated. |
538 |
rich_root_data = True |
|
0.200.1105
by Jelmer Vernooij
Don't claim to support leaving locks. |
539 |
supports_leaving_lock = False |
|
0.200.1106
by Jelmer Vernooij
Claim to support fast deltas. |
540 |
fast_deltas = True |
|
0.200.1123
by Jelmer Vernooij
Set more repository format flags. |
541 |
supports_funky_characters = True |
|
0.200.1134
by Jelmer Vernooij
Set RepositoryFormat.supports_external_lookups. |
542 |
supports_external_lookups = False |
|
0.200.1135
by Jelmer Vernooij
Set supports_full_versioned_files=False. |
543 |
supports_full_versioned_files = False |
|
0.200.1162
by Jelmer Vernooij
Set RepositoryFormat.supports_revision_signatures. |
544 |
supports_revision_signatures = False |
|
0.200.1383
by Jelmer Vernooij
Claim to not support nested repositories. |
545 |
supports_nesting_repositories = False |
|
0.200.1166
by Jelmer Vernooij
Set GitRepositoryFormat.revision_graph_can_have_wrong_parents. |
546 |
revision_graph_can_have_wrong_parents = False |
|
0.200.71
by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description. |
547 |
|
|
0.200.1083
by Jelmer Vernooij
Register repository format. |
548 |
@property
|
549 |
def _matchingbzrdir(self): |
|
550 |
from bzrlib.plugins.git.dir import LocalGitControlDirFormat |
|
551 |
return LocalGitControlDirFormat() |
|
552 |
||
|
0.200.71
by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description. |
553 |
def get_format_description(self): |
554 |
return "Git Repository" |
|
|
0.200.133
by Jelmer Vernooij
Unmark as deprecated. |
555 |
|
|
0.200.1084
by Jelmer Vernooij
Support 'initializing' repositories in control directories. |
556 |
def initialize(self, controldir, shared=False, _internal=False): |
557 |
from bzrlib.plugins.git.dir import GitDir |
|
558 |
if not isinstance(controldir, GitDir): |
|
559 |
raise errors.UninitializableFormat(self) |
|
560 |
return controldir.open_repository() |
|
|
0.200.133
by Jelmer Vernooij
Unmark as deprecated. |
561 |
|
562 |
def check_conversion_target(self, target_repo_format): |
|
563 |
return target_repo_format.rich_root_data |
|
|
0.200.536
by Jelmer Vernooij
Implement network name. |
564 |
|
|
0.200.658
by Jelmer Vernooij
Provide right infrastructure for foreign repository tests from bzrlib. |
565 |
def get_foreign_tests_repository_factory(self): |
|
0.200.713
by Jelmer Vernooij
Improve formatting. |
566 |
from bzrlib.plugins.git.tests.test_repository import ( |
567 |
ForeignTestsRepositoryFactory, |
|
568 |
)
|
|
|
0.200.658
by Jelmer Vernooij
Provide right infrastructure for foreign repository tests from bzrlib. |
569 |
return ForeignTestsRepositoryFactory() |
570 |
||
|
0.200.536
by Jelmer Vernooij
Implement network name. |
571 |
def network_name(self): |
572 |
return "git" |