bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.196
by Jelmer Vernooij
Add simple tests and docstrings for GraphWalker. |
1 |
# Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
|
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.264
by Jelmer Vernooij
Add more tests. |
17 |
from dulwich.objects import ( |
18 |
Blob, |
|
19 |
)
|
|
|
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
20 |
import os |
21 |
||
|
0.200.264
by Jelmer Vernooij
Add more tests. |
22 |
from bzrlib import ( |
23 |
knit, |
|
24 |
versionedfile, |
|
25 |
)
|
|
26 |
from bzrlib.bzrdir import ( |
|
27 |
BzrDir, |
|
28 |
)
|
|
29 |
from bzrlib.inventory import ( |
|
30 |
Inventory, |
|
31 |
)
|
|
32 |
from bzrlib.repository import ( |
|
33 |
Repository, |
|
34 |
)
|
|
35 |
from bzrlib.tests import ( |
|
36 |
TestCaseWithTransport, |
|
37 |
)
|
|
38 |
from bzrlib.transport import ( |
|
39 |
get_transport, |
|
40 |
)
|
|
|
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
41 |
|
42 |
from bzrlib.plugins.git import ( |
|
43 |
get_rich_root_format, |
|
44 |
)
|
|
|
0.200.264
by Jelmer Vernooij
Add more tests. |
45 |
from bzrlib.plugins.git.fetch import ( |
46 |
BzrFetchGraphWalker, |
|
47 |
import_git_blob, |
|
48 |
import_git_tree, |
|
49 |
)
|
|
50 |
from bzrlib.plugins.git.mapping import ( |
|
51 |
BzrGitMappingv1, |
|
52 |
default_mapping, |
|
53 |
)
|
|
54 |
from bzrlib.plugins.git.shamap import ( |
|
55 |
DictGitShaMap, |
|
56 |
)
|
|
|
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
57 |
from bzrlib.plugins.git.tests import ( |
58 |
GitBranchBuilder, |
|
59 |
run_git, |
|
60 |
)
|
|
|
0.200.196
by Jelmer Vernooij
Add simple tests and docstrings for GraphWalker. |
61 |
|
62 |
||
63 |
class FetchGraphWalkerTests(TestCaseWithTransport): |
|
64 |
||
65 |
def setUp(self): |
|
66 |
TestCaseWithTransport.setUp(self) |
|
67 |
self.mapping = default_mapping |
|
68 |
||
69 |
def test_empty(self): |
|
70 |
tree = self.make_branch_and_tree("wt") |
|
71 |
graphwalker = BzrFetchGraphWalker(tree.branch.repository, self.mapping) |
|
72 |
self.assertEquals(None, graphwalker.next()) |
|
73 |
||
74 |
||
|
0.228.2
by Jelmer Vernooij
Add test for fetching executables. |
75 |
class LocalRepositoryFetchTests(TestCaseWithTransport): |
|
0.228.1
by Jelmer Vernooij
Add basic tests for local fetch. |
76 |
|
77 |
def make_git_repo(self, path): |
|
78 |
os.mkdir(path) |
|
79 |
os.chdir(path) |
|
80 |
run_git("init") |
|
81 |
os.chdir("..") |
|
82 |
||
83 |
def clone_git_repo(self, from_url, to_url): |
|
84 |
oldrepos = Repository.open(from_url) |
|
85 |
dir = BzrDir.create(to_url, get_rich_root_format()) |
|
86 |
newrepos = dir.create_repository() |
|
87 |
oldrepos.copy_content_into(newrepos) |
|
88 |
return newrepos |
|
89 |
||
90 |
def test_empty(self): |
|
91 |
self.make_git_repo("d") |
|
92 |
newrepos = self.clone_git_repo("d", "f") |
|
93 |
self.assertEquals([], newrepos.all_revision_ids()) |
|
94 |
||
95 |
def test_single_rev(self): |
|
96 |
self.make_git_repo("d") |
|
97 |
os.chdir("d") |
|
98 |
bb = GitBranchBuilder() |
|
99 |
bb.set_file("foobar", "foo\nbar\n", False) |
|
100 |
mark = bb.commit("Somebody <somebody@someorg.org>", "mymsg") |
|
101 |
gitsha = bb.finish()[mark] |
|
102 |
os.chdir("..") |
|
103 |
oldrepo = Repository.open("d") |
|
104 |
newrepo = self.clone_git_repo("d", "f") |
|
105 |
self.assertEquals([oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha)], newrepo.all_revision_ids()) |
|
106 |
||
|
0.228.2
by Jelmer Vernooij
Add test for fetching executables. |
107 |
def test_executable(self): |
108 |
self.make_git_repo("d") |
|
109 |
os.chdir("d") |
|
110 |
bb = GitBranchBuilder() |
|
111 |
bb.set_file("foobar", "foo\nbar\n", True) |
|
112 |
bb.set_file("notexec", "foo\nbar\n", False) |
|
113 |
mark = bb.commit("Somebody <somebody@someorg.org>", "mymsg") |
|
114 |
gitsha = bb.finish()[mark] |
|
115 |
os.chdir("..") |
|
116 |
oldrepo = Repository.open("d") |
|
117 |
newrepo = self.clone_git_repo("d", "f") |
|
118 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
119 |
tree = newrepo.revision_tree(revid) |
|
120 |
self.assertTrue(tree.has_filename("foobar")) |
|
121 |
self.assertEquals(True, tree.inventory[tree.path2id("foobar")].executable) |
|
122 |
self.assertTrue(tree.has_filename("notexec")) |
|
123 |
self.assertEquals(False, tree.inventory[tree.path2id("notexec")].executable) |
|
|
0.200.264
by Jelmer Vernooij
Add more tests. |
124 |
|
125 |
||
126 |
class ImportObjects(TestCaseWithTransport): |
|
127 |
||
128 |
def setUp(self): |
|
129 |
super(ImportObjects, self).setUp() |
|
130 |
self._map = DictGitShaMap() |
|
131 |
factory = knit.make_file_factory(True, versionedfile.PrefixMapper()) |
|
132 |
self._texts = factory(self.get_transport('texts')) |
|
133 |
||
134 |
def test_import_blob_simple(self): |
|
135 |
blob = Blob.from_string("bar") |
|
136 |
inv = Inventory() |
|
137 |
inv.revision_id = "somerevid" |
|
138 |
import_git_blob(self._texts, BzrGitMappingv1(), "bla", blob, |
|
139 |
inv, [], self._map, False) |
|
140 |
self.assertEquals(set([('bla', 'somerevid')]), self._texts.keys()) |