bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.51
by Jelmer Vernooij
Fix copyright. |
1 |
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
|
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
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
18 |
from bzrlib.inventory import ( |
19 |
InventoryDirectory, |
|
20 |
InventoryFile, |
|
21 |
)
|
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
22 |
from bzrlib.revision import ( |
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.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
29 |
Tree, |
0.200.264
by Jelmer Vernooij
Add more tests. |
30 |
)
|
31 |
||
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
32 |
from bzrlib.plugins.git import tests |
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
33 |
from bzrlib.plugins.git.mapping import ( |
34 |
BzrGitMappingv1, |
|
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
35 |
directory_to_tree, |
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
36 |
escape_file_id, |
37 |
unescape_file_id, |
|
38 |
)
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
39 |
|
40 |
||
41 |
class TestRevidConversionV1(tests.TestCase): |
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
42 |
|
43 |
def test_simple_git_to_bzr_revision_id(self): |
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
44 |
self.assertEqual("git-v1:" |
0.204.1
by James Westby
Fix id tests to match new revid prefix. |
45 |
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356", |
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
46 |
BzrGitMappingv1().revision_id_foreign_to_bzr( |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
47 |
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356")) |
48 |
||
49 |
def test_simple_bzr_to_git_revision_id(self): |
|
0.200.195
by Jelmer Vernooij
Return mapping in revision_id_bzr_to_foreign() as required by the interface. |
50 |
self.assertEqual(("c6a4d8f1fa4ac650748e647c4b1b368f589a7356", |
51 |
BzrGitMappingv1()), |
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
52 |
BzrGitMappingv1().revision_id_bzr_to_foreign( |
53 |
"git-v1:"
|
|
0.204.1
by James Westby
Fix id tests to match new revid prefix. |
54 |
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356")) |
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
55 |
|
0.252.26
by Jelmer Vernooij
Add is_control_file method to BzrGitMapping. |
56 |
def test_is_control_file(self): |
57 |
mapping = BzrGitMappingv1() |
|
0.200.920
by Jelmer Vernooij
Fix some more tests. |
58 |
if mapping.roundtripping: |
59 |
self.assertTrue(mapping.is_control_file(".bzrdummy")) |
|
60 |
self.assertTrue(mapping.is_control_file(".bzrfileids")) |
|
0.252.26
by Jelmer Vernooij
Add is_control_file method to BzrGitMapping. |
61 |
self.assertFalse(mapping.is_control_file(".bzrfoo")) |
62 |
||
0.200.973
by Jelmer Vernooij
Add tests for generate_file_id. |
63 |
def test_generate_file_id(self): |
64 |
mapping = BzrGitMappingv1() |
|
65 |
self.assertIsInstance(mapping.generate_file_id("la"), str) |
|
66 |
self.assertIsInstance(mapping.generate_file_id(u"é"), str) |
|
67 |
||
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
68 |
|
69 |
class FileidTests(tests.TestCase): |
|
70 |
||
71 |
def test_escape_space(self): |
|
72 |
self.assertEquals("bla_s", escape_file_id("bla ")) |
|
73 |
||
74 |
def test_escape_underscore(self): |
|
75 |
self.assertEquals("bla__", escape_file_id("bla_")) |
|
76 |
||
77 |
def test_escape_underscore_space(self): |
|
78 |
self.assertEquals("bla___s", escape_file_id("bla_ ")) |
|
79 |
||
80 |
def test_unescape_underscore(self): |
|
81 |
self.assertEquals("bla ", unescape_file_id("bla_s")) |
|
82 |
||
83 |
def test_unescape_underscore_space(self): |
|
84 |
self.assertEquals("bla _", unescape_file_id("bla_s__")) |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
85 |
|
86 |
||
87 |
class TestImportCommit(tests.TestCase): |
|
88 |
||
89 |
def test_commit(self): |
|
90 |
c = Commit() |
|
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
91 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
92 |
c.message = "Some message" |
|
93 |
c.committer = "Committer" |
|
94 |
c.commit_time = 4 |
|
95 |
c.author_time = 5 |
|
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
96 |
c.commit_timezone = 60 * 5 |
97 |
c.author_timezone = 60 * 3 |
|
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
98 |
c.author = "Author" |
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
99 |
mapping = BzrGitMappingv1() |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
100 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
101 |
mapping.revision_id_foreign_to_bzr) |
102 |
self.assertEquals(None, roundtrip_revid) |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
103 |
self.assertEquals({}, verifiers) |
0.200.264
by Jelmer Vernooij
Add more tests. |
104 |
self.assertEquals("Some message", rev.message) |
105 |
self.assertEquals("Committer", rev.committer) |
|
106 |
self.assertEquals("Author", rev.properties['author']) |
|
0.200.368
by Jelmer Vernooij
Cope with more granular timezones. |
107 |
self.assertEquals(300, rev.timezone) |
0.200.264
by Jelmer Vernooij
Add more tests. |
108 |
self.assertEquals((), rev.parent_ids) |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
109 |
self.assertEquals("5", rev.properties['author-timestamp']) |
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
110 |
self.assertEquals("180", rev.properties['author-timezone']) |
0.200.264
by Jelmer Vernooij
Add more tests. |
111 |
self.assertEquals("git-v1:" + c.id, rev.revision_id) |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
112 |
|
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
113 |
def test_explicit_encoding(self): |
114 |
c = Commit() |
|
115 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
116 |
c.message = "Some message" |
|
117 |
c.committer = "Committer" |
|
118 |
c.commit_time = 4 |
|
119 |
c.author_time = 5 |
|
120 |
c.commit_timezone = 60 * 5 |
|
121 |
c.author_timezone = 60 * 3 |
|
122 |
c.author = u"Authér".encode("iso8859-1") |
|
123 |
c.encoding = "iso8859-1" |
|
0.252.44
by Jelmer Vernooij
Properly look up Bazaar revision ids for revision parents in case they are round-tripped. |
124 |
mapping = BzrGitMappingv1() |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
125 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
126 |
mapping.revision_id_foreign_to_bzr) |
127 |
self.assertEquals(None, roundtrip_revid) |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
128 |
self.assertEquals({}, verifiers) |
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
129 |
self.assertEquals(u"Authér", rev.properties['author']) |
130 |
self.assertEquals("iso8859-1", rev.properties["git-explicit-encoding"]) |
|
131 |
self.assertTrue("git-implicit-encoding" not in rev.properties) |
|
132 |
||
133 |
def test_implicit_encoding_fallback(self): |
|
134 |
c = Commit() |
|
135 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
136 |
c.message = "Some message" |
|
137 |
c.committer = "Committer" |
|
138 |
c.commit_time = 4 |
|
139 |
c.author_time = 5 |
|
140 |
c.commit_timezone = 60 * 5 |
|
141 |
c.author_timezone = 60 * 3 |
|
142 |
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. |
143 |
mapping = BzrGitMappingv1() |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
144 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
145 |
mapping.revision_id_foreign_to_bzr) |
146 |
self.assertEquals(None, roundtrip_revid) |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
147 |
self.assertEquals({}, verifiers) |
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
148 |
self.assertEquals(u"Authér", rev.properties['author']) |
149 |
self.assertEquals("latin1", rev.properties["git-implicit-encoding"]) |
|
150 |
self.assertTrue("git-explicit-encoding" not in rev.properties) |
|
151 |
||
152 |
def test_implicit_encoding_utf8(self): |
|
153 |
c = Commit() |
|
154 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
155 |
c.message = "Some message" |
|
156 |
c.committer = "Committer" |
|
157 |
c.commit_time = 4 |
|
158 |
c.author_time = 5 |
|
159 |
c.commit_timezone = 60 * 5 |
|
160 |
c.author_timezone = 60 * 3 |
|
161 |
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. |
162 |
mapping = BzrGitMappingv1() |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
163 |
rev, roundtrip_revid, verifiers = mapping.import_commit(c, |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
164 |
mapping.revision_id_foreign_to_bzr) |
165 |
self.assertEquals(None, roundtrip_revid) |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
166 |
self.assertEquals({}, verifiers) |
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
167 |
self.assertEquals(u"Authér", rev.properties['author']) |
168 |
self.assertTrue("git-explicit-encoding" not in rev.properties) |
|
169 |
self.assertTrue("git-implicit-encoding" not in rev.properties) |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
170 |
|
171 |
||
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
172 |
class RoundtripRevisionsFromBazaar(tests.TestCase): |
173 |
||
174 |
def setUp(self): |
|
175 |
super(RoundtripRevisionsFromBazaar, self).setUp() |
|
176 |
self.mapping = BzrGitMappingv1() |
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
177 |
self._parent_map = {} |
178 |
self._lookup_parent = self._parent_map.__getitem__ |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
179 |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
180 |
def assertRoundtripRevision(self, orig_rev): |
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
181 |
commit = self.mapping.export_commit(orig_rev, "mysha", |
0.200.1023
by Jelmer Vernooij
Set and verify testament. |
182 |
self._lookup_parent, True, "testamentsha") |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
183 |
rev, roundtrip_revid, verifiers = self.mapping.import_commit( |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
184 |
commit, self.mapping.revision_id_foreign_to_bzr) |
185 |
self.assertEquals(rev.revision_id, |
|
186 |
self.mapping.revision_id_foreign_to_bzr(commit.id)) |
|
0.200.912
by Jelmer Vernooij
Merge roundtrip support. |
187 |
if self.mapping.roundtripping: |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
188 |
self.assertEquals({"testament3-sha1": "testamentsha"} , verifiers) |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
189 |
self.assertEquals(orig_rev.revision_id, roundtrip_revid) |
0.200.912
by Jelmer Vernooij
Merge roundtrip support. |
190 |
self.assertEquals(orig_rev.properties, rev.properties) |
191 |
self.assertEquals(orig_rev.committer, rev.committer) |
|
192 |
self.assertEquals(orig_rev.timestamp, rev.timestamp) |
|
193 |
self.assertEquals(orig_rev.timezone, rev.timezone) |
|
194 |
self.assertEquals(orig_rev.message, rev.message) |
|
195 |
self.assertEquals(list(orig_rev.parent_ids), list(rev.parent_ids)) |
|
0.200.1023
by Jelmer Vernooij
Set and verify testament. |
196 |
else: |
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
197 |
self.assertEquals({}, verifiers) |
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
198 |
|
199 |
def test_simple_commit(self): |
|
200 |
r = Revision(self.mapping.revision_id_foreign_to_bzr("edf99e6c56495c620f20d5dacff9859ff7119261")) |
|
201 |
r.message = "MyCommitMessage" |
|
202 |
r.parent_ids = [] |
|
203 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
|
204 |
r.timestamp = 453543543 |
|
205 |
r.timezone = 0 |
|
206 |
r.properties = {} |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
207 |
self.assertRoundtripRevision(r) |
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
208 |
|
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
209 |
def test_revision_id(self): |
210 |
r = Revision("myrevid") |
|
211 |
r.message = "MyCommitMessage" |
|
212 |
r.parent_ids = [] |
|
213 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
|
214 |
r.timestamp = 453543543 |
|
215 |
r.timezone = 0 |
|
216 |
r.properties = {} |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
217 |
self.assertRoundtripRevision(r) |
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
218 |
|
219 |
def test_ghost_parent(self): |
|
220 |
r = Revision("myrevid") |
|
221 |
r.message = "MyCommitMessage" |
|
222 |
r.parent_ids = ["iamaghost"] |
|
223 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
|
224 |
r.timestamp = 453543543 |
|
225 |
r.timezone = 0 |
|
226 |
r.properties = {} |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
227 |
self.assertRoundtripRevision(r) |
0.252.8
by Jelmer Vernooij
Support ghost revisions while roundtripping. |
228 |
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
229 |
def test_custom_property(self): |
230 |
r = Revision("myrevid") |
|
231 |
r.message = "MyCommitMessage" |
|
232 |
r.parent_ids = [] |
|
233 |
r.properties = {"fool": "bar"} |
|
234 |
r.committer = "Jelmer Vernooij <jelmer@apache.org>" |
|
235 |
r.timestamp = 453543543 |
|
236 |
r.timezone = 0 |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
237 |
self.assertRoundtripRevision(r) |
0.252.16
by Jelmer Vernooij
make sure file ids are roundtripped properly. |
238 |
|
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
239 |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
240 |
class RoundtripRevisionsFromGit(tests.TestCase): |
241 |
||
242 |
def setUp(self): |
|
243 |
super(RoundtripRevisionsFromGit, self).setUp() |
|
244 |
self.mapping = BzrGitMappingv1() |
|
245 |
||
246 |
def assertRoundtripTree(self, tree): |
|
247 |
raise NotImplementedError(self.assertRoundtripTree) |
|
248 |
||
249 |
def assertRoundtripBlob(self, blob): |
|
250 |
raise NotImplementedError(self.assertRoundtripBlob) |
|
251 |
||
252 |
def assertRoundtripCommit(self, commit1): |
|
0.200.1029
by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere. |
253 |
rev, roundtrip_revid, verifiers = self.mapping.import_commit( |
0.200.1021
by Jelmer Vernooij
Put testament sha1 in revisions. |
254 |
commit1, self.mapping.revision_id_foreign_to_bzr) |
0.252.7
by Jelmer Vernooij
Add basic test for roundtripping from Bazaar. |
255 |
commit2 = self.mapping.export_commit(rev, "12341212121212", None, |
0.200.1023
by Jelmer Vernooij
Set and verify testament. |
256 |
True, None) |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
257 |
self.assertEquals(commit1.committer, commit2.committer) |
258 |
self.assertEquals(commit1.commit_time, commit2.commit_time) |
|
0.200.362
by Jelmer Vernooij
Fix tests. |
259 |
self.assertEquals(commit1.commit_timezone, commit2.commit_timezone) |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
260 |
self.assertEquals(commit1.author, commit2.author) |
261 |
self.assertEquals(commit1.author_time, commit2.author_time) |
|
0.200.362
by Jelmer Vernooij
Fix tests. |
262 |
self.assertEquals(commit1.author_timezone, commit2.author_timezone) |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
263 |
self.assertEquals(commit1.message, commit2.message) |
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
264 |
self.assertEquals(commit1.encoding, commit2.encoding) |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
265 |
|
266 |
def test_commit(self): |
|
267 |
c = Commit() |
|
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
268 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
269 |
c.message = "Some message" |
|
270 |
c.committer = "Committer <Committer>" |
|
271 |
c.commit_time = 4 |
|
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
272 |
c.commit_timezone = -60 * 3 |
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
273 |
c.author_time = 5 |
0.200.440
by Jelmer Vernooij
Remove silly mapping of timezones; dulwich uses offsets now as well. |
274 |
c.author_timezone = 60 * 2 |
0.200.416
by Jelmer Vernooij
Use public properties to set git objects values. |
275 |
c.author = "Author <author>" |
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
276 |
self.assertRoundtripCommit(c) |
277 |
||
0.200.884
by Jelmer Vernooij
Cope with -0000 as timezone in Git commits. |
278 |
def test_commit_zero_utc_timezone(self): |
279 |
c = Commit() |
|
280 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
281 |
c.message = "Some message" |
|
282 |
c.committer = "Committer <Committer>" |
|
283 |
c.commit_time = 4 |
|
284 |
c.commit_timezone = 0 |
|
285 |
c._commit_timezone_neg_utc = True |
|
286 |
c.author_time = 5 |
|
287 |
c.author_timezone = 60 * 2 |
|
288 |
c.author = "Author <author>" |
|
289 |
self.assertRoundtripCommit(c) |
|
290 |
||
0.200.727
by Jelmer Vernooij
Cope with different encodings better, rather than just stripping out |
291 |
def test_commit_encoding(self): |
292 |
c = Commit() |
|
293 |
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
294 |
c.message = "Some message" |
|
295 |
c.committer = "Committer <Committer>" |
|
296 |
c.encoding = 'iso8859-1' |
|
297 |
c.commit_time = 4 |
|
298 |
c.commit_timezone = -60 * 3 |
|
299 |
c.author_time = 5 |
|
300 |
c.author_timezone = 60 * 2 |
|
301 |
c.author = "Author <author>" |
|
302 |
self.assertRoundtripCommit(c) |
|
303 |
||
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
304 |
|
305 |
class DirectoryToTreeTests(tests.TestCase): |
|
306 |
||
307 |
def test_empty(self): |
|
308 |
ie = InventoryDirectory('foo', 'foo', 'foo') |
|
0.252.30
by Jelmer Vernooij
Support creating dummy files for empty directories. |
309 |
t = directory_to_tree(ie, None, {}, None) |
0.200.589
by Jelmer Vernooij
Fix handling of empty trees. |
310 |
self.assertEquals(None, t) |
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
311 |
|
312 |
def test_empty_dir(self): |
|
313 |
ie = InventoryDirectory('foo', 'foo', 'foo') |
|
314 |
child_ie = InventoryDirectory('bar', 'bar', 'bar') |
|
315 |
ie.children['bar'] = child_ie |
|
0.252.30
by Jelmer Vernooij
Support creating dummy files for empty directories. |
316 |
t = directory_to_tree(ie, lambda x: None, {}, None) |
0.200.589
by Jelmer Vernooij
Fix handling of empty trees. |
317 |
self.assertEquals(None, t) |
318 |
||
0.252.30
by Jelmer Vernooij
Support creating dummy files for empty directories. |
319 |
def test_empty_dir_dummy_files(self): |
320 |
ie = InventoryDirectory('foo', 'foo', 'foo') |
|
321 |
child_ie = InventoryDirectory('bar', 'bar', 'bar') |
|
322 |
ie.children['bar'] = child_ie |
|
323 |
t = directory_to_tree(ie, lambda x: None, {}, ".mydummy") |
|
324 |
self.assertTrue(".mydummy" in t) |
|
325 |
||
0.200.589
by Jelmer Vernooij
Fix handling of empty trees. |
326 |
def test_empty_root(self): |
327 |
ie = InventoryDirectory('foo', 'foo', None) |
|
328 |
child_ie = InventoryDirectory('bar', 'bar', 'bar') |
|
329 |
ie.children['bar'] = child_ie |
|
0.252.30
by Jelmer Vernooij
Support creating dummy files for empty directories. |
330 |
t = directory_to_tree(ie, lambda x: None, {}, None) |
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
331 |
self.assertEquals(Tree(), t) |
332 |
||
333 |
def test_with_file(self): |
|
334 |
ie = InventoryDirectory('foo', 'foo', 'foo') |
|
335 |
child_ie = InventoryFile('bar', 'bar', 'bar') |
|
336 |
ie.children['bar'] = child_ie |
|
337 |
b = Blob.from_string("bla") |
|
0.252.30
by Jelmer Vernooij
Support creating dummy files for empty directories. |
338 |
t1 = directory_to_tree(ie, lambda x: b.id, {}, None) |
0.200.588
by Jelmer Vernooij
Cope with empty directories that are not allowed in git. |
339 |
t2 = Tree() |
340 |
t2.add(0100644, "bar", b.id) |
|
341 |
self.assertEquals(t1, t2) |