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