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) 2009-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
0.200.298
by Jelmer Vernooij
Add test for non-ascii characters. |
2 |
# -*- coding: utf-8 -*-
|
0.200.196
by Jelmer Vernooij
Add simple tests and docstrings for GraphWalker. |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
0.200.196
by Jelmer Vernooij
Add simple tests and docstrings for GraphWalker. |
17 |
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
18 |
"""Tests from fetching from git into bzr."""
|
19 |
||
0.200.264
by Jelmer Vernooij
Add more tests. |
20 |
from dulwich.objects import ( |
21 |
Blob, |
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
22 |
Tag, |
0.200.265
by Jelmer Vernooij
Add more tests. |
23 |
Tree, |
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
24 |
S_IFGITLINK, |
0.200.264
by Jelmer Vernooij
Add more tests. |
25 |
)
|
0.200.447
by Jelmer Vernooij
Rely less on command-line git. |
26 |
from dulwich.repo import ( |
27 |
Repo as GitRepo, |
|
28 |
)
|
|
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
29 |
import os |
0.200.817
by Jelmer Vernooij
Deal with all modes locally. |
30 |
import stat |
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
31 |
import time |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
32 |
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
33 |
from ... import ( |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
34 |
osutils, |
35 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
36 |
from ...bzr import ( |
0.200.264
by Jelmer Vernooij
Add more tests. |
37 |
knit, |
38 |
versionedfile, |
|
39 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
40 |
from ...branch import ( |
0.200.1404
by jelmer at samba
Add test for stacked on. |
41 |
Branch, |
42 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
43 |
from ...controldir import ( |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
44 |
ControlDir, |
0.200.264
by Jelmer Vernooij
Add more tests. |
45 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
46 |
from ...bzr.inventory import ( |
0.200.264
by Jelmer Vernooij
Add more tests. |
47 |
Inventory, |
48 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
49 |
from ...repository import ( |
0.200.264
by Jelmer Vernooij
Add more tests. |
50 |
Repository, |
51 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
52 |
from ...tests import ( |
0.200.264
by Jelmer Vernooij
Add more tests. |
53 |
TestCaseWithTransport, |
54 |
)
|
|
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
55 |
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
56 |
from ..fetch import ( |
0.200.264
by Jelmer Vernooij
Add more tests. |
57 |
import_git_blob, |
58 |
import_git_tree, |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
59 |
import_git_submodule, |
0.200.264
by Jelmer Vernooij
Add more tests. |
60 |
)
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
61 |
from ..mapping import ( |
0.200.264
by Jelmer Vernooij
Add more tests. |
62 |
BzrGitMappingv1, |
0.200.816
by Jelmer Vernooij
Leave mode handling for blobs to import_git_blob. |
63 |
DEFAULT_FILE_MODE, |
0.200.264
by Jelmer Vernooij
Add more tests. |
64 |
)
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
65 |
from . import ( |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
66 |
GitBranchBuilder, |
67 |
)
|
|
0.200.196
by Jelmer Vernooij
Add simple tests and docstrings for GraphWalker. |
68 |
|
69 |
||
0.259.8
by Jelmer Vernooij
Add test. |
70 |
class RepositoryFetchTests(object): |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
71 |
|
72 |
def make_git_repo(self, path): |
|
73 |
os.mkdir(path) |
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
74 |
return GitRepo.init(os.path.abspath(path)) |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
75 |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
76 |
def clone_git_repo(self, from_url, to_url, revision_id=None): |
77 |
oldrepos = self.open_git_repo(from_url) |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
78 |
dir = ControlDir.create(to_url) |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
79 |
newrepos = dir.create_repository() |
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
80 |
oldrepos.copy_content_into(newrepos, revision_id=revision_id) |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
81 |
return newrepos |
82 |
||
83 |
def test_empty(self): |
|
84 |
self.make_git_repo("d") |
|
85 |
newrepos = self.clone_git_repo("d", "f") |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
86 |
self.assertEqual([], newrepos.all_revision_ids()) |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
87 |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
88 |
def make_onerev_branch(self): |
89 |
self.make_git_repo("d") |
|
90 |
os.chdir("d") |
|
91 |
bb = GitBranchBuilder() |
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
92 |
bb.set_file("foobar", b"foo\nbar\n", False) |
93 |
mark = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
94 |
gitsha = bb.finish()[mark] |
95 |
os.chdir("..") |
|
96 |
return "d", gitsha |
|
97 |
||
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
98 |
def test_single_rev(self): |
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
99 |
path, gitsha = self.make_onerev_branch() |
100 |
oldrepo = self.open_git_repo(path) |
|
101 |
newrepo = self.clone_git_repo(path, "f") |
|
0.200.1404
by jelmer at samba
Add test for stacked on. |
102 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
6964.2.3
by Jelmer Vernooij
Review comments. |
103 |
self.assertEqual([revid], newrepo.all_revision_ids()) |
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
104 |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
105 |
def test_single_rev_specific(self): |
106 |
path, gitsha = self.make_onerev_branch() |
|
107 |
oldrepo = self.open_git_repo(path) |
|
108 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
109 |
newrepo = self.clone_git_repo(path, "f", revision_id=revid) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
110 |
self.assertEqual([revid], newrepo.all_revision_ids()) |
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
111 |
|
112 |
def test_incremental(self): |
|
113 |
self.make_git_repo("d") |
|
114 |
os.chdir("d") |
|
115 |
bb = GitBranchBuilder() |
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
116 |
bb.set_file("foobar", b"foo\nbar\n", False) |
117 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
118 |
bb.set_file("foobar", b"fooll\nbar\n", False) |
|
119 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"nextmsg") |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
120 |
marks = bb.finish() |
121 |
gitsha1 = marks[mark1] |
|
122 |
gitsha2 = marks[mark2] |
|
123 |
os.chdir("..") |
|
124 |
oldrepo = self.open_git_repo("d") |
|
125 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
126 |
newrepo = self.clone_git_repo("d", "f", revision_id=revid1) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
127 |
self.assertEqual([revid1], newrepo.all_revision_ids()) |
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
128 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
129 |
newrepo.fetch(oldrepo, revision_id=revid2) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
130 |
self.assertEqual(set([revid1, revid2]), |
131 |
set(newrepo.all_revision_ids())) |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
132 |
|
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
133 |
def test_dir_becomes_symlink(self): |
134 |
self.make_git_repo("d") |
|
135 |
os.chdir("d") |
|
136 |
bb = GitBranchBuilder() |
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
137 |
bb.set_file("mylink/somefile", b"foo\nbar\n", False) |
138 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg1") |
|
7058.4.37
by Jelmer Vernooij
Fix dir deletion. |
139 |
bb.delete_entry("mylink/somefile") |
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
140 |
bb.set_symlink("mylink", "target/") |
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
141 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg2") |
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
142 |
marks = bb.finish() |
143 |
gitsha1 = marks[mark1] |
|
144 |
gitsha2 = marks[mark2] |
|
145 |
os.chdir("..") |
|
146 |
oldrepo = self.open_git_repo("d") |
|
147 |
newrepo = self.clone_git_repo("d", "f") |
|
148 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
149 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
150 |
tree1 = newrepo.revision_tree(revid1) |
|
151 |
tree2 = newrepo.revision_tree(revid2) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
152 |
self.assertEqual(revid1, tree1.get_file_revision("mylink")) |
153 |
self.assertEqual("directory", tree1.kind("mylink")) |
|
154 |
self.assertEqual(None, tree1.get_symlink_target("mylink")) |
|
155 |
self.assertEqual(revid2, tree2.get_file_revision("mylink")) |
|
156 |
self.assertEqual("symlink", tree2.kind("mylink")) |
|
157 |
self.assertEqual("target/", tree2.get_symlink_target("mylink")) |
|
0.200.552
by Jelmer Vernooij
Cope with directories becoming symlinks. |
158 |
|
0.200.553
by Jelmer Vernooij
Support symlinks being turned into directories. |
159 |
def test_symlink_becomes_dir(self): |
160 |
self.make_git_repo("d") |
|
161 |
os.chdir("d") |
|
162 |
bb = GitBranchBuilder() |
|
163 |
bb.set_symlink("mylink", "target/") |
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
164 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg1") |
7105.1.2
by Jelmer Vernooij
Add missing delete commands. |
165 |
bb.delete_entry("mylink") |
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
166 |
bb.set_file("mylink/somefile", b"foo\nbar\n", False) |
167 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg2") |
|
0.200.553
by Jelmer Vernooij
Support symlinks being turned into directories. |
168 |
marks = bb.finish() |
169 |
gitsha1 = marks[mark1] |
|
170 |
gitsha2 = marks[mark2] |
|
171 |
os.chdir("..") |
|
172 |
oldrepo = self.open_git_repo("d") |
|
173 |
newrepo = self.clone_git_repo("d", "f") |
|
174 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
175 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
176 |
tree1 = newrepo.revision_tree(revid1) |
|
177 |
tree2 = newrepo.revision_tree(revid2) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
178 |
self.assertEqual(revid1, tree1.get_file_revision("mylink")) |
179 |
self.assertEqual("symlink", tree1.kind("mylink")) |
|
180 |
self.assertEqual("target/", tree1.get_symlink_target("mylink")) |
|
181 |
self.assertEqual(revid2, tree2.get_file_revision("mylink")) |
|
182 |
self.assertEqual("directory", tree2.kind("mylink")) |
|
183 |
self.assertEqual(None, tree2.get_symlink_target("mylink")) |
|
0.200.553
by Jelmer Vernooij
Support symlinks being turned into directories. |
184 |
|
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
185 |
def test_changing_symlink(self): |
186 |
self.make_git_repo("d") |
|
187 |
os.chdir("d") |
|
188 |
bb = GitBranchBuilder() |
|
189 |
bb.set_symlink("mylink", "target") |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
190 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg1") |
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
191 |
bb.set_symlink("mylink", "target/") |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
192 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg2") |
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
193 |
marks = bb.finish() |
194 |
gitsha1 = marks[mark1] |
|
195 |
gitsha2 = marks[mark2] |
|
196 |
os.chdir("..") |
|
197 |
oldrepo = self.open_git_repo("d") |
|
198 |
newrepo = self.clone_git_repo("d", "f") |
|
199 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
200 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
201 |
tree1 = newrepo.revision_tree(revid1) |
|
202 |
tree2 = newrepo.revision_tree(revid2) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
203 |
self.assertEqual(revid1, tree1.get_file_revision("mylink")) |
204 |
self.assertEqual("target", tree1.get_symlink_target("mylink")) |
|
205 |
self.assertEqual(revid2, tree2.get_file_revision("mylink")) |
|
206 |
self.assertEqual("target/", tree2.get_symlink_target("mylink")) |
|
0.200.551
by Jelmer Vernooij
Properly set InventoryEntry revision when changing symlink targets. |
207 |
|
0.228.2
by Jelmer Vernooij
Add test for fetching executables. |
208 |
def test_executable(self): |
209 |
self.make_git_repo("d") |
|
210 |
os.chdir("d") |
|
211 |
bb = GitBranchBuilder() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
212 |
bb.set_file("foobar", b"foo\nbar\n", True) |
213 |
bb.set_file("notexec", b"foo\nbar\n", False) |
|
214 |
mark = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
0.228.2
by Jelmer Vernooij
Add test for fetching executables. |
215 |
gitsha = bb.finish()[mark] |
216 |
os.chdir("..") |
|
0.200.268
by Jelmer Vernooij
Add more fetch tests. |
217 |
oldrepo = self.open_git_repo("d") |
0.228.2
by Jelmer Vernooij
Add test for fetching executables. |
218 |
newrepo = self.clone_git_repo("d", "f") |
219 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
220 |
tree = newrepo.revision_tree(revid) |
|
221 |
self.assertTrue(tree.has_filename("foobar")) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
222 |
self.assertEqual(True, tree.is_executable("foobar")) |
0.228.2
by Jelmer Vernooij
Add test for fetching executables. |
223 |
self.assertTrue(tree.has_filename("notexec")) |
6964.2.3
by Jelmer Vernooij
Review comments. |
224 |
self.assertEqual(False, tree.is_executable("notexec")) |
0.200.264
by Jelmer Vernooij
Add more tests. |
225 |
|
0.200.537
by Jelmer Vernooij
Fix handling of not-executable files becoming executable without any other changes. |
226 |
def test_becomes_executable(self): |
227 |
self.make_git_repo("d") |
|
228 |
os.chdir("d") |
|
229 |
bb = GitBranchBuilder() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
230 |
bb.set_file("foobar", b"foo\nbar\n", False) |
231 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
232 |
bb.set_file("foobar", b"foo\nbar\n", True) |
|
233 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
0.200.537
by Jelmer Vernooij
Fix handling of not-executable files becoming executable without any other changes. |
234 |
gitsha2 = bb.finish()[mark2] |
235 |
os.chdir("..") |
|
236 |
oldrepo = self.open_git_repo("d") |
|
237 |
newrepo = self.clone_git_repo("d", "f") |
|
238 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
239 |
tree = newrepo.revision_tree(revid) |
|
240 |
self.assertTrue(tree.has_filename("foobar")) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
241 |
self.assertEqual(True, tree.is_executable("foobar")) |
242 |
self.assertEqual(revid, tree.get_file_revision("foobar")) |
|
0.200.537
by Jelmer Vernooij
Fix handling of not-executable files becoming executable without any other changes. |
243 |
|
0.200.1404
by jelmer at samba
Add test for stacked on. |
244 |
def test_into_stacked_on(self): |
245 |
r = self.make_git_repo("d") |
|
246 |
os.chdir("d") |
|
247 |
bb = GitBranchBuilder() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
248 |
bb.set_file(u"foobar", b"foo\n", False) |
249 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg1") |
|
0.200.1404
by jelmer at samba
Add test for stacked on. |
250 |
gitsha1 = bb.finish()[mark1] |
251 |
os.chdir("..") |
|
252 |
stacked_on = self.clone_git_repo("d", "stacked-on") |
|
253 |
oldrepo = Repository.open("d") |
|
254 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
255 |
self.assertEqual([revid1], stacked_on.all_revision_ids()) |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
256 |
b = stacked_on.controldir.create_branch() |
0.200.1404
by jelmer at samba
Add test for stacked on. |
257 |
b.generate_revision_history(revid1) |
6964.2.3
by Jelmer Vernooij
Review comments. |
258 |
self.assertEqual(b.last_revision(), revid1) |
0.200.1404
by jelmer at samba
Add test for stacked on. |
259 |
tree = self.make_branch_and_tree("stacked") |
260 |
tree.branch.set_stacked_on_url(b.user_url) |
|
261 |
os.chdir("d") |
|
262 |
bb = GitBranchBuilder() |
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
263 |
bb.set_file(u"barbar", b"bar\n", False) |
264 |
bb.set_file(u"foo/blie/bla", b"bla\n", False) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
265 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg2") |
0.200.1404
by jelmer at samba
Add test for stacked on. |
266 |
gitsha2 = bb.finish()[mark2] |
267 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
268 |
os.chdir("..") |
|
269 |
tree.branch.fetch(Branch.open("d")) |
|
270 |
tree.branch.repository.check() |
|
271 |
self.addCleanup(tree.lock_read().unlock) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
272 |
self.assertEqual( |
0.200.1404
by jelmer at samba
Add test for stacked on. |
273 |
set([(revid2,)]), |
274 |
tree.branch.repository.revisions.without_fallbacks().keys()) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
275 |
self.assertEqual( |
0.200.1404
by jelmer at samba
Add test for stacked on. |
276 |
set([revid1, revid2]), |
277 |
set(tree.branch.repository.all_revision_ids())) |
|
278 |
||
0.200.298
by Jelmer Vernooij
Add test for non-ascii characters. |
279 |
def test_non_ascii_characters(self): |
280 |
self.make_git_repo("d") |
|
281 |
os.chdir("d") |
|
282 |
bb = GitBranchBuilder() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
283 |
bb.set_file(u"foőbar", b"foo\nbar\n", False) |
284 |
mark = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
0.200.298
by Jelmer Vernooij
Add test for non-ascii characters. |
285 |
gitsha = bb.finish()[mark] |
286 |
os.chdir("..") |
|
287 |
oldrepo = self.open_git_repo("d") |
|
288 |
newrepo = self.clone_git_repo("d", "f") |
|
289 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
290 |
tree = newrepo.revision_tree(revid) |
|
291 |
self.assertTrue(tree.has_filename(u"foőbar")) |
|
292 |
||
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
293 |
def test_tagged_tree(self): |
294 |
r = self.make_git_repo("d") |
|
295 |
os.chdir("d") |
|
296 |
bb = GitBranchBuilder() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
297 |
bb.set_file("foobar", b"fooll\nbar\n", False) |
298 |
mark = bb.commit(b"Somebody <somebody@someorg.org>", b"nextmsg") |
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
299 |
marks = bb.finish() |
300 |
gitsha = marks[mark] |
|
301 |
tag = Tag() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
302 |
tag.name = b"sometag" |
0.281.6
by William Grant
Fix test_tagged_tree to not create a non-integral tag timestamp. |
303 |
tag.tag_time = int(time.time()) |
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
304 |
tag.tag_timezone = 0 |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
305 |
tag.tagger = b"Somebody <somebody@example.com>" |
306 |
tag.message = b"Created tag pointed at tree" |
|
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
307 |
tag.object = (Tree, r[gitsha].tree) |
308 |
r.object_store.add_object(tag) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
309 |
r[b"refs/tags/sometag"] = tag |
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
310 |
os.chdir("..") |
311 |
oldrepo = self.open_git_repo("d") |
|
312 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
313 |
newrepo = self.clone_git_repo("d", "f") |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
314 |
self.assertEqual(set([revid]), set(newrepo.all_revision_ids())) |
0.200.1403
by Jelmer Vernooij
Cope with tags pointing at tree objects when cloning local git repositories. |
315 |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
316 |
|
0.200.269
by Jelmer Vernooij
Prepare for testing remote repos. |
317 |
class LocalRepositoryFetchTests(RepositoryFetchTests, TestCaseWithTransport): |
318 |
||
319 |
def open_git_repo(self, path): |
|
320 |
return Repository.open(path) |
|
321 |
||
322 |
||
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
323 |
class DummyStoreUpdater(object): |
324 |
||
0.200.952
by Jelmer Vernooij
Write git pack files rather than loose objects. |
325 |
def add_object(self, obj, ie, path): |
0.200.839
by Jelmer Vernooij
Add convenience object for updating the object store caching layer. |
326 |
pass
|
327 |
||
328 |
def finish(self): |
|
329 |
pass
|
|
330 |
||
331 |
||
0.200.264
by Jelmer Vernooij
Add more tests. |
332 |
class ImportObjects(TestCaseWithTransport): |
333 |
||
334 |
def setUp(self): |
|
335 |
super(ImportObjects, self).setUp() |
|
0.200.265
by Jelmer Vernooij
Add more tests. |
336 |
self._mapping = BzrGitMappingv1() |
0.200.264
by Jelmer Vernooij
Add more tests. |
337 |
factory = knit.make_file_factory(True, versionedfile.PrefixMapper()) |
338 |
self._texts = factory(self.get_transport('texts')) |
|
339 |
||
7069.1.3
by Jelmer Vernooij
Fix test. |
340 |
def test_import_blob_missing_in_one_parent(self): |
341 |
builder = self.make_branch_builder('br') |
|
342 |
builder.start_series() |
|
343 |
rev_root = builder.build_snapshot(None, [ |
|
344 |
('add', ('', b'rootid', 'directory', ''))]) |
|
345 |
rev1 = builder.build_snapshot([rev_root], [ |
|
346 |
('add', ('bla', self._mapping.generate_file_id('bla'), 'file', b'content'))]) |
|
347 |
rev2 = builder.build_snapshot([rev_root], []) |
|
348 |
builder.finish_series() |
|
349 |
branch = builder.get_branch() |
|
7069.1.2
by Jelmer Vernooij
Add test. |
350 |
|
351 |
blob = Blob.from_string(b"bar") |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
352 |
objs = {"blobname": blob} |
7069.1.2
by Jelmer Vernooij
Add test. |
353 |
ret = import_git_blob(self._texts, self._mapping, b"bla", b"bla", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
354 |
(None, "blobname"), |
355 |
branch.repository.revision_tree( |
|
356 |
rev1), b'rootid', b"somerevid", |
|
357 |
[branch.repository.revision_tree(r) for r in [ |
|
358 |
rev1, rev2]], |
|
359 |
objs.__getitem__, |
|
360 |
(None, DEFAULT_FILE_MODE), DummyStoreUpdater(), |
|
361 |
self._mapping.generate_file_id) |
|
7069.1.2
by Jelmer Vernooij
Add test. |
362 |
self.assertEqual(set([(b'git:bla', b'somerevid')]), self._texts.keys()) |
363 |
||
0.200.264
by Jelmer Vernooij
Add more tests. |
364 |
def test_import_blob_simple(self): |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
365 |
blob = Blob.from_string(b"bar") |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
366 |
objs = {"blobname": blob} |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
367 |
ret = import_git_blob(self._texts, self._mapping, b"bla", b"bla", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
368 |
(None, "blobname"), |
369 |
None, None, b"somerevid", [], objs.__getitem__, |
|
370 |
(None, DEFAULT_FILE_MODE), DummyStoreUpdater(), |
|
371 |
self._mapping.generate_file_id) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
372 |
self.assertEqual(set([(b'git:bla', b'somerevid')]), self._texts.keys()) |
7018.3.10
by Jelmer Vernooij
Consistent return values in PreviewTree.list_files. |
373 |
self.assertEqual(next(self._texts.get_record_stream([(b'git:bla', b'somerevid')], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
374 |
"unordered", True)).get_bytes_as("fulltext"), b"bar") |
7027.3.4
by Jelmer Vernooij
Some fixes. |
375 |
self.assertEqual(1, len(ret)) |
6964.2.3
by Jelmer Vernooij
Review comments. |
376 |
self.assertEqual(None, ret[0][0]) |
377 |
self.assertEqual("bla", ret[0][1]) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
378 |
ie = ret[0][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
379 |
self.assertEqual(False, ie.executable) |
380 |
self.assertEqual("file", ie.kind) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
381 |
self.assertEqual(b"somerevid", ie.revision) |
7027.3.4
by Jelmer Vernooij
Some fixes. |
382 |
self.assertEqual(osutils.sha_strings([b"bar"]), ie.text_sha1) |
0.200.265
by Jelmer Vernooij
Add more tests. |
383 |
|
384 |
def test_import_tree_empty_root(self): |
|
385 |
tree = Tree() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
386 |
ret, child_modes = import_git_tree(self._texts, self._mapping, b"", b"", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
387 |
(None, tree.id), None, |
388 |
None, b"somerevid", [], { |
|
389 |
tree.id: tree}.__getitem__, |
|
390 |
(None, stat.S_IFDIR), DummyStoreUpdater(), |
|
391 |
self._mapping.generate_file_id) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
392 |
self.assertEqual(child_modes, {}) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
393 |
self.assertEqual( |
394 |
set([(b"TREE_ROOT", b'somerevid')]), self._texts.keys()) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
395 |
self.assertEqual(1, len(ret)) |
396 |
self.assertEqual(None, ret[0][0]) |
|
397 |
self.assertEqual("", ret[0][1]) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
398 |
ie = ret[0][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
399 |
self.assertEqual(False, ie.executable) |
400 |
self.assertEqual("directory", ie.kind) |
|
401 |
self.assertEqual({}, ie.children) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
402 |
self.assertEqual(b"somerevid", ie.revision) |
6964.2.3
by Jelmer Vernooij
Review comments. |
403 |
self.assertEqual(None, ie.text_sha1) |
0.200.265
by Jelmer Vernooij
Add more tests. |
404 |
|
405 |
def test_import_tree_empty(self): |
|
406 |
tree = Tree() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
407 |
ret, child_modes = import_git_tree(self._texts, self._mapping, b"bla", b"bla", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
408 |
(None, tree.id), None, None, b"somerevid", [], |
409 |
{tree.id: tree}.__getitem__, |
|
410 |
(None, stat.S_IFDIR), DummyStoreUpdater(), |
|
411 |
self._mapping.generate_file_id) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
412 |
self.assertEqual(child_modes, {}) |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
413 |
self.assertEqual(set([(b"git:bla", b'somerevid')]), self._texts.keys()) |
6964.2.3
by Jelmer Vernooij
Review comments. |
414 |
self.assertEqual(1, len(ret)) |
415 |
self.assertEqual(None, ret[0][0]) |
|
416 |
self.assertEqual("bla", ret[0][1]) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
417 |
ie = ret[0][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
418 |
self.assertEqual("directory", ie.kind) |
419 |
self.assertEqual(False, ie.executable) |
|
420 |
self.assertEqual({}, ie.children) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
421 |
self.assertEqual(b"somerevid", ie.revision) |
6964.2.3
by Jelmer Vernooij
Review comments. |
422 |
self.assertEqual(None, ie.text_sha1) |
0.200.267
by Jelmer Vernooij
Add more tests for fetch code. |
423 |
|
424 |
def test_import_tree_with_file(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
425 |
blob = Blob.from_string(b"bar1") |
0.200.267
by Jelmer Vernooij
Add more tests for fetch code. |
426 |
tree = Tree() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
427 |
tree.add(b"foo", stat.S_IFREG | 0o644, blob.id) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
428 |
objects = {blob.id: blob, tree.id: tree} |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
429 |
ret, child_modes = import_git_tree(self._texts, self._mapping, b"bla", b"bla", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
430 |
(None, tree.id), None, None, b"somerevid", [], |
431 |
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater( |
|
432 |
),
|
|
433 |
self._mapping.generate_file_id) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
434 |
self.assertEqual(child_modes, {}) |
435 |
self.assertEqual(2, len(ret)) |
|
436 |
self.assertEqual(None, ret[0][0]) |
|
437 |
self.assertEqual("bla", ret[0][1]) |
|
438 |
self.assertEqual(None, ret[1][0]) |
|
439 |
self.assertEqual("bla/foo", ret[1][1]) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
440 |
ie = ret[0][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
441 |
self.assertEqual("directory", ie.kind) |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
442 |
ie = ret[1][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
443 |
self.assertEqual("file", ie.kind) |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
444 |
self.assertEqual(b"git:bla/foo", ie.file_id) |
445 |
self.assertEqual(b"somerevid", ie.revision) |
|
446 |
self.assertEqual(osutils.sha_strings([b"bar1"]), ie.text_sha1) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
447 |
self.assertEqual(False, ie.executable) |
0.200.267
by Jelmer Vernooij
Add more tests for fetch code. |
448 |
|
0.200.878
by Jelmer Vernooij
Fix determining of unusual file modes. |
449 |
def test_import_tree_with_unusual_mode_file(self): |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
450 |
blob = Blob.from_string(b"bar1") |
0.200.878
by Jelmer Vernooij
Fix determining of unusual file modes. |
451 |
tree = Tree() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
452 |
tree.add(b"foo", stat.S_IFREG | 0o664, blob.id) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
453 |
objects = {blob.id: blob, tree.id: tree} |
0.200.1152
by Jelmer Vernooij
Require dulwich 0.7.1. |
454 |
ret, child_modes = import_git_tree(self._texts, self._mapping, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
455 |
b"bla", b"bla", (None, tree.id), None, None, b"somerevid", [ |
456 |
],
|
|
457 |
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater( |
|
458 |
),
|
|
459 |
self._mapping.generate_file_id) |
|
460 |
self.assertEqual(child_modes, {b"bla/foo": stat.S_IFREG | 0o664}) |
|
0.200.878
by Jelmer Vernooij
Fix determining of unusual file modes. |
461 |
|
0.200.267
by Jelmer Vernooij
Add more tests for fetch code. |
462 |
def test_import_tree_with_file_exe(self): |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
463 |
blob = Blob.from_string(b"bar") |
0.200.267
by Jelmer Vernooij
Add more tests for fetch code. |
464 |
tree = Tree() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
465 |
tree.add(b"foo", 0o100755, blob.id) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
466 |
objects = {blob.id: blob, tree.id: tree} |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
467 |
ret, child_modes = import_git_tree(self._texts, self._mapping, b"", b"", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
468 |
(None, tree.id), None, None, b"somerevid", [], |
469 |
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater( |
|
470 |
),
|
|
471 |
self._mapping.generate_file_id) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
472 |
self.assertEqual(child_modes, {}) |
473 |
self.assertEqual(2, len(ret)) |
|
474 |
self.assertEqual(None, ret[0][0]) |
|
475 |
self.assertEqual("", ret[0][1]) |
|
476 |
self.assertEqual(None, ret[1][0]) |
|
477 |
self.assertEqual("foo", ret[1][1]) |
|
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
478 |
ie = ret[0][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
479 |
self.assertEqual("directory", ie.kind) |
0.229.3
by Jelmer Vernooij
Use inventory deltas internally so fetch is O(changes) rather than O(tree). |
480 |
ie = ret[1][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
481 |
self.assertEqual("file", ie.kind) |
482 |
self.assertEqual(True, ie.executable) |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
483 |
|
484 |
def test_directory_converted_to_submodule(self): |
|
485 |
base_inv = Inventory() |
|
486 |
base_inv.add_path("foo", "directory") |
|
487 |
base_inv.add_path("foo/bar", "file") |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
488 |
othertree = Blob.from_string(b"someotherthing") |
489 |
blob = Blob.from_string(b"bar") |
|
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
490 |
tree = Tree() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
491 |
tree.add(b"bar", 0o160000, blob.id) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
492 |
objects = {tree.id: tree} |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
493 |
ret, child_modes = import_git_submodule(self._texts, self._mapping, b"foo", b"foo", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
494 |
(tree.id, othertree.id), base_inv, base_inv.root.file_id, b"somerevid", [ |
495 |
],
|
|
496 |
objects.__getitem__, (stat.S_IFDIR | 0o755, S_IFGITLINK), DummyStoreUpdater( |
|
497 |
),
|
|
498 |
self._mapping.generate_file_id) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
499 |
self.assertEqual(child_modes, {}) |
500 |
self.assertEqual(2, len(ret)) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
501 |
self.assertEqual( |
502 |
ret[0], ("foo/bar", None, base_inv.path2id("foo/bar"), None)) |
|
7458.1.2
by Jelmer Vernooij
Fix tests on Python 3. |
503 |
self.assertEqual(ret[1][:3], ("foo", "foo", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
504 |
self._mapping.generate_file_id("foo"))) |
0.200.1408
by Jelmer Vernooij
Remove old ie children when converting directory into tree reference. |
505 |
ie = ret[1][3] |
6964.2.3
by Jelmer Vernooij
Review comments. |
506 |
self.assertEqual(ie.kind, "tree-reference") |