bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.910
by Jelmer Vernooij
update copyright years |
1 |
# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org>
|
|
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
0.200.1594
by Jelmer Vernooij
Use absolute_import everywhere. |
17 |
from __future__ import absolute_import |
18 |
||
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
19 |
from dulwich.errors import ( |
20 |
NotCommitError, |
|
21 |
)
|
|
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
22 |
from dulwich.objects import ( |
23 |
Commit, |
|
|
0.200.303
by Jelmer Vernooij
Cope with tags during fetch. |
24 |
Tag, |
|
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
25 |
Tree, |
|
0.200.1407
by Jelmer Vernooij
Don't consider submodule modes unusual. |
26 |
S_IFGITLINK, |
|
0.200.540
by Jelmer Vernooij
Handle submodules explicitly. |
27 |
S_ISGITLINK, |
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
28 |
ZERO_SHA, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
29 |
)
|
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
30 |
from dulwich.object_store import ( |
|
0.281.5
by William Grant
Fix pull with new dulwich by avoiding removed ObjectStore.get_graph_walker. |
31 |
ObjectStoreGraphWalker, |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
32 |
tree_lookup_path, |
33 |
)
|
|
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
34 |
from dulwich.walk import Walker |
|
0.200.830
by Jelmer Vernooij
Bump minimum dulwich version. |
35 |
from itertools import ( |
36 |
imap, |
|
37 |
)
|
|
|
0.200.819
by Jelmer Vernooij
Avoid decoding basename twice. |
38 |
import posixpath |
|
0.200.563
by Jelmer Vernooij
Attempt to parse progress indication from git status reports. |
39 |
import re |
|
0.200.352
by Jelmer Vernooij
Simplify mode handling. |
40 |
import stat |
|
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
41 |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
42 |
from ... import ( |
|
0.231.2
by Jelmer Vernooij
Add -Dverify flag (not fully implemented yet). |
43 |
debug, |
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
44 |
errors, |
|
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
45 |
osutils, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
46 |
trace, |
|
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
47 |
ui, |
48 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
49 |
from ...errors import ( |
|
0.239.5
by Jelmer Vernooij
Print user-understandable error message when encountering submodules. |
50 |
BzrError, |
|
0.200.252
by Jelmer Vernooij
Clarify history, copyright. |
51 |
)
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
52 |
from ...bzr.inventory import ( |
|
0.229.2
by Jelmer Vernooij
Initial work relying on inventory deltas. |
53 |
InventoryDirectory, |
54 |
InventoryFile, |
|
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
55 |
InventoryLink, |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
56 |
TreeReference, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
57 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
58 |
from ...repository import ( |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
59 |
InterRepository, |
60 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
61 |
from ...revision import ( |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
62 |
NULL_REVISION, |
63 |
)
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
64 |
from ...bzr.inventorytree import InventoryRevisionTree |
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
65 |
from ...testament import ( |
|
0.200.1023
by Jelmer Vernooij
Set and verify testament. |
66 |
StrictTestament3, |
67 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
68 |
from ...tsort import ( |
|
0.200.292
by Jelmer Vernooij
Fix formatting. |
69 |
topo_sort, |
70 |
)
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
71 |
from ...bzr.versionedfile import ( |
|
0.200.811
by Jelmer Vernooij
Use ChunkedContentFactory when possible. |
72 |
ChunkedContentFactory, |
|
0.200.417
by Jelmer Vernooij
use insert_record_stream rather than add_lines. |
73 |
)
|
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
74 |
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
75 |
from .mapping import ( |
|
0.200.345
by Jelmer Vernooij
Keep track of file modes to use. |
76 |
DEFAULT_FILE_MODE, |
|
0.200.521
by Jelmer Vernooij
Abstract out kind mapping a bit, initial work on support tree-references. |
77 |
mode_is_executable, |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
78 |
mode_kind, |
|
0.200.490
by Jelmer Vernooij
Warn about unusual modes and escaped XML-invalid characters. |
79 |
warn_unusual_mode, |
|
0.231.2
by Jelmer Vernooij
Add -Dverify flag (not fully implemented yet). |
80 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
81 |
from .object_store import ( |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
82 |
BazaarObjectStore, |
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
83 |
LRUTreeCache, |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
84 |
_tree_to_objects, |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
85 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
86 |
from .refs import ( |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
87 |
is_tag, |
|
0.200.1458
by Jelmer Vernooij
Gather peeled shas rather than unpeeled. |
88 |
)
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
89 |
from .remote import ( |
|
0.200.426
by Jelmer Vernooij
Fix import of RemoteGitRepository. |
90 |
RemoteGitRepository, |
91 |
)
|
|
|
0.200.1641
by Jelmer Vernooij
Use relative imports where possible. |
92 |
from .repository import ( |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
93 |
GitRepository, |
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
94 |
GitRepositoryFormat, |
|
0.200.426
by Jelmer Vernooij
Fix import of RemoteGitRepository. |
95 |
LocalGitRepository, |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
96 |
)
|
|
0.216.4
by Jelmer Vernooij
Add basic pack fetch infrastructure. |
97 |
|
98 |
||
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
99 |
def import_git_blob(texts, mapping, path, name, (base_hexsha, hexsha), |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
100 |
base_bzr_tree, parent_id, revision_id, |
101 |
parent_bzr_trees, lookup_object, (base_mode, mode), store_updater, |
|
|
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
102 |
lookup_file_id): |
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
103 |
"""Import a git blob object into a bzr repository. |
104 |
||
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
105 |
:param texts: VersionedFiles to add to
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
106 |
:param path: Path in the tree
|
107 |
:param blob: A git blob
|
|
|
0.229.1
by Jelmer Vernooij
Start working with inventory deltas. |
108 |
:return: Inventory delta for this file
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
109 |
"""
|
|
0.252.28
by Jelmer Vernooij
Don't import control files. |
110 |
if mapping.is_control_file(path): |
111 |
return [] |
|
|
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
112 |
if base_hexsha == hexsha and base_mode == mode: |
113 |
# 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. |
114 |
return [] |
|
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
115 |
file_id = lookup_file_id(path) |
|
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
116 |
if stat.S_ISLNK(mode): |
|
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
117 |
cls = InventoryLink |
118 |
else: |
|
119 |
cls = InventoryFile |
|
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
120 |
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. |
121 |
if ie.kind == "file": |
122 |
ie.executable = mode_is_executable(mode) |
|
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
123 |
if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode): |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
124 |
base_exec = base_bzr_tree.is_executable(path) |
|
0.200.995
by Jelmer Vernooij
Support newer versions of bzr where only some InventoryFile/InventoryLink attributes are writable. |
125 |
if ie.kind == "symlink": |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
126 |
ie.symlink_target = base_bzr_tree.get_symlink_target(path) |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
127 |
else: |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
128 |
ie.text_size = base_bzr_tree.get_file_size(path) |
129 |
ie.text_sha1 = base_bzr_tree.get_file_sha1(path) |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
130 |
if ie.kind == "symlink" or ie.executable == base_exec: |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
131 |
ie.revision = base_bzr_tree.get_file_revision(path) |
|
0.200.537
by Jelmer Vernooij
Fix handling of not-executable files becoming executable without any other changes. |
132 |
else: |
133 |
blob = lookup_object(hexsha) |
|
|
0.200.304
by Jelmer Vernooij
Try a bit harder to avoid fetching objects we don't need. |
134 |
else: |
135 |
blob = lookup_object(hexsha) |
|
|
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
136 |
if ie.kind == "symlink": |
|
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
137 |
ie.revision = None |
|
0.200.1344
by Jelmer Vernooij
Unicode symlinks should be unicode in inventory entries. |
138 |
ie.symlink_target = blob.data.decode("utf-8") |
|
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
139 |
else: |
|
0.200.830
by Jelmer Vernooij
Bump minimum dulwich version. |
140 |
ie.text_size = sum(imap(len, blob.chunked)) |
141 |
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). |
142 |
# Check what revision we should store
|
|
0.200.283
by Jelmer Vernooij
Avoid storing repeated texts for blobs. |
143 |
parent_keys = [] |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
144 |
for ptree in parent_bzr_trees: |
|
0.200.1576
by Jelmer Vernooij
Merge a bunch of fixes from store-roundtrip-info. |
145 |
try: |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
146 |
ppath = ptree.id2path(file_id) |
|
0.200.1576
by Jelmer Vernooij
Merge a bunch of fixes from store-roundtrip-info. |
147 |
except errors.NoSuchId: |
|
0.200.829
by Jelmer Vernooij
Cope with the fact that _type is gone in upstream dulwich. |
148 |
continue
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
149 |
pkind = ptree.kind(ppath, file_id) |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
150 |
if (pkind == ie.kind and |
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
151 |
((pkind == "symlink" and ptree.get_symlink_target(ppath, file_id) == ie.symlink_target) or |
152 |
(pkind == "file" and ptree.get_file_sha1(ppath, file_id) == ie.text_sha1 and |
|
153 |
ptree.is_executable(ppath, file_id) == ie.executable))): |
|
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
154 |
# found a revision in one of the parents to use
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
155 |
ie.revision = ptree.get_file_revision(ppath, file_id) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
156 |
break
|
|
0.285.1
by Jelmer Vernooij
Swap arguments for tree methods. |
157 |
parent_key = (file_id, ptree.get_file_revision(ppath, file_id)) |
|
0.200.904
by Jelmer Vernooij
Fix inconsistent parents. |
158 |
if not parent_key in parent_keys: |
159 |
parent_keys.append(parent_key) |
|
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
160 |
if ie.revision is None: |
161 |
# Need to store a new revision
|
|
162 |
ie.revision = revision_id |
|
163 |
assert ie.revision is not None |
|
|
0.200.698
by Jelmer Vernooij
Merge fixes for SHA1s of symlinks. |
164 |
if ie.kind == 'symlink': |
|
0.200.811
by Jelmer Vernooij
Use ChunkedContentFactory when possible. |
165 |
chunks = [] |
|
0.200.1292
by Jelmer Vernooij
Fix repeeling objects when determining what to send. |
166 |
else: |
|
0.200.830
by Jelmer Vernooij
Bump minimum dulwich version. |
167 |
chunks = blob.chunked |
|
0.252.25
by Jelmer Vernooij
Reformatting. |
168 |
texts.insert_record_stream([ |
169 |
ChunkedContentFactory((file_id, ie.revision), |
|
170 |
tuple(parent_keys), ie.text_sha1, chunks)]) |
|
|
0.200.572
by Jelmer Vernooij
Avoid some extra path lookups. |
171 |
invdelta = [] |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
172 |
if base_hexsha is not None: |
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
173 |
old_path = path.decode("utf-8") # Renames are not supported yet |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
174 |
if stat.S_ISDIR(base_mode): |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
175 |
invdelta.extend(remove_disappeared_children(base_bzr_tree, old_path, |
|
0.200.826
by Jelmer Vernooij
Fix some long lines. |
176 |
lookup_object(base_hexsha), [], lookup_object)) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
177 |
else: |
178 |
old_path = None |
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
179 |
new_path = path.decode("utf-8") |
180 |
invdelta.append((old_path, new_path, file_id, ie)) |
|
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
181 |
if base_hexsha != hexsha: |
|
0.275.2
by Jelmer Vernooij
Pass tuples around for cache entries, rather than inventory entries. |
182 |
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. |
183 |
return invdelta |
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
184 |
|
185 |
||
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
186 |
class SubmodulesRequireSubtrees(BzrError): |
|
0.200.1596
by Jelmer Vernooij
Don't mention development-subtree when submodules are encountered. |
187 |
_fmt = ("The repository you are fetching from contains submodules, " |
188 |
"which are not yet supported.") |
|
|
0.239.5
by Jelmer Vernooij
Print user-understandable error message when encountering submodules. |
189 |
internal = False |
190 |
||
191 |
||
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
192 |
def import_git_submodule(texts, mapping, path, name, (base_hexsha, hexsha), |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
193 |
base_bzr_tree, parent_id, revision_id, parent_bzr_trees, lookup_object, |
|
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
194 |
(base_mode, mode), store_updater, lookup_file_id): |
|
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
195 |
"""Import a git submodule.""" |
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
196 |
if base_hexsha == hexsha and base_mode == mode: |
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
197 |
return [], {} |
|
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
198 |
file_id = lookup_file_id(path) |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
199 |
invdelta = [] |
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
200 |
ie = TreeReference(file_id, name.decode("utf-8"), parent_id) |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
201 |
ie.revision = revision_id |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
202 |
if base_hexsha is not None: |
203 |
old_path = path.decode("utf-8") # Renames are not supported yet |
|
204 |
if stat.S_ISDIR(base_mode): |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
205 |
invdelta.extend(remove_disappeared_children(base_bzr_tree, old_path, |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
206 |
lookup_object(base_hexsha), [], lookup_object)) |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
207 |
else: |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
208 |
old_path = None |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
209 |
ie.reference_revision = mapping.revision_id_foreign_to_bzr(hexsha) |
|
0.252.25
by Jelmer Vernooij
Reformatting. |
210 |
texts.insert_record_stream([ |
211 |
ChunkedContentFactory((file_id, ie.revision), (), None, [])]) |
|
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
212 |
invdelta.append((old_path, path, file_id, ie)) |
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
213 |
return invdelta, {} |
|
0.200.540
by Jelmer Vernooij
Handle submodules explicitly. |
214 |
|
215 |
||
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
216 |
def remove_disappeared_children(base_bzr_tree, path, base_tree, existing_children, |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
217 |
lookup_object): |
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
218 |
"""Generate an inventory delta for removed children. |
219 |
||
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
220 |
: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. |
221 |
inventory delta.
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
222 |
:param path: Path to process (unicode)
|
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
223 |
:param base_tree: Git Tree base object
|
224 |
:param existing_children: Children that still exist
|
|
225 |
:param lookup_object: Lookup a git object by its SHA1
|
|
226 |
:return: Inventory delta, as list
|
|
227 |
"""
|
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
228 |
assert type(path) is unicode |
|
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
229 |
ret = [] |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
230 |
for name, mode, hexsha in base_tree.iteritems(): |
231 |
if name in existing_children: |
|
232 |
continue
|
|
233 |
c_path = posixpath.join(path, name.decode("utf-8")) |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
234 |
file_id = base_bzr_tree.path2id(c_path) |
|
0.200.930
by Jelmer Vernooij
Add assert demonstrating 571055 and triggering it for all target formats. |
235 |
assert file_id is not None |
236 |
ret.append((c_path, None, file_id, None)) |
|
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
237 |
if stat.S_ISDIR(mode): |
238 |
ret.extend(remove_disappeared_children( |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
239 |
base_bzr_tree, c_path, lookup_object(hexsha), [], lookup_object)) |
|
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
240 |
return ret |
241 |
||
242 |
||
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
243 |
def import_git_tree(texts, mapping, path, name, (base_hexsha, hexsha), |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
244 |
base_bzr_tree, parent_id, revision_id, parent_bzr_trees, |
|
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
245 |
lookup_object, (base_mode, mode), store_updater, |
246 |
lookup_file_id, allow_submodules=False): |
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
247 |
"""Import a git tree object into a bzr repository. |
248 |
||
|
0.200.261
by Jelmer Vernooij
More formatting fixes. |
249 |
:param texts: VersionedFiles object to add to
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
250 |
:param path: Path in the tree (str)
|
251 |
:param name: Name of the tree (str)
|
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
252 |
:param tree: A git tree object
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
253 |
:param base_bzr_tree: Base inventory against which to return inventory delta
|
|
0.229.1
by Jelmer Vernooij
Start working with inventory deltas. |
254 |
:return: Inventory delta for this subtree
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
255 |
"""
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
256 |
assert type(path) is str |
257 |
assert type(name) is str |
|
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
258 |
if base_hexsha == hexsha and base_mode == mode: |
259 |
# 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. |
260 |
return [], {} |
|
0.200.344
by Jelmer Vernooij
Clarify names, use convenience function |
261 |
invdelta = [] |
|
0.200.896
by Jelmer Vernooij
Add separate function for looking up file ids. |
262 |
file_id = lookup_file_id(path) |
|
0.200.297
by Jelmer Vernooij
Cope with non-ascii characters in filenames (needs a test..). |
263 |
# We just have to hope this is indeed utf-8:
|
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
264 |
ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id) |
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
265 |
tree = lookup_object(hexsha) |
266 |
if base_hexsha is None: |
|
267 |
base_tree = None |
|
|
0.200.823
by Jelmer Vernooij
Simplify logic in import_git_tree a bit. |
268 |
old_path = None # Newly appeared here |
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
269 |
else: |
270 |
base_tree = lookup_object(base_hexsha) |
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
271 |
old_path = path.decode("utf-8") # Renames aren't supported yet |
272 |
new_path = path.decode("utf-8") |
|
|
0.200.823
by Jelmer Vernooij
Simplify logic in import_git_tree a bit. |
273 |
if base_tree is None or type(base_tree) is not Tree: |
274 |
ie.revision = revision_id |
|
|
0.200.984
by Jelmer Vernooij
Handle non-ascii characters in filenames. |
275 |
invdelta.append((old_path, new_path, ie.file_id, ie)) |
|
0.252.24
by Jelmer Vernooij
Support reading fileid map. |
276 |
texts.insert_record_stream([ |
277 |
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). |
278 |
# Remember for next time
|
|
0.200.300
by Jelmer Vernooij
Fix recursive deletion of dirs. |
279 |
existing_children = set() |
|
0.200.345
by Jelmer Vernooij
Keep track of file modes to use. |
280 |
child_modes = {} |
|
0.200.1147
by Jelmer Vernooij
Use Tree.items() rather than Tree.entries(). |
281 |
for name, child_mode, child_hexsha in tree.iteritems(): |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
282 |
existing_children.add(name) |
|
0.200.819
by Jelmer Vernooij
Avoid decoding basename twice. |
283 |
child_path = posixpath.join(path, name) |
|
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
284 |
if type(base_tree) is Tree: |
285 |
try: |
|
286 |
child_base_mode, child_base_hexsha = base_tree[name] |
|
287 |
except KeyError: |
|
288 |
child_base_hexsha = None |
|
289 |
child_base_mode = 0 |
|
290 |
else: |
|
291 |
child_base_hexsha = None |
|
292 |
child_base_mode = 0 |
|
|
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
293 |
if stat.S_ISDIR(child_mode): |
|
0.252.25
by Jelmer Vernooij
Reformatting. |
294 |
subinvdelta, grandchildmodes = import_git_tree(texts, mapping, |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
295 |
child_path, name, (child_base_hexsha, child_hexsha), |
296 |
base_bzr_tree, file_id, revision_id, parent_bzr_trees, |
|
297 |
lookup_object, (child_base_mode, child_mode), store_updater, |
|
298 |
lookup_file_id, allow_submodules=allow_submodules) |
|
|
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
299 |
elif S_ISGITLINK(child_mode): # submodule |
|
0.200.666
by Jelmer Vernooij
Refuse to add tree references to non-subtree formats. |
300 |
if not allow_submodules: |
301 |
raise SubmodulesRequireSubtrees() |
|
|
0.252.25
by Jelmer Vernooij
Reformatting. |
302 |
subinvdelta, grandchildmodes = import_git_submodule(texts, mapping, |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
303 |
child_path, name, (child_base_hexsha, child_hexsha), |
304 |
base_bzr_tree, file_id, revision_id, parent_bzr_trees, |
|
305 |
lookup_object, (child_base_mode, child_mode), store_updater, |
|
306 |
lookup_file_id) |
|
|
0.200.352
by Jelmer Vernooij
Simplify mode handling. |
307 |
else: |
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
308 |
if not mapping.is_special_file(name): |
309 |
subinvdelta = import_git_blob(texts, mapping, child_path, name, |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
310 |
(child_base_hexsha, child_hexsha), base_bzr_tree, file_id, |
311 |
revision_id, parent_bzr_trees, lookup_object, |
|
|
0.200.1328
by Jelmer Vernooij
More test fixes. |
312 |
(child_base_mode, child_mode), store_updater, lookup_file_id) |
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, |
|
0.200.1407
by Jelmer Vernooij
Don't consider submodule modes unusual. |
319 |
stat.S_IFLNK, DEFAULT_FILE_MODE|0111, |
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: |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
324 |
invdelta.extend(remove_disappeared_children(base_bzr_tree, old_path, |
|
0.200.820
by Jelmer Vernooij
Avoid relying on InventoryDirectory.children. |
325 |
base_tree, existing_children, lookup_object)) |
|
0.275.2
by Jelmer Vernooij
Pass tuples around for cache entries, rather than inventory entries. |
326 |
store_updater.add_object(tree, (file_id, ), path) |
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
327 |
return invdelta, child_modes |
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
328 |
|
329 |
||
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
330 |
def verify_commit_reconstruction(target_git_object_retriever, lookup_object, |
|
0.200.1047
by Jelmer Vernooij
Fix -Dverify. |
331 |
o, rev, ret_tree, parent_trees, mapping, unusual_modes, verifiers): |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
332 |
new_unusual_modes = mapping.export_unusual_file_modes(rev) |
333 |
if new_unusual_modes != unusual_modes: |
|
334 |
raise AssertionError("unusual modes don't match: %r != %r" % ( |
|
335 |
unusual_modes, new_unusual_modes)) |
|
336 |
# Verify that we can reconstruct the commit properly
|
|
|
0.200.1047
by Jelmer Vernooij
Fix -Dverify. |
337 |
rec_o = target_git_object_retriever._reconstruct_commit(rev, o.tree, True, |
338 |
verifiers) |
|
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
339 |
if rec_o != o: |
340 |
raise AssertionError("Reconstructed commit differs: %r != %r" % ( |
|
341 |
rec_o, o)) |
|
342 |
diff = [] |
|
343 |
new_objs = {} |
|
344 |
for path, obj, ie in _tree_to_objects(ret_tree, parent_trees, |
|
|
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
345 |
target_git_object_retriever._cache.idmap, unusual_modes, |
346 |
mapping.BZR_DUMMY_FILE): |
|
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
347 |
old_obj_id = tree_lookup_path(lookup_object, o.tree, path)[1] |
348 |
new_objs[path] = obj |
|
349 |
if obj.id != old_obj_id: |
|
350 |
diff.append((path, lookup_object(old_obj_id), obj)) |
|
351 |
for (path, old_obj, new_obj) in diff: |
|
352 |
while (old_obj.type_name == "tree" and |
|
353 |
new_obj.type_name == "tree" and |
|
354 |
sorted(old_obj) == sorted(new_obj)): |
|
355 |
for name in old_obj: |
|
356 |
if old_obj[name][0] != new_obj[name][0]: |
|
|
0.252.25
by Jelmer Vernooij
Reformatting. |
357 |
raise AssertionError("Modes for %s differ: %o != %o" % |
358 |
(path, old_obj[name][0], new_obj[name][0])) |
|
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
359 |
if old_obj[name][1] != new_obj[name][1]: |
360 |
# Found a differing child, delve deeper
|
|
361 |
path = posixpath.join(path, name) |
|
362 |
old_obj = lookup_object(old_obj[name][1]) |
|
363 |
new_obj = new_objs[path] |
|
364 |
break
|
|
365 |
raise AssertionError("objects differ for %s: %r != %r" % (path, |
|
366 |
old_obj, new_obj)) |
|
367 |
||
368 |
||
|
0.200.1409
by Jelmer Vernooij
Support fetching into repositories that are stacked. |
369 |
def ensure_inventories_in_repo(repo, trees): |
370 |
real_inv_vf = repo.inventories.without_fallbacks() |
|
371 |
for t in trees: |
|
372 |
revid = t.get_revision_id() |
|
373 |
if not real_inv_vf.get_parent_map([(revid, )]): |
|
374 |
repo.add_inventory(revid, t.inventory, t.get_parent_ids()) |
|
375 |
||
376 |
||
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
377 |
def import_git_commit(repo, mapping, head, lookup_object, |
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
378 |
target_git_object_retriever, trees_cache): |
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
379 |
o = lookup_object(head) |
|
0.261.5
by Jelmer Vernooij
Fix looking up of parents during fetch. |
380 |
# Note that this uses mapping.revision_id_foreign_to_bzr. If the parents
|
381 |
# were bzr roundtripped revisions they would be specified in the
|
|
382 |
# roundtrip data.
|
|
|
0.261.4
by Jelmer Vernooij
Fix tests. |
383 |
rev, roundtrip_revid, verifiers = mapping.import_commit( |
|
0.261.5
by Jelmer Vernooij
Fix looking up of parents during fetch. |
384 |
o, mapping.revision_id_foreign_to_bzr) |
|
0.200.1329
by Jelmer Vernooij
Fix more tests. |
385 |
if roundtrip_revid is not None: |
386 |
original_revid = rev.revision_id |
|
387 |
rev.revision_id = roundtrip_revid |
|
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
388 |
# We have to do this here, since we have to walk the tree and
|
389 |
# we need to make sure to import the blobs / trees with the right
|
|
390 |
# path; this may involve adding them more than once.
|
|
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
391 |
parent_trees = trees_cache.revision_trees(rev.parent_ids) |
|
0.200.1409
by Jelmer Vernooij
Support fetching into repositories that are stacked. |
392 |
ensure_inventories_in_repo(repo, parent_trees) |
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
393 |
if parent_trees == []: |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
394 |
base_bzr_tree = trees_cache.revision_tree(NULL_REVISION) |
|
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
395 |
base_tree = None |
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
396 |
base_mode = None |
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
397 |
else: |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
398 |
base_bzr_tree = parent_trees[0] |
|
0.200.814
by Jelmer Vernooij
Avoid the use of InventoryDirectory.children. This speeds up |
399 |
base_tree = lookup_object(o.parents[0]).tree |
|
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
400 |
base_mode = stat.S_IFDIR |
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
401 |
store_updater = target_git_object_retriever._get_updater(rev) |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
402 |
tree_supplement = mapping.get_fileid_map(lookup_object, o.tree) |
|
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
403 |
inv_delta, unusual_modes = import_git_tree(repo.texts, |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
404 |
mapping, "", "", (base_tree, o.tree), base_bzr_tree, |
405 |
None, rev.revision_id, parent_trees, |
|
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
406 |
lookup_object, (base_mode, stat.S_IFDIR), store_updater, |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
407 |
tree_supplement.lookup_file_id, |
|
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
408 |
allow_submodules=getattr(repo._format, "supports_tree_reference", |
409 |
False)) |
|
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
410 |
if unusual_modes != {}: |
411 |
for path, mode in unusual_modes.iteritems(): |
|
412 |
warn_unusual_mode(rev.foreign_revid, path, mode) |
|
413 |
mapping.import_unusual_file_modes(rev, unusual_modes) |
|
414 |
try: |
|
415 |
basis_id = rev.parent_ids[0] |
|
416 |
except IndexError: |
|
417 |
basis_id = NULL_REVISION |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
418 |
base_bzr_inventory = None |
419 |
else: |
|
420 |
try: |
|
421 |
base_bzr_inventory = base_bzr_tree.root_inventory |
|
422 |
except AttributeError: # bzr < 2.6 |
|
423 |
base_bzr_inventory = base_bzr_tree.inventory |
|
|
0.200.679
by Jelmer Vernooij
Moving commit import functionality to a separate function. |
424 |
rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id, |
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
425 |
inv_delta, rev.revision_id, rev.parent_ids, |
426 |
base_bzr_inventory) |
|
|
0.200.1195
by Jelmer Vernooij
Cope with new StrictTestament3 arguments. |
427 |
ret_tree = InventoryRevisionTree(repo, inv, rev.revision_id) |
|
0.200.1329
by Jelmer Vernooij
Fix more tests. |
428 |
# Check verifiers
|
429 |
if verifiers and roundtrip_revid is not None: |
|
|
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
430 |
testament = StrictTestament3(rev, ret_tree) |
|
0.200.1329
by Jelmer Vernooij
Fix more tests. |
431 |
calculated_verifiers = { "testament3-sha1": testament.as_sha1() } |
432 |
if calculated_verifiers != verifiers: |
|
433 |
trace.mutter("Testament SHA1 %r for %r did not match %r.", |
|
434 |
calculated_verifiers["testament3-sha1"], |
|
435 |
rev.revision_id, verifiers["testament3-sha1"]) |
|
436 |
rev.revision_id = original_revid |
|
437 |
rev.inventory_sha1, inv = repo.add_inventory_by_delta(basis_id, |
|
|
0.275.3
by Jelmer Vernooij
Avoid inventories in a few more places. |
438 |
inv_delta, rev.revision_id, rev.parent_ids, 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: |
|
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
447 |
verify_commit_reconstruction(target_git_object_retriever, |
|
0.200.883
by Jelmer Vernooij
Add function for verifying reconstruction of objects still works. |
448 |
lookup_object, o, rev, ret_tree, parent_trees, mapping, |
|
0.200.1047
by Jelmer Vernooij
Fix -Dverify. |
449 |
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, |
453 |
target_git_object_retriever, heads, pb=None, limit=None): |
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
454 |
"""Import a set of git objects into a bzr repository. |
455 |
||
|
0.200.483
by Jelmer Vernooij
Add NEWS entry about sha map. |
456 |
:param repo: Target Bazaar repository
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
457 |
:param mapping: Mapping to use
|
458 |
:param object_iter: Iterator over Git objects.
|
|
|
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
459 |
:return: Tuple with pack hints and last imported revision id
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
460 |
"""
|
|
0.200.469
by Jelmer Vernooij
Fix fetch when revisions are already present locally, just only mapped. |
461 |
def lookup_object(sha): |
462 |
try: |
|
463 |
return object_iter[sha] |
|
464 |
except KeyError: |
|
465 |
return target_git_object_retriever[sha] |
|
|
0.200.158
by Jelmer Vernooij
fetch works \o/ |
466 |
graph = [] |
|
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
467 |
checked = set() |
|
0.200.734
by Jelmer Vernooij
Don't import head revision twice when pulling from Git. |
468 |
heads = list(set(heads)) |
|
0.200.852
by Jelmer Vernooij
Cache trees rather than inventories. |
469 |
trees_cache = LRUTreeCache(repo) |
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
470 |
# Find and convert commit objects
|
|
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
471 |
while heads: |
472 |
if pb is not None: |
|
473 |
pb.update("finding revisions to fetch", len(graph), None) |
|
474 |
head = heads.pop() |
|
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
475 |
if head == ZERO_SHA: |
476 |
continue
|
|
|
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
477 |
assert isinstance(head, str), "head is %r" % (head,) |
|
0.200.310
by Jelmer Vernooij
Fix pull from remote branches. |
478 |
try: |
|
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
479 |
o = lookup_object(head) |
|
0.200.310
by Jelmer Vernooij
Fix pull from remote branches. |
480 |
except KeyError: |
481 |
continue
|
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
482 |
if isinstance(o, Commit): |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
483 |
rev, roundtrip_revid, verifiers = mapping.import_commit(o, |
|
0.261.6
by Jelmer Vernooij
Use mapping.revision_id_foreign_to_bzr to find parents everywhere. |
484 |
mapping.revision_id_foreign_to_bzr) |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
485 |
if (repo.has_revision(rev.revision_id) or |
486 |
(roundtrip_revid and repo.has_revision(roundtrip_revid))): |
|
|
0.200.295
by Jelmer Vernooij
Don't re-import revisions already fetched. |
487 |
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. |
488 |
graph.append((o.id, o.parents)) |
|
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
489 |
heads.extend([p for p in o.parents if p not in checked]) |
|
0.200.303
by Jelmer Vernooij
Cope with tags during fetch. |
490 |
elif isinstance(o, Tag): |
|
0.200.734
by Jelmer Vernooij
Don't import head revision twice when pulling from Git. |
491 |
if o.object[1] not in checked: |
492 |
heads.append(o.object[1]) |
|
|
0.200.296
by Jelmer Vernooij
Avoid iterating over all objects just to find the *Commits* to retrieve. |
493 |
else: |
494 |
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. |
495 |
checked.add(o.id) |
496 |
del checked |
|
|
0.200.158
by Jelmer Vernooij
fetch works \o/ |
497 |
# Order the revisions
|
|
0.200.151
by Jelmer Vernooij
Support converting git objects to bzr objects. |
498 |
# Create the inventory objects
|
|
0.200.821
by Jelmer Vernooij
Remove last references to ID.children. |
499 |
batch_size = 1000 |
|
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
500 |
revision_ids = topo_sort(graph) |
501 |
pack_hints = [] |
|
|
0.247.2
by Michael Hudson
this works for my tests, but i'm pretty sure it's wrong in general |
502 |
if limit is not None: |
503 |
revision_ids = revision_ids[:limit] |
|
|
0.247.3
by Michael Hudson
oh, so it wasn't (particularly) wrong, but it was a bit obscure |
504 |
last_imported = None |
|
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
505 |
for offset in range(0, len(revision_ids), batch_size): |
|
0.200.1636
by Jelmer Vernooij
Some formatting fixes. |
506 |
target_git_object_retriever.start_write_group() |
|
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
507 |
try: |
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
508 |
repo.start_write_group() |
509 |
try: |
|
|
0.200.824
by Jelmer Vernooij
Commit cache data in batches as well. |
510 |
for i, head in enumerate( |
511 |
revision_ids[offset:offset+batch_size]): |
|
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
512 |
if pb is not None: |
|
0.200.824
by Jelmer Vernooij
Commit cache data in batches as well. |
513 |
pb.update("fetching revisions", offset+i, |
514 |
len(revision_ids)) |
|
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
515 |
import_git_commit(repo, mapping, head, lookup_object, |
|
0.252.25
by Jelmer Vernooij
Reformatting. |
516 |
target_git_object_retriever, trees_cache) |
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
517 |
last_imported = head |
518 |
except: |
|
519 |
repo.abort_write_group() |
|
520 |
raise
|
|
521 |
else: |
|
522 |
hint = repo.commit_write_group() |
|
523 |
if hint is not None: |
|
524 |
pack_hints.extend(hint) |
|
|
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
525 |
except: |
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
526 |
target_git_object_retriever.abort_write_group() |
|
0.200.680
by Jelmer Vernooij
fetch revisions in batches |
527 |
raise
|
528 |
else: |
|
|
0.254.33
by Jelmer Vernooij
Merge trunk. |
529 |
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 |
530 |
return pack_hints, last_imported |
|
0.200.141
by Jelmer Vernooij
Separate out local and remote fetching. |
531 |
|
532 |
||
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
533 |
class InterFromGitRepository(InterRepository): |
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
534 |
|
|
0.200.289
by Jelmer Vernooij
Cope with new member variables in RepositoryFormat. |
535 |
_matching_repo_format = GitRepositoryFormat() |
|
0.200.143
by Jelmer Vernooij
Reoncile InterGitRepository objects. |
536 |
|
|
0.200.1154
by Jelmer Vernooij
Share more code in InterGitRepository. |
537 |
def _target_has_shas(self, shas): |
538 |
raise NotImplementedError(self._target_has_shas) |
|
539 |
||
540 |
def get_determine_wants_heads(self, wants, include_tags=False): |
|
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
541 |
raise NotImplementedError(self.get_determine_wants_heads) |
|
0.200.1154
by Jelmer Vernooij
Share more code in InterGitRepository. |
542 |
|
543 |
def determine_wants_all(self, refs): |
|
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
544 |
raise NotImplementedError(self.determine_wants_all) |
|
0.200.1154
by Jelmer Vernooij
Share more code in InterGitRepository. |
545 |
|
|
0.200.143
by Jelmer Vernooij
Reoncile InterGitRepository objects. |
546 |
@staticmethod
|
547 |
def _get_repo_format_to_test(): |
|
548 |
return None |
|
549 |
||
|
0.200.1492
by Jelmer Vernooij
Fix test |
550 |
def copy_content(self, revision_id=None): |
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
551 |
"""See InterRepository.copy_content.""" |
|
0.200.1492
by Jelmer Vernooij
Fix test |
552 |
self.fetch(revision_id, find_ghosts=False) |
|
0.200.135
by Jelmer Vernooij
Add stub for fetching data. |
553 |
|
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
554 |
def search_missing_revision_ids(self, |
555 |
find_ghosts=True, revision_ids=None, if_present_ids=None, |
|
556 |
limit=None): |
|
557 |
git_shas = [] |
|
558 |
todo = [] |
|
559 |
if revision_ids: |
|
560 |
todo.extend(revision_ids) |
|
561 |
if if_present_ids: |
|
562 |
todo.extend(revision_ids) |
|
563 |
for revid in revision_ids: |
|
564 |
if revid == NULL_REVISION: |
|
565 |
continue
|
|
566 |
git_sha, mapping = self.source.lookup_bzr_revision_id(revid) |
|
567 |
git_shas.append(git_sha) |
|
568 |
walker = Walker(self.source._git.object_store, |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
569 |
include=git_shas, exclude=[ |
570 |
sha for sha in self.target.controldir.get_refs_container().as_dict().values() if sha != ZERO_SHA]) |
|
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
571 |
missing_revids = set() |
572 |
for entry in walker: |
|
573 |
missing_revids.add(self.source.lookup_foreign_revision_id(entry.commit.id)) |
|
574 |
return self.source.revision_ids_to_search_result(missing_revids) |
|
575 |
||
576 |
||
577 |
class InterGitNonGitRepository(InterFromGitRepository): |
|
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
578 |
"""Base InterRepository that copies revisions from a Git into a non-Git |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
579 |
repository."""
|
580 |
||
|
0.259.4
by Jelmer Vernooij
Put determine_wants methods on InterRepo. |
581 |
def _target_has_shas(self, shas): |
|
0.200.1456
by Jelmer Vernooij
Fix target_has_shas. |
582 |
revids = {} |
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
583 |
for sha in shas: |
584 |
try: |
|
585 |
revid = self.source.lookup_foreign_revision_id(sha) |
|
586 |
except NotCommitError: |
|
|
0.200.1456
by Jelmer Vernooij
Fix target_has_shas. |
587 |
# Commit is definitely not present
|
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
588 |
continue
|
589 |
else: |
|
|
0.200.1456
by Jelmer Vernooij
Fix target_has_shas. |
590 |
revids[revid] = sha |
591 |
return set([revids[r] for r in self.target.has_revisions(revids)]) |
|
|
0.259.4
by Jelmer Vernooij
Put determine_wants methods on InterRepo. |
592 |
|
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
593 |
def determine_wants_all(self, refs): |
594 |
potential = set() |
|
595 |
for k, v in refs.as_dict().iteritems(): |
|
596 |
# For non-git target repositories, only worry about peeled
|
|
|
0.200.1513
by Jelmer Vernooij
Cope with zero shas. |
597 |
if v == ZERO_SHA: |
598 |
continue
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
599 |
potential.add(self.source.controldir.get_peeled(k)) |
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
600 |
return list(potential - self._target_has_shas(potential)) |
601 |
||
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
602 |
def get_determine_wants_heads(self, wants, include_tags=False): |
603 |
wants = set(wants) |
|
604 |
def determine_wants(refs): |
|
605 |
potential = set(wants) |
|
606 |
if include_tags: |
|
607 |
for k, unpeeled in refs.as_dict().iteritems(): |
|
608 |
if not is_tag(k): |
|
609 |
continue
|
|
|
0.200.1513
by Jelmer Vernooij
Cope with zero shas. |
610 |
if unpeeled == ZERO_SHA: |
611 |
continue
|
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
612 |
potential.add(self.source.controldir.get_peeled(k)) |
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
613 |
return list(potential - self._target_has_shas(potential)) |
614 |
return determine_wants |
|
615 |
||
|
0.259.6
by Jelmer Vernooij
Fetch tags during pull. |
616 |
def get_determine_wants_revids(self, revids, include_tags=False): |
617 |
wants = set() |
|
618 |
for revid in set(revids): |
|
|
0.200.1388
by Jelmer Vernooij
Don't fetch revision already present. |
619 |
if self.target.has_revision(revid): |
620 |
continue
|
|
|
0.259.6
by Jelmer Vernooij
Fetch tags during pull. |
621 |
git_sha, mapping = self.source.lookup_bzr_revision_id(revid) |
622 |
wants.add(git_sha) |
|
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
623 |
return self.get_determine_wants_heads(wants, include_tags=include_tags) |
|
0.259.6
by Jelmer Vernooij
Fetch tags during pull. |
624 |
|
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
625 |
def fetch_objects(self, determine_wants, mapping, limit=None): |
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
626 |
"""Fetch objects from a remote server. |
627 |
||
628 |
:param determine_wants: determine_wants callback
|
|
629 |
:param mapping: BzrGitMapping to use
|
|
630 |
:param limit: Maximum number of commits to import.
|
|
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
631 |
:return: Tuple with pack hint, last imported revision id and remote refs
|
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
632 |
"""
|
633 |
raise NotImplementedError(self.fetch_objects) |
|
634 |
||
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
635 |
def fetch(self, revision_id=None, find_ghosts=False, |
|
0.200.247
by Jelmer Vernooij
Fix git-import. |
636 |
mapping=None, fetch_spec=None): |
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
637 |
if mapping is None: |
638 |
mapping = self.source.get_mapping() |
|
|
0.226.2
by Jelmer Vernooij
Cope with new fetch_spec argument. |
639 |
if revision_id is not None: |
640 |
interesting_heads = [revision_id] |
|
641 |
elif fetch_spec is not None: |
|
|
0.200.1089
by Jelmer Vernooij
Cope with fancy fetch_spec behaviour. |
642 |
recipe = fetch_spec.get_recipe() |
643 |
if recipe[0] in ("search", "proxy-search"): |
|
644 |
interesting_heads = recipe[1] |
|
645 |
else: |
|
|
0.200.1300
by Jelmer Vernooij
Fix formatting. |
646 |
raise AssertionError("Unsupported search result type %s" % |
647 |
recipe[0]) |
|
|
0.226.2
by Jelmer Vernooij
Cope with new fetch_spec argument. |
648 |
else: |
649 |
interesting_heads = None |
|
|
0.259.4
by Jelmer Vernooij
Put determine_wants methods on InterRepo. |
650 |
|
651 |
if interesting_heads is not None: |
|
|
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
652 |
determine_wants = self.get_determine_wants_revids( |
653 |
interesting_heads, include_tags=False) |
|
|
0.259.4
by Jelmer Vernooij
Put determine_wants methods on InterRepo. |
654 |
else: |
655 |
determine_wants = self.determine_wants_all |
|
|
0.200.1079
by Jelmer Vernooij
Avoid looking up revid if not necessary. |
656 |
|
657 |
(pack_hint, _, remote_refs) = self.fetch_objects(determine_wants, |
|
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
658 |
mapping) |
|
0.200.579
by Jelmer Vernooij
Only pack if it makes the target repo smaller. |
659 |
if pack_hint is not None and self.target._format.pack_compresses: |
|
0.200.578
by Jelmer Vernooij
Only do optimal packing on bzr >= 1.17. |
660 |
self.target.pack(hint=pack_hint) |
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
661 |
return remote_refs |
|
0.200.225
by Jelmer Vernooij
Implement custom InterBranch to support fetching from remote git branches. |
662 |
|
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
663 |
|
|
0.200.563
by Jelmer Vernooij
Attempt to parse progress indication from git status reports. |
664 |
_GIT_PROGRESS_RE = re.compile(r"(.*?): +(\d+)% \((\d+)/(\d+)\)") |
665 |
def report_git_progress(pb, text): |
|
666 |
text = text.rstrip("\r\n") |
|
667 |
g = _GIT_PROGRESS_RE.match(text) |
|
668 |
if g is not None: |
|
669 |
(text, pct, current, total) = g.groups() |
|
670 |
pb.update(text, int(current), int(total)) |
|
671 |
else: |
|
672 |
pb.update(text, 0, 0) |
|
673 |
||
674 |
||
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
675 |
class DetermineWantsRecorder(object): |
676 |
||
677 |
def __init__(self, actual): |
|
678 |
self.actual = actual |
|
679 |
self.wants = [] |
|
680 |
self.remote_refs = {} |
|
681 |
||
682 |
def __call__(self, refs): |
|
683 |
self.remote_refs = refs |
|
684 |
self.wants = self.actual(refs) |
|
685 |
return self.wants |
|
686 |
||
687 |
||
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
688 |
class InterRemoteGitNonGitRepository(InterGitNonGitRepository): |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
689 |
"""InterRepository that copies revisions from a remote Git into a non-Git |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
690 |
repository."""
|
691 |
||
|
0.200.582
by Jelmer Vernooij
Use more efficient algorithm for finding out heads. |
692 |
def get_target_heads(self): |
693 |
# FIXME: This should be more efficient
|
|
694 |
all_revs = self.target.all_revision_ids() |
|
695 |
parent_map = self.target.get_parent_map(all_revs) |
|
696 |
all_parents = set() |
|
697 |
map(all_parents.update, parent_map.itervalues()) |
|
698 |
return set(all_revs) - all_parents |
|
699 |
||
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
700 |
def fetch_objects(self, determine_wants, mapping, limit=None): |
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
701 |
"""See `InterGitNonGitRepository`.""" |
|
0.200.466
by Jelmer Vernooij
Fix finding of heads for fetch_objects. |
702 |
store = BazaarObjectStore(self.target, mapping) |
|
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
703 |
store.lock_write() |
|
0.200.465
by Jelmer Vernooij
Use dulwich standard functionality for finding missing revisions. |
704 |
try: |
|
0.200.582
by Jelmer Vernooij
Use more efficient algorithm for finding out heads. |
705 |
heads = self.get_target_heads() |
|
0.281.5
by William Grant
Fix pull with new dulwich by avoiding removed ObjectStore.get_graph_walker. |
706 |
graph_walker = ObjectStoreGraphWalker( |
707 |
[store._lookup_revision_sha1(head) for head in heads], |
|
|
0.200.1631
by William Grant
Fix ObjectStoreGraphWalker invocation. |
708 |
lambda sha: store[sha].parents) |
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
709 |
wants_recorder = DetermineWantsRecorder(determine_wants) |
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
710 |
|
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
711 |
pb = ui.ui_factory.nested_progress_bar() |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
712 |
try: |
|
0.200.1000
by Jelmer Vernooij
Fix fetch between local and remote git branches. |
713 |
objects_iter = self.source.fetch_objects( |
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
714 |
wants_recorder, graph_walker, store.get_raw, |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
715 |
progress=lambda text: report_git_progress(pb, text)) |
|
0.200.1300
by Jelmer Vernooij
Fix formatting. |
716 |
trace.mutter("Importing %d new revisions", |
717 |
len(wants_recorder.wants)) |
|
718 |
(pack_hint, last_rev) = import_git_objects(self.target, |
|
719 |
mapping, objects_iter, store, wants_recorder.wants, pb, |
|
720 |
limit) |
|
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
721 |
return (pack_hint, last_rev, wants_recorder.remote_refs) |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
722 |
finally: |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
723 |
pb.finished() |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
724 |
finally: |
|
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
725 |
store.unlock() |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
726 |
|
727 |
@staticmethod
|
|
728 |
def is_compatible(source, target): |
|
729 |
"""Be compatible with GitRepository.""" |
|
|
0.200.1222
by Jelmer Vernooij
Better checks in is_compatible methods. |
730 |
if not isinstance(source, RemoteGitRepository): |
731 |
return False |
|
732 |
if not target.supports_rich_root(): |
|
733 |
return False |
|
734 |
if isinstance(target, GitRepository): |
|
735 |
return False |
|
|
0.200.1270
by Jelmer Vernooij
Cope with older versions of bzr. |
736 |
if not getattr(target._format, "supports_full_versioned_files", True): |
|
0.200.1222
by Jelmer Vernooij
Better checks in is_compatible methods. |
737 |
return False |
738 |
return True |
|
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
739 |
|
740 |
||
741 |
class InterLocalGitNonGitRepository(InterGitNonGitRepository): |
|
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
742 |
"""InterRepository that copies revisions from a local Git into a non-Git |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
743 |
repository."""
|
744 |
||
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
745 |
def fetch_objects(self, determine_wants, mapping, limit=None): |
|
0.200.1001
by Jelmer Vernooij
Simplify handling of determine wants, add stub for fetch_objects(). |
746 |
"""See `InterGitNonGitRepository`.""" |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
747 |
remote_refs = self.source.controldir.get_refs_container() |
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
748 |
wants = determine_wants(remote_refs) |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
749 |
create_pb = None |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
750 |
pb = ui.ui_factory.nested_progress_bar() |
|
0.200.320
by Jelmer Vernooij
Handle lightweight checkouts. |
751 |
target_git_object_retriever = BazaarObjectStore(self.target, mapping) |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
752 |
try: |
|
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
753 |
target_git_object_retriever.lock_write() |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
754 |
try: |
|
0.200.1300
by Jelmer Vernooij
Fix formatting. |
755 |
(pack_hint, last_rev) = import_git_objects(self.target, |
756 |
mapping, self.source._git.object_store, |
|
|
0.248.5
by Jelmer Vernooij
Reformatting, fix dpush. |
757 |
target_git_object_retriever, wants, pb, limit) |
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
758 |
return (pack_hint, last_rev, remote_refs) |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
759 |
finally: |
|
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
760 |
target_git_object_retriever.unlock() |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
761 |
finally: |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
762 |
pb.finished() |
|
0.200.306
by Jelmer Vernooij
Fix tests, split up InterGitNonGitRepository. |
763 |
|
764 |
@staticmethod
|
|
765 |
def is_compatible(source, target): |
|
766 |
"""Be compatible with GitRepository.""" |
|
|
0.200.1222
by Jelmer Vernooij
Better checks in is_compatible methods. |
767 |
if not isinstance(source, LocalGitRepository): |
768 |
return False |
|
769 |
if not target.supports_rich_root(): |
|
770 |
return False |
|
771 |
if isinstance(target, GitRepository): |
|
772 |
return False |
|
|
0.200.1266
by Jelmer Vernooij
Fix 2.3 support. |
773 |
if not getattr(target._format, "supports_full_versioned_files", True): |
|
0.200.1222
by Jelmer Vernooij
Better checks in is_compatible methods. |
774 |
return False |
775 |
return True |
|
|
0.200.175
by Jelmer Vernooij
Add optimized handling when fetching from git to git. |
776 |
|
777 |
||
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
778 |
class InterGitGitRepository(InterFromGitRepository): |
|
0.200.291
by Jelmer Vernooij
Print proper error about not supporting push. |
779 |
"""InterRepository that copies between Git repositories.""" |
|
0.200.175
by Jelmer Vernooij
Add optimized handling when fetching from git to git. |
780 |
|
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
781 |
def fetch_refs(self, update_refs, lossy=False): |
782 |
if lossy: |
|
783 |
raise errors.LossyPushToSameVCS(self.source, self.target) |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
784 |
old_refs = self.target.controldir.get_refs_container() |
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
785 |
ref_changes = {} |
786 |
def determine_wants(heads): |
|
|
0.200.1524
by Jelmer Vernooij
Fix inter-git fetching. |
787 |
old_refs = dict([(k, (v, None)) for (k, v) in heads.as_dict().iteritems()]) |
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
788 |
new_refs = update_refs(old_refs) |
789 |
ref_changes.update(new_refs) |
|
790 |
return [sha1 for (sha1, bzr_revid) in new_refs.itervalues()] |
|
791 |
self.fetch_objects(determine_wants) |
|
792 |
for k, (git_sha, bzr_revid) in ref_changes.iteritems(): |
|
793 |
self.target._git.refs[k] = git_sha |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
794 |
new_refs = self.target.controldir.get_refs_container() |
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
795 |
return None, old_refs, new_refs |
796 |
||
|
0.200.1535
by Jelmer Vernooij
Support limit argument. |
797 |
def fetch_objects(self, determine_wants, mapping=None, limit=None): |
|
0.200.635
by Jelmer Vernooij
Fix fetching between git repositories. |
798 |
graphwalker = self.target._git.get_graph_walker() |
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
799 |
if (isinstance(self.source, LocalGitRepository) and |
800 |
isinstance(self.target, LocalGitRepository)): |
|
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
801 |
def wrap_determine_wants(refs): |
802 |
return determine_wants(self.source._git.refs) |
|
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
803 |
pb = ui.ui_factory.nested_progress_bar() |
804 |
try: |
|
|
0.200.1493
by Jelmer Vernooij
Test fixes. |
805 |
refs = self.source._git.fetch(self.target._git, wrap_determine_wants, |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
806 |
lambda text: report_git_progress(pb, text)) |
807 |
finally: |
|
808 |
pb.finished() |
|
|
0.200.1002
by Jelmer Vernooij
Fix regression in git-import. |
809 |
return (None, None, refs) |
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
810 |
elif (isinstance(self.source, LocalGitRepository) and |
811 |
isinstance(self.target, RemoteGitRepository)): |
|
|
0.200.635
by Jelmer Vernooij
Fix fetching between git repositories. |
812 |
raise NotImplementedError |
|
0.200.695
by Jelmer Vernooij
Clean up trailing whitespace. |
813 |
elif (isinstance(self.source, RemoteGitRepository) and |
814 |
isinstance(self.target, LocalGitRepository)): |
|
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
815 |
pb = ui.ui_factory.nested_progress_bar() |
|
0.200.635
by Jelmer Vernooij
Fix fetching between git repositories. |
816 |
try: |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
817 |
f, commit = self.target._git.object_store.add_pack() |
818 |
try: |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
819 |
refs = self.source.controldir.fetch_pack( |
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
820 |
determine_wants, graphwalker, f.write, |
821 |
lambda text: report_git_progress(pb, text)) |
|
822 |
commit() |
|
823 |
return (None, None, refs) |
|
824 |
except: |
|
825 |
f.close() |
|
826 |
raise
|
|
827 |
finally: |
|
828 |
pb.finished() |
|
|
0.200.635
by Jelmer Vernooij
Fix fetching between git repositories. |
829 |
else: |
|
0.200.1433
by Jelmer Vernooij
Fix fetching between git repositories. |
830 |
raise AssertionError("fetching between %r and %r not supported" % |
831 |
(self.source, self.target)) |
|
|
0.200.635
by Jelmer Vernooij
Fix fetching between git repositories. |
832 |
|
|
0.200.1154
by Jelmer Vernooij
Share more code in InterGitRepository. |
833 |
def _target_has_shas(self, shas): |
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
834 |
return set([sha for sha in shas if sha in self.target._git.object_store]) |
|
0.200.1154
by Jelmer Vernooij
Share more code in InterGitRepository. |
835 |
|
|
0.200.1491
by Jelmer Vernooij
Fix progress reporting for git -> git. |
836 |
def fetch(self, revision_id=None, find_ghosts=False, |
|
0.200.1535
by Jelmer Vernooij
Support limit argument. |
837 |
mapping=None, fetch_spec=None, branches=None, limit=None): |
|
0.200.175
by Jelmer Vernooij
Add optimized handling when fetching from git to git. |
838 |
if mapping is None: |
839 |
mapping = self.source.get_mapping() |
|
840 |
r = self.target._git |
|
|
0.226.2
by Jelmer Vernooij
Cope with new fetch_spec argument. |
841 |
if revision_id is not None: |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
842 |
args = [self.source.lookup_bzr_revision_id(revision_id)[0]] |
|
0.226.2
by Jelmer Vernooij
Cope with new fetch_spec argument. |
843 |
elif fetch_spec is not None: |
|
0.200.1089
by Jelmer Vernooij
Cope with fancy fetch_spec behaviour. |
844 |
recipe = fetch_spec.get_recipe() |
845 |
if recipe[0] in ("search", "proxy-search"): |
|
846 |
heads = recipe[1] |
|
847 |
else: |
|
|
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
848 |
raise AssertionError( |
849 |
"Unsupported search result type %s" % recipe[0]) |
|
|
0.200.1350
by Jelmer Vernooij
Implement search_missing_revision_ids. |
850 |
args = [self.source.lookup_bzr_revision_id(revid)[0] for revid in heads] |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
851 |
if branches is not None: |
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
852 |
determine_wants = lambda x: [x[y] for y in branches if not x[y] in r.object_store and x[y] != ZERO_SHA] |
|
0.200.456
by Jelmer Vernooij
Fix git -> git fetching. |
853 |
elif fetch_spec is None and revision_id is None: |
|
0.200.1154
by Jelmer Vernooij
Share more code in InterGitRepository. |
854 |
determine_wants = self.determine_wants_all |
|
0.226.2
by Jelmer Vernooij
Cope with new fetch_spec argument. |
855 |
else: |
|
0.200.1176
by Jelmer Vernooij
Fix fetch return value for inter git fetching. |
856 |
determine_wants = lambda x: [y for y in args if not y in r.object_store and y != ZERO_SHA] |
857 |
wants_recorder = DetermineWantsRecorder(determine_wants) |
|
858 |
self.fetch_objects(wants_recorder, mapping) |
|
859 |
return wants_recorder.remote_refs |
|
|
0.200.175
by Jelmer Vernooij
Add optimized handling when fetching from git to git. |
860 |
|
861 |
@staticmethod
|
|
862 |
def is_compatible(source, target): |
|
863 |
"""Be compatible with GitRepository.""" |
|
|
0.200.664
by Jelmer Vernooij
Support submodules during fetch. |
864 |
return (isinstance(source, GitRepository) and |
|
0.200.175
by Jelmer Vernooij
Add optimized handling when fetching from git to git. |
865 |
isinstance(target, GitRepository)) |
|
0.200.1174
by Jelmer Vernooij
Fix specific revision fetching between git repositories. |
866 |
|
867 |
def get_determine_wants_revids(self, revids, include_tags=False): |
|
868 |
wants = set() |
|
869 |
for revid in set(revids): |
|
|
0.200.1388
by Jelmer Vernooij
Don't fetch revision already present. |
870 |
if self.target.has_revision(revid): |
871 |
continue
|
|
|
0.200.1174
by Jelmer Vernooij
Fix specific revision fetching between git repositories. |
872 |
git_sha, mapping = self.source.lookup_bzr_revision_id(revid) |
873 |
wants.add(git_sha) |
|
|
0.200.1309
by Jelmer Vernooij
Break some more long lines. |
874 |
return self.get_determine_wants_heads(wants, |
875 |
include_tags=include_tags) |
|
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
876 |
|
877 |
def determine_wants_all(self, refs): |
|
|
0.200.1513
by Jelmer Vernooij
Cope with zero shas. |
878 |
potential = set([v for v in refs.as_dict().values() if not v == ZERO_SHA]) |
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
879 |
return list(potential - self._target_has_shas(potential)) |
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
880 |
|
881 |
def get_determine_wants_heads(self, wants, include_tags=False): |
|
882 |
wants = set(wants) |
|
883 |
def determine_wants(refs): |
|
884 |
potential = set(wants) |
|
885 |
if include_tags: |
|
886 |
for k, unpeeled in refs.as_dict().iteritems(): |
|
887 |
if not is_tag(k): |
|
888 |
continue
|
|
|
0.200.1513
by Jelmer Vernooij
Cope with zero shas. |
889 |
if unpeeled == ZERO_SHA: |
890 |
continue
|
|
|
0.200.1490
by Jelmer Vernooij
Fix target_has_shas. |
891 |
potential.add(unpeeled) |
892 |
return list(potential - self._target_has_shas(potential)) |
|
893 |
return determine_wants |
|
894 |
||
895 |