bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2008-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
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
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
16 |
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
17 |
"""Fetching from git into bzr."""
|
18 |
||
0.200.1594
by Jelmer Vernooij
Use absolute_import everywhere. |
19 |
from __future__ import absolute_import |
20 |
||
0.200.261
by Jelmer Vernooij
More formatting fixes. |
21 |
from dulwich.objects import ( |
22 |
Commit, |
|
0.200.303
by Jelmer Vernooij
Cope with tags during fetch. |
23 |
Tag, |
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
24 |
Tree, |
0.200.1407
by Jelmer Vernooij
Don't consider submodule modes unusual. |
25 |
S_IFGITLINK, |
0.200.540
by Jelmer Vernooij
Handle submodules explicitly. |
26 |
S_ISGITLINK, |
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
27 |
ZERO_SHA, |
0.200.261
by Jelmer Vernooij
More formatting fixes. |
28 |
)
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
29 |
from dulwich.object_store import ( |
30 |
tree_lookup_path, |
|
31 |
)
|
|
0.200.819
by Jelmer Vernooij
Avoid decoding basename twice. |
32 |
import posixpath |
0.200.352
by Jelmer Vernooij
Simplify mode handling. |
33 |
import stat |
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
34 |
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
35 |
from .. import ( |
0.231.2
by Jelmer Vernooij
Add -Dverify flag (not fully implemented yet). |
36 |
debug, |
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
37 |
errors, |
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
38 |
osutils, |
0.200.261
by Jelmer Vernooij
More formatting fixes. |
39 |
trace, |
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
40 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
41 |
from ..errors import ( |
0.239.5
by Jelmer Vernooij
Print user-understandable error message when encountering submodules. |
42 |
BzrError, |
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
43 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
44 |
from ..bzr.inventory import ( |
0.229.2
by Jelmer Vernooij
Initial work relying on inventory deltas. |
45 |
InventoryDirectory, |
46 |
InventoryFile, |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
47 |
InventoryLink, |
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
48 |
TreeReference, |
0.200.261
by Jelmer Vernooij
More formatting fixes. |
49 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
50 |
from ..revision import ( |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
51 |
NULL_REVISION, |
52 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
53 |
from ..bzr.inventorytree import InventoryRevisionTree |
6986.2.2
by Jelmer Vernooij
Merge trunk. |
54 |
from ..sixish import text_type |
7206.4.1
by Jelmer Vernooij
Move breezy.testament to breezy.bzr.testament. |
55 |
from ..bzr.testament import ( |
0.200.1023
by Jelmer Vernooij
Set and verify testament. |
56 |
StrictTestament3, |
57 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
58 |
from ..tsort import ( |
0.200.292
by Jelmer Vernooij
Fix formatting. |
59 |
topo_sort, |
60 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
61 |
from ..bzr.versionedfile import ( |
0.200.811
by Jelmer Vernooij
Use ChunkedContentFactory when possible. |
62 |
ChunkedContentFactory, |
0.200.417
by Jelmer Vernooij
use insert_record_stream rather than add_lines. |
63 |
)
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
64 |
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
65 |
from .mapping import ( |
0.200.345
by Jelmer Vernooij
Keep track of file modes to use. |
66 |
DEFAULT_FILE_MODE, |
0.200.521
by Jelmer Vernooij
Abstract out kind mapping a bit, initial work on support tree-references. |
67 |
mode_is_executable, |
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
68 |
mode_kind, |
0.200.490
by Jelmer Vernooij
Warn about unusual modes and escaped XML-invalid characters. |
69 |
warn_unusual_mode, |
0.231.2
by Jelmer Vernooij
Add -Dverify flag (not fully implemented yet). |
70 |
)
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
71 |
from .object_store import ( |
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
72 |
LRUTreeCache, |
0.423.1
by Jelmer Vernooij
Some performance fixes. |
73 |
_tree_to_objects, |
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
74 |
)
|
0.216.4
by Jelmer Vernooij
Add basic pack fetch infrastructure. |
75 |
|
76 |
||
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
77 |
def import_git_blob(texts, mapping, path, name, hexshas, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
78 |
base_bzr_tree, parent_id, revision_id, |
79 |
parent_bzr_trees, lookup_object, modes, store_updater, |
|
80 |
lookup_file_id): |
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
81 |
"""Import a git blob object into a bzr repository. |
82 |
||
0.200.261
by Jelmer Vernooij
More formatting fixes. |
83 |
:param texts: VersionedFiles to add to
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
84 |
:param path: Path in the tree
|
85 |
:param blob: A git blob
|
|
0.229.1
by Jelmer Vernooij
Start working with inventory deltas. |
86 |
:return: Inventory delta for this file
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
87 |
"""
|
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
88 |
if not isinstance(path, bytes): |
89 |
raise TypeError(path) |
|
90 |
decoded_path = path.decode('utf-8') |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
91 |
(base_mode, mode) = modes |
92 |
(base_hexsha, hexsha) = hexshas |
|
0.200.1752
by Jelmer Vernooij
Don't traverse nested trees in WorkingTree.smart_add. |
93 |
if mapping.is_special_file(path): |
0.252.28
by Jelmer Vernooij
Don't import control files. |
94 |
return [] |
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
95 |
if base_hexsha == hexsha and base_mode == mode: |
96 |
# If nothing has changed since the base revision, we're done
|
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
97 |
return [] |
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
98 |
file_id = lookup_file_id(decoded_path) |
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
99 |
if stat.S_ISLNK(mode): |
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
100 |
cls = InventoryLink |
101 |
else: |
|
102 |
cls = InventoryFile |
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
103 |
ie = cls(file_id, name.decode("utf-8"), parent_id) |
0.200.995
by Jelmer Vernooij
Support newer versions of bzr where only some InventoryFile/InventoryLink attributes are writable. |
104 |
if ie.kind == "file": |
105 |
ie.executable = mode_is_executable(mode) |
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
106 |
if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode): |
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
107 |
base_exec = base_bzr_tree.is_executable(decoded_path) |
0.200.995
by Jelmer Vernooij
Support newer versions of bzr where only some InventoryFile/InventoryLink attributes are writable. |
108 |
if ie.kind == "symlink": |
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
109 |
ie.symlink_target = base_bzr_tree.get_symlink_target(decoded_path) |
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
110 |
else: |
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
111 |
ie.text_size = base_bzr_tree.get_file_size(decoded_path) |
112 |
ie.text_sha1 = base_bzr_tree.get_file_sha1(decoded_path) |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
113 |
if ie.kind == "symlink" or ie.executable == base_exec: |
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
114 |
ie.revision = base_bzr_tree.get_file_revision(decoded_path) |
0.200.537
by Jelmer Vernooij
Fix handling of not-executable files becoming executable without any other changes. |
115 |
else: |
116 |
blob = lookup_object(hexsha) |
|
0.200.304
by Jelmer Vernooij
Try a bit harder to avoid fetching objects we don't need. |
117 |
else: |
118 |
blob = lookup_object(hexsha) |
|
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
119 |
if ie.kind == "symlink": |
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
120 |
ie.revision = None |
0.200.1344
by Jelmer Vernooij
Unicode symlinks should be unicode in inventory entries. |
121 |
ie.symlink_target = blob.data.decode("utf-8") |
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
122 |
else: |
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
123 |
ie.text_size = sum(map(len, blob.chunked)) |
0.200.830
by Jelmer Vernooij
Bump minimum dulwich version. |
124 |
ie.text_sha1 = osutils.sha_strings(blob.chunked) |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
125 |
# Check what revision we should store
|
0.200.283
by Jelmer Vernooij
Avoid storing repeated texts for blobs. |
126 |
parent_keys = [] |
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
127 |
for ptree in parent_bzr_trees: |
0.200.1576
by Jelmer Vernooij
Merge a bunch of fixes from store-roundtrip-info. |
128 |
try: |
7069.1.1
by Jelmer Vernooij
Remove incorrect use of find_related_paths_across_trees. |
129 |
ppath = ptree.id2path(file_id) |
130 |
except errors.NoSuchId: |
|
0.200.829
by Jelmer Vernooij
Cope with the fact that _type is gone in upstream dulwich. |
131 |
continue
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
132 |
pkind = ptree.kind(ppath) |
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
133 |
if (pkind == ie.kind and |
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
134 |
((pkind == "symlink" and ptree.get_symlink_target(ppath) == ie.symlink_target) or |
135 |
(pkind == "file" and ptree.get_file_sha1(ppath) == ie.text_sha1 and |
|
136 |
ptree.is_executable(ppath) == ie.executable))): |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
137 |
# found a revision in one of the parents to use
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
138 |
ie.revision = ptree.get_file_revision(ppath) |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
139 |
break
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
140 |
parent_key = (file_id, ptree.get_file_revision(ppath)) |
7183.3.1
by Martin
Fix E71* lint errors |
141 |
if parent_key not in parent_keys: |
0.200.904
by Jelmer Vernooij
Fix inconsistent parents. |
142 |
parent_keys.append(parent_key) |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
143 |
if ie.revision is None: |
144 |
# Need to store a new revision
|
|
145 |
ie.revision = revision_id |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
146 |
if ie.revision is None: |
147 |
raise ValueError("no file revision set") |
|
0.200.698
by Jelmer Vernooij
Merge fixes for SHA1s of symlinks. |
148 |
if ie.kind == 'symlink': |
0.200.811
by Jelmer Vernooij
Use ChunkedContentFactory when possible. |
149 |
chunks = [] |
0.200.1292
by Jelmer Vernooij
Fix repeeling objects when determining what to send. |
150 |
else: |
0.200.830
by Jelmer Vernooij
Bump minimum dulwich version. |
151 |
chunks = blob.chunked |
0.252.25
by Jelmer Vernooij
Reformatting. |
152 |
texts.insert_record_stream([ |
153 |
ChunkedContentFactory((file_id, ie.revision), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
154 |
tuple(parent_keys), ie.text_sha1, chunks)]) |
0.200.572
by Jelmer Vernooij
Avoid some extra path lookups. |
155 |
invdelta = [] |
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
156 |
if base_hexsha is not None: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
157 |
old_path = decoded_path # Renames are not supported yet |
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
158 |
if stat.S_ISDIR(base_mode): |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
159 |
invdelta.extend(remove_disappeared_children( |
160 |
base_bzr_tree, old_path, lookup_object(base_hexsha), [], |
|
161 |
lookup_object)) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
162 |
else: |
163 |
old_path = None |
|
7027.4.8
by Jelmer Vernooij
Fix tests, drop broken tests. |
164 |
invdelta.append((old_path, decoded_path, file_id, ie)) |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
165 |
if base_hexsha != hexsha: |
0.275.2
by Jelmer Vernooij
Pass tuples around for cache entries, rather than inventory entries. |
166 |
store_updater.add_object(blob, (ie.file_id, ie.revision), path) |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
167 |
return invdelta |
0.200.261
by Jelmer Vernooij
More formatting fixes. |
168 |
|
169 |
||
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
170 |
class SubmodulesRequireSubtrees(BzrError): |
0.200.1596
by Jelmer Vernooij
Don't mention development-subtree when submodules are encountered. |
171 |
_fmt = ("The repository you are fetching from contains submodules, " |
0.404.2
by Jelmer Vernooij
Clarify error message about nested trees. |
172 |
"which require a Bazaar format that supports tree references.") |
0.239.5
by Jelmer Vernooij
Print user-understandable error message when encountering submodules. |
173 |
internal = False |
174 |
||
175 |
||
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
176 |
def import_git_submodule(texts, mapping, path, name, hexshas, |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
177 |
base_bzr_tree, parent_id, revision_id, |
178 |
parent_bzr_trees, lookup_object, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
179 |
modes, store_updater, lookup_file_id): |
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
180 |
"""Import a git submodule.""" |
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
181 |
(base_hexsha, hexsha) = hexshas |
182 |
(base_mode, mode) = modes |
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
183 |
if base_hexsha == hexsha and base_mode == mode: |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
184 |
return [], {} |
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
185 |
file_id = lookup_file_id(path) |
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
186 |
invdelta = [] |
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
187 |
ie = TreeReference(file_id, name.decode("utf-8"), parent_id) |
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
188 |
ie.revision = revision_id |
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
189 |
if base_hexsha is not None: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
190 |
old_path = path.decode("utf-8") # Renames are not supported yet |
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
191 |
if stat.S_ISDIR(base_mode): |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
192 |
invdelta.extend(remove_disappeared_children( |
193 |
base_bzr_tree, old_path, lookup_object(base_hexsha), [], |
|
194 |
lookup_object)) |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
195 |
else: |
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
196 |
old_path = None |
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
197 |
ie.reference_revision = mapping.revision_id_foreign_to_bzr(hexsha) |
0.252.25
by Jelmer Vernooij
Reformatting. |
198 |
texts.insert_record_stream([ |
199 |
ChunkedContentFactory((file_id, ie.revision), (), None, [])]) |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
200 |
invdelta.append((old_path, path, file_id, ie)) |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
201 |
return invdelta, {} |
0.200.540
by Jelmer Vernooij
Handle submodules explicitly. |
202 |
|
203 |
||
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
204 |
def remove_disappeared_children(base_bzr_tree, path, base_tree, |
205 |
existing_children, lookup_object): |
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
206 |
"""Generate an inventory delta for removed children. |
207 |
||
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
208 |
:param base_bzr_tree: Base bzr tree against which to generate the
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
209 |
inventory delta.
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
210 |
:param path: Path to process (unicode)
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
211 |
:param base_tree: Git Tree base object
|
212 |
:param existing_children: Children that still exist
|
|
213 |
:param lookup_object: Lookup a git object by its SHA1
|
|
214 |
:return: Inventory delta, as list
|
|
215 |
"""
|
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
216 |
if not isinstance(path, text_type): |
0.361.1
by Jelmer Vernooij
Don't use assert. |
217 |
raise TypeError(path) |
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
218 |
ret = [] |
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
219 |
for name, mode, hexsha in base_tree.iteritems(): |
220 |
if name in existing_children: |
|
221 |
continue
|
|
222 |
c_path = posixpath.join(path, name.decode("utf-8")) |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
223 |
file_id = base_bzr_tree.path2id(c_path) |
0.361.1
by Jelmer Vernooij
Don't use assert. |
224 |
if file_id is None: |
225 |
raise TypeError(file_id) |
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
226 |
ret.append((c_path, None, file_id, None)) |
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
227 |
if stat.S_ISDIR(mode): |
228 |
ret.extend(remove_disappeared_children( |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
229 |
base_bzr_tree, c_path, lookup_object(hexsha), [], |
230 |
lookup_object)) |
|
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
231 |
return ret |
232 |
||
233 |
||
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
234 |
def import_git_tree(texts, mapping, path, name, hexshas, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
235 |
base_bzr_tree, parent_id, revision_id, parent_bzr_trees, |
236 |
lookup_object, modes, store_updater, |
|
237 |
lookup_file_id, allow_submodules=False): |
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
238 |
"""Import a git tree object into a bzr repository. |
239 |
||
0.200.261
by Jelmer Vernooij
More formatting fixes. |
240 |
:param texts: VersionedFiles object to add to
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
241 |
:param path: Path in the tree (str)
|
242 |
:param name: Name of the tree (str)
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
243 |
:param tree: A git tree object
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
244 |
:param base_bzr_tree: Base inventory against which to return inventory
|
245 |
delta
|
|
0.229.1
by Jelmer Vernooij
Start working with inventory deltas. |
246 |
:return: Inventory delta for this subtree
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
247 |
"""
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
248 |
(base_hexsha, hexsha) = hexshas |
249 |
(base_mode, mode) = modes |
|
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
250 |
if not isinstance(path, bytes): |
0.361.1
by Jelmer Vernooij
Don't use assert. |
251 |
raise TypeError(path) |
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
252 |
if not isinstance(name, bytes): |
0.361.1
by Jelmer Vernooij
Don't use assert. |
253 |
raise TypeError(name) |
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
254 |
if base_hexsha == hexsha and base_mode == mode: |
255 |
# If nothing has changed since the base revision, we're done
|
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
256 |
return [], {} |
0.200.344
by Jelmer Vernooij
Clarify names, use convenience function |
257 |
invdelta = [] |
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
258 |
file_id = lookup_file_id(osutils.safe_unicode(path)) |
0.200.297
by Jelmer Vernooij
Cope with non-ascii characters in filenames (needs a test..). |
259 |
# We just have to hope this is indeed utf-8:
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
260 |
ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id) |
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
261 |
tree = lookup_object(hexsha) |
262 |
if base_hexsha is None: |
|
263 |
base_tree = None |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
264 |
old_path = None # Newly appeared here |
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
265 |
else: |
266 |
base_tree = lookup_object(base_hexsha) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
267 |
old_path = path.decode("utf-8") # Renames aren't supported yet |
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
268 |
new_path = path.decode("utf-8") |
0.200.823
by Jelmer Vernooij
Simplify logic in import_git_tree a bit. |
269 |
if base_tree is None or type(base_tree) is not Tree: |
270 |
ie.revision = revision_id |
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
271 |
invdelta.append((old_path, new_path, ie.file_id, ie)) |
0.252.24
by Jelmer Vernooij
Support reading fileid map. |
272 |
texts.insert_record_stream([ |
273 |
ChunkedContentFactory((ie.file_id, ie.revision), (), None, [])]) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
274 |
# Remember for next time
|
0.200.300
by Jelmer Vernooij
Fix recursive deletion of dirs. |
275 |
existing_children = set() |
0.200.345
by Jelmer Vernooij
Keep track of file modes to use. |
276 |
child_modes = {} |
0.200.1147
by Jelmer Vernooij
Use Tree.items() rather than Tree.entries(). |
277 |
for name, child_mode, child_hexsha in tree.iteritems(): |
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
278 |
existing_children.add(name) |
0.200.819
by Jelmer Vernooij
Avoid decoding basename twice. |
279 |
child_path = posixpath.join(path, name) |
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
280 |
if type(base_tree) is Tree: |
281 |
try: |
|
282 |
child_base_mode, child_base_hexsha = base_tree[name] |
|
283 |
except KeyError: |
|
284 |
child_base_hexsha = None |
|
285 |
child_base_mode = 0 |
|
286 |
else: |
|
287 |
child_base_hexsha = None |
|
288 |
child_base_mode = 0 |
|
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
289 |
if stat.S_ISDIR(child_mode): |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
290 |
subinvdelta, grandchildmodes = import_git_tree( |
291 |
texts, mapping, child_path, name, |
|
292 |
(child_base_hexsha, child_hexsha), base_bzr_tree, file_id, |
|
293 |
revision_id, parent_bzr_trees, lookup_object, |
|
294 |
(child_base_mode, child_mode), store_updater, lookup_file_id, |
|
295 |
allow_submodules=allow_submodules) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
296 |
elif S_ISGITLINK(child_mode): # submodule |
0.200.666
by Jelmer Vernooij
Refuse to add tree references to non-subtree formats. |
297 |
if not allow_submodules: |
298 |
raise SubmodulesRequireSubtrees() |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
299 |
subinvdelta, grandchildmodes = import_git_submodule( |
300 |
texts, mapping, child_path, name, |
|
301 |
(child_base_hexsha, child_hexsha), |
|
302 |
base_bzr_tree, file_id, revision_id, parent_bzr_trees, |
|
303 |
lookup_object, (child_base_mode, child_mode), store_updater, |
|
304 |
lookup_file_id) |
|
0.200.352
by Jelmer Vernooij
Simplify mode handling. |
305 |
else: |
0.200.1328
by Jelmer Vernooij
More test fixes. |
306 |
if not mapping.is_special_file(name): |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
307 |
subinvdelta = import_git_blob( |
308 |
texts, mapping, child_path, name, |
|
309 |
(child_base_hexsha, child_hexsha), base_bzr_tree, file_id, |
|
310 |
revision_id, parent_bzr_trees, lookup_object, |
|
311 |
(child_base_mode, child_mode), store_updater, |
|
312 |
lookup_file_id) |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
313 |
else: |
314 |
subinvdelta = [] |
|
0.200.757
by Jelmer Vernooij
Use inventory deltas. |
315 |
grandchildmodes = {} |
316 |
child_modes.update(grandchildmodes) |
|
317 |
invdelta.extend(subinvdelta) |
|
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
318 |
if child_mode not in (stat.S_IFDIR, DEFAULT_FILE_MODE, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
319 |
stat.S_IFLNK, DEFAULT_FILE_MODE | 0o111, |
320 |
S_IFGITLINK): |
|
0.200.879
by Jelmer Vernooij
Fix unusual modes. |
321 |
child_modes[child_path] = child_mode |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
322 |
# Remove any children that have disappeared
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
323 |
if base_tree is not None and type(base_tree) is Tree: |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
324 |
invdelta.extend(remove_disappeared_children( |
325 |
base_bzr_tree, old_path, base_tree, existing_children, |
|
326 |
lookup_object)) |
|
0.421.6
by Jelmer Vernooij
Some more simplifications. |
327 |
store_updater.add_object(tree, (file_id, revision_id), path) |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
328 |
return invdelta, child_modes |
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
329 |
|
330 |
||
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
331 |
def verify_commit_reconstruction(target_git_object_retriever, lookup_object, |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
332 |
o, rev, ret_tree, parent_trees, mapping, |
333 |
unusual_modes, verifiers): |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
334 |
new_unusual_modes = mapping.export_unusual_file_modes(rev) |
335 |
if new_unusual_modes != unusual_modes: |
|
336 |
raise AssertionError("unusual modes don't match: %r != %r" % ( |
|
337 |
unusual_modes, new_unusual_modes)) |
|
338 |
# Verify that we can reconstruct the commit properly
|
|
0.200.1047
by Jelmer Vernooij
Fix -Dverify. |
339 |
rec_o = target_git_object_retriever._reconstruct_commit(rev, o.tree, True, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
340 |
verifiers) |
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
341 |
if rec_o != o: |
342 |
raise AssertionError("Reconstructed commit differs: %r != %r" % ( |
|
343 |
rec_o, o)) |
|
344 |
diff = [] |
|
345 |
new_objs = {} |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
346 |
for path, obj, ie in _tree_to_objects( |
347 |
ret_tree, parent_trees, target_git_object_retriever._cache.idmap, |
|
348 |
unusual_modes, mapping.BZR_DUMMY_FILE): |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
349 |
old_obj_id = tree_lookup_path(lookup_object, o.tree, path)[1] |
350 |
new_objs[path] = obj |
|
351 |
if obj.id != old_obj_id: |
|
352 |
diff.append((path, lookup_object(old_obj_id), obj)) |
|
353 |
for (path, old_obj, new_obj) in diff: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
354 |
while (old_obj.type_name == "tree" |
355 |
and new_obj.type_name == "tree" |
|
356 |
and sorted(old_obj) == sorted(new_obj)): |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
357 |
for name in old_obj: |
358 |
if old_obj[name][0] != new_obj[name][0]: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
359 |
raise AssertionError( |
360 |
"Modes for %s differ: %o != %o" % |
|
361 |
(path, old_obj[name][0], new_obj[name][0])) |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
362 |
if old_obj[name][1] != new_obj[name][1]: |
363 |
# Found a differing child, delve deeper
|
|
364 |
path = posixpath.join(path, name) |
|
365 |
old_obj = lookup_object(old_obj[name][1]) |
|
366 |
new_obj = new_objs[path] |
|
367 |
break
|
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
368 |
raise AssertionError( |
369 |
"objects differ for %s: %r != %r" % (path, old_obj, new_obj)) |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
370 |
|
371 |
||
0.200.1409
by Jelmer Vernooij
Support fetching into repositories that are stacked. |
372 |
def ensure_inventories_in_repo(repo, trees): |
373 |
real_inv_vf = repo.inventories.without_fallbacks() |
|
374 |
for t in trees: |
|
375 |
revid = t.get_revision_id() |
|
376 |
if not real_inv_vf.get_parent_map([(revid, )]): |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
377 |
repo.add_inventory(revid, t.root_inventory, t.get_parent_ids()) |
0.200.1409
by Jelmer Vernooij
Support fetching into repositories that are stacked. |
378 |
|
379 |
||
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
380 |
def import_git_commit(repo, mapping, head, lookup_object, |
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
381 |
target_git_object_retriever, trees_cache): |
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
382 |
o = lookup_object(head) |
0.261.5
by Jelmer Vernooij
Fix looking up of parents during fetch. |
383 |
# Note that this uses mapping.revision_id_foreign_to_bzr. If the parents
|
384 |
# were bzr roundtripped revisions they would be specified in the
|
|
385 |
# roundtrip data.
|
|
0.261.4
by Jelmer Vernooij
Fix tests. |
386 |
rev, roundtrip_revid, verifiers = mapping.import_commit( |
0.261.5
by Jelmer Vernooij
Fix looking up of parents during fetch. |
387 |
o, mapping.revision_id_foreign_to_bzr) |
0.200.1329
by Jelmer Vernooij
Fix more tests. |
388 |
if roundtrip_revid is not None: |
389 |
original_revid = rev.revision_id |
|
390 |
rev.revision_id = roundtrip_revid |
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
391 |
# We have to do this here, since we have to walk the tree and
|
392 |
# we need to make sure to import the blobs / trees with the right
|
|
393 |
# path; this may involve adding them more than once.
|
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
394 |
parent_trees = trees_cache.revision_trees(rev.parent_ids) |
0.200.1409
by Jelmer Vernooij
Support fetching into repositories that are stacked. |
395 |
ensure_inventories_in_repo(repo, parent_trees) |
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
396 |
if parent_trees == []: |
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
397 |
base_bzr_tree = trees_cache.revision_tree(NULL_REVISION) |
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
398 |
base_tree = None |
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
399 |
base_mode = None |
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
400 |
else: |
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
401 |
base_bzr_tree = parent_trees[0] |
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
402 |
base_tree = lookup_object(o.parents[0]).tree |
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
403 |
base_mode = stat.S_IFDIR |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
404 |
store_updater = target_git_object_retriever._get_updater(rev) |
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
405 |
tree_supplement = mapping.get_fileid_map(lookup_object, o.tree) |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
406 |
inv_delta, unusual_modes = import_git_tree( |
407 |
repo.texts, mapping, b"", b"", (base_tree, o.tree), base_bzr_tree, |
|
408 |
None, rev.revision_id, parent_trees, lookup_object, |
|
409 |
(base_mode, stat.S_IFDIR), store_updater, |
|
410 |
tree_supplement.lookup_file_id, |
|
411 |
allow_submodules=repo._format.supports_tree_reference) |
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
412 |
if unusual_modes != {}: |
413 |
for path, mode in unusual_modes.iteritems(): |
|
414 |
warn_unusual_mode(rev.foreign_revid, path, mode) |
|
415 |
mapping.import_unusual_file_modes(rev, unusual_modes) |
|
416 |
try: |
|
417 |
basis_id = rev.parent_ids[0] |
|
418 |
except IndexError: |
|
419 |
basis_id = NULL_REVISION |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
420 |
base_bzr_inventory = None |
421 |
else: |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
422 |
base_bzr_inventory = base_bzr_tree.root_inventory |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
423 |
rev.inventory_sha1, inv = repo.add_inventory_by_delta( |
424 |
basis_id, inv_delta, rev.revision_id, rev.parent_ids, |
|
425 |
base_bzr_inventory) |
|
0.200.1195
by Jelmer Vernooij
Cope with new StrictTestament3 arguments. |
426 |
ret_tree = InventoryRevisionTree(repo, inv, rev.revision_id) |
0.200.1329
by Jelmer Vernooij
Fix more tests. |
427 |
# Check verifiers
|
428 |
if verifiers and roundtrip_revid is not None: |
|
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
429 |
testament = StrictTestament3(rev, ret_tree) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
430 |
calculated_verifiers = {"testament3-sha1": testament.as_sha1()} |
0.200.1329
by Jelmer Vernooij
Fix more tests. |
431 |
if calculated_verifiers != verifiers: |
432 |
trace.mutter("Testament SHA1 %r for %r did not match %r.", |
|
433 |
calculated_verifiers["testament3-sha1"], |
|
434 |
rev.revision_id, verifiers["testament3-sha1"]) |
|
435 |
rev.revision_id = original_revid |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
436 |
rev.inventory_sha1, inv = repo.add_inventory_by_delta( |
437 |
basis_id, inv_delta, rev.revision_id, rev.parent_ids, |
|
438 |
base_bzr_tree) |
|
0.200.1329
by Jelmer Vernooij
Fix more tests. |
439 |
ret_tree = InventoryRevisionTree(repo, inv, rev.revision_id) |
0.200.1179
by Jelmer Vernooij
Avoid using verifiers for natively imported revisions, save a lot of time. |
440 |
else: |
441 |
calculated_verifiers = {} |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
442 |
store_updater.add_object(o, calculated_verifiers, None) |
443 |
store_updater.finish() |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
444 |
trees_cache.add(ret_tree) |
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
445 |
repo.add_revision(rev.revision_id, rev) |
446 |
if "verify" in debug.debug_flags: |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
447 |
verify_commit_reconstruction( |
448 |
target_git_object_retriever, lookup_object, o, rev, ret_tree, |
|
449 |
parent_trees, mapping, unusual_modes, verifiers) |
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
450 |
|
451 |
||
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
452 |
def import_git_objects(repo, mapping, object_iter, |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
453 |
target_git_object_retriever, heads, pb=None, |
454 |
limit=None): |
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
455 |
"""Import a set of git objects into a bzr repository. |
456 |
||
0.200.483
by Jelmer Vernooij
Add NEWS entry about sha map. |
457 |
:param repo: Target Bazaar repository
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
458 |
:param mapping: Mapping to use
|
459 |
:param object_iter: Iterator over Git objects.
|
|
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
460 |
:return: Tuple with pack hints and last imported revision id
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
461 |
"""
|
0.200.469
by Jelmer Vernooij
Fix fetch when revisions are already present locally, just only mapped. |
462 |
def lookup_object(sha): |
463 |
try: |
|
464 |
return object_iter[sha] |
|
465 |
except KeyError: |
|
466 |
return target_git_object_retriever[sha] |
|
0.200.158
by Jelmer Vernooij
fetch works \o/ |
467 |
graph = [] |
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
468 |
checked = set() |
0.200.734
by Jelmer Vernooij
Don't import head revision twice when pulling from Git. |
469 |
heads = list(set(heads)) |
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
470 |
trees_cache = LRUTreeCache(repo) |
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
471 |
# Find and convert commit objects
|
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
472 |
while heads: |
473 |
if pb is not None: |
|
474 |
pb.update("finding revisions to fetch", len(graph), None) |
|
475 |
head = heads.pop() |
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
476 |
if head == ZERO_SHA: |
477 |
continue
|
|
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
478 |
if not isinstance(head, bytes): |
0.361.1
by Jelmer Vernooij
Don't use assert. |
479 |
raise TypeError(head) |
0.200.310
by Jelmer Vernooij
Fix pull from remote branches. |
480 |
try: |
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
481 |
o = lookup_object(head) |
0.200.310
by Jelmer Vernooij
Fix pull from remote branches. |
482 |
except KeyError: |
483 |
continue
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
484 |
if isinstance(o, Commit): |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
485 |
rev, roundtrip_revid, verifiers = mapping.import_commit( |
486 |
o, mapping.revision_id_foreign_to_bzr) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
487 |
if (repo.has_revision(rev.revision_id) |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
488 |
or (roundtrip_revid and |
489 |
repo.has_revision(roundtrip_revid))): |
|
0.200.295
by Jelmer Vernooij
Don't re-import revisions already fetched. |
490 |
continue
|
0.200.668
by Jelmer Vernooij
Fix some places where we were way too much memory for repositories with a large number of entries in the inventory and a large number of revisions. |
491 |
graph.append((o.id, o.parents)) |
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
492 |
heads.extend([p for p in o.parents if p not in checked]) |
0.200.303
by Jelmer Vernooij
Cope with tags during fetch. |
493 |
elif isinstance(o, Tag): |
0.200.734
by Jelmer Vernooij
Don't import head revision twice when pulling from Git. |
494 |
if o.object[1] not in checked: |
495 |
heads.append(o.object[1]) |
|
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
496 |
else: |
497 |
trace.warning("Unable to import head object %r" % o) |
|
0.200.668
by Jelmer Vernooij
Fix some places where we were way too much memory for repositories with a large number of entries in the inventory and a large number of revisions. |
498 |
checked.add(o.id) |
499 |
del checked |
|
0.200.158
by Jelmer Vernooij
fetch works \o/ |
500 |
# Order the revisions
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
501 |
# Create the inventory objects
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
502 |
batch_size = 1000 |
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
503 |
revision_ids = topo_sort(graph) |
504 |
pack_hints = [] |
|
0.247.2
by Michael Hudson
this works for my tests, but i'm pretty sure it's wrong in general |
505 |
if limit is not None: |
506 |
revision_ids = revision_ids[:limit] |
|
0.247.3
by Michael Hudson
oh, so it wasn't (particularly) wrong, but it was a bit obscure |
507 |
last_imported = None |
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
508 |
for offset in range(0, len(revision_ids), batch_size): |
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
509 |
target_git_object_retriever.start_write_group() |
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
510 |
try: |
0.254.33
by Jelmer Vernooij
Merge trunk. |
511 |
repo.start_write_group() |
512 |
try: |
|
0.200.824
by Jelmer Vernooij
Commit cache data in batches as well. |
513 |
for i, head in enumerate( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
514 |
revision_ids[offset:offset + batch_size]): |
0.254.33
by Jelmer Vernooij
Merge trunk. |
515 |
if pb is not None: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
516 |
pb.update("fetching revisions", offset + i, |
0.200.824
by Jelmer Vernooij
Commit cache data in batches as well. |
517 |
len(revision_ids)) |
0.254.33
by Jelmer Vernooij
Merge trunk. |
518 |
import_git_commit(repo, mapping, head, lookup_object, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
519 |
target_git_object_retriever, trees_cache) |
0.254.33
by Jelmer Vernooij
Merge trunk. |
520 |
last_imported = head |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
521 |
except BaseException: |
0.254.33
by Jelmer Vernooij
Merge trunk. |
522 |
repo.abort_write_group() |
523 |
raise
|
|
524 |
else: |
|
525 |
hint = repo.commit_write_group() |
|
526 |
if hint is not None: |
|
527 |
pack_hints.extend(hint) |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
528 |
except BaseException: |
0.254.33
by Jelmer Vernooij
Merge trunk. |
529 |
target_git_object_retriever.abort_write_group() |
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
530 |
raise
|
531 |
else: |
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
532 |
target_git_object_retriever.commit_write_group() |
0.247.2
by Michael Hudson
this works for my tests, but i'm pretty sure it's wrong in general |
533 |
return pack_hints, last_imported |
0.200.141
by Jelmer Vernooij
Separate out local and remote fetching. |
534 |
|
535 |
||
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
536 |
class DetermineWantsRecorder(object): |
537 |
||
538 |
def __init__(self, actual): |
|
539 |
self.actual = actual |
|
540 |
self.wants = [] |
|
541 |
self.remote_refs = {} |
|
542 |
||
543 |
def __call__(self, refs): |
|
0.361.1
by Jelmer Vernooij
Don't use assert. |
544 |
if type(refs) is not dict: |
545 |
raise TypeError(refs) |
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
546 |
self.remote_refs = refs |
547 |
self.wants = self.actual(refs) |
|
548 |
return self.wants |