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