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) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
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
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
16 |
|
17 |
"""Test the smart client."""
|
|
18 |
||
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
19 |
from __future__ import absolute_import |
20 |
||
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
21 |
from io import BytesIO |
|
0.406.3
by Jelmer Vernooij
Add extra tests. |
22 |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
23 |
import os |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
24 |
import time |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
25 |
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
26 |
from ...controldir import ControlDir |
27 |
from ...errors import ( |
|
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
28 |
BzrError, |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
29 |
DivergedBranches, |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
30 |
NotBranchError, |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
31 |
NoSuchTag, |
|
7103.1.2
by Jelmer Vernooij
Handle PermissionDenied. |
32 |
PermissionDenied, |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
33 |
)
|
34 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
35 |
from ...tests import ( |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
36 |
TestCase, |
37 |
TestCaseWithTransport, |
|
38 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
39 |
from ...tests.features import ExecutableFeature |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
40 |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
41 |
from ..mapping import default_mapping |
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
42 |
from ..remote import ( |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
43 |
split_git_url, |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
44 |
parse_git_error, |
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
45 |
HeadUpdateFailed, |
46 |
RemoteGitError, |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
47 |
RemoteGitBranchFormat, |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
48 |
)
|
49 |
||
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
50 |
from dulwich import porcelain |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
51 |
from dulwich.repo import Repo as GitRepo |
52 |
||
53 |
||
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
54 |
class SplitUrlTests(TestCase): |
55 |
||
56 |
def test_simple(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
57 |
self.assertEqual(("foo", None, None, "/bar"), |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
58 |
split_git_url("git://foo/bar")) |
59 |
||
60 |
def test_port(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
61 |
self.assertEqual(("foo", 343, None, "/bar"), |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
62 |
split_git_url("git://foo:343/bar")) |
63 |
||
64 |
def test_username(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
65 |
self.assertEqual(("foo", None, "la", "/bar"), |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
66 |
split_git_url("git://la@foo/bar")) |
67 |
||
68 |
def test_nopath(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
69 |
self.assertEqual(("foo", None, None, "/"), |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
70 |
split_git_url("git://foo/")) |
71 |
||
72 |
def test_slashpath(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
73 |
self.assertEqual(("foo", None, None, "//bar"), |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
74 |
split_git_url("git://foo//bar")) |
|
0.246.2
by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories. |
75 |
|
76 |
def test_homedir(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
77 |
self.assertEqual(("foo", None, None, "~bar"), |
|
0.246.2
by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories. |
78 |
split_git_url("git://foo/~bar")) |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
79 |
|
80 |
||
81 |
class ParseGitErrorTests(TestCase): |
|
82 |
||
83 |
def test_unknown(self): |
|
84 |
e = parse_git_error("url", "foo") |
|
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
85 |
self.assertIsInstance(e, RemoteGitError) |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
86 |
|
87 |
def test_notbrancherror(self): |
|
88 |
e = parse_git_error("url", "\n Could not find Repository foo/bar") |
|
89 |
self.assertIsInstance(e, NotBranchError) |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
90 |
|
|
7104.2.1
by Jelmer Vernooij
Handle another way of formatting Git "repository not found" errors. |
91 |
def test_notbrancherror_launchpad(self): |
92 |
e = parse_git_error("url", "Repository 'foo/bar' not found.") |
|
93 |
self.assertIsInstance(e, NotBranchError) |
|
94 |
||
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
95 |
def test_notbrancherror_github(self): |
96 |
e = parse_git_error("url", "Repository not found.\n") |
|
97 |
self.assertIsInstance(e, NotBranchError) |
|
98 |
||
99 |
def test_head_update(self): |
|
100 |
e = parse_git_error("url", "HEAD failed to update\n") |
|
101 |
self.assertIsInstance(e, HeadUpdateFailed) |
|
102 |
||
|
7103.1.2
by Jelmer Vernooij
Handle PermissionDenied. |
103 |
def test_permission_dnied(self): |
104 |
e = parse_git_error( |
|
105 |
"url", |
|
106 |
"access denied or repository not exported: /debian/altermime.git") |
|
107 |
self.assertIsInstance(e, PermissionDenied) |
|
108 |
||
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
109 |
|
110 |
class TestRemoteGitBranchFormat(TestCase): |
|
111 |
||
112 |
def setUp(self): |
|
113 |
super(TestRemoteGitBranchFormat, self).setUp() |
|
114 |
self.format = RemoteGitBranchFormat() |
|
115 |
||
116 |
def test_get_format_description(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
117 |
self.assertEqual("Remote Git Branch", self.format.get_format_description()) |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
118 |
|
119 |
def test_get_network_name(self): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
120 |
self.assertEqual(b"git", self.format.network_name()) |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
121 |
|
122 |
def test_supports_tags(self): |
|
123 |
self.assertTrue(self.format.supports_tags()) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
124 |
|
125 |
||
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
126 |
class FetchFromRemoteTestBase(object): |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
127 |
|
128 |
_test_needs_features = [ExecutableFeature('git')] |
|
129 |
||
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
130 |
_to_format = None |
131 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
132 |
def setUp(self): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
133 |
TestCaseWithTransport.setUp(self) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
134 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
135 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
136 |
self.permit_url(self.remote_url) |
|
137 |
||
138 |
def test_sprout_simple(self): |
|
139 |
self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
140 |
message=b'message', |
141 |
committer=b'committer <committer@example.com>', |
|
142 |
author=b'author <author@example.com>') |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
143 |
|
144 |
remote = ControlDir.open(self.remote_url) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
145 |
self.make_controldir('local', format=self._to_format) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
146 |
local = remote.sprout('local') |
147 |
self.assertEqual( |
|
148 |
default_mapping.revision_id_foreign_to_bzr(self.remote_real.head()), |
|
149 |
local.open_branch().last_revision()) |
|
150 |
||
151 |
def test_sprout_with_tags(self): |
|
152 |
c1 = self.remote_real.do_commit( |
|
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
153 |
message=b'message', |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
154 |
committer=b'committer <committer@example.com>', |
155 |
author=b'author <author@example.com>') |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
156 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
157 |
message=b'another commit', |
158 |
committer=b'committer <committer@example.com>', |
|
159 |
author=b'author <author@example.com>', |
|
160 |
ref=b'refs/tags/another') |
|
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
161 |
self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head() |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
162 |
|
163 |
remote = ControlDir.open(self.remote_url) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
164 |
self.make_controldir('local', format=self._to_format) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
165 |
local = remote.sprout('local') |
166 |
local_branch = local.open_branch() |
|
167 |
self.assertEqual( |
|
168 |
default_mapping.revision_id_foreign_to_bzr(c1), |
|
169 |
local_branch.last_revision()) |
|
170 |
self.assertEqual( |
|
171 |
{'blah': local_branch.last_revision(), |
|
172 |
'another': default_mapping.revision_id_foreign_to_bzr(c2)}, |
|
173 |
local_branch.tags.get_tag_dict()) |
|
174 |
||
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
175 |
def test_sprout_with_annotated_tag(self): |
176 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
177 |
message=b'message', |
178 |
committer=b'committer <committer@example.com>', |
|
179 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
180 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
181 |
message=b'another commit', |
182 |
committer=b'committer <committer@example.com>', |
|
183 |
author=b'author <author@example.com>', |
|
184 |
ref=b'refs/heads/another') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
185 |
porcelain.tag_create( |
186 |
self.remote_real, |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
187 |
tag=b"blah", |
188 |
author=b'author <author@example.com>', |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
189 |
objectish=c2, |
190 |
tag_time=int(time.time()), |
|
191 |
tag_timezone=0, |
|
192 |
annotated=True, |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
193 |
message=b"Annotated tag") |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
194 |
|
195 |
remote = ControlDir.open(self.remote_url) |
|
196 |
self.make_controldir('local', format=self._to_format) |
|
197 |
local = remote.sprout('local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1)) |
|
198 |
local_branch = local.open_branch() |
|
199 |
self.assertEqual( |
|
200 |
default_mapping.revision_id_foreign_to_bzr(c1), |
|
201 |
local_branch.last_revision()) |
|
202 |
self.assertEqual( |
|
203 |
{'blah': default_mapping.revision_id_foreign_to_bzr(c2)}, |
|
204 |
local_branch.tags.get_tag_dict()) |
|
205 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
206 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
207 |
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase,TestCaseWithTransport): |
208 |
||
209 |
_to_format = '2a' |
|
210 |
||
211 |
||
212 |
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase,TestCaseWithTransport): |
|
213 |
||
214 |
_to_format = 'git' |
|
215 |
||
216 |
||
217 |
class PushToRemoteBase(object): |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
218 |
|
219 |
_test_needs_features = [ExecutableFeature('git')] |
|
220 |
||
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
221 |
_from_format = None |
222 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
223 |
def setUp(self): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
224 |
TestCaseWithTransport.setUp(self) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
225 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
226 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
227 |
self.permit_url(self.remote_url) |
|
228 |
||
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
229 |
def test_push_branch_new(self): |
230 |
remote = ControlDir.open(self.remote_url) |
|
231 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
232 |
self.build_tree(['local/blah']) |
|
233 |
wt.add(['blah']) |
|
234 |
revid = wt.commit('blah') |
|
235 |
||
236 |
if self._from_format == 'git': |
|
|
0.406.2
by Jelmer Vernooij
Add tests. |
237 |
result = remote.push_branch(wt.branch, name='newbranch') |
238 |
else: |
|
239 |
result = remote.push_branch(wt.branch, lossy=True, name='newbranch') |
|
240 |
||
241 |
self.assertEqual(0, result.old_revno) |
|
242 |
if self._from_format == 'git': |
|
243 |
self.assertEqual(1, result.new_revno) |
|
244 |
else: |
|
245 |
self.assertIs(None, result.new_revno) |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
246 |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
247 |
result.report(BytesIO()) |
|
0.406.3
by Jelmer Vernooij
Add extra tests. |
248 |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
249 |
self.assertEqual( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
250 |
{b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'], |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
251 |
},
|
252 |
self.remote_real.get_refs()) |
|
253 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
254 |
def test_push(self): |
255 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
256 |
message=b'message', |
257 |
committer=b'committer <committer@example.com>', |
|
258 |
author=b'author <author@example.com>') |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
259 |
|
260 |
remote = ControlDir.open(self.remote_url) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
261 |
self.make_controldir('local', format=self._from_format) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
262 |
local = remote.sprout('local') |
263 |
self.build_tree(['local/blah']) |
|
264 |
wt = local.open_workingtree() |
|
265 |
wt.add(['blah']) |
|
266 |
revid = wt.commit('blah') |
|
267 |
wt.branch.tags.set_tag('sometag', revid) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
268 |
wt.branch.get_config_stack().set('branch.fetch_tags', True) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
269 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
270 |
if self._from_format == 'git': |
|
0.406.2
by Jelmer Vernooij
Add tests. |
271 |
result = wt.branch.push(remote.create_branch('newbranch')) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
272 |
else: |
|
0.406.2
by Jelmer Vernooij
Add tests. |
273 |
result = wt.branch.push(remote.create_branch('newbranch'), lossy=True) |
274 |
||
275 |
self.assertEqual(0, result.old_revno) |
|
276 |
self.assertEqual(2, result.new_revno) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
277 |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
278 |
result.report(BytesIO()) |
|
0.406.3
by Jelmer Vernooij
Add extra tests. |
279 |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
280 |
self.assertEqual( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
281 |
{b'refs/heads/master': self.remote_real.head(), |
282 |
b'HEAD': self.remote_real.head(), |
|
283 |
b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'], |
|
284 |
b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'], |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
285 |
},
|
286 |
self.remote_real.get_refs()) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
287 |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
288 |
def test_push_diverged(self): |
289 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
290 |
message=b'message', |
291 |
committer=b'committer <committer@example.com>', |
|
292 |
author=b'author <author@example.com>', |
|
293 |
ref=b'refs/heads/newbranch') |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
294 |
|
295 |
remote = ControlDir.open(self.remote_url) |
|
296 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
297 |
self.build_tree(['local/blah']) |
|
298 |
wt.add(['blah']) |
|
299 |
revid = wt.commit('blah') |
|
300 |
||
301 |
newbranch = remote.open_branch('newbranch') |
|
302 |
if self._from_format == 'git': |
|
303 |
self.assertRaises(DivergedBranches, wt.branch.push, newbranch) |
|
304 |
else: |
|
305 |
self.assertRaises(DivergedBranches, wt.branch.push, newbranch, lossy=True) |
|
306 |
||
307 |
self.assertEqual( |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
308 |
{b'refs/heads/newbranch': c1 }, |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
309 |
self.remote_real.get_refs()) |
310 |
||
311 |
if self._from_format == 'git': |
|
312 |
wt.branch.push(newbranch, overwrite=True) |
|
313 |
else: |
|
314 |
wt.branch.push(newbranch, lossy=True, overwrite=True) |
|
315 |
||
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
316 |
self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch']) |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
317 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
318 |
|
319 |
class PushToRemoteFromBzrTests(PushToRemoteBase,TestCaseWithTransport): |
|
320 |
||
321 |
_from_format = '2a' |
|
322 |
||
323 |
||
324 |
class PushToRemoteFromGitTests(PushToRemoteBase,TestCaseWithTransport): |
|
325 |
||
326 |
_from_format = 'git' |
|
327 |
||
328 |
||
329 |
class RemoteControlDirTests(TestCaseWithTransport): |
|
330 |
||
331 |
_test_needs_features = [ExecutableFeature('git')] |
|
332 |
||
333 |
def setUp(self): |
|
334 |
TestCaseWithTransport.setUp(self) |
|
335 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
|
336 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
337 |
self.permit_url(self.remote_url) |
|
338 |
||
339 |
def test_remove_branch(self): |
|
340 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
341 |
message=b'message', |
342 |
committer=b'committer <committer@example.com>', |
|
343 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
344 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
345 |
message=b'another commit', |
346 |
committer=b'committer <committer@example.com>', |
|
347 |
author=b'author <author@example.com>', |
|
348 |
ref=b'refs/heads/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
349 |
|
350 |
remote = ControlDir.open(self.remote_url) |
|
351 |
remote.destroy_branch(name='blah') |
|
352 |
self.assertEqual( |
|
353 |
self.remote_real.get_refs(), |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
354 |
{b'refs/heads/master': self.remote_real.head(), |
355 |
b'HEAD': self.remote_real.head(), |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
356 |
})
|
357 |
||
358 |
def test_list_branches(self): |
|
359 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
360 |
message=b'message', |
361 |
committer=b'committer <committer@example.com>', |
|
362 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
363 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
364 |
message=b'another commit', |
365 |
committer=b'committer <committer@example.com>', |
|
366 |
author=b'author <author@example.com>', |
|
367 |
ref=b'refs/heads/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
368 |
|
369 |
remote = ControlDir.open(self.remote_url) |
|
370 |
self.assertEqual( |
|
|
6997.1.1
by Jelmer Vernooij
Fix tests on Python3.5. |
371 |
set(['master', 'blah', 'master']), |
372 |
set([b.name for b in remote.list_branches()])) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
373 |
|
374 |
def test_get_branches(self): |
|
375 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
376 |
message=b'message', |
377 |
committer=b'committer <committer@example.com>', |
|
378 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
379 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
380 |
message=b'another commit', |
381 |
committer=b'committer <committer@example.com>', |
|
382 |
author=b'author <author@example.com>', |
|
383 |
ref=b'refs/heads/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
384 |
|
385 |
remote = ControlDir.open(self.remote_url) |
|
386 |
self.assertEqual( |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
387 |
{'': 'master', 'blah': 'blah', 'master': 'master'}, |
388 |
{n: b.name for (n, b) in remote.get_branches().items()}) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
389 |
|
390 |
def test_remove_tag(self): |
|
391 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
392 |
message=b'message', |
393 |
committer=b'committer <committer@example.com>', |
|
394 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
395 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
396 |
message=b'another commit', |
397 |
committer=b'committer <committer@example.com>', |
|
398 |
author=b'author <author@example.com>', |
|
399 |
ref=b'refs/tags/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
400 |
|
401 |
remote = ControlDir.open(self.remote_url) |
|
402 |
remote_branch = remote.open_branch() |
|
403 |
remote_branch.tags.delete_tag('blah') |
|
404 |
self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah') |
|
405 |
self.assertEqual( |
|
406 |
self.remote_real.get_refs(), |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
407 |
{b'refs/heads/master': self.remote_real.head(), |
408 |
b'HEAD': self.remote_real.head(), |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
409 |
})
|
410 |
||
411 |
def test_set_tag(self): |
|
412 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
413 |
message=b'message', |
414 |
committer=b'committer <committer@example.com>', |
|
415 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
416 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
417 |
message=b'another commit', |
418 |
committer=b'committer <committer@example.com>', |
|
419 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
420 |
|
421 |
remote = ControlDir.open(self.remote_url) |
|
422 |
remote.open_branch().tags.set_tag( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
423 |
b'blah', default_mapping.revision_id_foreign_to_bzr(c1)) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
424 |
self.assertEqual( |
425 |
self.remote_real.get_refs(), |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
426 |
{b'refs/heads/master': self.remote_real.head(), |
427 |
b'refs/tags/blah': c1, |
|
428 |
b'HEAD': self.remote_real.head(), |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
429 |
})
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
430 |
|
431 |
def test_annotated_tag(self): |
|
432 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
433 |
message=b'message', |
434 |
committer=b'committer <committer@example.com>', |
|
435 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
436 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
437 |
message=b'another commit', |
438 |
committer=b'committer <committer@example.com>', |
|
439 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
440 |
|
441 |
porcelain.tag_create( |
|
442 |
self.remote_real, |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
443 |
tag=b"blah", |
444 |
author=b'author <author@example.com>', |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
445 |
objectish=c2, |
446 |
tag_time=int(time.time()), |
|
447 |
tag_timezone=0, |
|
448 |
annotated=True, |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
449 |
message=b"Annotated tag") |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
450 |
|
451 |
remote = ControlDir.open(self.remote_url) |
|
452 |
remote_branch = remote.open_branch() |
|
453 |
self.assertEqual({ |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
454 |
'blah': default_mapping.revision_id_foreign_to_bzr(c2)}, |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
455 |
remote_branch.tags.get_tag_dict()) |
456 |
||
457 |
def tetst_get_branch_reference(self): |
|
458 |
c1 = self.remote_real.do_commit( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
459 |
message=b'message', |
460 |
committer=b'committer <committer@example.com>', |
|
461 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
462 |
c2 = self.remote_real.do_commit( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
463 |
message=b'another commit', |
464 |
committer=b'committer <committer@example.com>', |
|
465 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
466 |
|
467 |
remote = ControlDir.open(self.remote_url) |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
468 |
self.assertEqual(b'refs/heads/master', remote.get_branch_reference('')) |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
469 |
self.assertEqual(None, remote.get_branch_reference('master')) |