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