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.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
28 |
DivergedBranches, |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
29 |
NotBranchError, |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
30 |
NoSuchTag, |
|
7103.1.2
by Jelmer Vernooij
Handle PermissionDenied. |
31 |
PermissionDenied, |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
32 |
)
|
33 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
34 |
from ...tests import ( |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
35 |
TestCase, |
36 |
TestCaseWithTransport, |
|
37 |
)
|
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
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, |
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
44 |
HeadUpdateFailed, |
45 |
RemoteGitError, |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
46 |
RemoteGitBranchFormat, |
|
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 |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
50 |
from dulwich.repo import Repo as GitRepo |
51 |
||
52 |
||
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
53 |
class SplitUrlTests(TestCase): |
54 |
||
55 |
def test_simple(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
56 |
self.assertEqual(("foo", None, None, "/bar"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
57 |
split_git_url("git://foo/bar")) |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
58 |
|
59 |
def test_port(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
60 |
self.assertEqual(("foo", 343, None, "/bar"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
61 |
split_git_url("git://foo:343/bar")) |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
62 |
|
63 |
def test_username(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
64 |
self.assertEqual(("foo", None, "la", "/bar"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
65 |
split_git_url("git://la@foo/bar")) |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
66 |
|
67 |
def test_nopath(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
68 |
self.assertEqual(("foo", None, None, "/"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
69 |
split_git_url("git://foo/")) |
|
0.200.709
by Jelmer Vernooij
When unpacking URLs, strip leftmost slash to match gits behaviour. |
70 |
|
71 |
def test_slashpath(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
72 |
self.assertEqual(("foo", None, None, "//bar"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
73 |
split_git_url("git://foo//bar")) |
|
0.246.2
by Jelmer Vernooij
Improve the fix dealing with git repo's in home directories. |
74 |
|
75 |
def test_homedir(self): |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
76 |
self.assertEqual(("foo", None, None, "~bar"), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
77 |
split_git_url("git://foo/~bar")) |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
78 |
|
79 |
||
80 |
class ParseGitErrorTests(TestCase): |
|
81 |
||
82 |
def test_unknown(self): |
|
83 |
e = parse_git_error("url", "foo") |
|
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
84 |
self.assertIsInstance(e, RemoteGitError) |
|
0.200.1275
by Jelmer Vernooij
recognize missing repositories |
85 |
|
86 |
def test_notbrancherror(self): |
|
87 |
e = parse_git_error("url", "\n Could not find Repository foo/bar") |
|
88 |
self.assertIsInstance(e, NotBranchError) |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
89 |
|
|
7104.2.1
by Jelmer Vernooij
Handle another way of formatting Git "repository not found" errors. |
90 |
def test_notbrancherror_launchpad(self): |
91 |
e = parse_git_error("url", "Repository 'foo/bar' not found.") |
|
92 |
self.assertIsInstance(e, NotBranchError) |
|
93 |
||
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
94 |
def test_notbrancherror_github(self): |
95 |
e = parse_git_error("url", "Repository not found.\n") |
|
96 |
self.assertIsInstance(e, NotBranchError) |
|
97 |
||
|
7131.7.3
by Jelmer Vernooij
Handle one more error. |
98 |
def test_notbrancherror_normal(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
99 |
e = parse_git_error( |
100 |
"url", "fatal: '/srv/git/lintian-brush' does not appear to be a git repository") |
|
|
7131.7.3
by Jelmer Vernooij
Handle one more error. |
101 |
self.assertIsInstance(e, NotBranchError) |
102 |
||
|
7103.1.1
by Jelmer Vernooij
Improved error parsing for Git branches. |
103 |
def test_head_update(self): |
104 |
e = parse_git_error("url", "HEAD failed to update\n") |
|
105 |
self.assertIsInstance(e, HeadUpdateFailed) |
|
106 |
||
|
7103.1.2
by Jelmer Vernooij
Handle PermissionDenied. |
107 |
def test_permission_dnied(self): |
108 |
e = parse_git_error( |
|
109 |
"url", |
|
110 |
"access denied or repository not exported: /debian/altermime.git") |
|
111 |
self.assertIsInstance(e, PermissionDenied) |
|
112 |
||
|
7131.7.1
by Jelmer Vernooij
Handle permission denied by GitLab. |
113 |
def test_permission_denied_gitlab(self): |
114 |
e = parse_git_error( |
|
115 |
"url", |
|
116 |
'GitLab: You are not allowed to push code to this project.\n') |
|
117 |
self.assertIsInstance(e, PermissionDenied) |
|
118 |
||
|
7131.7.2
by Jelmer Vernooij
Handle github PermissionDenied. |
119 |
def test_permission_denied_github(self): |
120 |
e = parse_git_error( |
|
121 |
"url", |
|
122 |
'Permission to porridge/gaduhistory.git denied to jelmer.') |
|
123 |
self.assertIsInstance(e, PermissionDenied) |
|
124 |
self.assertEqual(e.path, 'porridge/gaduhistory.git') |
|
125 |
self.assertEqual(e.extra, ': denied to jelmer') |
|
126 |
||
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
127 |
|
128 |
class TestRemoteGitBranchFormat(TestCase): |
|
129 |
||
130 |
def setUp(self): |
|
131 |
super(TestRemoteGitBranchFormat, self).setUp() |
|
132 |
self.format = RemoteGitBranchFormat() |
|
133 |
||
134 |
def test_get_format_description(self): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
135 |
self.assertEqual("Remote Git Branch", |
136 |
self.format.get_format_description()) |
|
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
137 |
|
138 |
def test_get_network_name(self): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
139 |
self.assertEqual(b"git", self.format.network_name()) |
|
0.295.1
by Jelmer Vernooij
Split up branch formats. |
140 |
|
141 |
def test_supports_tags(self): |
|
142 |
self.assertTrue(self.format.supports_tags()) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
143 |
|
144 |
||
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
145 |
class TestRemoteGitBranch(TestCaseWithTransport): |
146 |
||
|
7183.1.1
by Jelmer Vernooij
Add missing feature for git test that requires git executable. |
147 |
_test_needs_features = [ExecutableFeature('git')] |
148 |
||
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
149 |
def setUp(self): |
150 |
TestCaseWithTransport.setUp(self) |
|
151 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
|
152 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
153 |
self.permit_url(self.remote_url) |
|
154 |
||
155 |
def test_set_last_revision_info(self): |
|
156 |
c1 = self.remote_real.do_commit( |
|
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
157 |
message=b'message 1', |
158 |
committer=b'committer <committer@example.com>', |
|
159 |
author=b'author <author@example.com>', |
|
160 |
ref=b'refs/heads/newbranch') |
|
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
161 |
c2 = self.remote_real.do_commit( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
162 |
message=b'message 2', |
163 |
committer=b'committer <committer@example.com>', |
|
164 |
author=b'author <author@example.com>', |
|
165 |
ref=b'refs/heads/newbranch') |
|
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
166 |
|
167 |
remote = ControlDir.open(self.remote_url) |
|
168 |
newbranch = remote.open_branch('newbranch') |
|
169 |
self.assertEqual(newbranch.lookup_foreign_revision_id(c2), |
|
170 |
newbranch.last_revision()) |
|
171 |
newbranch.set_last_revision_info( |
|
172 |
1, newbranch.lookup_foreign_revision_id(c1)) |
|
|
7131.12.2
by Jelmer Vernooij
Fix tests on python 3. |
173 |
self.assertEqual(c1, self.remote_real.refs[b'refs/heads/newbranch']) |
|
7131.12.1
by Jelmer Vernooij
Support uncommit on remote git branches. |
174 |
self.assertEqual(newbranch.last_revision(), |
175 |
newbranch.lookup_foreign_revision_id(c1)) |
|
176 |
||
177 |
||
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
178 |
class FetchFromRemoteTestBase(object): |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
179 |
|
180 |
_test_needs_features = [ExecutableFeature('git')] |
|
181 |
||
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
182 |
_to_format = None |
183 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
184 |
def setUp(self): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
185 |
TestCaseWithTransport.setUp(self) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
186 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
187 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
188 |
self.permit_url(self.remote_url) |
|
189 |
||
190 |
def test_sprout_simple(self): |
|
191 |
self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
192 |
message=b'message', |
193 |
committer=b'committer <committer@example.com>', |
|
194 |
author=b'author <author@example.com>') |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
195 |
|
196 |
remote = ControlDir.open(self.remote_url) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
197 |
self.make_controldir('local', format=self._to_format) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
198 |
local = remote.sprout('local') |
199 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
200 |
default_mapping.revision_id_foreign_to_bzr( |
201 |
self.remote_real.head()), |
|
202 |
local.open_branch().last_revision()) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
203 |
|
204 |
def test_sprout_with_tags(self): |
|
205 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
206 |
message=b'message', |
207 |
committer=b'committer <committer@example.com>', |
|
208 |
author=b'author <author@example.com>') |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
209 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
210 |
message=b'another commit', |
211 |
committer=b'committer <committer@example.com>', |
|
212 |
author=b'author <author@example.com>', |
|
213 |
ref=b'refs/tags/another') |
|
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
214 |
self.remote_real.refs[b'refs/tags/blah'] = self.remote_real.head() |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
215 |
|
216 |
remote = ControlDir.open(self.remote_url) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
217 |
self.make_controldir('local', format=self._to_format) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
218 |
local = remote.sprout('local') |
219 |
local_branch = local.open_branch() |
|
220 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
221 |
default_mapping.revision_id_foreign_to_bzr(c1), |
222 |
local_branch.last_revision()) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
223 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
224 |
{'blah': local_branch.last_revision(), |
225 |
'another': default_mapping.revision_id_foreign_to_bzr(c2)}, |
|
226 |
local_branch.tags.get_tag_dict()) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
227 |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
228 |
def test_sprout_with_annotated_tag(self): |
229 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
230 |
message=b'message', |
231 |
committer=b'committer <committer@example.com>', |
|
232 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
233 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
234 |
message=b'another commit', |
235 |
committer=b'committer <committer@example.com>', |
|
236 |
author=b'author <author@example.com>', |
|
237 |
ref=b'refs/heads/another') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
238 |
porcelain.tag_create( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
239 |
self.remote_real, |
240 |
tag=b"blah", |
|
241 |
author=b'author <author@example.com>', |
|
242 |
objectish=c2, |
|
243 |
tag_time=int(time.time()), |
|
244 |
tag_timezone=0, |
|
245 |
annotated=True, |
|
246 |
message=b"Annotated tag") |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
247 |
|
248 |
remote = ControlDir.open(self.remote_url) |
|
249 |
self.make_controldir('local', format=self._to_format) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
250 |
local = remote.sprout( |
251 |
'local', revision_id=default_mapping.revision_id_foreign_to_bzr(c1)) |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
252 |
local_branch = local.open_branch() |
253 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
254 |
default_mapping.revision_id_foreign_to_bzr(c1), |
255 |
local_branch.last_revision()) |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
256 |
self.assertEqual( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
257 |
{'blah': default_mapping.revision_id_foreign_to_bzr(c2)}, |
258 |
local_branch.tags.get_tag_dict()) |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
259 |
|
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
260 |
def test_sprout_with_annotated_tag_unreferenced(self): |
261 |
c1 = self.remote_real.do_commit( |
|
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
262 |
message=b'message', |
263 |
committer=b'committer <committer@example.com>', |
|
264 |
author=b'author <author@example.com>') |
|
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
265 |
c2 = self.remote_real.do_commit( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
266 |
message=b'another commit', |
267 |
committer=b'committer <committer@example.com>', |
|
268 |
author=b'author <author@example.com>') |
|
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
269 |
porcelain.tag_create( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
270 |
self.remote_real, |
271 |
tag=b"blah", |
|
272 |
author=b'author <author@example.com>', |
|
273 |
objectish=c1, |
|
274 |
tag_time=int(time.time()), |
|
275 |
tag_timezone=0, |
|
276 |
annotated=True, |
|
277 |
message=b"Annotated tag") |
|
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
278 |
|
279 |
remote = ControlDir.open(self.remote_url) |
|
280 |
self.make_controldir('local', format=self._to_format) |
|
281 |
local = remote.sprout( |
|
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
282 |
'local', |
283 |
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. |
284 |
local_branch = local.open_branch() |
285 |
self.assertEqual( |
|
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
286 |
default_mapping.revision_id_foreign_to_bzr(c1), |
287 |
local_branch.last_revision()) |
|
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
288 |
self.assertEqual( |
|
7143.16.8
by Jelmer Vernooij
Fix E126 |
289 |
{'blah': default_mapping.revision_id_foreign_to_bzr(c1)}, |
290 |
local_branch.tags.get_tag_dict()) |
|
|
7143.12.1
by Jelmer Vernooij
Support cloning revisions referenced only by an annotated tag. |
291 |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
292 |
|
|
7143.16.21
by Jelmer Vernooij
Fix regressions. |
293 |
class FetchFromRemoteToBzrTests(FetchFromRemoteTestBase, TestCaseWithTransport): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
294 |
|
295 |
_to_format = '2a' |
|
296 |
||
297 |
||
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
298 |
class FetchFromRemoteToGitTests(FetchFromRemoteTestBase, TestCaseWithTransport): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
299 |
|
300 |
_to_format = 'git' |
|
301 |
||
302 |
||
303 |
class PushToRemoteBase(object): |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
304 |
|
305 |
_test_needs_features = [ExecutableFeature('git')] |
|
306 |
||
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
307 |
_from_format = None |
308 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
309 |
def setUp(self): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
310 |
TestCaseWithTransport.setUp(self) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
311 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
312 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
313 |
self.permit_url(self.remote_url) |
|
314 |
||
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
315 |
def test_push_branch_new(self): |
316 |
remote = ControlDir.open(self.remote_url) |
|
317 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
318 |
self.build_tree(['local/blah']) |
|
319 |
wt.add(['blah']) |
|
320 |
revid = wt.commit('blah') |
|
321 |
||
322 |
if self._from_format == 'git': |
|
|
0.406.2
by Jelmer Vernooij
Add tests. |
323 |
result = remote.push_branch(wt.branch, name='newbranch') |
324 |
else: |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
325 |
result = remote.push_branch( |
326 |
wt.branch, lossy=True, name='newbranch') |
|
|
0.406.2
by Jelmer Vernooij
Add tests. |
327 |
|
328 |
self.assertEqual(0, result.old_revno) |
|
329 |
if self._from_format == 'git': |
|
330 |
self.assertEqual(1, result.new_revno) |
|
331 |
else: |
|
332 |
self.assertIs(None, result.new_revno) |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
333 |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
334 |
result.report(BytesIO()) |
|
0.406.3
by Jelmer Vernooij
Add extra tests. |
335 |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
336 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
337 |
{b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'], |
338 |
},
|
|
339 |
self.remote_real.get_refs()) |
|
|
0.403.3
by Jelmer Vernooij
Test RemoteGitDir.push_branch. |
340 |
|
|
7289.1.2
by Jelmer Vernooij
Fix pushing of tags as part of nascent git branches. |
341 |
def test_push_branch_new_with_tags(self): |
342 |
remote = ControlDir.open(self.remote_url) |
|
343 |
builder = self.make_branch_builder('local', format=self._from_format) |
|
344 |
builder.start_series() |
|
345 |
rev_1 = builder.build_snapshot(None, [ |
|
346 |
('add', ('', None, 'directory', '')), |
|
347 |
('add', ('filename', None, 'file', b'content'))]) |
|
348 |
rev_2 = builder.build_snapshot( |
|
349 |
[rev_1], [('modify', ('filename', b'new-content\n'))]) |
|
350 |
rev_3 = builder.build_snapshot( |
|
351 |
[rev_1], [('modify', ('filename', b'new-new-content\n'))]) |
|
352 |
builder.finish_series() |
|
353 |
branch = builder.get_branch() |
|
354 |
try: |
|
355 |
branch.tags.set_tag('atag', rev_2) |
|
356 |
except TagsNotSupported: |
|
357 |
raise TestNotApplicable('source format does not support tags') |
|
358 |
||
359 |
branch.get_config_stack().set('branch.fetch_tags', True) |
|
360 |
if self._from_format == 'git': |
|
361 |
result = remote.push_branch(branch, name='newbranch') |
|
362 |
else: |
|
363 |
result = remote.push_branch( |
|
364 |
branch, lossy=True, name='newbranch') |
|
365 |
||
366 |
self.assertEqual(0, result.old_revno) |
|
367 |
if self._from_format == 'git': |
|
368 |
self.assertEqual(2, result.new_revno) |
|
369 |
else: |
|
370 |
self.assertIs(None, result.new_revno) |
|
371 |
||
372 |
result.report(BytesIO()) |
|
373 |
||
374 |
self.assertEqual( |
|
375 |
{b'refs/heads/newbranch', b'refs/tags/atag'}, |
|
376 |
set(self.remote_real.get_refs().keys())) |
|
377 |
||
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
378 |
def test_push(self): |
379 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
380 |
message=b'message', |
381 |
committer=b'committer <committer@example.com>', |
|
382 |
author=b'author <author@example.com>') |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
383 |
|
384 |
remote = ControlDir.open(self.remote_url) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
385 |
self.make_controldir('local', format=self._from_format) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
386 |
local = remote.sprout('local') |
387 |
self.build_tree(['local/blah']) |
|
388 |
wt = local.open_workingtree() |
|
389 |
wt.add(['blah']) |
|
390 |
revid = wt.commit('blah') |
|
391 |
wt.branch.tags.set_tag('sometag', revid) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
392 |
wt.branch.get_config_stack().set('branch.fetch_tags', True) |
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
393 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
394 |
if self._from_format == 'git': |
|
0.406.2
by Jelmer Vernooij
Add tests. |
395 |
result = wt.branch.push(remote.create_branch('newbranch')) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
396 |
else: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
397 |
result = wt.branch.push( |
398 |
remote.create_branch('newbranch'), lossy=True) |
|
|
0.406.2
by Jelmer Vernooij
Add tests. |
399 |
|
400 |
self.assertEqual(0, result.old_revno) |
|
401 |
self.assertEqual(2, result.new_revno) |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
402 |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
403 |
result.report(BytesIO()) |
|
0.406.3
by Jelmer Vernooij
Add extra tests. |
404 |
|
|
0.376.1
by Jelmer Vernooij
Add tests for remote operations. |
405 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
406 |
{b'refs/heads/master': self.remote_real.head(), |
407 |
b'HEAD': self.remote_real.head(), |
|
408 |
b'refs/heads/newbranch': self.remote_real.refs[b'refs/heads/newbranch'], |
|
409 |
b'refs/tags/sometag': self.remote_real.refs[b'refs/heads/newbranch'], |
|
410 |
},
|
|
411 |
self.remote_real.get_refs()) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
412 |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
413 |
def test_push_diverged(self): |
414 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
415 |
message=b'message', |
416 |
committer=b'committer <committer@example.com>', |
|
417 |
author=b'author <author@example.com>', |
|
418 |
ref=b'refs/heads/newbranch') |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
419 |
|
420 |
remote = ControlDir.open(self.remote_url) |
|
421 |
wt = self.make_branch_and_tree('local', format=self._from_format) |
|
422 |
self.build_tree(['local/blah']) |
|
423 |
wt.add(['blah']) |
|
424 |
revid = wt.commit('blah') |
|
425 |
||
426 |
newbranch = remote.open_branch('newbranch') |
|
427 |
if self._from_format == 'git': |
|
428 |
self.assertRaises(DivergedBranches, wt.branch.push, newbranch) |
|
429 |
else: |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
430 |
self.assertRaises(DivergedBranches, wt.branch.push, |
431 |
newbranch, lossy=True) |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
432 |
|
433 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
434 |
{b'refs/heads/newbranch': c1}, |
435 |
self.remote_real.get_refs()) |
|
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
436 |
|
437 |
if self._from_format == 'git': |
|
438 |
wt.branch.push(newbranch, overwrite=True) |
|
439 |
else: |
|
440 |
wt.branch.push(newbranch, lossy=True, overwrite=True) |
|
441 |
||
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
442 |
self.assertNotEqual(c1, self.remote_real.refs[b'refs/heads/newbranch']) |
|
0.404.5
by Jelmer Vernooij
Check for diverged branches during push. |
443 |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
444 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
445 |
class PushToRemoteFromBzrTests(PushToRemoteBase, TestCaseWithTransport): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
446 |
|
447 |
_from_format = '2a' |
|
448 |
||
449 |
||
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
450 |
class PushToRemoteFromGitTests(PushToRemoteBase, TestCaseWithTransport): |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
451 |
|
452 |
_from_format = 'git' |
|
453 |
||
454 |
||
455 |
class RemoteControlDirTests(TestCaseWithTransport): |
|
456 |
||
457 |
_test_needs_features = [ExecutableFeature('git')] |
|
458 |
||
459 |
def setUp(self): |
|
460 |
TestCaseWithTransport.setUp(self) |
|
461 |
self.remote_real = GitRepo.init('remote', mkdir=True) |
|
462 |
self.remote_url = 'git://%s/' % os.path.abspath(self.remote_real.path) |
|
463 |
self.permit_url(self.remote_url) |
|
464 |
||
465 |
def test_remove_branch(self): |
|
466 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
467 |
message=b'message', |
468 |
committer=b'committer <committer@example.com>', |
|
469 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
470 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
471 |
message=b'another commit', |
472 |
committer=b'committer <committer@example.com>', |
|
473 |
author=b'author <author@example.com>', |
|
474 |
ref=b'refs/heads/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
475 |
|
476 |
remote = ControlDir.open(self.remote_url) |
|
477 |
remote.destroy_branch(name='blah') |
|
478 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
479 |
self.remote_real.get_refs(), |
480 |
{b'refs/heads/master': self.remote_real.head(), |
|
481 |
b'HEAD': self.remote_real.head(), |
|
482 |
})
|
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
483 |
|
484 |
def test_list_branches(self): |
|
485 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
486 |
message=b'message', |
487 |
committer=b'committer <committer@example.com>', |
|
488 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
489 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
490 |
message=b'another commit', |
491 |
committer=b'committer <committer@example.com>', |
|
492 |
author=b'author <author@example.com>', |
|
493 |
ref=b'refs/heads/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
494 |
|
495 |
remote = ControlDir.open(self.remote_url) |
|
496 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
497 |
set(['master', 'blah', 'master']), |
498 |
set([b.name for b in remote.list_branches()])) |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
499 |
|
500 |
def test_get_branches(self): |
|
501 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
502 |
message=b'message', |
503 |
committer=b'committer <committer@example.com>', |
|
504 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
505 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
506 |
message=b'another commit', |
507 |
committer=b'committer <committer@example.com>', |
|
508 |
author=b'author <author@example.com>', |
|
509 |
ref=b'refs/heads/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
510 |
|
511 |
remote = ControlDir.open(self.remote_url) |
|
512 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
513 |
{'': 'master', 'blah': 'blah', 'master': 'master'}, |
514 |
{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. |
515 |
|
516 |
def test_remove_tag(self): |
|
517 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
518 |
message=b'message', |
519 |
committer=b'committer <committer@example.com>', |
|
520 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
521 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
522 |
message=b'another commit', |
523 |
committer=b'committer <committer@example.com>', |
|
524 |
author=b'author <author@example.com>', |
|
525 |
ref=b'refs/tags/blah') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
526 |
|
527 |
remote = ControlDir.open(self.remote_url) |
|
528 |
remote_branch = remote.open_branch() |
|
529 |
remote_branch.tags.delete_tag('blah') |
|
530 |
self.assertRaises(NoSuchTag, remote_branch.tags.delete_tag, 'blah') |
|
531 |
self.assertEqual( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
532 |
self.remote_real.get_refs(), |
533 |
{b'refs/heads/master': self.remote_real.head(), |
|
534 |
b'HEAD': self.remote_real.head(), |
|
535 |
})
|
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
536 |
|
537 |
def test_set_tag(self): |
|
538 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
539 |
message=b'message', |
540 |
committer=b'committer <committer@example.com>', |
|
541 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
542 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
543 |
message=b'another commit', |
544 |
committer=b'committer <committer@example.com>', |
|
545 |
author=b'author <author@example.com>') |
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
546 |
|
547 |
remote = ControlDir.open(self.remote_url) |
|
548 |
remote.open_branch().tags.set_tag( |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
549 |
b'blah', default_mapping.revision_id_foreign_to_bzr(c1)) |
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
550 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
551 |
self.remote_real.get_refs(), |
552 |
{b'refs/heads/master': self.remote_real.head(), |
|
553 |
b'refs/tags/blah': c1, |
|
554 |
b'HEAD': self.remote_real.head(), |
|
555 |
})
|
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
556 |
|
557 |
def test_annotated_tag(self): |
|
558 |
c1 = self.remote_real.do_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
559 |
message=b'message', |
560 |
committer=b'committer <committer@example.com>', |
|
561 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
562 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
563 |
message=b'another commit', |
564 |
committer=b'committer <committer@example.com>', |
|
565 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
566 |
|
567 |
porcelain.tag_create( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
568 |
self.remote_real, |
569 |
tag=b"blah", |
|
570 |
author=b'author <author@example.com>', |
|
571 |
objectish=c2, |
|
572 |
tag_time=int(time.time()), |
|
573 |
tag_timezone=0, |
|
574 |
annotated=True, |
|
575 |
message=b"Annotated tag") |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
576 |
|
577 |
remote = ControlDir.open(self.remote_url) |
|
578 |
remote_branch = remote.open_branch() |
|
579 |
self.assertEqual({ |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
580 |
'blah': default_mapping.revision_id_foreign_to_bzr(c2)}, |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
581 |
remote_branch.tags.get_tag_dict()) |
582 |
||
|
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
583 |
def test_get_branch_reference(self): |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
584 |
c1 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
585 |
message=b'message', |
586 |
committer=b'committer <committer@example.com>', |
|
587 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
588 |
c2 = self.remote_real.do_commit( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
589 |
message=b'another commit', |
590 |
committer=b'committer <committer@example.com>', |
|
591 |
author=b'author <author@example.com>') |
|
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
592 |
|
593 |
remote = ControlDir.open(self.remote_url) |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
594 |
self.assertEqual(b'refs/heads/master', remote.get_branch_reference('')) |
|
0.382.1
by Jelmer Vernooij
Various fixes for annotated tags and symrefs. |
595 |
self.assertEqual(None, remote.get_branch_reference('master')) |
|
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
596 |
|
597 |
def test_get_branch_nick(self): |
|
598 |
c1 = self.remote_real.do_commit( |
|
|
7143.16.21
by Jelmer Vernooij
Fix regressions. |
599 |
message=b'message', |
600 |
committer=b'committer <committer@example.com>', |
|
601 |
author=b'author <author@example.com>') |
|
|
7142.3.1
by Jelmer Vernooij
Support .nick on remote branches and fix get_branch_reference. |
602 |
remote = ControlDir.open(self.remote_url) |
603 |
self.assertEqual('master', remote.open_branch().nick) |