bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
1 |
# Copyright (C) 2007 Canonical Ltd
|
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 |
||
17 |
"""Tests for interfacing with a Git Repository"""
|
|
18 |
||
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
19 |
import dulwich as git |
20 |
import os |
|
21 |
||
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
22 |
from bzrlib import ( |
|
0.200.61
by Jelmer Vernooij
Fix tests. |
23 |
errors, |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
24 |
inventory, |
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
25 |
revision, |
26 |
)
|
|
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
27 |
from bzrlib.repository import ( |
|
0.200.357
by Jelmer Vernooij
Move push code to push.py. |
28 |
InterRepository, |
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
29 |
Repository, |
30 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
31 |
|
|
0.200.27
by David Allouche
Flat is better than nested, remove the gitlib hierarchy. |
32 |
from bzrlib.plugins.git import ( |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
33 |
dir, |
34 |
repository, |
|
|
0.200.97
by Jelmer Vernooij
use mapping object. |
35 |
tests, |
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
36 |
)
|
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
37 |
from bzrlib.plugins.git.mapping import ( |
38 |
default_mapping, |
|
39 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
40 |
|
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
41 |
class TestGitRepositoryFeatures(tests.TestCaseInTempDir): |
|
0.200.32
by David Allouche
Rewrite GitRepository._parse_rev, with unit tests. |
42 |
"""Feature tests for GitRepository.""" |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
43 |
|
44 |
_test_needs_features = [tests.GitCommandFeature] |
|
45 |
||
46 |
def test_open_existing(self): |
|
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
47 |
tests.run_git('init') |
48 |
||
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
49 |
repo = Repository.open('.') |
50 |
self.assertIsInstance(repo, repository.GitRepository) |
|
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
51 |
|
|
0.200.56
by Jelmer Vernooij
Switch to using GitPython rather than our own in-house stuff. |
52 |
def test_has_git_repo(self): |
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
53 |
tests.run_git('init') |
54 |
||
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
55 |
repo = Repository.open('.') |
|
0.200.119
by Jelmer Vernooij
Make API resemble that of python-git. |
56 |
self.assertIsInstance(repo._git, git.repo.Repo) |
|
0.200.21
by John Arbash Meinel
Fix Repository.get_revision_graph() |
57 |
|
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
58 |
def test_get_revision(self): |
|
0.200.32
by David Allouche
Rewrite GitRepository._parse_rev, with unit tests. |
59 |
# GitRepository.get_revision gives a Revision object.
|
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
60 |
|
61 |
# Create a git repository with a revision.
|
|
62 |
tests.run_git('init') |
|
63 |
builder = tests.GitBranchBuilder() |
|
|
0.200.32
by David Allouche
Rewrite GitRepository._parse_rev, with unit tests. |
64 |
builder.set_file('a', 'text for a\n', False) |
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
65 |
commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message') |
66 |
mapping = builder.finish() |
|
67 |
commit_id = mapping[commit_handle] |
|
68 |
||
69 |
# Get the corresponding Revision object.
|
|
|
0.200.104
by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids. |
70 |
revid = default_mapping.revision_id_foreign_to_bzr(commit_id) |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
71 |
repo = Repository.open('.') |
|
0.200.29
by David Allouche
Smoke test for GitRepository.get_revision, and corresponding fixes. |
72 |
rev = repo.get_revision(revid) |
73 |
self.assertIsInstance(rev, revision.Revision) |
|
|
0.200.32
by David Allouche
Rewrite GitRepository._parse_rev, with unit tests. |
74 |
|
|
0.200.106
by Jelmer Vernooij
Test that getting an unknown revision fails. |
75 |
def test_get_revision_unknown(self): |
76 |
tests.run_git('init') |
|
77 |
||
78 |
repo = Repository.open('.') |
|
79 |
self.assertRaises(errors.NoSuchRevision, repo.get_revision, "bla") |
|
80 |
||
|
0.200.79
by Jelmer Vernooij
Implement RevisionTree.get_revision_id(). |
81 |
def simple_commit(self): |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
82 |
# Create a git repository with some interesting files in a revision.
|
83 |
tests.run_git('init') |
|
84 |
builder = tests.GitBranchBuilder() |
|
85 |
builder.set_file('data', 'text\n', False) |
|
86 |
builder.set_file('executable', 'content', True) |
|
87 |
builder.set_link('link', 'broken') |
|
88 |
builder.set_file('subdir/subfile', 'subdir text\n', False) |
|
|
0.204.4
by James Westby
Make the inventory test match what the code produces. |
89 |
commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message', |
90 |
timestamp=1205433193) |
|
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
91 |
mapping = builder.finish() |
|
0.200.79
by Jelmer Vernooij
Implement RevisionTree.get_revision_id(). |
92 |
return mapping[commit_handle] |
93 |
||
94 |
def test_revision_tree(self): |
|
95 |
commit_id = self.simple_commit() |
|
|
0.200.104
by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids. |
96 |
revid = default_mapping.revision_id_foreign_to_bzr(commit_id) |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
97 |
repo = Repository.open('.') |
|
0.200.79
by Jelmer Vernooij
Implement RevisionTree.get_revision_id(). |
98 |
tree = repo.revision_tree(revid) |
99 |
self.assertEquals(tree.get_revision_id(), revid) |
|
|
0.200.88
by Jelmer Vernooij
Fix RevisionTree.get_file_text(). |
100 |
self.assertEquals("text\n", tree.get_file_text(tree.path2id("data"))) |
|
0.200.79
by Jelmer Vernooij
Implement RevisionTree.get_revision_id(). |
101 |
|
102 |
def test_get_inventory(self): |
|
103 |
# GitRepository.get_inventory gives a GitInventory object with
|
|
104 |
# plausible entries for typical cases.
|
|
105 |
||
106 |
commit_id = self.simple_commit() |
|
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
107 |
|
108 |
# Get the corresponding Inventory object.
|
|
|
0.200.104
by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids. |
109 |
revid = default_mapping.revision_id_foreign_to_bzr(commit_id) |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
110 |
repo = Repository.open('.') |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
111 |
inv = repo.get_inventory(revid) |
112 |
self.assertIsInstance(inv, inventory.Inventory) |
|
113 |
printed_inv = '\n'.join( |
|
114 |
repr((path, entry.executable, entry)) |
|
115 |
for path, entry in inv.iter_entries()) |
|
116 |
self.assertEqualDiff( |
|
117 |
printed_inv, |
|
118 |
"('', False, InventoryDirectory('TREE_ROOT', u'', parent_id=None,"
|
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
119 |
" revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n" |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
120 |
"(u'data', False, InventoryFile('data', u'data',"
|
121 |
" parent_id='TREE_ROOT',"
|
|
|
0.204.4
by James Westby
Make the inventory test match what the code produces. |
122 |
" sha1='aa785adca3fcdfe1884ae840e13c6d294a2414e8', len=5))\n" |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
123 |
"(u'executable', True, InventoryFile('executable', u'executable',"
|
124 |
" parent_id='TREE_ROOT',"
|
|
|
0.204.4
by James Westby
Make the inventory test match what the code produces. |
125 |
" sha1='040f06fd774092478d450774f5ba30c5da78acc8', len=7))\n" |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
126 |
"(u'link', False, InventoryLink('link', u'link',"
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
127 |
" parent_id='TREE_ROOT', revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n" |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
128 |
"(u'subdir', False, InventoryDirectory('subdir', u'subdir',"
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
129 |
" parent_id='TREE_ROOT', revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n" |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
130 |
"(u'subdir/subfile', False, InventoryFile('subdir/subfile',"
|
131 |
" u'subfile', parent_id='subdir',"
|
|
|
0.204.4
by James Westby
Make the inventory test match what the code produces. |
132 |
" sha1='67b75c3e49f31fcadddbf9df6a1d8be8c3e44290', len=12))") |
|
0.200.38
by David Allouche
Reimplement GitRepository.get_inventory, simpler and faster. |
133 |
|
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
134 |
|
|
0.204.2
by James Westby
Switch to TestCaseWithTransport so that the cache dir can be |
135 |
class TestGitRepository(tests.TestCaseWithTransport): |
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
136 |
|
137 |
def setUp(self): |
|
|
0.204.2
by James Westby
Switch to TestCaseWithTransport so that the cache dir can be |
138 |
tests.TestCaseWithTransport.setUp(self) |
|
0.200.119
by Jelmer Vernooij
Make API resemble that of python-git. |
139 |
git.repo.Repo.create(self.test_dir) |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
140 |
self.git_repo = Repository.open(self.test_dir) |
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
141 |
|
|
0.200.40
by David Allouche
GitRepository.supports_rich_root() => False |
142 |
def test_supports_rich_root(self): |
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
143 |
repo = self.git_repo |
|
0.200.131
by Jelmer Vernooij
Fix all tests but two, use rich roots by default. |
144 |
self.assertEqual(repo.supports_rich_root(), True) |
|
0.200.40
by David Allouche
GitRepository.supports_rich_root() => False |
145 |
|
|
0.200.60
by Jelmer Vernooij
Support signature functions. |
146 |
def test_get_signature_text(self): |
|
0.200.61
by Jelmer Vernooij
Fix tests. |
147 |
self.assertRaises(errors.NoSuchRevision, self.git_repo.get_signature_text, revision.NULL_REVISION) |
|
0.200.60
by Jelmer Vernooij
Support signature functions. |
148 |
|
149 |
def test_has_signature_for_revision_id(self): |
|
150 |
self.assertEquals(False, self.git_repo.has_signature_for_revision_id(revision.NULL_REVISION)) |
|
151 |
||
|
0.200.75
by Jelmer Vernooij
Implement Repository.all_revision_ids(). |
152 |
def test_all_revision_ids_none(self): |
|
0.200.254
by Jelmer Vernooij
Fix tests. |
153 |
self.assertEquals(set([revision.NULL_REVISION]), self.git_repo.all_revision_ids()) |
|
0.200.75
by Jelmer Vernooij
Implement Repository.all_revision_ids(). |
154 |
|
|
0.200.65
by Jelmer Vernooij
Implement get_ancestry properly. |
155 |
def test_get_ancestry_null(self): |
|
0.200.237
by Jelmer Vernooij
Fix get_ancestry() contents. |
156 |
self.assertEquals([None, revision.NULL_REVISION], self.git_repo.get_ancestry(revision.NULL_REVISION)) |
|
0.200.65
by Jelmer Vernooij
Implement get_ancestry properly. |
157 |
|
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
158 |
def assertIsNullInventory(self, inv): |
159 |
self.assertEqual(inv.root, None) |
|
160 |
self.assertEqual(inv.revision_id, revision.NULL_REVISION) |
|
161 |
self.assertEqual(list(inv.iter_entries()), []) |
|
162 |
||
163 |
def test_get_inventory_none(self): |
|
164 |
# GitRepository.get_inventory(None) returns the null inventory.
|
|
165 |
repo = self.git_repo |
|
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
166 |
inv = repo.get_inventory(revision.NULL_REVISION) |
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
167 |
self.assertIsNullInventory(inv) |
168 |
||
169 |
def test_revision_tree_none(self): |
|
170 |
# GitRepository.revision_tree(None) returns the null tree.
|
|
171 |
repo = self.git_repo |
|
|
0.200.57
by Jelmer Vernooij
Fix more tests. |
172 |
tree = repo.revision_tree(revision.NULL_REVISION) |
|
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
173 |
self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION) |
174 |
self.assertIsNullInventory(tree.inventory) |
|
175 |
||
|
0.200.77
by Jelmer Vernooij
Handle NULL_REVISION in get_parent_map. |
176 |
def test_get_parent_map_null(self): |
177 |
self.assertEquals({revision.NULL_REVISION: ()}, |
|
178 |
self.git_repo.get_parent_map([revision.NULL_REVISION])) |
|
179 |
||
|
0.200.71
by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description. |
180 |
|
181 |
class GitRepositoryFormat(tests.TestCase): |
|
182 |
||
183 |
def setUp(self): |
|
184 |
super(GitRepositoryFormat, self).setUp() |
|
|
0.200.290
by Jelmer Vernooij
Fix tests. |
185 |
self.format = repository.GitRepositoryFormat() |
|
0.200.71
by Jelmer Vernooij
Implement GitRepositoryFormat.get_format_description. |
186 |
|
187 |
def test_get_format_description(self): |
|
188 |
self.assertEquals("Git Repository", self.format.get_format_description()) |
|
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
189 |
|
190 |
||
191 |
class RevisionGistImportTests(tests.TestCaseWithTransport): |
|
192 |
||
193 |
def setUp(self): |
|
194 |
tests.TestCaseWithTransport.setUp(self) |
|
195 |
self.git_path = os.path.join(self.test_dir, "git") |
|
196 |
os.mkdir(self.git_path) |
|
197 |
git.repo.Repo.create(self.git_path) |
|
198 |
self.git_repo = Repository.open(self.git_path) |
|
199 |
self.bzr_tree = self.make_branch_and_tree("bzr") |
|
200 |
||
|
0.200.357
by Jelmer Vernooij
Move push code to push.py. |
201 |
def get_inter(self): |
202 |
return InterRepository.get(self.bzr_tree.branch.repository, |
|
203 |
self.git_repo) |
|
204 |
||
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
205 |
def import_rev(self, revid, parent_lookup=None): |
|
0.200.357
by Jelmer Vernooij
Move push code to push.py. |
206 |
return self.get_inter().import_revision_gist(revid, parent_lookup) |
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
207 |
|
208 |
def test_pointless(self): |
|
|
0.200.257
by Jelmer Vernooij
Add more details for commit, to avoid checksum from changing. |
209 |
revid = self.bzr_tree.commit("pointless", timestamp=1205433193, |
|
0.200.362
by Jelmer Vernooij
Fix tests. |
210 |
timezone=0, |
|
0.200.257
by Jelmer Vernooij
Add more details for commit, to avoid checksum from changing. |
211 |
committer="Jelmer Vernooij <jelmer@samba.org>") |
212 |
self.assertEquals("2caa8094a5b794961cd9bf582e3e2bb090db0b14", |
|
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
213 |
self.import_rev(revid)) |
|
0.200.257
by Jelmer Vernooij
Add more details for commit, to avoid checksum from changing. |
214 |
self.assertEquals("2caa8094a5b794961cd9bf582e3e2bb090db0b14", |
|
0.200.256
by Jelmer Vernooij
Add tests for import_revision_gist. |
215 |
self.import_rev(revid)) |