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