bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.115.12
by John Arbash Meinel
Add a bunch of direct tests for the _TreeShim interface. |
1 |
# Copyright (C) 2008, 2009 Canonical Ltd
|
|
0.64.5
by Ian Clatworthy
first cut at generic processing method |
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
|
|
|
0.64.334
by Jelmer Vernooij
Remove old FSF address. Thanks Dan Callaghan. |
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
0.64.5
by Ian Clatworthy
first cut at generic processing method |
15 |
|
|
0.81.4
by Ian Clatworthy
generalise RevisionLoader to RevisionStore as a repo abstraction |
16 |
"""An abstraction of a repository providing just the bits importing needs."""
|
|
0.64.5
by Ian Clatworthy
first cut at generic processing method |
17 |
|
|
6628.1.2
by Jelmer Vernooij
Fix imports, move exporter.py, drop explorer metadata. |
18 |
from __future__ import absolute_import |
19 |
||
|
6855.4.8
by Jelmer Vernooij
Fix some more tests. |
20 |
from io import BytesIO |
|
0.64.5
by Ian Clatworthy
first cut at generic processing method |
21 |
|
|
6628.1.2
by Jelmer Vernooij
Fix imports, move exporter.py, drop explorer metadata. |
22 |
from ... import ( |
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
23 |
errors, |
24 |
graph as _mod_graph, |
|
25 |
osutils, |
|
26 |
revision as _mod_revision, |
|
27 |
)
|
|
|
7322.1.6
by Jelmer Vernooij
Use the new attributes on TreeChange. |
28 |
from ...tree import TreeChange |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
29 |
from ...bzr import ( |
30 |
inventory, |
|
31 |
)
|
|
|
0.64.6
by Ian Clatworthy
generic processing method working for one revision in one branch |
32 |
|
33 |
||
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
34 |
class _TreeShim(object): |
35 |
"""Fake a Tree implementation. |
|
36 |
||
37 |
This implements just enough of the tree api to make commit builder happy.
|
|
38 |
"""
|
|
39 |
||
|
0.115.7
by John Arbash Meinel
Fall back to the repository for cases where the content is not present in the stream yet. |
40 |
def __init__(self, repo, basis_inv, inv_delta, content_provider): |
41 |
self._repo = repo |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
42 |
self._content_provider = content_provider |
43 |
self._basis_inv = basis_inv |
|
44 |
self._inv_delta = inv_delta |
|
45 |
self._new_info_by_id = dict([(file_id, (new_path, ie)) |
|
46 |
for _, new_path, file_id, ie in inv_delta]) |
|
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
47 |
self._new_info_by_path = {new_path: ie |
48 |
for _, new_path, file_id, ie in inv_delta} |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
49 |
|
50 |
def id2path(self, file_id): |
|
51 |
if file_id in self._new_info_by_id: |
|
52 |
new_path = self._new_info_by_id[file_id][0] |
|
53 |
if new_path is None: |
|
|
0.115.12
by John Arbash Meinel
Add a bunch of direct tests for the _TreeShim interface. |
54 |
raise errors.NoSuchId(self, file_id) |
55 |
return new_path |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
56 |
return self._basis_inv.id2path(file_id) |
57 |
||
58 |
def path2id(self, path): |
|
|
0.115.12
by John Arbash Meinel
Add a bunch of direct tests for the _TreeShim interface. |
59 |
# CommitBuilder currently only requires access to the root id. We don't
|
60 |
# build a map of renamed files, etc. One possibility if we ever *do*
|
|
61 |
# need more than just root, is to defer to basis_inv.path2id() and then
|
|
62 |
# check if the file_id is in our _new_info_by_id dict. And in that
|
|
63 |
# case, return _new_info_by_id[file_id][0]
|
|
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
64 |
try: |
65 |
return self._new_info_by_path[path].file_id |
|
66 |
except KeyError: |
|
67 |
return self._basis_inv.path2id(path) |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
68 |
|
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
69 |
def get_file_with_stat(self, path): |
70 |
content = self.get_file_text(path) |
|
|
6855.4.8
by Jelmer Vernooij
Fix some more tests. |
71 |
sio = BytesIO(content) |
|
0.123.16
by Jelmer Vernooij
Support get_file_text in _TreeShim. |
72 |
return sio, None |
73 |
||
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
74 |
def get_file_text(self, path): |
75 |
file_id = self.path2id(path) |
|
|
0.115.7
by John Arbash Meinel
Fall back to the repository for cases where the content is not present in the stream yet. |
76 |
try: |
|
0.123.16
by Jelmer Vernooij
Support get_file_text in _TreeShim. |
77 |
return self._content_provider(file_id) |
|
0.115.7
by John Arbash Meinel
Fall back to the repository for cases where the content is not present in the stream yet. |
78 |
except KeyError: |
79 |
# The content wasn't shown as 'new'. Just validate this fact
|
|
80 |
assert file_id not in self._new_info_by_id |
|
|
6915.4.2
by Jelmer Vernooij
Remove __getitem__ and __iter__ from Inventory. |
81 |
old_ie = self._basis_inv.get_entry(file_id) |
|
0.115.7
by John Arbash Meinel
Fall back to the repository for cases where the content is not present in the stream yet. |
82 |
old_text_key = (file_id, old_ie.revision) |
83 |
stream = self._repo.texts.get_record_stream([old_text_key], |
|
84 |
'unordered', True) |
|
|
7018.3.10
by Jelmer Vernooij
Consistent return values in PreviewTree.list_files. |
85 |
return next(stream).get_bytes_as('fulltext') |
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
86 |
|
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
87 |
def get_symlink_target(self, path): |
88 |
try: |
|
89 |
ie = self._new_info_by_path[path] |
|
90 |
except KeyError: |
|
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
91 |
file_id = self.path2id(path) |
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
92 |
return self._basis_inv.get_entry(file_id).symlink_target |
93 |
else: |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
94 |
return ie.symlink_target |
95 |
||
|
7141.7.2
by Jelmer Vernooij
Fix more tests. |
96 |
def get_reference_revision(self, path): |
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
97 |
raise NotImplementedError(_TreeShim.get_reference_revision) |
98 |
||
99 |
def _delta_to_iter_changes(self): |
|
100 |
"""Convert the inv_delta into an iter_changes repr.""" |
|
101 |
# iter_changes is:
|
|
102 |
# (file_id,
|
|
103 |
# (old_path, new_path),
|
|
104 |
# content_changed,
|
|
105 |
# (old_versioned, new_versioned),
|
|
106 |
# (old_parent_id, new_parent_id),
|
|
107 |
# (old_name, new_name),
|
|
108 |
# (old_kind, new_kind),
|
|
109 |
# (old_exec, new_exec),
|
|
110 |
# )
|
|
111 |
basis_inv = self._basis_inv |
|
112 |
for old_path, new_path, file_id, ie in self._inv_delta: |
|
|
0.115.12
by John Arbash Meinel
Add a bunch of direct tests for the _TreeShim interface. |
113 |
# Perf: Would this be faster if we did 'if file_id in basis_inv'?
|
114 |
# Since the *very* common case is that the file already exists, it
|
|
115 |
# probably is better to optimize for that
|
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
116 |
try: |
|
6915.4.2
by Jelmer Vernooij
Remove __getitem__ and __iter__ from Inventory. |
117 |
old_ie = basis_inv.get_entry(file_id) |
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
118 |
except errors.NoSuchId: |
119 |
old_ie = None |
|
|
0.115.6
by John Arbash Meinel
We need to handle when the object has been deleted. |
120 |
if ie is None: |
121 |
raise AssertionError('How is both old and new None?') |
|
|
7322.1.6
by Jelmer Vernooij
Use the new attributes on TreeChange. |
122 |
change = TreeChange( |
123 |
file_id, |
|
124 |
(old_path, new_path), |
|
125 |
False, |
|
126 |
(False, False), |
|
127 |
(None, None), |
|
128 |
(None, None), |
|
129 |
(None, None), |
|
130 |
(None, None), |
|
131 |
)
|
|
132 |
change = TreeChange( |
|
133 |
file_id, |
|
134 |
(old_path, new_path), |
|
135 |
True, |
|
136 |
(False, True), |
|
137 |
(None, ie.parent_id), |
|
138 |
(None, ie.name), |
|
139 |
(None, ie.kind), |
|
140 |
(None, ie.executable), |
|
141 |
)
|
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
142 |
else: |
|
0.115.6
by John Arbash Meinel
We need to handle when the object has been deleted. |
143 |
if ie is None: |
|
7322.1.6
by Jelmer Vernooij
Use the new attributes on TreeChange. |
144 |
change = TreeChange( |
145 |
file_id, |
|
146 |
(old_path, new_path), |
|
147 |
True, |
|
148 |
(True, False), |
|
149 |
(old_ie.parent_id, None), |
|
150 |
(old_ie.name, None), |
|
151 |
(old_ie.kind, None), |
|
152 |
(old_ie.executable, None), |
|
153 |
)
|
|
|
0.115.6
by John Arbash Meinel
We need to handle when the object has been deleted. |
154 |
else: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
155 |
content_modified = (ie.text_sha1 != old_ie.text_sha1 or |
156 |
ie.text_size != old_ie.text_size) |
|
|
0.115.7
by John Arbash Meinel
Fall back to the repository for cases where the content is not present in the stream yet. |
157 |
# TODO: ie.kind != old_ie.kind
|
|
0.115.12
by John Arbash Meinel
Add a bunch of direct tests for the _TreeShim interface. |
158 |
# TODO: symlinks changing targets, content_modified?
|
|
7322.1.6
by Jelmer Vernooij
Use the new attributes on TreeChange. |
159 |
change = TreeChange( |
160 |
file_id, |
|
161 |
(old_path, new_path), |
|
162 |
content_modified, |
|
163 |
(True, True), |
|
164 |
(old_ie.parent_id, ie.parent_id), |
|
165 |
(old_ie.name, ie.name), |
|
166 |
(old_ie.kind, ie.kind), |
|
167 |
(old_ie.executable, ie.executable), |
|
168 |
)
|
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
169 |
yield change |
170 |
||
171 |
||
|
7027.2.3
by Jelmer Vernooij
Drop old RevisionStore implementation. |
172 |
class RevisionStore(object): |
|
0.64.5
by Ian Clatworthy
first cut at generic processing method |
173 |
|
|
0.64.48
by Ian Clatworthy
one revision loader instance |
174 |
def __init__(self, repo): |
|
0.64.5
by Ian Clatworthy
first cut at generic processing method |
175 |
"""An object responsible for loading revisions into a repository. |
176 |
||
177 |
NOTE: Repository locking is not managed by this class. Clients
|
|
178 |
should take a write lock, call load() multiple times, then release
|
|
179 |
the lock.
|
|
180 |
||
181 |
:param repository: the target repository
|
|
|
0.64.48
by Ian Clatworthy
one revision loader instance |
182 |
"""
|
183 |
self.repo = repo |
|
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
184 |
self._graph = None |
185 |
self._use_known_graph = True |
|
|
0.84.8
by Ian Clatworthy
ensure the chk stuff is only used on formats actually supporting it |
186 |
self._supports_chks = getattr(repo._format, 'supports_chks', False) |
|
0.81.3
by Ian Clatworthy
enhance RevisionLoader to try inventory deltas & decide on rich-roots |
187 |
|
188 |
def expects_rich_root(self): |
|
|
0.81.4
by Ian Clatworthy
generalise RevisionLoader to RevisionStore as a repo abstraction |
189 |
"""Does this store expect inventories with rich roots?""" |
|
0.81.3
by Ian Clatworthy
enhance RevisionLoader to try inventory deltas & decide on rich-roots |
190 |
return self.repo.supports_rich_root() |
|
0.64.48
by Ian Clatworthy
one revision loader instance |
191 |
|
|
0.84.4
by Ian Clatworthy
improved-but-not-yet-working CHKInventory support |
192 |
def init_inventory(self, revision_id): |
193 |
"""Generate an inventory for a parentless revision.""" |
|
|
0.84.8
by Ian Clatworthy
ensure the chk stuff is only used on formats actually supporting it |
194 |
if self._supports_chks: |
|
0.84.4
by Ian Clatworthy
improved-but-not-yet-working CHKInventory support |
195 |
inv = self._init_chk_inventory(revision_id, inventory.ROOT_ID) |
196 |
else: |
|
197 |
inv = inventory.Inventory(revision_id=revision_id) |
|
|
0.84.6
by Ian Clatworthy
set maximum_size & key_width for initial parent_id_basename_to_file_id map |
198 |
if self.expects_rich_root(): |
199 |
# The very first root needs to have the right revision
|
|
200 |
inv.root.revision = revision_id |
|
|
0.84.4
by Ian Clatworthy
improved-but-not-yet-working CHKInventory support |
201 |
return inv |
202 |
||
203 |
def _init_chk_inventory(self, revision_id, root_id): |
|
204 |
"""Generate a CHKInventory for a parentless revision.""" |
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
205 |
from ...bzr import chk_map |
|
0.84.4
by Ian Clatworthy
improved-but-not-yet-working CHKInventory support |
206 |
# Get the creation parameters
|
|
0.84.8
by Ian Clatworthy
ensure the chk stuff is only used on formats actually supporting it |
207 |
chk_store = self.repo.chk_bytes |
|
0.84.4
by Ian Clatworthy
improved-but-not-yet-working CHKInventory support |
208 |
serializer = self.repo._format._serializer |
209 |
search_key_name = serializer.search_key_name |
|
210 |
maximum_size = serializer.maximum_size |
|
211 |
||
212 |
# Maybe the rest of this ought to be part of the CHKInventory API?
|
|
213 |
inv = inventory.CHKInventory(search_key_name) |
|
214 |
inv.revision_id = revision_id |
|
215 |
inv.root_id = root_id |
|
216 |
search_key_func = chk_map.search_key_registry.get(search_key_name) |
|
217 |
inv.id_to_entry = chk_map.CHKMap(chk_store, None, search_key_func) |
|
218 |
inv.id_to_entry._root_node.set_maximum_size(maximum_size) |
|
|
0.64.151
by Ian Clatworthy
parent_id_to_basename_index is no longer a serializer attribute - always required now |
219 |
inv.parent_id_basename_to_file_id = chk_map.CHKMap(chk_store, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
220 |
None, search_key_func) |
|
0.64.151
by Ian Clatworthy
parent_id_to_basename_index is no longer a serializer attribute - always required now |
221 |
inv.parent_id_basename_to_file_id._root_node.set_maximum_size( |
222 |
maximum_size) |
|
223 |
inv.parent_id_basename_to_file_id._root_node._key_width = 2 |
|
|
0.84.4
by Ian Clatworthy
improved-but-not-yet-working CHKInventory support |
224 |
return inv |
225 |
||
|
0.81.4
by Ian Clatworthy
generalise RevisionLoader to RevisionStore as a repo abstraction |
226 |
def get_inventory(self, revision_id): |
227 |
"""Get a stored inventory.""" |
|
228 |
return self.repo.get_inventory(revision_id) |
|
229 |
||
|
7391.1.1
by Jelmer Vernooij
Avoid use of id2path in fastimport plugin. |
230 |
def get_file_lines(self, revision_id, path): |
|
0.81.7
by Ian Clatworthy
merge import tests and tweaks to make them pass |
231 |
"""Get the lines stored for a file in a given revision.""" |
|
0.64.156
by Ian Clatworthy
minor revision_store clean-ups |
232 |
revtree = self.repo.revision_tree(revision_id) |
|
7391.1.1
by Jelmer Vernooij
Avoid use of id2path in fastimport plugin. |
233 |
return revtree.get_file_lines(path) |
|
0.81.7
by Ian Clatworthy
merge import tests and tweaks to make them pass |
234 |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
235 |
def start_new_revision(self, revision, parents, parent_invs): |
236 |
"""Init the metadata needed for get_parents_and_revision_for_entry(). |
|
237 |
||
238 |
:param revision: a Revision object
|
|
239 |
"""
|
|
240 |
self._current_rev_id = revision.revision_id |
|
241 |
self._rev_parents = parents |
|
242 |
self._rev_parent_invs = parent_invs |
|
243 |
# We don't know what the branch will be so there's no real BranchConfig.
|
|
244 |
# That means we won't be triggering any hooks and that's a good thing.
|
|
245 |
# Without a config though, we must pass in the committer below so that
|
|
246 |
# the commit builder doesn't try to look up the config.
|
|
247 |
config = None |
|
248 |
# We can't use self.repo.get_commit_builder() here because it starts a
|
|
249 |
# new write group. We want one write group around a batch of imports
|
|
250 |
# where the default batch size is currently 10000. IGC 20090312
|
|
251 |
self._commit_builder = self.repo._commit_builder_class(self.repo, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
252 |
parents, config, timestamp=revision.timestamp, |
253 |
timezone=revision.timezone, committer=revision.committer, |
|
254 |
revprops=revision.properties, revision_id=revision.revision_id) |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
255 |
|
256 |
def get_parents_and_revision_for_entry(self, ie): |
|
257 |
"""Get the parents and revision for an inventory entry. |
|
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
258 |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
259 |
:param ie: the inventory entry
|
260 |
:return parents, revision_id where
|
|
|
0.64.160
by Ian Clatworthy
make per-file parents tuples and fix text loading in chk formats |
261 |
parents is the tuple of parent revision_ids for the per-file graph
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
262 |
revision_id is the revision_id to use for this entry
|
263 |
"""
|
|
264 |
# Check for correct API usage
|
|
265 |
if self._current_rev_id is None: |
|
266 |
raise AssertionError("start_new_revision() must be called" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
267 |
" before get_parents_and_revision_for_entry()") |
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
268 |
if ie.revision != self._current_rev_id: |
269 |
raise AssertionError("start_new_revision() registered a different" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
270 |
" revision (%s) to that in the inventory entry (%s)" % |
271 |
(self._current_rev_id, ie.revision)) |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
272 |
|
273 |
# Find the heads. This code is lifted from
|
|
274 |
# repository.CommitBuilder.record_entry_contents().
|
|
275 |
parent_candidate_entries = ie.parent_candidates(self._rev_parent_invs) |
|
276 |
head_set = self._commit_builder._heads(ie.file_id, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
277 |
list(parent_candidate_entries)) |
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
278 |
heads = [] |
279 |
for inv in self._rev_parent_invs: |
|
|
6883.7.11
by Jelmer Vernooij
Avoid has_id. |
280 |
try: |
|
6915.4.2
by Jelmer Vernooij
Remove __getitem__ and __iter__ from Inventory. |
281 |
old_rev = inv.get_entry(ie.file_id).revision |
|
6883.7.11
by Jelmer Vernooij
Avoid has_id. |
282 |
except errors.NoSuchId: |
283 |
pass
|
|
284 |
else: |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
285 |
if old_rev in head_set: |
|
6915.4.2
by Jelmer Vernooij
Remove __getitem__ and __iter__ from Inventory. |
286 |
rev_id = inv.get_entry(ie.file_id).revision |
|
0.64.161
by Ian Clatworthy
fix per-graph parent handling for adds and renames |
287 |
heads.append(rev_id) |
288 |
head_set.remove(rev_id) |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
289 |
|
290 |
# Find the revision to use. If the content has not changed
|
|
291 |
# since the parent, record the parent's revision.
|
|
|
0.64.161
by Ian Clatworthy
fix per-graph parent handling for adds and renames |
292 |
if len(heads) == 0: |
293 |
return (), ie.revision |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
294 |
parent_entry = parent_candidate_entries[heads[0]] |
295 |
changed = False |
|
296 |
if len(heads) > 1: |
|
297 |
changed = True |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
298 |
elif (parent_entry.name != ie.name or parent_entry.kind != ie.kind |
299 |
or parent_entry.parent_id != ie.parent_id): |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
300 |
changed = True |
301 |
elif ie.kind == 'file': |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
302 |
if (parent_entry.text_sha1 != ie.text_sha1 |
303 |
or parent_entry.executable != ie.executable): |
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
304 |
changed = True |
305 |
elif ie.kind == 'symlink': |
|
306 |
if parent_entry.symlink_target != ie.symlink_target: |
|
307 |
changed = True |
|
308 |
if changed: |
|
309 |
rev_id = ie.revision |
|
310 |
else: |
|
311 |
rev_id = parent_entry.revision |
|
|
0.64.160
by Ian Clatworthy
make per-file parents tuples and fix text loading in chk formats |
312 |
return tuple(heads), rev_id |
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
313 |
|
|
0.64.171
by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs |
314 |
def load_using_delta(self, rev, basis_inv, inv_delta, signature, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
315 |
text_provider, parents_provider, inventories_provider=None): |
|
0.64.171
by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs |
316 |
"""Load a revision by applying a delta to a (CHK)Inventory. |
|
0.84.13
by Ian Clatworthy
smarter RevisionStore.chk_load() |
317 |
|
318 |
:param rev: the Revision
|
|
|
0.64.171
by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs |
319 |
:param basis_inv: the basis Inventory or CHKInventory
|
|
0.84.13
by Ian Clatworthy
smarter RevisionStore.chk_load() |
320 |
:param inv_delta: the inventory delta
|
321 |
:param signature: signing information
|
|
322 |
:param text_provider: a callable expecting a file_id parameter
|
|
323 |
that returns the text for that file-id
|
|
|
0.85.2
by Ian Clatworthy
improve per-file graph generation |
324 |
:param parents_provider: a callable expecting a file_id parameter
|
325 |
that return the list of parent-ids for that file-id
|
|
|
0.84.13
by Ian Clatworthy
smarter RevisionStore.chk_load() |
326 |
:param inventories_provider: a callable expecting a repository and
|
327 |
a list of revision-ids, that returns:
|
|
328 |
* the list of revision-ids present in the repository
|
|
329 |
* the list of inventories for the revision-id's,
|
|
330 |
including an empty inventory for the missing revisions
|
|
331 |
If None, a default implementation is provided.
|
|
332 |
"""
|
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
333 |
# TODO: set revision_id = rev.revision_id
|
334 |
builder = self.repo._commit_builder_class(self.repo, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
335 |
parents=rev.parent_ids, config=None, timestamp=rev.timestamp, |
336 |
timezone=rev.timezone, committer=rev.committer, |
|
337 |
revprops=rev.properties, revision_id=rev.revision_id) |
|
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
338 |
if self._graph is None and self._use_known_graph: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
339 |
if (getattr(_mod_graph, 'GraphThunkIdsToKeys', None) |
340 |
and getattr(_mod_graph.GraphThunkIdsToKeys, "add_node", None) |
|
341 |
and getattr(self.repo, "get_known_graph_ancestry", None)): |
|
|
0.64.290
by Jelmer Vernooij
Avoid use of Repository.revisions, which may not be set. |
342 |
self._graph = self.repo.get_known_graph_ancestry( |
343 |
rev.parent_ids) |
|
344 |
else: |
|
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
345 |
self._use_known_graph = False |
346 |
if self._graph is not None: |
|
|
0.116.2
by John Arbash Meinel
Some debugging code. It looks like the main bugs involve files that are deleted and restored. |
347 |
orig_heads = builder._heads |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
348 |
|
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
349 |
def thunked_heads(file_id, revision_ids): |
350 |
# self._graph thinks in terms of keys, not ids, so translate
|
|
351 |
# them
|
|
|
0.116.2
by John Arbash Meinel
Some debugging code. It looks like the main bugs involve files that are deleted and restored. |
352 |
# old_res = orig_heads(file_id, revision_ids)
|
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
353 |
if len(revision_ids) < 2: |
|
0.116.2
by John Arbash Meinel
Some debugging code. It looks like the main bugs involve files that are deleted and restored. |
354 |
res = set(revision_ids) |
355 |
else: |
|
|
0.64.290
by Jelmer Vernooij
Avoid use of Repository.revisions, which may not be set. |
356 |
res = set(self._graph.heads(revision_ids)) |
|
0.116.2
by John Arbash Meinel
Some debugging code. It looks like the main bugs involve files that are deleted and restored. |
357 |
# if old_res != res:
|
358 |
# import pdb; pdb.set_trace()
|
|
359 |
return res |
|
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
360 |
builder._heads = thunked_heads |
|
0.84.13
by Ian Clatworthy
smarter RevisionStore.chk_load() |
361 |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
362 |
if rev.parent_ids: |
363 |
basis_rev_id = rev.parent_ids[0] |
|
364 |
else: |
|
365 |
basis_rev_id = _mod_revision.NULL_REVISION |
|
|
0.115.7
by John Arbash Meinel
Fall back to the repository for cases where the content is not present in the stream yet. |
366 |
tree = _TreeShim(self.repo, basis_inv, inv_delta, text_provider) |
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
367 |
changes = tree._delta_to_iter_changes() |
|
7206.6.1
by Jelmer Vernooij
Drop file_id from record_iter_changes return value. |
368 |
for (path, fs_hash) in builder.record_iter_changes( |
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
369 |
tree, basis_rev_id, changes): |
370 |
# So far, we don't *do* anything with the result
|
|
|
0.84.13
by Ian Clatworthy
smarter RevisionStore.chk_load() |
371 |
pass
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
372 |
builder.finish_inventory() |
|
6628.1.2
by Jelmer Vernooij
Fix imports, move exporter.py, drop explorer metadata. |
373 |
# TODO: This is working around a bug in the breezy code base.
|
|
0.115.5
by John Arbash Meinel
Found a bug in CommitBuilder.finish_inventory(). |
374 |
# 'builder.finish_inventory()' ends up doing:
|
375 |
# self.inv_sha1 = self.repository.add_inventory_by_delta(...)
|
|
376 |
# However, add_inventory_by_delta returns (sha1, inv)
|
|
377 |
# And we *want* to keep a handle on both of those objects
|
|
378 |
if isinstance(builder.inv_sha1, tuple): |
|
379 |
builder.inv_sha1, builder.new_inventory = builder.inv_sha1 |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
380 |
# This is a duplicate of Builder.commit() since we already have the
|
381 |
# Revision object, and we *don't* want to call commit_write_group()
|
|
382 |
rev.inv_sha1 = builder.inv_sha1 |
|
|
6690.2.2
by Jelmer Vernooij
Drop support for bzr < 2.5. |
383 |
config = builder._config_stack |
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
384 |
builder.repository.add_revision(builder._new_revision_id, rev, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
385 |
builder.revision_tree().root_inventory) |
|
0.116.1
by John Arbash Meinel
Use the new KnownGraph.add_node() functionality. |
386 |
if self._graph is not None: |
387 |
# TODO: Use StaticTuple and .intern() for these things
|
|
|
0.64.290
by Jelmer Vernooij
Avoid use of Repository.revisions, which may not be set. |
388 |
self._graph.add_node(builder._new_revision_id, rev.parent_ids) |
|
0.84.13
by Ian Clatworthy
smarter RevisionStore.chk_load() |
389 |
|
390 |
if signature is not None: |
|
|
0.115.4
by John Arbash Meinel
(broken) Start working towards using CommitBuilder rather than using a custom implementation. |
391 |
raise AssertionError('signatures not guaranteed yet') |
|
0.64.290
by Jelmer Vernooij
Avoid use of Repository.revisions, which may not be set. |
392 |
self.repo.add_signature_text(rev.revision_id, signature) |
|
6643.1.1
by Jelmer Vernooij
Fix fastimport tests now that RevisionTree.inventory has been removed. |
393 |
return builder.revision_tree().root_inventory |