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