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 |
||
|
0.200.411
by Jelmer Vernooij
Stop pretending dulwich has the same api as python-git. |
17 |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
18 |
"""Tests for interfacing with a Git Branch"""
|
19 |
||
|
0.200.411
by Jelmer Vernooij
Stop pretending dulwich has the same api as python-git. |
20 |
|
21 |
import dulwich |
|
|
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
22 |
import os |
23 |
||
24 |
from bzrlib import ( |
|
25 |
revision, |
|
26 |
)
|
|
27 |
from bzrlib.branch import ( |
|
28 |
Branch, |
|
29 |
)
|
|
30 |
from bzrlib.bzrdir import ( |
|
31 |
BzrDir, |
|
32 |
)
|
|
33 |
from bzrlib.repository import ( |
|
34 |
Repository, |
|
35 |
)
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
36 |
|
|
0.200.27
by David Allouche
Flat is better than nested, remove the gitlib hierarchy. |
37 |
from bzrlib.plugins.git import ( |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
38 |
branch, |
|
0.200.97
by Jelmer Vernooij
use mapping object. |
39 |
tests, |
|
0.200.20
by John Arbash Meinel
All tests are passing again |
40 |
)
|
|
0.200.97
by Jelmer Vernooij
use mapping object. |
41 |
from bzrlib.plugins.git.mapping import default_mapping |
|
0.200.123
by Jelmer Vernooij
Use central git module. |
42 |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
43 |
|
44 |
class TestGitBranch(tests.TestCaseInTempDir): |
|
45 |
||
46 |
_test_needs_features = [tests.GitCommandFeature] |
|
47 |
||
48 |
def test_open_existing(self): |
|
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
49 |
tests.run_git('init') |
50 |
||
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
51 |
thebranch = Branch.open('.') |
52 |
self.assertIsInstance(thebranch, branch.GitBranch) |
|
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
53 |
|
|
0.200.412
by Jelmer Vernooij
Implement GitBranch.__repr__. |
54 |
def test_repr(self): |
55 |
tests.run_git('init') |
|
56 |
thebranch = Branch.open('.') |
|
57 |
self.assertEquals("LocalGitBranch('file://%s/', 'HEAD')" % self.test_dir, repr(thebranch)) |
|
58 |
||
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
59 |
def test_last_revision_is_null(self): |
60 |
tests.run_git('init') |
|
61 |
||
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
62 |
thebranch = Branch.open('.') |
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
63 |
self.assertEqual(revision.NULL_REVISION, thebranch.last_revision()) |
64 |
self.assertEqual((0, revision.NULL_REVISION), |
|
65 |
thebranch.last_revision_info()) |
|
|
0.200.20
by John Arbash Meinel
All tests are passing again |
66 |
|
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
67 |
def simple_commit_a(self): |
68 |
tests.run_git('init') |
|
69 |
self.build_tree(['a']) |
|
70 |
tests.run_git('add', 'a') |
|
71 |
tests.run_git('commit', '-m', 'a') |
|
72 |
||
|
0.200.20
by John Arbash Meinel
All tests are passing again |
73 |
def test_last_revision_is_valid(self): |
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
74 |
self.simple_commit_a() |
|
0.200.20
by John Arbash Meinel
All tests are passing again |
75 |
head = tests.run_git('rev-parse', 'HEAD').strip() |
76 |
||
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
77 |
thebranch = Branch.open('.') |
|
0.200.104
by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids. |
78 |
self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head), |
|
0.200.20
by John Arbash Meinel
All tests are passing again |
79 |
thebranch.last_revision()) |
|
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
80 |
|
81 |
def test_revision_history(self): |
|
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
82 |
self.simple_commit_a() |
|
0.200.59
by Jelmer Vernooij
Add more tests, fix revision history. |
83 |
reva = tests.run_git('rev-parse', 'HEAD').strip() |
84 |
self.build_tree(['b']) |
|
85 |
tests.run_git('add', 'b') |
|
86 |
tests.run_git('commit', '-m', 'b') |
|
87 |
revb = tests.run_git('rev-parse', 'HEAD').strip() |
|
|
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
88 |
|
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
89 |
thebranch = Branch.open('.') |
|
0.200.104
by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids. |
90 |
self.assertEqual([default_mapping.revision_id_foreign_to_bzr(r) for r in (reva, revb)], |
|
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
91 |
thebranch.revision_history()) |
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
92 |
|
|
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
93 |
def test_tag_annotated(self): |
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
94 |
self.simple_commit_a() |
95 |
reva = tests.run_git('rev-parse', 'HEAD').strip() |
|
96 |
tests.run_git('tag', '-a', '-m', 'add tag', 'foo') |
|
|
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
97 |
thebranch = Branch.open('.') |
98 |
self.assertEquals({"foo": default_mapping.revision_id_foreign_to_bzr(reva)}, |
|
99 |
thebranch.tags.get_tag_dict()) |
|
100 |
||
101 |
def test_tag(self): |
|
102 |
self.simple_commit_a() |
|
103 |
reva = tests.run_git('rev-parse', 'HEAD').strip() |
|
104 |
tests.run_git('tag', '-m', 'add tag', 'foo') |
|
105 |
thebranch = Branch.open('.') |
|
106 |
self.assertEquals({"foo": default_mapping.revision_id_foreign_to_bzr(reva)}, |
|
107 |
thebranch.tags.get_tag_dict()) |
|
108 |
||
|
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
109 |
|
|
0.200.66
by Jelmer Vernooij
Implement branch.get_parent(). |
110 |
|
111 |
class TestWithGitBranch(tests.TestCaseWithTransport): |
|
112 |
||
113 |
def setUp(self): |
|
114 |
tests.TestCaseWithTransport.setUp(self) |
|
|
0.200.411
by Jelmer Vernooij
Stop pretending dulwich has the same api as python-git. |
115 |
dulwich.repo.Repo.create(self.test_dir) |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
116 |
self.git_branch = Branch.open(self.test_dir) |
|
0.200.66
by Jelmer Vernooij
Implement branch.get_parent(). |
117 |
|
118 |
def test_get_parent(self): |
|
119 |
self.assertIs(None, self.git_branch.get_parent()) |
|
|
0.200.67
by Jelmer Vernooij
Implement Branch.get_stacked_on_url. |
120 |
|
121 |
def test_get_stacked_on_url(self): |
|
122 |
self.assertIs(None, self.git_branch.get_stacked_on_url()) |
|
|
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
123 |
|
|
0.200.72
by Jelmer Vernooij
Implement Branch.get_physical_lock_status. |
124 |
def test_get_physical_lock_status(self): |
125 |
self.assertFalse(self.git_branch.get_physical_lock_status()) |
|
126 |
||
|
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
127 |
|
128 |
class TestGitBranchFormat(tests.TestCase): |
|
129 |
||
130 |
def setUp(self): |
|
131 |
super(TestGitBranchFormat, self).setUp() |
|
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
132 |
self.format = branch.GitBranchFormat() |
|
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
133 |
|
134 |
def test_get_format_description(self): |
|
135 |
self.assertEquals("Git Branch", self.format.get_format_description()) |
|
|
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
136 |
|
137 |
||
138 |
||
|
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
139 |
class BranchTests(tests.TestCaseInTempDir): |
|
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
140 |
|
141 |
def make_onerev_branch(self): |
|
142 |
os.mkdir("d") |
|
143 |
os.chdir("d") |
|
144 |
tests.run_git("init") |
|
145 |
bb = tests.GitBranchBuilder() |
|
146 |
bb.set_file("foobar", "foo\nbar\n", False) |
|
147 |
mark = bb.commit("Somebody <somebody@someorg.org>", "mymsg") |
|
148 |
gitsha = bb.finish()[mark] |
|
149 |
os.chdir("..") |
|
150 |
return "d", gitsha |
|
151 |
||
152 |
def clone_git_branch(self, from_url, to_url): |
|
153 |
from_dir = BzrDir.open(from_url) |
|
154 |
to_dir = from_dir.sprout(to_url) |
|
155 |
return to_dir.open_branch() |
|
156 |
||
157 |
def test_single_rev(self): |
|
158 |
path, gitsha = self.make_onerev_branch() |
|
159 |
oldrepo = Repository.open(path) |
|
160 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
161 |
newbranch = self.clone_git_branch(path, "f") |
|
162 |
self.assertEquals([revid], newbranch.repository.all_revision_ids()) |
|
|
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
163 |
|
164 |
def test_sprouted_tags(self): |
|
165 |
path, gitsha = self.make_onerev_branch() |
|
166 |
os.chdir(path) |
|
167 |
tests.run_git("tag", "lala") |
|
168 |
os.chdir(self.test_dir) |
|
169 |
oldrepo = Repository.open(path) |
|
170 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
171 |
newbranch = self.clone_git_branch(path, "f") |
|
172 |
self.assertEquals({"lala": revid}, newbranch.tags.get_tag_dict()) |
|
173 |
self.assertEquals([revid], newbranch.repository.all_revision_ids()) |