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.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
2 |
# Copyright (C) 2007 Canonical Ltd
|
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.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
17 |
|
0.200.411
by Jelmer Vernooij
Stop pretending dulwich has the same api as python-git. |
18 |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
19 |
"""Tests for interfacing with a Git Branch"""
|
20 |
||
0.358.3
by Jelmer Vernooij
Enable absolute import. |
21 |
from __future__ import absolute_import |
0.200.411
by Jelmer Vernooij
Stop pretending dulwich has the same api as python-git. |
22 |
|
23 |
import dulwich |
|
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
24 |
from dulwich.objects import ( |
25 |
Commit, |
|
26 |
Tag, |
|
27 |
)
|
|
0.200.447
by Jelmer Vernooij
Rely less on command-line git. |
28 |
from dulwich.repo import ( |
29 |
Repo as GitRepo, |
|
30 |
)
|
|
31 |
||
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
32 |
import os |
33 |
||
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
34 |
from ... import ( |
7131.14.4
by Jelmer Vernooij
Fix test. |
35 |
errors, |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
36 |
revision, |
0.266.1
by Martin
Expect native-style file urls in branch object reprs |
37 |
urlutils, |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
38 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
39 |
from ...branch import ( |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
40 |
Branch, |
0.247.1
by Michael Hudson
test |
41 |
InterBranch, |
0.200.1660
by Jelmer Vernooij
Fix imports. |
42 |
UnstackableBranchFormat, |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
43 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
44 |
from ...controldir import ( |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
45 |
ControlDir, |
0.200.1014
by Jelmer Vernooij
Fix tests. |
46 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
47 |
from ...repository import ( |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
48 |
Repository, |
49 |
)
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
50 |
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
51 |
from .. import ( |
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
52 |
branch, |
0.200.97
by Jelmer Vernooij
use mapping object. |
53 |
tests, |
0.200.20
by John Arbash Meinel
All tests are passing again |
54 |
)
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
55 |
from ..dir import ( |
0.200.1140
by Jelmer Vernooij
Update now that the control dir formats are no longer in __init__. |
56 |
LocalGitControlDirFormat, |
57 |
)
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
58 |
from ..mapping import ( |
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
59 |
default_mapping, |
60 |
)
|
|
0.200.123
by Jelmer Vernooij
Use central git module. |
61 |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
62 |
|
63 |
class TestGitBranch(tests.TestCaseInTempDir): |
|
64 |
||
0.200.1361
by Jelmer Vernooij
Support branches where the ref can't be mapped back to a branch name. |
65 |
def test_open_by_ref(self): |
66 |
GitRepo.init('.') |
|
0.200.1427
by Jelmer Vernooij
fix 2.3 and 2.4 compatibility. |
67 |
url = "%s,ref=%s" % ( |
0.200.1361
by Jelmer Vernooij
Support branches where the ref can't be mapped back to a branch name. |
68 |
urlutils.local_path_to_url(self.test_dir), |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
69 |
urlutils.quote("refs/remotes/origin/unstable", safe='') |
0.200.1427
by Jelmer Vernooij
fix 2.3 and 2.4 compatibility. |
70 |
)
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
71 |
d = ControlDir.open(url) |
0.200.1361
by Jelmer Vernooij
Support branches where the ref can't be mapped back to a branch name. |
72 |
b = d.create_branch() |
7045.4.2
by Jelmer Vernooij
Fix some more gitty tests. |
73 |
self.assertEqual(b.ref, b"refs/remotes/origin/unstable") |
0.200.1361
by Jelmer Vernooij
Support branches where the ref can't be mapped back to a branch name. |
74 |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
75 |
def test_open_existing(self): |
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
76 |
r = GitRepo.init('.') |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
77 |
d = ControlDir.open('.') |
0.200.769
by Jelmer Vernooij
Cope with open_branch() actually checking whether there is a branch present. |
78 |
thebranch = d.create_branch() |
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
79 |
self.assertIsInstance(thebranch, branch.GitBranch) |
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
80 |
|
0.200.412
by Jelmer Vernooij
Implement GitBranch.__repr__. |
81 |
def test_repr(self): |
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
82 |
r = GitRepo.init('.') |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
83 |
d = ControlDir.open('.') |
0.200.769
by Jelmer Vernooij
Cope with open_branch() actually checking whether there is a branch present. |
84 |
thebranch = d.create_branch() |
6964.2.3
by Jelmer Vernooij
Review comments. |
85 |
self.assertEqual( |
7045.4.1
by Jelmer Vernooij
Some brz-git fixes. |
86 |
"<LocalGitBranch('%s/', %r)>" % ( |
87 |
urlutils.local_path_to_url(self.test_dir), |
|
88 |
u'master'), |
|
0.266.1
by Martin
Expect native-style file urls in branch object reprs |
89 |
repr(thebranch)) |
0.200.412
by Jelmer Vernooij
Implement GitBranch.__repr__. |
90 |
|
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
91 |
def test_last_revision_is_null(self): |
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
92 |
r = GitRepo.init('.') |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
93 |
thedir = ControlDir.open('.') |
0.200.769
by Jelmer Vernooij
Cope with open_branch() actually checking whether there is a branch present. |
94 |
thebranch = thedir.create_branch() |
0.200.19
by John Arbash Meinel
More refactoring. Add some direct tests for GitModel. |
95 |
self.assertEqual(revision.NULL_REVISION, thebranch.last_revision()) |
96 |
self.assertEqual((0, revision.NULL_REVISION), |
|
97 |
thebranch.last_revision_info()) |
|
0.200.20
by John Arbash Meinel
All tests are passing again |
98 |
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
99 |
def simple_commit_a(self): |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
100 |
r = GitRepo.init('.') |
0.200.82
by Jelmer Vernooij
Support listing tags. |
101 |
self.build_tree(['a']) |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
102 |
r.stage(["a"]) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
103 |
return r.do_commit(b"a", committer=b"Somebody <foo@example.com>") |
0.200.82
by Jelmer Vernooij
Support listing tags. |
104 |
|
0.200.20
by John Arbash Meinel
All tests are passing again |
105 |
def test_last_revision_is_valid(self): |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
106 |
head = self.simple_commit_a() |
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
107 |
thebranch = Branch.open('.') |
0.200.104
by Jelmer Vernooij
Use bzr-foreign function names for converting between git and bzr revids. |
108 |
self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head), |
0.200.20
by John Arbash Meinel
All tests are passing again |
109 |
thebranch.last_revision()) |
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
110 |
|
0.200.1602
by Jelmer Vernooij
Remove Branch.revision_history. |
111 |
def test_last_revision_info(self): |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
112 |
reva = self.simple_commit_a() |
0.200.59
by Jelmer Vernooij
Add more tests, fix revision history. |
113 |
self.build_tree(['b']) |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
114 |
r = GitRepo(".") |
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
115 |
self.addCleanup(r.close) |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
116 |
r.stage("b") |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
117 |
revb = r.do_commit(b"b", committer=b"Somebody <foo@example.com>") |
0.200.58
by Jelmer Vernooij
Fix remaining tests. |
118 |
|
0.200.94
by Jelmer Vernooij
Eliminate (duplicate) git_ prefix. |
119 |
thebranch = Branch.open('.') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
120 |
self.assertEqual((2, default_mapping.revision_id_foreign_to_bzr( |
121 |
revb)), thebranch.last_revision_info()) |
|
0.200.82
by Jelmer Vernooij
Support listing tags. |
122 |
|
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
123 |
def test_tag_annotated(self): |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
124 |
reva = self.simple_commit_a() |
125 |
o = Tag() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
126 |
o.name = b"foo" |
127 |
o.tagger = b"Jelmer <foo@example.com>" |
|
128 |
o.message = b"add tag" |
|
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
129 |
o.object = (Commit, reva) |
130 |
o.tag_timezone = 0 |
|
131 |
o.tag_time = 42 |
|
132 |
r = GitRepo(".") |
|
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
133 |
self.addCleanup(r.close) |
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
134 |
r.object_store.add_object(o) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
135 |
r[b'refs/tags/foo'] = o.id |
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
136 |
thebranch = Branch.open('.') |
6964.2.3
by Jelmer Vernooij
Review comments. |
137 |
self.assertEqual({"foo": default_mapping.revision_id_foreign_to_bzr(reva)}, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
138 |
thebranch.tags.get_tag_dict()) |
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
139 |
|
140 |
def test_tag(self): |
|
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
141 |
reva = self.simple_commit_a() |
142 |
r = GitRepo(".") |
|
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
143 |
self.addCleanup(r.close) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
144 |
r.refs[b"refs/tags/foo"] = reva |
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
145 |
thebranch = Branch.open('.') |
6964.2.3
by Jelmer Vernooij
Review comments. |
146 |
self.assertEqual({"foo": default_mapping.revision_id_foreign_to_bzr(reva)}, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
147 |
thebranch.tags.get_tag_dict()) |
0.200.956
by Jelmer Vernooij
Add some more format tests. |
148 |
|
0.200.66
by Jelmer Vernooij
Implement branch.get_parent(). |
149 |
|
150 |
class TestWithGitBranch(tests.TestCaseWithTransport): |
|
151 |
||
152 |
def setUp(self): |
|
153 |
tests.TestCaseWithTransport.setUp(self) |
|
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
154 |
r = dulwich.repo.Repo.create(self.test_dir) |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
155 |
d = ControlDir.open(self.test_dir) |
0.200.769
by Jelmer Vernooij
Cope with open_branch() actually checking whether there is a branch present. |
156 |
self.git_branch = d.create_branch() |
0.200.66
by Jelmer Vernooij
Implement branch.get_parent(). |
157 |
|
158 |
def test_get_parent(self): |
|
159 |
self.assertIs(None, self.git_branch.get_parent()) |
|
0.200.67
by Jelmer Vernooij
Implement Branch.get_stacked_on_url. |
160 |
|
161 |
def test_get_stacked_on_url(self): |
|
0.200.1660
by Jelmer Vernooij
Fix imports. |
162 |
self.assertRaises(UnstackableBranchFormat, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
163 |
self.git_branch.get_stacked_on_url) |
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
164 |
|
0.200.72
by Jelmer Vernooij
Implement Branch.get_physical_lock_status. |
165 |
def test_get_physical_lock_status(self): |
166 |
self.assertFalse(self.git_branch.get_physical_lock_status()) |
|
167 |
||
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
168 |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
169 |
class TestLocalGitBranchFormat(tests.TestCase): |
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
170 |
|
171 |
def setUp(self): |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
172 |
super(TestLocalGitBranchFormat, self).setUp() |
173 |
self.format = branch.LocalGitBranchFormat() |
|
0.200.70
by Jelmer Vernooij
Implement GitBranchFormat.get_format_description. |
174 |
|
175 |
def test_get_format_description(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
176 |
self.assertEqual("Local Git Branch", |
177 |
self.format.get_format_description()) |
|
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
178 |
|
0.200.956
by Jelmer Vernooij
Add some more format tests. |
179 |
def test_get_network_name(self): |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
180 |
self.assertEqual(b"git", self.format.network_name()) |
0.200.956
by Jelmer Vernooij
Add some more format tests. |
181 |
|
182 |
def test_supports_tags(self): |
|
183 |
self.assertTrue(self.format.supports_tags()) |
|
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
184 |
|
185 |
||
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
186 |
class BranchTests(tests.TestCaseInTempDir): |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
187 |
|
188 |
def make_onerev_branch(self): |
|
189 |
os.mkdir("d") |
|
190 |
os.chdir("d") |
|
0.200.447
by Jelmer Vernooij
Rely less on command-line git. |
191 |
GitRepo.init('.') |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
192 |
bb = tests.GitBranchBuilder() |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
193 |
bb.set_file("foobar", b"foo\nbar\n", False) |
194 |
mark = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
195 |
gitsha = bb.finish()[mark] |
196 |
os.chdir("..") |
|
0.200.1373
by Jelmer Vernooij
Prevent accidentally removing branch. |
197 |
return os.path.abspath("d"), gitsha |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
198 |
|
0.247.1
by Michael Hudson
test |
199 |
def make_tworev_branch(self): |
200 |
os.mkdir("d") |
|
201 |
os.chdir("d") |
|
202 |
GitRepo.init('.') |
|
203 |
bb = tests.GitBranchBuilder() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
204 |
bb.set_file("foobar", b"foo\nbar\n", False) |
205 |
mark1 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
206 |
mark2 = bb.commit(b"Somebody <somebody@someorg.org>", b"mymsg") |
|
0.247.1
by Michael Hudson
test |
207 |
marks = bb.finish() |
208 |
os.chdir("..") |
|
209 |
return "d", (marks[mark1], marks[mark2]) |
|
210 |
||
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
211 |
def clone_git_branch(self, from_url, to_url): |
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
212 |
from_dir = ControlDir.open(from_url) |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
213 |
to_dir = from_dir.sprout(to_url) |
214 |
return to_dir.open_branch() |
|
215 |
||
216 |
def test_single_rev(self): |
|
217 |
path, gitsha = self.make_onerev_branch() |
|
218 |
oldrepo = Repository.open(path) |
|
219 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
220 |
self.assertEqual(gitsha, oldrepo._git.get_refs()[b"refs/heads/master"]) |
0.200.270
by Jelmer Vernooij
add tests for branch sprouting. |
221 |
newbranch = self.clone_git_branch(path, "f") |
6964.2.3
by Jelmer Vernooij
Review comments. |
222 |
self.assertEqual([revid], newbranch.repository.all_revision_ids()) |
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
223 |
|
224 |
def test_sprouted_tags(self): |
|
225 |
path, gitsha = self.make_onerev_branch() |
|
0.200.992
by Jelmer Vernooij
Avoid invoking git directly. |
226 |
r = GitRepo(path) |
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
227 |
self.addCleanup(r.close) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
228 |
r.refs[b"refs/tags/lala"] = r.head() |
0.200.271
by Jelmer Vernooij
Stop importing tags as branches as part of git-import. |
229 |
oldrepo = Repository.open(path) |
230 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
231 |
newbranch = self.clone_git_branch(path, "f") |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
232 |
self.assertEqual({"lala": revid}, newbranch.tags.get_tag_dict()) |
233 |
self.assertEqual([revid], newbranch.repository.all_revision_ids()) |
|
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
234 |
|
7240.2.1
by Jelmer Vernooij
Don't copy tags that don't point to valid objects. |
235 |
def test_sprouted_ghost_tags(self): |
236 |
path, gitsha = self.make_onerev_branch() |
|
237 |
r = GitRepo(path) |
|
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
238 |
self.addCleanup(r.close) |
7240.2.1
by Jelmer Vernooij
Don't copy tags that don't point to valid objects. |
239 |
r.refs[b"refs/tags/lala"] = b"aa" * 20 |
240 |
oldrepo = Repository.open(path) |
|
241 |
revid = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha) |
|
242 |
warnings, newbranch = self.callCatchWarnings( |
|
243 |
self.clone_git_branch, path, "f") |
|
244 |
self.assertEqual({}, newbranch.tags.get_tag_dict()) |
|
245 |
# Dulwich raises a UserWarning for tags with invalid target
|
|
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
246 |
self.assertIn(('ref refs/tags/lala points at non-present sha ' + ("aa" * 20), ), [w.args for w in warnings]) |
7240.2.1
by Jelmer Vernooij
Don't copy tags that don't point to valid objects. |
247 |
|
0.247.1
by Michael Hudson
test |
248 |
def test_interbranch_pull(self): |
249 |
path, (gitsha1, gitsha2) = self.make_tworev_branch() |
|
250 |
oldrepo = Repository.open(path) |
|
251 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
252 |
newbranch = self.make_branch('g') |
|
253 |
inter_branch = InterBranch.get(Branch.open(path), newbranch) |
|
254 |
inter_branch.pull() |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
255 |
self.assertEqual(revid2, newbranch.last_revision()) |
0.247.1
by Michael Hudson
test |
256 |
|
0.247.5
by Michael Hudson
test and fix for noop pull case |
257 |
def test_interbranch_pull_noop(self): |
258 |
path, (gitsha1, gitsha2) = self.make_tworev_branch() |
|
259 |
oldrepo = Repository.open(path) |
|
260 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
261 |
newbranch = self.make_branch('g') |
|
262 |
inter_branch = InterBranch.get(Branch.open(path), newbranch) |
|
263 |
inter_branch.pull() |
|
264 |
# This is basically "assertNotRaises"
|
|
265 |
inter_branch.pull() |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
266 |
self.assertEqual(revid2, newbranch.last_revision()) |
0.247.5
by Michael Hudson
test and fix for noop pull case |
267 |
|
0.247.3
by Michael Hudson
oh, so it wasn't (particularly) wrong, but it was a bit obscure |
268 |
def test_interbranch_pull_stop_revision(self): |
269 |
path, (gitsha1, gitsha2) = self.make_tworev_branch() |
|
270 |
oldrepo = Repository.open(path) |
|
271 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
272 |
newbranch = self.make_branch('g') |
|
273 |
inter_branch = InterBranch.get(Branch.open(path), newbranch) |
|
274 |
inter_branch.pull(stop_revision=revid1) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
275 |
self.assertEqual(revid1, newbranch.last_revision()) |
0.247.3
by Michael Hudson
oh, so it wasn't (particularly) wrong, but it was a bit obscure |
276 |
|
0.259.8
by Jelmer Vernooij
Add test. |
277 |
def test_interbranch_pull_with_tags(self): |
278 |
path, (gitsha1, gitsha2) = self.make_tworev_branch() |
|
279 |
gitrepo = GitRepo(path) |
|
7288.2.2
by Jelmer Vernooij
Check for specific warning rather than total number of warnings. |
280 |
self.addCleanup(gitrepo.close) |
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
281 |
gitrepo.refs[b"refs/tags/sometag"] = gitsha2 |
0.259.8
by Jelmer Vernooij
Add test. |
282 |
oldrepo = Repository.open(path) |
283 |
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1) |
|
284 |
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2) |
|
285 |
newbranch = self.make_branch('g') |
|
0.200.1305
by Jelmer Vernooij
Only actually fetch tags if "branch.fetch_tags" is set to true. |
286 |
source_branch = Branch.open(path) |
287 |
source_branch.get_config().set_user_option("branch.fetch_tags", True) |
|
288 |
inter_branch = InterBranch.get(source_branch, newbranch) |
|
0.259.8
by Jelmer Vernooij
Add test. |
289 |
inter_branch.pull(stop_revision=revid1) |
6964.2.3
by Jelmer Vernooij
Review comments. |
290 |
self.assertEqual(revid1, newbranch.last_revision()) |
0.259.8
by Jelmer Vernooij
Add test. |
291 |
self.assertTrue(newbranch.repository.has_revision(revid2)) |
292 |
||
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
293 |
def test_bzr_branch_bound_to_git(self): |
294 |
path, (gitsha1, gitsha2) = self.make_tworev_branch() |
|
7131.14.2
by Jelmer Vernooij
Make sure resulting branch is correct too. |
295 |
wt = Branch.open(path).create_checkout('co') |
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
296 |
self.build_tree_contents([('co/foobar', b'blah')]) |
7131.14.4
by Jelmer Vernooij
Fix test. |
297 |
self.assertRaises( |
298 |
errors.NoRoundtrippingSupport, wt.commit, |
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
299 |
'commit from bound branch.') |
7131.14.2
by Jelmer Vernooij
Make sure resulting branch is correct too. |
300 |
revid = wt.commit('commit from bound branch.', lossy=True) |
301 |
self.assertEqual(revid, wt.branch.last_revision()) |
|
302 |
self.assertEqual( |
|
7131.14.4
by Jelmer Vernooij
Fix test. |
303 |
revid, |
304 |
wt.branch.get_master_branch().last_revision()) |
|
7131.14.1
by Jelmer Vernooij
Fix committing to a bzr branch bound to a git branch. |
305 |
|
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
306 |
|
307 |
class ForeignTestsBranchFactory(object): |
|
308 |
||
309 |
def make_empty_branch(self, transport): |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
310 |
d = LocalGitControlDirFormat().initialize_on_transport(transport) |
0.200.769
by Jelmer Vernooij
Cope with open_branch() actually checking whether there is a branch present. |
311 |
return d.create_branch() |
0.243.1
by Jelmer Vernooij
Use foreign branch testing infrastructure. |
312 |
|
313 |
make_branch = make_empty_branch |