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