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) 2007-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
2 |
# -*- encoding: utf-8 -*-
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
3 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
4 |
# This program is free software; you can redistribute it and/or modify
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
8 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
9 |
# This program is distributed in the hope that it will be useful,
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
13 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
14 |
# You should have received a copy of the GNU General Public License
|
15 |
# along with this program; if not, write to the Free Software
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
17 |
|
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
18 |
"""Tests for mapping."""
|
19 |
||
20 |
from __future__ import absolute_import |
|
21 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
22 |
from ...revision import ( |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
23 |
Revision, |
24 |
)
|
|
|
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
25 |
|
|
0.200.264
by Jelmer Vernooij
Add more tests. |
26 |
from dulwich.objects import ( |
|
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
27 |
Blob, |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
28 |
Commit, |
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
29 |
Tag, |
|
0.200.1589
by Jelmer Vernooij
Add test to make sure that certain invalid timezones are roundtripped correctly. |
30 |
parse_timezone, |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
31 |
)
|
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
32 |
from dulwich.tests.utils import ( |
33 |
make_object, |
|
34 |
)
|
|
|
0.200.264
by Jelmer Vernooij
Add more tests. |
35 |
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
36 |
from .. import tests |
|
7240.10.1
by Jelmer Vernooij
Properly handle exceptions about hg extra fields. |
37 |
from ..errors import ( |
38 |
UnknownCommitExtra, |
|
39 |
UnknownMercurialCommitExtra, |
|
40 |
)
|
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
41 |
from ..mapping import ( |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
42 |
BzrGitMappingv1, |
43 |
escape_file_id, |
|
|
0.402.1
by Jelmer Vernooij
Improve identifier handling. |
44 |
fix_person_identifier, |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
45 |
unescape_file_id, |
46 |
)
|
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
47 |
|
48 |
||
49 |
class TestRevidConversionV1(tests.TestCase): |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
50 |
|
51 |
def test_simple_git_to_bzr_revision_id(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
52 |
self.assertEqual(b"git-v1:" |
53 |
b"c6a4d8f1fa4ac650748e647c4b1b368f589a7356", |
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
54 |
BzrGitMappingv1().revision_id_foreign_to_bzr( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
55 |
b"c6a4d8f1fa4ac650748e647c4b1b368f589a7356")) |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
56 |
|
57 |
def test_simple_bzr_to_git_revision_id(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
58 |
self.assertEqual((b"c6a4d8f1fa4ac650748e647c4b1b368f589a7356", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
59 |
BzrGitMappingv1()), |
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
60 |
BzrGitMappingv1().revision_id_bzr_to_foreign( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
61 |
b"git-v1:" |
62 |
b"c6a4d8f1fa4ac650748e647c4b1b368f589a7356")) |
|
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
63 |
|
|
0.252.26
by Jelmer Vernooij
Add is_control_file method to BzrGitMapping. |
64 |
def test_is_control_file(self): |
65 |
mapping = BzrGitMappingv1() |
|
|
0.200.920
by Jelmer Vernooij
Fix some more tests. |
66 |
if mapping.roundtripping: |
|
0.200.1752
by Jelmer Vernooij
Don't traverse nested trees in WorkingTree.smart_add. |
67 |
self.assertTrue(mapping.is_special_file(".bzrdummy")) |
68 |
self.assertTrue(mapping.is_special_file(".bzrfileids")) |
|
69 |
self.assertFalse(mapping.is_special_file(".bzrfoo")) |
|
|
0.252.26
by Jelmer Vernooij
Add is_control_file method to BzrGitMapping. |
70 |
|
|
0.200.973
by Jelmer Vernooij
Add tests for generate_file_id. |
71 |
def test_generate_file_id(self): |
72 |
mapping = BzrGitMappingv1() |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
73 |
self.assertIsInstance(mapping.generate_file_id("la"), bytes) |
74 |
self.assertIsInstance(mapping.generate_file_id(u"é"), bytes) |
|
|
0.200.973
by Jelmer Vernooij
Add tests for generate_file_id. |
75 |
|
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
76 |
|
77 |
class FileidTests(tests.TestCase): |
|
78 |
||
79 |
def test_escape_space(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
80 |
self.assertEqual(b"bla_s", escape_file_id(b"bla ")) |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
81 |
|
|
0.200.1419
by Jelmer Vernooij
Escape/unescape ^L characters. |
82 |
def test_escape_control_l(self): |
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
83 |
self.assertEqual(b"bla_c", escape_file_id(b"bla\x0c")) |
|
0.200.1419
by Jelmer Vernooij
Escape/unescape ^L characters. |
84 |
|
85 |
def test_unescape_control_l(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
86 |
self.assertEqual(b"bla\x0c", unescape_file_id(b"bla_c")) |
|
0.200.1419
by Jelmer Vernooij
Escape/unescape ^L characters. |
87 |
|
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
88 |
def test_escape_underscore(self): |
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
89 |
self.assertEqual(b"bla__", escape_file_id(b"bla_")) |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
90 |
|
91 |
def test_escape_underscore_space(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
92 |
self.assertEqual(b"bla___s", escape_file_id(b"bla_ ")) |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
93 |
|
94 |
def test_unescape_underscore(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
95 |
self.assertEqual(b"bla ", unescape_file_id(b"bla_s")) |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
96 |
|
97 |
def test_unescape_underscore_space(self): |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
98 |
self.assertEqual(b"bla _", unescape_file_id(b"bla_s__")) |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
99 |
|
100 |
||
101 |
class TestImportCommit(tests.TestCase): |
|
102 |
||
103 |
def test_commit(self): |
|
104 |
c = Commit() |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
105 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
106 |
c.message = b"Some message" |
|
107 |
c.committer = b"Committer" |
|
|
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
108 |
c.commit_time = 4 |
109 |
c.author_time = 5 |
|
|
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
110 |
c.commit_timezone = 60 * 5 |
111 |
c.author_timezone = 60 * 3 |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
112 |
c.author = b"Author" |
|
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
113 |
mapping = BzrGitMappingv1() |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
114 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
115 |
mapping.revision_id_foreign_to_bzr) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
116 |
self.assertEqual(None, roundtrip_revid) |
117 |
self.assertEqual({}, verifiers) |
|
|
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
118 |
self.assertEqual(u"Some message", rev.message) |
119 |
self.assertEqual(u"Committer", rev.committer) |
|
120 |
self.assertEqual(u"Author", rev.properties[u'author']) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
121 |
self.assertEqual(300, rev.timezone) |
|
7096.3.2
by Jelmer Vernooij
Fix some git tests. |
122 |
self.assertEqual([], rev.parent_ids) |
|
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
123 |
self.assertEqual("5", rev.properties[u'author-timestamp']) |
124 |
self.assertEqual("180", rev.properties[u'author-timezone']) |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
125 |
self.assertEqual(b"git-v1:" + c.id, rev.revision_id) |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
126 |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
127 |
def test_explicit_encoding(self): |
128 |
c = Commit() |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
129 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
130 |
c.message = b"Some message" |
|
131 |
c.committer = b"Committer" |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
132 |
c.commit_time = 4 |
133 |
c.author_time = 5 |
|
134 |
c.commit_timezone = 60 * 5 |
|
135 |
c.author_timezone = 60 * 3 |
|
136 |
c.author = u"Authér".encode("iso8859-1") |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
137 |
c.encoding = b"iso8859-1" |
|
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
138 |
mapping = BzrGitMappingv1() |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
139 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
140 |
mapping.revision_id_foreign_to_bzr) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
141 |
self.assertEqual(None, roundtrip_revid) |
142 |
self.assertEqual({}, verifiers) |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
143 |
self.assertEqual(u"Authér", rev.properties[u'author']) |
144 |
self.assertEqual("iso8859-1", rev.properties[u"git-explicit-encoding"]) |
|
145 |
self.assertTrue(u"git-implicit-encoding" not in rev.properties) |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
146 |
|
147 |
def test_implicit_encoding_fallback(self): |
|
148 |
c = Commit() |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
149 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
150 |
c.message = b"Some message" |
|
151 |
c.committer = b"Committer" |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
152 |
c.commit_time = 4 |
153 |
c.author_time = 5 |
|
154 |
c.commit_timezone = 60 * 5 |
|
155 |
c.author_timezone = 60 * 3 |
|
156 |
c.author = u"Authér".encode("latin1") |
|
|
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
157 |
mapping = BzrGitMappingv1() |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
158 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
159 |
mapping.revision_id_foreign_to_bzr) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
160 |
self.assertEqual(None, roundtrip_revid) |
161 |
self.assertEqual({}, verifiers) |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
162 |
self.assertEqual(u"Authér", rev.properties[u'author']) |
163 |
self.assertEqual("latin1", rev.properties[u"git-implicit-encoding"]) |
|
164 |
self.assertTrue(u"git-explicit-encoding" not in rev.properties) |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
165 |
|
166 |
def test_implicit_encoding_utf8(self): |
|
167 |
c = Commit() |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
168 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
169 |
c.message = b"Some message" |
|
170 |
c.committer = b"Committer" |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
171 |
c.commit_time = 4 |
172 |
c.author_time = 5 |
|
173 |
c.commit_timezone = 60 * 5 |
|
174 |
c.author_timezone = 60 * 3 |
|
175 |
c.author = u"Authér".encode("utf-8") |
|
|
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
176 |
mapping = BzrGitMappingv1() |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
177 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
178 |
mapping.revision_id_foreign_to_bzr) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
179 |
self.assertEqual(None, roundtrip_revid) |
180 |
self.assertEqual({}, verifiers) |
|
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
181 |
self.assertEqual(u"Authér", rev.properties[u'author']) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
182 |
self.assertTrue(u"git-explicit-encoding" not in rev.properties) |
183 |
self.assertTrue(u"git-implicit-encoding" not in rev.properties) |
|
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
184 |
|
|
0.200.1598
by Jelmer Vernooij
Print proper error when unknown fields are encountered. |
185 |
def test_unknown_extra(self): |
186 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
187 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
188 |
c.message = b"Some message" |
|
189 |
c.committer = b"Committer" |
|
|
0.200.1598
by Jelmer Vernooij
Print proper error when unknown fields are encountered. |
190 |
c.commit_time = 4 |
191 |
c.author_time = 5 |
|
192 |
c.commit_timezone = 60 * 5 |
|
193 |
c.author_timezone = 60 * 3 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
194 |
c.author = b"Author" |
195 |
c._extra.append((b"iamextra", b"foo")) |
|
|
0.200.1598
by Jelmer Vernooij
Print proper error when unknown fields are encountered. |
196 |
mapping = BzrGitMappingv1() |
197 |
self.assertRaises(UnknownCommitExtra, mapping.import_commit, c, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
198 |
mapping.revision_id_foreign_to_bzr) |
|
0.200.1598
by Jelmer Vernooij
Print proper error when unknown fields are encountered. |
199 |
|
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
200 |
def test_mergetag(self): |
201 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
202 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
203 |
c.message = b"Some message" |
|
204 |
c.committer = b"Committer" |
|
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
205 |
c.commit_time = 4 |
206 |
c.author_time = 5 |
|
207 |
c.commit_timezone = 60 * 5 |
|
208 |
c.author_timezone = 60 * 3 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
209 |
c.author = b"Author" |
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
210 |
tag = make_object(Tag, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
211 |
tagger=b'Jelmer Vernooij <jelmer@samba.org>', |
212 |
name=b'0.1', message=None, |
|
213 |
object=( |
|
214 |
Blob, b'd80c186a03f423a81b39df39dc87fd269736ca86'), |
|
215 |
tag_time=423423423, tag_timezone=0) |
|
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
216 |
c.mergetag = [tag] |
217 |
mapping = BzrGitMappingv1() |
|
218 |
rev, roundtrip_revid, verifiers = mapping.import_commit( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
219 |
c, mapping.revision_id_foreign_to_bzr) |
220 |
self.assertEqual( |
|
221 |
rev.properties[u'git-mergetag-0'], tag.as_raw_string()) |
|
|
0.413.2
by Jelmer Vernooij
Add support for the mergetag property in git. |
222 |
|
|
7240.10.1
by Jelmer Vernooij
Properly handle exceptions about hg extra fields. |
223 |
def test_unknown_hg_fields(self): |
224 |
c = Commit() |
|
225 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
226 |
c.message = b"Some message" |
|
227 |
c.committer = b"Committer" |
|
228 |
c.commit_time = 4 |
|
229 |
c.author_time = 5 |
|
230 |
c.commit_timezone = 60 * 5 |
|
231 |
c.author_timezone = 60 * 3 |
|
232 |
c.author = b"Author" |
|
233 |
c._extra = [(b"HG:extra", b"bla:Foo")] |
|
234 |
mapping = BzrGitMappingv1() |
|
235 |
self.assertRaises( |
|
236 |
UnknownMercurialCommitExtra, |
|
237 |
mapping.import_commit, c, mapping.revision_id_foreign_to_bzr) |
|
|
7268.1.2
by Jelmer Vernooij
Allow access to native git repositories, ignoring unknown hg fields. |
238 |
self.assertEqual( |
239 |
mapping.revision_id_foreign_to_bzr(c.id), |
|
240 |
mapping.get_revision_id(c)) |
|
|
7240.10.1
by Jelmer Vernooij
Properly handle exceptions about hg extra fields. |
241 |
|
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
242 |
|
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
243 |
class RoundtripRevisionsFromBazaar(tests.TestCase): |
244 |
||
245 |
def setUp(self): |
|
246 |
super(RoundtripRevisionsFromBazaar, self).setUp() |
|
247 |
self.mapping = BzrGitMappingv1() |
|
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
248 |
self._parent_map = {} |
249 |
self._lookup_parent = self._parent_map.__getitem__ |
|
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
250 |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
251 |
def assertRoundtripRevision(self, orig_rev): |
|
7018.3.5
by Jelmer Vernooij
Fix remaining tests. |
252 |
commit = self.mapping.export_commit(orig_rev, b"mysha", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
253 |
self._lookup_parent, True, b"testamentsha") |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
254 |
rev, roundtrip_revid, verifiers = self.mapping.import_commit( |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
255 |
commit, self.mapping.revision_id_foreign_to_bzr) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
256 |
self.assertEqual(rev.revision_id, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
257 |
self.mapping.revision_id_foreign_to_bzr(commit.id)) |
|
0.200.912
by Jelmer Vernooij
Merge roundtrip support. |
258 |
if self.mapping.roundtripping: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
259 |
self.assertEqual({"testament3-sha1": b"testamentsha"}, verifiers) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
260 |
self.assertEqual(orig_rev.revision_id, roundtrip_revid) |
261 |
self.assertEqual(orig_rev.properties, rev.properties) |
|
262 |
self.assertEqual(orig_rev.committer, rev.committer) |
|
263 |
self.assertEqual(orig_rev.timestamp, rev.timestamp) |
|
264 |
self.assertEqual(orig_rev.timezone, rev.timezone) |
|
265 |
self.assertEqual(orig_rev.message, rev.message) |
|
266 |
self.assertEqual(list(orig_rev.parent_ids), list(rev.parent_ids)) |
|
|
0.200.1023
by Jelmer Vernooij
Set and verify testament. |
267 |
else: |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
268 |
self.assertEqual({}, verifiers) |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
269 |
|
270 |
def test_simple_commit(self): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
271 |
r = Revision(self.mapping.revision_id_foreign_to_bzr( |
272 |
b"edf99e6c56495c620f20d5dacff9859ff7119261")) |
|
|
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
273 |
r.message = "MyCommitMessage" |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
274 |
r.parent_ids = [] |
275 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
|
276 |
r.timestamp = 453543543 |
|
277 |
r.timezone = 0 |
|
278 |
r.properties = {} |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
279 |
self.assertRoundtripRevision(r) |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
280 |
|
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
281 |
def test_revision_id(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
282 |
r = Revision(b"myrevid") |
|
7018.3.7
by Jelmer Vernooij
Fix remaining git tests. |
283 |
r.message = "MyCommitMessage" |
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
284 |
r.parent_ids = [] |
285 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
|
286 |
r.timestamp = 453543543 |
|
287 |
r.timezone = 0 |
|
288 |
r.properties = {} |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
289 |
self.assertRoundtripRevision(r) |
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
290 |
|
291 |
def test_ghost_parent(self): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
292 |
r = Revision(b"myrevid") |
293 |
r.message = u"MyCommitMessage" |
|
294 |
r.parent_ids = [b"iamaghost"] |
|
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
295 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
296 |
r.timestamp = 453543543 |
|
297 |
r.timezone = 0 |
|
298 |
r.properties = {} |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
299 |
self.assertRoundtripRevision(r) |
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
300 |
|
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
301 |
def test_custom_property(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
302 |
r = Revision(b"myrevid") |
303 |
r.message = u"MyCommitMessage" |
|
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
304 |
r.parent_ids = [] |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
305 |
r.properties = {u"fool": "bar"} |
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
306 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
307 |
r.timestamp = 453543543 |
|
308 |
r.timezone = 0 |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
309 |
self.assertRoundtripRevision(r) |
|
0.252.16
by Jelmer Vernooij
make sure file ids are roundtripped properly. |
310 |
|
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
311 |
|
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
312 |
class RoundtripRevisionsFromGit(tests.TestCase): |
313 |
||
314 |
def setUp(self): |
|
315 |
super(RoundtripRevisionsFromGit, self).setUp() |
|
316 |
self.mapping = BzrGitMappingv1() |
|
317 |
||
318 |
def assertRoundtripTree(self, tree): |
|
319 |
raise NotImplementedError(self.assertRoundtripTree) |
|
320 |
||
321 |
def assertRoundtripBlob(self, blob): |
|
322 |
raise NotImplementedError(self.assertRoundtripBlob) |
|
323 |
||
324 |
def assertRoundtripCommit(self, commit1): |
|
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
325 |
rev, roundtrip_revid, verifiers = self.mapping.import_commit( |
|
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
326 |
commit1, self.mapping.revision_id_foreign_to_bzr) |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
327 |
commit2 = self.mapping.export_commit(rev, "12341212121212", None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
328 |
True, None) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
329 |
self.assertEqual(commit1.committer, commit2.committer) |
330 |
self.assertEqual(commit1.commit_time, commit2.commit_time) |
|
331 |
self.assertEqual(commit1.commit_timezone, commit2.commit_timezone) |
|
332 |
self.assertEqual(commit1.author, commit2.author) |
|
333 |
self.assertEqual(commit1.author_time, commit2.author_time) |
|
334 |
self.assertEqual(commit1.author_timezone, commit2.author_timezone) |
|
335 |
self.assertEqual(commit1.message, commit2.message) |
|
336 |
self.assertEqual(commit1.encoding, commit2.encoding) |
|
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
337 |
|
338 |
def test_commit(self): |
|
339 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
340 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
341 |
c.message = b"Some message" |
|
342 |
c.committer = b"Committer <Committer>" |
|
|
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
343 |
c.commit_time = 4 |
|
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
344 |
c.commit_timezone = -60 * 3 |
|
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
345 |
c.author_time = 5 |
|
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
346 |
c.author_timezone = 60 * 2 |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
347 |
c.author = b"Author <author>" |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
348 |
self.assertRoundtripCommit(c) |
349 |
||
|
0.200.1589
by Jelmer Vernooij
Add test to make sure that certain invalid timezones are roundtripped correctly. |
350 |
def test_commit_double_negative_timezone(self): |
351 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
352 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
353 |
c.message = b"Some message" |
|
354 |
c.committer = b"Committer <Committer>" |
|
|
0.200.1589
by Jelmer Vernooij
Add test to make sure that certain invalid timezones are roundtripped correctly. |
355 |
c.commit_time = 4 |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
356 |
(c.commit_timezone, c._commit_timezone_neg_utc) = parse_timezone(b"--700") |
|
0.200.1589
by Jelmer Vernooij
Add test to make sure that certain invalid timezones are roundtripped correctly. |
357 |
c.author_time = 5 |
358 |
c.author_timezone = 60 * 2 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
359 |
c.author = b"Author <author>" |
|
0.200.1589
by Jelmer Vernooij
Add test to make sure that certain invalid timezones are roundtripped correctly. |
360 |
self.assertRoundtripCommit(c) |
361 |
||
|
0.200.884
by Jelmer Vernooij
Cope with -0000 as timezone in Git commits. |
362 |
def test_commit_zero_utc_timezone(self): |
363 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
364 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
365 |
c.message = b"Some message" |
|
366 |
c.committer = b"Committer <Committer>" |
|
|
0.200.884
by Jelmer Vernooij
Cope with -0000 as timezone in Git commits. |
367 |
c.commit_time = 4 |
368 |
c.commit_timezone = 0 |
|
369 |
c._commit_timezone_neg_utc = True |
|
370 |
c.author_time = 5 |
|
371 |
c.author_timezone = 60 * 2 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
372 |
c.author = b"Author <author>" |
|
0.200.884
by Jelmer Vernooij
Cope with -0000 as timezone in Git commits. |
373 |
self.assertRoundtripCommit(c) |
374 |
||
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
375 |
def test_commit_encoding(self): |
376 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
377 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
378 |
c.message = b"Some message" |
|
379 |
c.committer = b"Committer <Committer>" |
|
380 |
c.encoding = b'iso8859-1' |
|
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
381 |
c.commit_time = 4 |
382 |
c.commit_timezone = -60 * 3 |
|
383 |
c.author_time = 5 |
|
384 |
c.author_timezone = 60 * 2 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
385 |
c.author = b"Author <author>" |
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
386 |
self.assertRoundtripCommit(c) |
387 |
||
|
0.200.1639
by Jelmer Vernooij
Properly roundtrip HG:rename-source fields. |
388 |
def test_commit_extra(self): |
389 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
390 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
391 |
c.message = b"Some message" |
|
392 |
c.committer = b"Committer <Committer>" |
|
|
0.200.1639
by Jelmer Vernooij
Properly roundtrip HG:rename-source fields. |
393 |
c.commit_time = 4 |
394 |
c.commit_timezone = -60 * 3 |
|
395 |
c.author_time = 5 |
|
396 |
c.author_timezone = 60 * 2 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
397 |
c.author = b"Author <author>" |
398 |
c._extra = [(b"HG:rename-source", b"hg")] |
|
|
0.200.1639
by Jelmer Vernooij
Properly roundtrip HG:rename-source fields. |
399 |
self.assertRoundtripCommit(c) |
400 |
||
|
0.414.2
by Jelmer Vernooij
Fix mergetag roundtripping. |
401 |
def test_commit_mergetag(self): |
402 |
c = Commit() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
403 |
c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
404 |
c.message = b"Some message" |
|
405 |
c.committer = b"Committer <Committer>" |
|
|
0.414.2
by Jelmer Vernooij
Fix mergetag roundtripping. |
406 |
c.commit_time = 4 |
407 |
c.commit_timezone = -60 * 3 |
|
408 |
c.author_time = 5 |
|
409 |
c.author_timezone = 60 * 2 |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
410 |
c.author = b"Author <author>" |
|
0.414.2
by Jelmer Vernooij
Fix mergetag roundtripping. |
411 |
tag = make_object(Tag, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
412 |
tagger=b'Jelmer Vernooij <jelmer@samba.org>', |
413 |
name=b'0.1', message=None, |
|
414 |
object=( |
|
415 |
Blob, b'd80c186a03f423a81b39df39dc87fd269736ca86'), |
|
416 |
tag_time=423423423, tag_timezone=0) |
|
|
0.414.2
by Jelmer Vernooij
Fix mergetag roundtripping. |
417 |
c.mergetag = [tag] |
418 |
self.assertRoundtripCommit(c) |
|
419 |
||
|
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
420 |
|
|
0.402.1
by Jelmer Vernooij
Improve identifier handling. |
421 |
class FixPersonIdentifierTests(tests.TestCase): |
422 |
||
423 |
def test_valid(self): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
424 |
self.assertEqual(b"foo <bar@blah.nl>", |
425 |
fix_person_identifier(b"foo <bar@blah.nl>")) |
|
426 |
self.assertEqual(b"bar@blah.nl <bar@blah.nl>", |
|
427 |
fix_person_identifier(b"bar@blah.nl")) |
|
|
0.402.1
by Jelmer Vernooij
Improve identifier handling. |
428 |
|
429 |
def test_fix(self): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
430 |
self.assertEqual(b"person <bar@blah.nl>", |
431 |
fix_person_identifier(b"somebody <person <bar@blah.nl>>")) |
|
432 |
self.assertEqual(b"person <bar@blah.nl>", |
|
433 |
fix_person_identifier(b"person<bar@blah.nl>")) |
|
|
0.402.1
by Jelmer Vernooij
Improve identifier handling. |
434 |
self.assertRaises(ValueError, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
435 |
fix_person_identifier, b"person >bar@blah.nl<") |