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.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
2 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
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.
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
7 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
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.
|
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
12 |
#
|
|
0.201.1
by Jelmer Vernooij
Add very small initial testsuite. |
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
0.200.264
by Jelmer Vernooij
Add more tests. |
17 |
from dulwich.objects import ( |
18 |
Commit, |
|
19 |
)
|
|
20 |
||
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
21 |
from bzrlib.plugins.git import tests |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
22 |
from bzrlib.plugins.git.mapping import ( |
23 |
BzrGitMappingv1, |
|
24 |
escape_file_id, |
|
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
25 |
revision_to_commit, |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
26 |
unescape_file_id, |
27 |
)
|
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
28 |
|
29 |
||
30 |
class TestRevidConversionV1(tests.TestCase): |
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
31 |
|
32 |
def test_simple_git_to_bzr_revision_id(self): |
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
33 |
self.assertEqual("git-v1:" |
|
0.204.1
by James Westby
Fix id tests to match new revid prefix. |
34 |
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356", |
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
35 |
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. |
36 |
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356")) |
37 |
||
38 |
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. |
39 |
self.assertEqual(("c6a4d8f1fa4ac650748e647c4b1b368f589a7356", |
40 |
BzrGitMappingv1()), |
|
|
0.200.190
by Jelmer Vernooij
Bless current mapping as v1. |
41 |
BzrGitMappingv1().revision_id_bzr_to_foreign( |
42 |
"git-v1:"
|
|
|
0.204.1
by James Westby
Fix id tests to match new revid prefix. |
43 |
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356")) |
|
0.200.258
by Jelmer Vernooij
add tests for file id escape/unescape. |
44 |
|
45 |
||
46 |
class FileidTests(tests.TestCase): |
|
47 |
||
48 |
def test_escape_space(self): |
|
49 |
self.assertEquals("bla_s", escape_file_id("bla ")) |
|
50 |
||
51 |
def test_escape_underscore(self): |
|
52 |
self.assertEquals("bla__", escape_file_id("bla_")) |
|
53 |
||
54 |
def test_escape_underscore_space(self): |
|
55 |
self.assertEquals("bla___s", escape_file_id("bla_ ")) |
|
56 |
||
57 |
def test_unescape_underscore(self): |
|
58 |
self.assertEquals("bla ", unescape_file_id("bla_s")) |
|
59 |
||
60 |
def test_unescape_underscore_space(self): |
|
61 |
self.assertEquals("bla _", unescape_file_id("bla_s__")) |
|
|
0.200.264
by Jelmer Vernooij
Add more tests. |
62 |
|
63 |
||
64 |
class TestImportCommit(tests.TestCase): |
|
65 |
||
66 |
def test_commit(self): |
|
67 |
c = Commit() |
|
68 |
c._tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
69 |
c._message = "Some message" |
|
70 |
c._committer = "Committer" |
|
71 |
c._commit_time = 4 |
|
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
72 |
c._author_time = 5 |
|
0.200.368
by Jelmer Vernooij
Cope with more granular timezones. |
73 |
c._commit_timezone = 500 |
74 |
c._author_timezone = 600 |
|
|
0.200.264
by Jelmer Vernooij
Add more tests. |
75 |
c._author = "Author" |
76 |
c.serialize() |
|
77 |
rev = BzrGitMappingv1().import_commit(c) |
|
78 |
self.assertEquals("Some message", rev.message) |
|
79 |
self.assertEquals("Committer", rev.committer) |
|
80 |
self.assertEquals("Author", rev.properties['author']) |
|
|
0.200.368
by Jelmer Vernooij
Cope with more granular timezones. |
81 |
self.assertEquals(300, rev.timezone) |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
82 |
self.assertEquals((), rev.parent_ids) |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
83 |
self.assertEquals("5", rev.properties['author-timestamp']) |
|
0.200.368
by Jelmer Vernooij
Cope with more granular timezones. |
84 |
self.assertEquals("360.000000", rev.properties['author-timezone']) |
|
0.200.264
by Jelmer Vernooij
Add more tests. |
85 |
self.assertEquals("git-v1:" + c.id, rev.revision_id) |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
86 |
|
87 |
||
88 |
||
89 |
class RoundtripRevisionsFromGit(tests.TestCase): |
|
90 |
||
91 |
def setUp(self): |
|
92 |
super(RoundtripRevisionsFromGit, self).setUp() |
|
93 |
self.mapping = BzrGitMappingv1() |
|
94 |
||
95 |
def assertRoundtripTree(self, tree): |
|
96 |
raise NotImplementedError(self.assertRoundtripTree) |
|
97 |
||
98 |
def assertRoundtripBlob(self, blob): |
|
99 |
raise NotImplementedError(self.assertRoundtripBlob) |
|
100 |
||
101 |
def assertRoundtripCommit(self, commit1): |
|
102 |
commit1.serialize() |
|
103 |
rev = self.mapping.import_commit(commit1) |
|
104 |
commit2 = revision_to_commit(rev, "12341212121212", None) |
|
105 |
self.assertEquals(commit1.committer, commit2.committer) |
|
106 |
self.assertEquals(commit1.commit_time, commit2.commit_time) |
|
|
0.200.362
by Jelmer Vernooij
Fix tests. |
107 |
self.assertEquals(commit1.commit_timezone, commit2.commit_timezone) |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
108 |
self.assertEquals(commit1.author, commit2.author) |
109 |
self.assertEquals(commit1.author_time, commit2.author_time) |
|
|
0.200.362
by Jelmer Vernooij
Fix tests. |
110 |
self.assertEquals(commit1.author_timezone, commit2.author_timezone) |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
111 |
self.assertEquals(commit1.message, commit2.message) |
112 |
||
113 |
def test_commit(self): |
|
114 |
c = Commit() |
|
115 |
c._tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba" |
|
116 |
c._message = "Some message" |
|
117 |
c._committer = "Committer" |
|
118 |
c._commit_time = 4 |
|
|
0.200.368
by Jelmer Vernooij
Cope with more granular timezones. |
119 |
c._commit_timezone = -0500 |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
120 |
c._author_time = 5 |
|
0.200.368
by Jelmer Vernooij
Cope with more granular timezones. |
121 |
c._author_timezone = 0600 |
|
0.200.351
by Jelmer Vernooij
Add roundtrip tests. |
122 |
c._author = "Author" |
123 |
self.assertRoundtripCommit(c) |
|
124 |