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 |
||
|
0.200.45
by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers. |
20 |
import bzrlib |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
21 |
from bzrlib import ( |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
22 |
errors, |
|
0.200.132
by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer. |
23 |
graph, |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
24 |
inventory, |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
25 |
osutils, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
26 |
repository, |
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
27 |
revision, |
|
0.200.39
by David Allouche
Black-box text for "bzr log" in a git tree. Further simplification of GitRevisionTree. |
28 |
revisiontree, |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
29 |
)
|
|
0.200.115
by Jelmer Vernooij
Pass mapping object. |
30 |
from bzrlib.foreign import ( |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
31 |
ForeignRepository, |
32 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
33 |
|
|
0.200.387
by Jelmer Vernooij
Initial work on supporting commit in git trees. |
34 |
from bzrlib.plugins.git.commit import ( |
35 |
GitCommitBuilder, |
|
36 |
)
|
|
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
37 |
from bzrlib.plugins.git.mapping import ( |
38 |
default_mapping, |
|
|
0.200.395
by Jelmer Vernooij
Set vcs attribute on GitRepository. |
39 |
foreign_git, |
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
40 |
mapping_registry, |
41 |
)
|
|
|
0.200.617
by Jelmer Vernooij
Add custom InterTree for use between git revision trees. |
42 |
from bzrlib.plugins.git.tree import ( |
43 |
GitRevisionTree, |
|
44 |
InterGitRevisionTrees, |
|
45 |
)
|
|
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
46 |
from bzrlib.plugins.git.versionedfiles import ( |
|
0.200.506
by Jelmer Vernooij
Remove bzr-foreign. |
47 |
GitRevisions, |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
48 |
GitTexts, |
49 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
50 |
|
51 |
||
|
0.200.115
by Jelmer Vernooij
Pass mapping object. |
52 |
class GitRepository(ForeignRepository): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
53 |
"""An adapter to git repositories for bzr.""" |
54 |
||
|
0.200.41
by David Allouche
Define _serializer = None in GitRepository. |
55 |
_serializer = None |
|
0.200.387
by Jelmer Vernooij
Initial work on supporting commit in git trees. |
56 |
_commit_builder_class = GitCommitBuilder |
|
0.200.395
by Jelmer Vernooij
Set vcs attribute on GitRepository. |
57 |
vcs = foreign_git |
|
0.200.41
by David Allouche
Define _serializer = None in GitRepository. |
58 |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
59 |
def __init__(self, gitdir, lockfiles): |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
60 |
ForeignRepository.__init__(self, GitRepositoryFormat(), gitdir, |
61 |
lockfiles) |
|
|
0.200.291
by Jelmer Vernooij
Print proper error about not supporting push. |
62 |
from bzrlib.plugins.git import fetch, push |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
63 |
for optimiser in [fetch.InterRemoteGitNonGitRepository, |
64 |
fetch.InterLocalGitNonGitRepository, |
|
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
65 |
fetch.InterGitGitRepository, |
|
0.200.425
by Jelmer Vernooij
Split out push to remote git repositories. |
66 |
push.InterToLocalGitRepository, |
67 |
push.InterToRemoteGitRepository]: |
|
|
0.200.276
by Jelmer Vernooij
Improve formatting. |
68 |
repository.InterRepository.register_optimiser(optimiser) |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
69 |
|
70 |
def is_shared(self): |
|
71 |
return True |
|
72 |
||
73 |
def supports_rich_root(self): |
|
74 |
return True |
|
75 |
||
76 |
def _warn_if_deprecated(self): |
|
77 |
# This class isn't deprecated
|
|
78 |
pass
|
|
79 |
||
80 |
def get_mapping(self): |
|
81 |
return default_mapping |
|
82 |
||
|
0.200.147
by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though. |
83 |
def make_working_trees(self): |
84 |
return True |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
85 |
|
|
0.200.557
by Jelmer Vernooij
Implement GitRepository.revision_graph_can_have_wrong_parents(). |
86 |
def revision_graph_can_have_wrong_parents(self): |
87 |
return False |
|
88 |
||
|
0.200.425
by Jelmer Vernooij
Split out push to remote git repositories. |
89 |
def dfetch(self, source, stop_revision): |
90 |
interrepo = repository.InterRepository.get(source, self) |
|
91 |
return interrepo.dfetch(stop_revision) |
|
92 |
||
|
0.200.428
by Jelmer Vernooij
use dfetch_refs, to prepare for dpush to remote repositories. |
93 |
def dfetch_refs(self, source, stop_revision): |
94 |
interrepo = repository.InterRepository.get(source, self) |
|
95 |
return interrepo.dfetch_refs(stop_revision) |
|
96 |
||
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
97 |
|
98 |
class LocalGitRepository(GitRepository): |
|
|
0.200.276
by Jelmer Vernooij
Improve formatting. |
99 |
"""Git repository on the file system.""" |
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
100 |
|
101 |
def __init__(self, gitdir, lockfiles): |
|
|
0.200.132
by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer. |
102 |
# FIXME: This also caches negatives. Need to be more careful
|
103 |
# about this once we start writing to git
|
|
104 |
self._parents_provider = graph.CachingParentsProvider(self) |
|
|
0.200.139
by Jelmer Vernooij
Share more code between local and remote classes, support opening remote branches. |
105 |
GitRepository.__init__(self, gitdir, lockfiles) |
|
0.200.61
by Jelmer Vernooij
Fix tests. |
106 |
self.base = gitdir.root_transport.base |
|
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
107 |
self._git = gitdir._git |
|
0.200.56
by Jelmer Vernooij
Switch to using GitPython rather than our own in-house stuff. |
108 |
self.texts = None |
|
0.200.506
by Jelmer Vernooij
Remove bzr-foreign. |
109 |
self.signatures = None |
110 |
self.revisions = GitRevisions(self._git.object_store) |
|
111 |
self.inventories = None |
|
|
0.200.209
by Jelmer Vernooij
Pass repository object to versionedfiles. |
112 |
self.texts = GitTexts(self) |
|
0.200.45
by David Allouche
More performance hacking, introduce sqlite cache, escape characters in commits that break serializers. |
113 |
|
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
114 |
def all_revision_ids(self): |
115 |
ret = set([revision.NULL_REVISION]) |
|
|
0.200.480
by Jelmer Vernooij
Cope with API changes in Dulwich. |
116 |
heads = self._git.refs.as_dict('refs/heads') |
|
0.200.254
by Jelmer Vernooij
Fix tests. |
117 |
if heads == {}: |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
118 |
return ret |
|
0.200.254
by Jelmer Vernooij
Fix tests. |
119 |
bzr_heads = [self.get_mapping().revision_id_foreign_to_bzr(h) for h in heads.itervalues()] |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
120 |
ret = set(bzr_heads) |
121 |
graph = self.get_graph() |
|
122 |
for rev, parents in graph.iter_ancestry(bzr_heads): |
|
123 |
ret.add(rev) |
|
|
0.200.74
by Jelmer Vernooij
Implement Repository.all_revision_ids(). |
124 |
return ret |
125 |
||
|
0.200.132
by Jelmer Vernooij
Use parents cache, don't set author revision property if it's equal to committer. |
126 |
def _make_parents_provider(self): |
127 |
"""See Repository._make_parents_provider().""" |
|
128 |
return self._parents_provider |
|
129 |
||
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
130 |
def get_parent_map(self, revids): |
131 |
parent_map = {} |
|
132 |
for revision_id in revids: |
|
133 |
assert isinstance(revision_id, str) |
|
134 |
if revision_id == revision.NULL_REVISION: |
|
135 |
parent_map[revision_id] = () |
|
136 |
continue
|
|
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
137 |
hexsha, mapping = self.lookup_git_revid(revision_id) |
|
0.200.612
by Jelmer Vernooij
Cope with Dulwich returning KeyError when a commit is not found. |
138 |
try: |
139 |
commit = self._git.commit(hexsha) |
|
140 |
except KeyError: |
|
141 |
continue
|
|
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
142 |
if commit is None: |
|
0.200.612
by Jelmer Vernooij
Cope with Dulwich returning KeyError when a commit is not found. |
143 |
# Older versions of Dulwich used to return None rather than
|
144 |
# raise KeyError.
|
|
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
145 |
continue
|
146 |
else: |
|
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
147 |
parent_map[revision_id] = [mapping.revision_id_foreign_to_bzr(p) for p in commit.parents] |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
148 |
return parent_map |
149 |
||
150 |
def get_ancestry(self, revision_id, topo_sorted=True): |
|
151 |
"""See Repository.get_ancestry(). |
|
152 |
"""
|
|
153 |
if revision_id is None: |
|
|
0.200.237
by Jelmer Vernooij
Fix get_ancestry() contents. |
154 |
return [None, revision.NULL_REVISION] + self._all_revision_ids() |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
155 |
assert isinstance(revision_id, str) |
156 |
ancestry = [] |
|
157 |
graph = self.get_graph() |
|
158 |
for rev, parents in graph.iter_ancestry([revision_id]): |
|
159 |
ancestry.append(rev) |
|
160 |
ancestry.reverse() |
|
|
0.200.237
by Jelmer Vernooij
Fix get_ancestry() contents. |
161 |
return [None] + ancestry |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
162 |
|
163 |
def get_signature_text(self, revision_id): |
|
164 |
raise errors.NoSuchRevision(self, revision_id) |
|
165 |
||
|
0.200.124
by Jelmer Vernooij
Add lookup_revision_id stub. |
166 |
def lookup_revision_id(self, revid): |
167 |
"""Lookup a revision id. |
|
168 |
|
|
169 |
:param revid: Bazaar revision id.
|
|
170 |
:return: Tuple with git revisionid and mapping.
|
|
171 |
"""
|
|
172 |
# Yes, this doesn't really work, but good enough as a stub
|
|
|
0.200.586
by Jelmer Vernooij
Fix issues pointed out by pyflakes. |
173 |
return osutils.sha(revid).hexdigest(), self.get_mapping() |
|
0.200.124
by Jelmer Vernooij
Add lookup_revision_id stub. |
174 |
|
|
0.200.60
by Jelmer Vernooij
Support signature functions. |
175 |
def has_signature_for_revision_id(self, revision_id): |
176 |
return False |
|
177 |
||
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
178 |
def lookup_git_revid(self, bzr_revid): |
|
0.200.105
by Jelmer Vernooij
Add common function for finding git commit by bzr revid. |
179 |
try: |
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
180 |
return 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. |
181 |
except errors.InvalidRevisionId: |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
182 |
raise errors.NoSuchRevision(self, bzr_revid) |
|
0.200.105
by Jelmer Vernooij
Add common function for finding git commit by bzr revid. |
183 |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
184 |
def get_revision(self, revision_id): |
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
185 |
git_commit_id, mapping = self.lookup_git_revid(revision_id) |
|
0.200.147
by Jelmer Vernooij
Merge new dulwich; fetching objects from local repository works now; they aren't converted yet though. |
186 |
try: |
187 |
commit = self._git.commit(git_commit_id) |
|
188 |
except KeyError: |
|
189 |
raise errors.NoSuchRevision(self, revision_id) |
|
|
0.204.5
by James Westby
Lose the debuggin prints. |
190 |
# print "fetched revision:", git_commit_id
|
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
191 |
revision = mapping.import_commit(commit) |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
192 |
assert revision is not None |
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
193 |
return revision |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
194 |
|
195 |
def has_revision(self, revision_id): |
|
196 |
try: |
|
197 |
self.get_revision(revision_id) |
|
|
0.200.130
by Jelmer Vernooij
Make most tree inspection tests succeed. |
198 |
except errors.NoSuchRevision: |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
199 |
return False |
200 |
else: |
|
201 |
return True |
|
202 |
||
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
203 |
def get_revisions(self, revids): |
|
0.200.134
by Jelmer Vernooij
Fix get_revisions(). |
204 |
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. |
205 |
|
206 |
def revision_trees(self, revids): |
|
207 |
for revid in revids: |
|
208 |
yield self.revision_tree(revid) |
|
209 |
||
210 |
def revision_tree(self, revision_id): |
|
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
211 |
revision_id = revision.ensure_null(revision_id) |
212 |
if revision_id == revision.NULL_REVISION: |
|
213 |
inv = inventory.Inventory(root_id=None) |
|
214 |
inv.revision_id = revision_id |
|
215 |
return revisiontree.RevisionTree(self, inv, revision_id) |
|
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
216 |
return GitRevisionTree(self, revision_id) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
217 |
|
218 |
def get_inventory(self, revision_id): |
|
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
219 |
assert revision_id != None |
220 |
return self.revision_tree(revision_id).inventory |
|
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
221 |
|
|
0.200.108
by Jelmer Vernooij
Support bzr init --git. |
222 |
def set_make_working_trees(self, trees): |
223 |
pass
|
|
224 |
||
|
0.200.276
by Jelmer Vernooij
Improve formatting. |
225 |
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref, |
226 |
progress=None): |
|
|
0.200.146
by Jelmer Vernooij
Merge dulwich. |
227 |
return self._git.fetch_objects(determine_wants, graph_walker, progress) |
|
0.200.138
by Jelmer Vernooij
Add initial infrastructure for accessing remote git repositories. |
228 |
|
|
0.200.43
by David Allouche
Ultra-experimental support for "bzr pull". No test. No sanity. |
229 |
|
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
230 |
class GitRepositoryFormat(repository.RepositoryFormat): |
|
0.200.429
by Jelmer Vernooij
get remote dpush to a point where we now what to send. |
231 |
"""Git repository format.""" |
|
0.203.1
by Aaron Bentley
Make checkouts work |
232 |
|
233 |
supports_tree_reference = False |
|
|
0.200.133
by Jelmer Vernooij
Unmark as deprecated. |
234 |
rich_root_data = True |
|
0.200.71
by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description. |
235 |
|
236 |
def get_format_description(self): |
|
237 |
return "Git Repository" |
|
|
0.200.133
by Jelmer Vernooij
Unmark as deprecated. |
238 |
|
239 |
def initialize(self, url, shared=False, _internal=False): |
|
|
0.200.586
by Jelmer Vernooij
Fix issues pointed out by pyflakes. |
240 |
raise errors.UninitializableFormat(self) |
|
0.200.133
by Jelmer Vernooij
Unmark as deprecated. |
241 |
|
242 |
def check_conversion_target(self, target_repo_format): |
|
243 |
return target_repo_format.rich_root_data |
|
|
0.200.536
by Jelmer Vernooij
Implement network name. |
244 |
|
245 |
def network_name(self): |
|
246 |
return "git" |