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 |
||
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
19 |
from io import BytesIO |
0.406.3
by Jelmer Vernooij
Add extra tests. |
20 |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
21 |
import os |
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
22 |
import time |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
23 |
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
24 |
from ...controldir import ControlDir |
25 |
from ...errors import ( |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
26 |
DivergedBranches, |
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
27 |
NotBranchError, |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
28 |
NoSuchTag, |
7103.1.2
by Jelmer Vernooij
Handle PermissionDenied. |
29 |
PermissionDenied, |
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
30 |
)
|
31 |
||
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
32 |
from ...tests import ( |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
33 |
TestCase, |
34 |
TestCaseWithTransport, |
|
35 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
36 |
from ...tests.features import ExecutableFeature |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
37 |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
38 |
from ..mapping import default_mapping |
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
39 |
from ..remote import ( |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
40 |
split_git_url, |
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
41 |
parse_git_error, |
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
42 |
parse_git_hangup, |
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
43 |
HeadUpdateFailed, |
44 |
RemoteGitError, |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
45 |
RemoteGitBranchFormat, |
7371.3.2
by Jelmer Vernooij
Fix URL parsing for Git. |
46 |
_git_url_and_path_from_transport, |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
47 |
)
|
48 |
||
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
49 |
from dulwich import porcelain |
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
50 |
from dulwich.errors import HangupException |
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"), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
58 |
split_git_url("git://foo/bar")) |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
59 |
|
60 |
def test_port(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
61 |
self.assertEqual(("foo", 343, None, "/bar"), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
62 |
split_git_url("git://foo:343/bar")) |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
63 |
|
64 |
def test_username(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
65 |
self.assertEqual(("foo", None, "la", "/bar"), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
66 |
split_git_url("git://la@foo/bar")) |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
67 |
|
7290.38.1
by Jelmer Vernooij
Backport python3.8 support patch to breezy 3.0. |
68 |
def test_username_password(self): |
69 |
self.assertEqual( |
|
70 |
("foo", None, "la", "/bar"), |
|
71 |
split_git_url("git://la:passwd@foo/bar")) |
|
72 |
||
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
73 |
def test_nopath(self): |
6964.2.3
by Jelmer Vernooij
Review comments. |
74 |
self.assertEqual(("foo", None, None, "/"), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
75 |
split_git_url("git://foo/")) |
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
76 |
|
77 |
def test_slashpath(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
78 |
self.assertEqual(("foo", None, None, "//bar"), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
79 |
split_git_url("git://foo//bar")) |
0.246.2
by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories. |
80 |
|
81 |
def test_homedir(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
82 |
self.assertEqual(("foo", None, None, "~bar"), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
83 |
split_git_url("git://foo/~bar")) |
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
84 |
|
7290.38.1
by Jelmer Vernooij
Backport python3.8 support patch to breezy 3.0. |
85 |
def test_file(self): |
7290.38.2
by Jelmer Vernooij
More fixes. |
86 |
self.assertEqual( |
87 |
("", None, None, "/bar"), |
|
88 |
split_git_url("file:///bar")) |
|
7290.38.1
by Jelmer Vernooij
Backport python3.8 support patch to breezy 3.0. |
89 |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
90 |
|
91 |
class ParseGitErrorTests(TestCase): |
|
92 |
||
93 |
def test_unknown(self): |
|
94 |
e = parse_git_error("url", "foo") |
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
95 |
self.assertIsInstance(e, RemoteGitError) |
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
96 |
|
97 |
def test_notbrancherror(self): |
|
98 |
e = parse_git_error("url", "\n Could not find Repository foo/bar") |
|
99 |
self.assertIsInstance(e, NotBranchError) |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
100 |
|
7104.2.1
by Jelmer Vernooij
Handle another way of formatting Git "repository not found" errors. |
101 |
def test_notbrancherror_launchpad(self): |
102 |
e = parse_git_error("url", "Repository 'foo/bar' not found.") |
|
103 |
self.assertIsInstance(e, NotBranchError) |
|
104 |
||
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
105 |
def test_notbrancherror_github(self): |
106 |
e = parse_git_error("url", "Repository not found.\n") |
|
107 |
self.assertIsInstance(e, NotBranchError) |
|
108 |
||
7131.7.3
by Jelmer Vernooij
Handle one more error. |
109 |
def test_notbrancherror_normal(self): |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
110 |
e = parse_git_error( |
111 |
"url", "fatal: '/srv/git/lintian-brush' does not appear to be a git repository") |
|
7131.7.3
by Jelmer Vernooij
Handle one more error. |
112 |
self.assertIsInstance(e, NotBranchError) |
113 |
||
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
114 |
def test_head_update(self): |
115 |
e = parse_git_error("url", "HEAD failed to update\n") |
|
116 |
self.assertIsInstance(e, HeadUpdateFailed) |
|
117 |
||
7103.1.2
by Jelmer Vernooij
Handle PermissionDenied. |
118 |
def test_permission_dnied(self): |
119 |
e = parse_git_error( |
|
120 |
"url", |
|
121 |
"access denied or repository not exported: /debian/altermime.git") |
|
122 |
self.assertIsInstance(e, PermissionDenied) |
|
123 |
||
7131.7.1
by Jelmer Vernooij
Handle permission denied by GitLab. |
124 |
def test_permission_denied_gitlab(self): |
125 |
e = parse_git_error( |
|
126 |
"url", |
|
127 |
'GitLab: You are not allowed to push code to this project.\n') |
|
128 |
self.assertIsInstance(e, PermissionDenied) |
|
129 |
||
7131.7.2
by Jelmer Vernooij
Handle github PermissionDenied. |
130 |
def test_permission_denied_github(self): |
131 |
e = parse_git_error( |
|
132 |
"url", |
|
133 |
'Permission to porridge/gaduhistory.git denied to jelmer.') |
|
134 |
self.assertIsInstance(e, PermissionDenied) |
|
135 |
self.assertEqual(e.path, 'porridge/gaduhistory.git') |
|
136 |
self.assertEqual(e.extra, ': denied to jelmer') |
|
137 |
||
7490.116.1
by Jelmer Vernooij
Handle pre-receive hook declined errors. |
138 |
def test_pre_receive_hook_declined(self): |
139 |
e = parse_git_error( |
|
140 |
"url", |
|
141 |
'pre-receive hook declined') |
|
142 |
self.assertIsInstance(e, PermissionDenied) |
|
143 |
self.assertEqual(e.path, "url") |
|
144 |
self.assertEqual(e.extra, ': pre-receive hook declined') |
|
145 |
||
7379.1.1
by Jelmer Vernooij
Handle invalid repository name on GitHub. |
146 |
def test_invalid_repo_name(self): |
147 |
e = parse_git_error( |
|
148 |
"url", |
|
149 |
"""Gregwar/fatcat/tree/debian is not a valid repository name |
|
150 |
Email support@github.com for help
|
|
151 |
""") |
|
152 |
self.assertIsInstance(e, NotBranchError) |
|
153 |
||
7490.91.1
by Jelmer Vernooij
Handle GitLab protected branch errors. |
154 |
def test_invalid_git_error(self): |
155 |
self.assertEqual( |
|
156 |
PermissionDenied( |
|
157 |
'url', |
|
158 |
'GitLab: You are not allowed to push code to protected '
|
|
159 |
'branches on this project.'), |
|
160 |
parse_git_error( |
|
161 |
'url', |
|
162 |
RemoteGitError( |
|
163 |
'GitLab: You are not allowed to push code to '
|
|
164 |
'protected branches on this project.'))) |
|
165 |
||
0.295.1
by Jelmer Vernooij
Split up branch formats. |
166 |
|
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
167 |
class ParseHangupTests(TestCase): |
168 |
||
169 |
def setUp(self): |
|
170 |
super(ParseHangupTests, self).setUp() |
|
171 |
try: |
|
7490.49.3
by Jelmer Vernooij
Fix tests with newer dulwich. |
172 |
HangupException([b'foo']) |
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
173 |
except TypeError: |
174 |
self.skipTest('dulwich version too old') |
|
175 |
||
176 |
def test_not_set(self): |
|
177 |
self.assertIsInstance( |
|
178 |
parse_git_hangup('http://', HangupException()), HangupException) |
|
179 |
||
180 |
def test_single_line(self): |
|
181 |
self.assertEqual( |
|
182 |
RemoteGitError('foo bar'), |
|
7490.49.3
by Jelmer Vernooij
Fix tests with newer dulwich. |
183 |
parse_git_hangup('http://', HangupException([b'foo bar']))) |
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
184 |
|
185 |
def test_multi_lines(self): |
|
186 |
self.assertEqual( |
|
187 |
RemoteGitError('foo bar\nbla bla'), |
|
188 |
parse_git_hangup( |
|
7490.49.3
by Jelmer Vernooij
Fix tests with newer dulwich. |
189 |
'http://', HangupException([b'foo bar', b'bla bla']))) |
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
190 |
|
191 |
def test_filter_boring(self): |
|
192 |
self.assertEqual( |
|
193 |
RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException( |
|
7490.49.3
by Jelmer Vernooij
Fix tests with newer dulwich. |
194 |
[b'=======', b'foo bar', b'======']))) |
7490.50.2
by Jelmer Vernooij
Strip 'remote: ' prefixes. |
195 |
self.assertEqual( |
196 |
RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException( |
|
197 |
[b'remote: =======', b'remote: foo bar', b'remote: ======']))) |
|
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
198 |
|
199 |
def test_permission_denied(self): |
|
200 |
self.assertEqual( |
|
201 |
PermissionDenied('http://', 'You are not allowed to push code to this project.'), |
|
202 |
parse_git_hangup( |
|
203 |
'http://', |
|
204 |
HangupException( |
|
7490.49.3
by Jelmer Vernooij
Fix tests with newer dulwich. |
205 |
[b'=======', |
206 |
b'You are not allowed to push code to this project.', b'', b'======']))) |
|
7490.29.12
by Jelmer Vernooij
Parse stderr from remote git servers when they hang up. |
207 |
|
208 |
||
0.295.1
by Jelmer Vernooij
Split up branch formats. |
209 |
class TestRemoteGitBranchFormat(TestCase): |
210 |
||
211 |
def setUp(self): |
|
212 |
super(TestRemoteGitBranchFormat, self).setUp() |
|
213 |
self.format = RemoteGitBranchFormat() |
|
214 |
||
215 |
def test_get_format_description(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
216 |
self.assertEqual("Remote Git Branch", |
217 |
self.format.get_format_description()) |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
218 |
|
219 |
def test_get_network_name(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
220 |
self.assertEqual(b"git", self.format.network_name()) |
0.295.1
by Jelmer Vernooij
Split up branch formats. |
221 |
|
222 |
def test_supports_tags(self): |
|
223 |
self.assertTrue(self.format.supports_tags()) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
224 |
|
225 |
||
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
226 |
class TestRemoteGitBranch(TestCaseWithTransport): |
227 |
||
7183.1.1
by Jelmer Vernooij
Add missing feature for git test that requires git executable. |
228 |
_test_needs_features = [ExecutableFeature('git')] |
229 |
||
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
230 |
def setUp(self): |
231 |
TestCaseWithTransport.setUp(self) |
|
232 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
|
233 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
234 |
self.permit_url(self.remote_url) |
|
235 |
||
236 |
def test_set_last_revision_info(self): |
|
237 |
c1 = self.remote_real.do_commit( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
238 |
message=b'message 1', |
239 |
committer=b'committer <committer@example.com>', |
|
240 |
author=b'author <author@example.com>', |
|
241 |
ref=b'refs/heads/newbranch') |
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
242 |
c2 = self.remote_real.do_commit( |
7143.16.8
by Jelmer Vernooij
Fix E126 |
243 |
message=b'message 2', |
244 |
committer=b'committer <committer@example.com>', |
|
245 |
author=b'author <author@example.com>', |
|
246 |
ref=b'refs/heads/newbranch') |
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
247 |
|
248 |
remote = ControlDir.open(self.remote_url) |
|
249 |
newbranch = remote.open_branch('newbranch') |
|
250 |
self.assertEqual(newbranch.lookup_foreign_revision_id(c2), |
|
251 |
newbranch.last_revision()) |
|
252 |
newbranch.set_last_revision_info( |
|
253 |
1, newbranch.lookup_foreign_revision_id(c1)) |
|
7131.12.2
by Jelmer Vernooij
Fix tests on python 3. |
254 |
self.assertEqual(c1, self.remote_real.refs[b'refs/heads/newbranch']) |
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
255 |
self.assertEqual(newbranch.last_revision(), |
256 |
newbranch.lookup_foreign_revision_id(c1)) |
|
257 |
||
258 |
||
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
259 |
class FetchFromRemoteTestBase(object): |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
260 |
|
261 |
_test_needs_features = [ExecutableFeature('git')] |
|
262 |
||
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
263 |
_to_format = None |
264 |
||
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
265 |
def setUp(self): |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
266 |
TestCaseWithTransport.setUp(self) |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
267 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
268 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
269 |
self.permit_url(self.remote_url) |
|
270 |
||
271 |
def test_sprout_simple(self): |
|
272 |
self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
273 |
message=b'message', |
274 |
committer=b'committer <committer@example.com>', |
|
275 |
author=b'author <author@example.com>') |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
276 |
|
277 |
remote = ControlDir.open(self.remote_url) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
278 |
self.make_controldir('local', format=self._to_format) |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
279 |
local = remote.sprout('local') |
280 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
281 |
default_mapping.revision_id_foreign_to_bzr( |
282 |
self.remote_real.head()), |
|
283 |
local.open_branch().last_revision()) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
284 |
|
285 |
def test_sprout_with_tags(self): |
|
286 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
287 |
message=b'message', |
288 |
committer=b'committer <committer@example.com>', |
|
289 |
author=b'author <author@example.com>') |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
290 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
291 |
message=b'another commit', |
292 |
committer=b'committer <committer@example.com>', |
|
293 |
author=b'author <author@example.com>', |
|
294 |
ref=b'refs/tags/another') |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
295 |
self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head() |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
296 |
|
297 |
remote = ControlDir.open(self.remote_url) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
298 |
self.make_controldir('local', format=self._to_format) |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
299 |
local = remote.sprout('local') |
300 |
local_branch = local.open_branch() |
|
301 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
302 |
default_mapping.revision_id_foreign_to_bzr(c1), |
303 |
local_branch.last_revision()) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
304 |
self.assertEqual( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
305 |
{'blah': local_branch.last_revision(), |
306 |
'another': default_mapping.revision_id_foreign_to_bzr(c2)}, |
|
307 |
local_branch.tags.get_tag_dict()) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
308 |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
309 |
def test_sprout_with_annotated_tag(self): |
310 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
311 |
message=b'message', |
312 |
committer=b'committer <committer@example.com>', |
|
313 |
author=b'author <author@example.com>') |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
314 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
315 |
message=b'another commit', |
316 |
committer=b'committer <committer@example.com>', |
|
317 |
author=b'author <author@example.com>', |
|
318 |
ref=b'refs/heads/another') |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
319 |
porcelain.tag_create( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
320 |
self.remote_real, |
321 |
tag=b"blah", |
|
322 |
author=b'author <author@example.com>', |
|
323 |
objectish=c2, |
|
324 |
tag_time=int(time.time()), |
|
325 |
tag_timezone=0, |
|
326 |
annotated=True, |
|
327 |
message=b"Annotated tag") |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
328 |
|
329 |
remote = ControlDir.open(self.remote_url) |
|
330 |
self.make_controldir('local', format=self._to_format) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
331 |
local = remote.sprout( |
332 |
'local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1)) |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
333 |
local_branch = local.open_branch() |
334 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
335 |
default_mapping.revision_id_foreign_to_bzr(c1), |
336 |
local_branch.last_revision()) |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
337 |
self.assertEqual( |
7143.16.8
by Jelmer Vernooij
Fix E126 |
338 |
{'blah': default_mapping.revision_id_foreign_to_bzr(c2)}, |
339 |
local_branch.tags.get_tag_dict()) |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
340 |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
341 |
def test_sprout_with_annotated_tag_unreferenced(self): |
342 |
c1 = self.remote_real.do_commit( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
343 |
message=b'message', |
344 |
committer=b'committer <committer@example.com>', |
|
345 |
author=b'author <author@example.com>') |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
346 |
c2 = self.remote_real.do_commit( |
7143.16.8
by Jelmer Vernooij
Fix E126 |
347 |
message=b'another commit', |
348 |
committer=b'committer <committer@example.com>', |
|
349 |
author=b'author <author@example.com>') |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
350 |
porcelain.tag_create( |
7143.16.8
by Jelmer Vernooij
Fix E126 |
351 |
self.remote_real, |
352 |
tag=b"blah", |
|
353 |
author=b'author <author@example.com>', |
|
354 |
objectish=c1, |
|
355 |
tag_time=int(time.time()), |
|
356 |
tag_timezone=0, |
|
357 |
annotated=True, |
|
358 |
message=b"Annotated tag") |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
359 |
|
360 |
remote = ControlDir.open(self.remote_url) |
|
361 |
self.make_controldir('local', format=self._to_format) |
|
362 |
local = remote.sprout( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
363 |
'local', |
364 |
revision_id=default_mapping.revision_id_foreign_to_bzr(c1)) |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
365 |
local_branch = local.open_branch() |
366 |
self.assertEqual( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
367 |
default_mapping.revision_id_foreign_to_bzr(c1), |
368 |
local_branch.last_revision()) |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
369 |
self.assertEqual( |
7143.16.8
by Jelmer Vernooij
Fix E126 |
370 |
{'blah': default_mapping.revision_id_foreign_to_bzr(c1)}, |
371 |
local_branch.tags.get_tag_dict()) |
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
372 |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
373 |
|
7143.16.21
by Jelmer Vernooij
Fix regressions. |
374 |
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase, TestCaseWithTransport): |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
375 |
|
376 |
_to_format = '2a' |
|
377 |
||
378 |
||
7143.15.2
by Jelmer Vernooij
Run autopep8. |
379 |
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase, TestCaseWithTransport): |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
380 |
|
381 |
_to_format = 'git' |
|
382 |
||
383 |
||
384 |
class PushToRemoteBase(object): |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
385 |
|
386 |
_test_needs_features = [ExecutableFeature('git')] |
|
387 |
||
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
388 |
_from_format = None |
389 |
||
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
390 |
def setUp(self): |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
391 |
TestCaseWithTransport.setUp(self) |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
392 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
393 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
394 |
self.permit_url(self.remote_url) |
|
395 |
||
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
396 |
def test_push_branch_new(self): |
397 |
remote = ControlDir.open(self.remote_url) |
|
398 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
399 |
self.build_tree(['local/blah']) |
|
400 |
wt.add(['blah']) |
|
401 |
revid = wt.commit('blah') |
|
402 |
||
403 |
if self._from_format == 'git': |
|
0.406.2
by Jelmer Vernooij
Add tests. |
404 |
result = remote.push_branch(wt.branch, name='newbranch') |
405 |
else: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
406 |
result = remote.push_branch( |
407 |
wt.branch, lossy=True, name='newbranch') |
|
0.406.2
by Jelmer Vernooij
Add tests. |
408 |
|
409 |
self.assertEqual(0, result.old_revno) |
|
410 |
if self._from_format == 'git': |
|
411 |
self.assertEqual(1, result.new_revno) |
|
412 |
else: |
|
413 |
self.assertIs(None, result.new_revno) |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
414 |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
415 |
result.report(BytesIO()) |
0.406.3
by Jelmer Vernooij
Add extra tests. |
416 |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
417 |
self.assertEqual( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
418 |
{b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'], |
419 |
},
|
|
420 |
self.remote_real.get_refs()) |
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
421 |
|
7484.1.2
by Jelmer Vernooij
Add some tests. |
422 |
def test_push_branch_symref(self): |
423 |
cfg = self.remote_real.get_config() |
|
424 |
cfg.set((b'core', ), b'bare', True) |
|
425 |
cfg.write_to_path() |
|
426 |
self.remote_real.refs.set_symbolic_ref(b'HEAD', b'refs/heads/master') |
|
427 |
c1 = self.remote_real.do_commit( |
|
428 |
message=b'message', |
|
429 |
committer=b'committer <committer@example.com>', |
|
430 |
author=b'author <author@example.com>', |
|
431 |
ref=b'refs/heads/master') |
|
432 |
remote = ControlDir.open(self.remote_url) |
|
433 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
434 |
self.build_tree(['local/blah']) |
|
435 |
wt.add(['blah']) |
|
436 |
revid = wt.commit('blah') |
|
437 |
||
438 |
if self._from_format == 'git': |
|
439 |
result = remote.push_branch(wt.branch, overwrite=True) |
|
440 |
else: |
|
441 |
result = remote.push_branch(wt.branch, lossy=True, overwrite=True) |
|
442 |
||
443 |
self.assertEqual(None, result.old_revno) |
|
444 |
if self._from_format == 'git': |
|
445 |
self.assertEqual(1, result.new_revno) |
|
446 |
else: |
|
447 |
self.assertIs(None, result.new_revno) |
|
448 |
||
449 |
result.report(BytesIO()) |
|
450 |
||
451 |
self.assertEqual( |
|
7484.1.3
by Jelmer Vernooij
Fix formatting. |
452 |
{
|
453 |
b'HEAD': self.remote_real.refs[b'refs/heads/master'], |
|
454 |
b'refs/heads/master': self.remote_real.refs[b'refs/heads/master'], |
|
7484.1.2
by Jelmer Vernooij
Add some tests. |
455 |
},
|
456 |
self.remote_real.get_refs()) |
|
457 |
||
7289.1.2
by Jelmer Vernooij
Fix pushing of tags as part of nascent git branches. |
458 |
def test_push_branch_new_with_tags(self): |
459 |
remote = ControlDir.open(self.remote_url) |
|
460 |
builder = self.make_branch_builder('local', format=self._from_format) |
|
461 |
builder.start_series() |
|
462 |
rev_1 = builder.build_snapshot(None, [ |
|
463 |
('add', ('', None, 'directory', '')), |
|
464 |
('add', ('filename', None, 'file', b'content'))]) |
|
465 |
rev_2 = builder.build_snapshot( |
|
466 |
[rev_1], [('modify', ('filename', b'new-content\n'))]) |
|
467 |
rev_3 = builder.build_snapshot( |
|
468 |
[rev_1], [('modify', ('filename', b'new-new-content\n'))]) |
|
469 |
builder.finish_series() |
|
470 |
branch = builder.get_branch() |
|
471 |
try: |
|
472 |
branch.tags.set_tag('atag', rev_2) |
|
473 |
except TagsNotSupported: |
|
474 |
raise TestNotApplicable('source format does not support tags') |
|
475 |
||
476 |
branch.get_config_stack().set('branch.fetch_tags', True) |
|
477 |
if self._from_format == 'git': |
|
478 |
result = remote.push_branch(branch, name='newbranch') |
|
479 |
else: |
|
480 |
result = remote.push_branch( |
|
481 |
branch, lossy=True, name='newbranch') |
|
482 |
||
483 |
self.assertEqual(0, result.old_revno) |
|
484 |
if self._from_format == 'git': |
|
485 |
self.assertEqual(2, result.new_revno) |
|
486 |
else: |
|
487 |
self.assertIs(None, result.new_revno) |
|
488 |
||
489 |
result.report(BytesIO()) |
|
490 |
||
491 |
self.assertEqual( |
|
492 |
{b'refs/heads/newbranch', b'refs/tags/atag'}, |
|
493 |
set(self.remote_real.get_refs().keys())) |
|
494 |
||
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
495 |
def test_push(self): |
496 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
497 |
message=b'message', |
498 |
committer=b'committer <committer@example.com>', |
|
499 |
author=b'author <author@example.com>') |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
500 |
|
501 |
remote = ControlDir.open(self.remote_url) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
502 |
self.make_controldir('local', format=self._from_format) |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
503 |
local = remote.sprout('local') |
504 |
self.build_tree(['local/blah']) |
|
505 |
wt = local.open_workingtree() |
|
506 |
wt.add(['blah']) |
|
507 |
revid = wt.commit('blah') |
|
508 |
wt.branch.tags.set_tag('sometag', revid) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
509 |
wt.branch.get_config_stack().set('branch.fetch_tags', True) |
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
510 |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
511 |
if self._from_format == 'git': |
0.406.2
by Jelmer Vernooij
Add tests. |
512 |
result = wt.branch.push(remote.create_branch('newbranch')) |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
513 |
else: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
514 |
result = wt.branch.push( |
515 |
remote.create_branch('newbranch'), lossy=True) |
|
0.406.2
by Jelmer Vernooij
Add tests. |
516 |
|
517 |
self.assertEqual(0, result.old_revno) |
|
518 |
self.assertEqual(2, result.new_revno) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
519 |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
520 |
result.report(BytesIO()) |
0.406.3
by Jelmer Vernooij
Add extra tests. |
521 |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
522 |
self.assertEqual( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
523 |
{b'refs/heads/master': self.remote_real.head(), |
524 |
b'HEAD': self.remote_real.head(), |
|
525 |
b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'], |
|
526 |
b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'], |
|
527 |
},
|
|
528 |
self.remote_real.get_refs()) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
529 |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
530 |
def test_push_diverged(self): |
531 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
532 |
message=b'message', |
533 |
committer=b'committer <committer@example.com>', |
|
534 |
author=b'author <author@example.com>', |
|
535 |
ref=b'refs/heads/newbranch') |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
536 |
|
537 |
remote = ControlDir.open(self.remote_url) |
|
538 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
539 |
self.build_tree(['local/blah']) |
|
540 |
wt.add(['blah']) |
|
541 |
revid = wt.commit('blah') |
|
542 |
||
543 |
newbranch = remote.open_branch('newbranch') |
|
544 |
if self._from_format == 'git': |
|
545 |
self.assertRaises(DivergedBranches, wt.branch.push, newbranch) |
|
546 |
else: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
547 |
self.assertRaises(DivergedBranches, wt.branch.push, |
548 |
newbranch, lossy=True) |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
549 |
|
550 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
551 |
{b'refs/heads/newbranch': c1}, |
552 |
self.remote_real.get_refs()) |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
553 |
|
554 |
if self._from_format == 'git': |
|
555 |
wt.branch.push(newbranch, overwrite=True) |
|
556 |
else: |
|
557 |
wt.branch.push(newbranch, lossy=True, overwrite=True) |
|
558 |
||
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
559 |
self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch']) |
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
560 |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
561 |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
562 |
class PushToRemoteFromBzrTests(PushToRemoteBase, TestCaseWithTransport): |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
563 |
|
564 |
_from_format = '2a' |
|
565 |
||
566 |
||
7143.15.2
by Jelmer Vernooij
Run autopep8. |
567 |
class PushToRemoteFromGitTests(PushToRemoteBase, TestCaseWithTransport): |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
568 |
|
569 |
_from_format = 'git' |
|
570 |
||
571 |
||
572 |
class RemoteControlDirTests(TestCaseWithTransport): |
|
573 |
||
574 |
_test_needs_features = [ExecutableFeature('git')] |
|
575 |
||
576 |
def setUp(self): |
|
577 |
TestCaseWithTransport.setUp(self) |
|
578 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
|
579 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
580 |
self.permit_url(self.remote_url) |
|
581 |
||
582 |
def test_remove_branch(self): |
|
583 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
584 |
message=b'message', |
585 |
committer=b'committer <committer@example.com>', |
|
586 |
author=b'author <author@example.com>') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
587 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
588 |
message=b'another commit', |
589 |
committer=b'committer <committer@example.com>', |
|
590 |
author=b'author <author@example.com>', |
|
591 |
ref=b'refs/heads/blah') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
592 |
|
593 |
remote = ControlDir.open(self.remote_url) |
|
594 |
remote.destroy_branch(name='blah') |
|
595 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
596 |
self.remote_real.get_refs(), |
597 |
{b'refs/heads/master': self.remote_real.head(), |
|
598 |
b'HEAD': self.remote_real.head(), |
|
599 |
})
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
600 |
|
601 |
def test_list_branches(self): |
|
602 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
603 |
message=b'message', |
604 |
committer=b'committer <committer@example.com>', |
|
605 |
author=b'author <author@example.com>') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
606 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
607 |
message=b'another commit', |
608 |
committer=b'committer <committer@example.com>', |
|
609 |
author=b'author <author@example.com>', |
|
610 |
ref=b'refs/heads/blah') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
611 |
|
612 |
remote = ControlDir.open(self.remote_url) |
|
613 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
614 |
set(['master', 'blah', 'master']), |
615 |
set([b.name for b in remote.list_branches()])) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
616 |
|
617 |
def test_get_branches(self): |
|
618 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
619 |
message=b'message', |
620 |
committer=b'committer <committer@example.com>', |
|
621 |
author=b'author <author@example.com>') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
622 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
623 |
message=b'another commit', |
624 |
committer=b'committer <committer@example.com>', |
|
625 |
author=b'author <author@example.com>', |
|
626 |
ref=b'refs/heads/blah') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
627 |
|
628 |
remote = ControlDir.open(self.remote_url) |
|
629 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
630 |
{'': 'master', 'blah': 'blah', 'master': 'master'}, |
631 |
{n: b.name for (n, b) in remote.get_branches().items()}) |
|
7490.13.6
by Jelmer Vernooij
Fix tests. |
632 |
self.assertEqual( |
633 |
set(['', 'blah', 'master']), set(remote.branch_names())) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
634 |
|
635 |
def test_remove_tag(self): |
|
636 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
637 |
message=b'message', |
638 |
committer=b'committer <committer@example.com>', |
|
639 |
author=b'author <author@example.com>') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
640 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
641 |
message=b'another commit', |
642 |
committer=b'committer <committer@example.com>', |
|
643 |
author=b'author <author@example.com>', |
|
644 |
ref=b'refs/tags/blah') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
645 |
|
646 |
remote = ControlDir.open(self.remote_url) |
|
647 |
remote_branch = remote.open_branch() |
|
648 |
remote_branch.tags.delete_tag('blah') |
|
649 |
self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah') |
|
650 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
651 |
self.remote_real.get_refs(), |
652 |
{b'refs/heads/master': self.remote_real.head(), |
|
653 |
b'HEAD': self.remote_real.head(), |
|
654 |
})
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
655 |
|
656 |
def test_set_tag(self): |
|
657 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
658 |
message=b'message', |
659 |
committer=b'committer <committer@example.com>', |
|
660 |
author=b'author <author@example.com>') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
661 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
662 |
message=b'another commit', |
663 |
committer=b'committer <committer@example.com>', |
|
664 |
author=b'author <author@example.com>') |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
665 |
|
666 |
remote = ControlDir.open(self.remote_url) |
|
667 |
remote.open_branch().tags.set_tag( |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
668 |
b'blah', default_mapping.revision_id_foreign_to_bzr(c1)) |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
669 |
self.assertEqual( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
670 |
self.remote_real.get_refs(), |
671 |
{b'refs/heads/master': self.remote_real.head(), |
|
672 |
b'refs/tags/blah': c1, |
|
673 |
b'HEAD': self.remote_real.head(), |
|
674 |
})
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
675 |
|
676 |
def test_annotated_tag(self): |
|
677 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
678 |
message=b'message', |
679 |
committer=b'committer <committer@example.com>', |
|
680 |
author=b'author <author@example.com>') |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
681 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
682 |
message=b'another commit', |
683 |
committer=b'committer <committer@example.com>', |
|
684 |
author=b'author <author@example.com>') |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
685 |
|
686 |
porcelain.tag_create( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
687 |
self.remote_real, |
688 |
tag=b"blah", |
|
689 |
author=b'author <author@example.com>', |
|
690 |
objectish=c2, |
|
691 |
tag_time=int(time.time()), |
|
692 |
tag_timezone=0, |
|
693 |
annotated=True, |
|
694 |
message=b"Annotated tag") |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
695 |
|
696 |
remote = ControlDir.open(self.remote_url) |
|
697 |
remote_branch = remote.open_branch() |
|
698 |
self.assertEqual({ |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
699 |
'blah': default_mapping.revision_id_foreign_to_bzr(c2)}, |
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
700 |
remote_branch.tags.get_tag_dict()) |
701 |
||
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
702 |
def test_get_branch_reference(self): |
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
703 |
c1 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
704 |
message=b'message', |
705 |
committer=b'committer <committer@example.com>', |
|
706 |
author=b'author <author@example.com>') |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
707 |
c2 = self.remote_real.do_commit( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
708 |
message=b'another commit', |
709 |
committer=b'committer <committer@example.com>', |
|
710 |
author=b'author <author@example.com>') |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
711 |
|
712 |
remote = ControlDir.open(self.remote_url) |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
713 |
self.assertEqual(b'refs/heads/master', remote.get_branch_reference('')) |
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
714 |
self.assertEqual(None, remote.get_branch_reference('master')) |
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
715 |
|
716 |
def test_get_branch_nick(self): |
|
717 |
c1 = self.remote_real.do_commit( |
|
7143.16.21
by Jelmer Vernooij
Fix regressions. |
718 |
message=b'message', |
719 |
committer=b'committer <committer@example.com>', |
|
720 |
author=b'author <author@example.com>') |
|
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
721 |
remote = ControlDir.open(self.remote_url) |
722 |
self.assertEqual('master', remote.open_branch().nick) |
|
7371.3.2
by Jelmer Vernooij
Fix URL parsing for Git. |
723 |
|
724 |
||
725 |
class GitUrlAndPathFromTransportTests(TestCase): |
|
726 |
||
727 |
def test_file(self): |
|
728 |
split_url = _git_url_and_path_from_transport('file:///home/blah') |
|
729 |
self.assertEqual(split_url.scheme, 'file') |
|
730 |
self.assertEqual(split_url.path, '/home/blah') |
|
731 |
||
732 |
def test_file_segment_params(self): |
|
733 |
split_url = _git_url_and_path_from_transport('file:///home/blah,branch=master') |
|
734 |
self.assertEqual(split_url.scheme, 'file') |
|
735 |
self.assertEqual(split_url.path, '/home/blah') |
|
736 |
||
737 |
def test_git_smart(self): |
|
738 |
split_url = _git_url_and_path_from_transport( |
|
739 |
'git://github.com/dulwich/dulwich,branch=master') |
|
740 |
self.assertEqual(split_url.scheme, 'git') |
|
741 |
self.assertEqual(split_url.path, '/dulwich/dulwich') |
|
742 |
||
743 |
def test_https(self): |
|
744 |
split_url = _git_url_and_path_from_transport( |
|
745 |
'https://github.com/dulwich/dulwich') |
|
746 |
self.assertEqual(split_url.scheme, 'https') |
|
747 |
self.assertEqual(split_url.path, '/dulwich/dulwich') |
|
748 |
||
749 |
def test_https_segment_params(self): |
|
750 |
split_url = _git_url_and_path_from_transport( |
|
751 |
'https://github.com/dulwich/dulwich,branch=master') |
|
752 |
self.assertEqual(split_url.scheme, 'https') |
|
753 |
self.assertEqual(split_url.path, '/dulwich/dulwich') |