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.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
17  | 
from bzrlib.inventory import (  | 
18  | 
InventoryDirectory,  | 
|
19  | 
InventoryFile,  | 
|
20  | 
    )
 | 
|
21  | 
||
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
22  | 
from dulwich.objects import (  | 
| 
0.200.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
23  | 
Blob,  | 
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
24  | 
Commit,  | 
| 
0.200.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
25  | 
Tree,  | 
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
26  | 
    )
 | 
27  | 
||
| 
0.200.18
by John Arbash Meinel
 Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.  | 
28  | 
from bzrlib.plugins.git import tests  | 
| 
0.200.258
by Jelmer Vernooij
 add tests for file id escape/unescape.  | 
29  | 
from bzrlib.plugins.git.mapping import (  | 
30  | 
BzrGitMappingv1,  | 
|
| 
0.200.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
31  | 
directory_to_tree,  | 
| 
0.200.258
by Jelmer Vernooij
 add tests for file id escape/unescape.  | 
32  | 
escape_file_id,  | 
33  | 
unescape_file_id,  | 
|
34  | 
    )
 | 
|
| 
0.200.190
by Jelmer Vernooij
 Bless current mapping as v1.  | 
35  | 
|
36  | 
||
37  | 
class TestRevidConversionV1(tests.TestCase):  | 
|
| 
0.200.18
by John Arbash Meinel
 Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc.  | 
38  | 
|
39  | 
def test_simple_git_to_bzr_revision_id(self):  | 
|
| 
0.200.190
by Jelmer Vernooij
 Bless current mapping as v1.  | 
40  | 
self.assertEqual("git-v1:"  | 
| 
0.204.1
by James Westby
 Fix id tests to match new revid prefix.  | 
41  | 
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356",  | 
| 
0.200.190
by Jelmer Vernooij
 Bless current mapping as v1.  | 
42  | 
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.  | 
43  | 
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356"))  | 
44  | 
||
45  | 
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.  | 
46  | 
self.assertEqual(("c6a4d8f1fa4ac650748e647c4b1b368f589a7356",  | 
47  | 
BzrGitMappingv1()),  | 
|
| 
0.200.190
by Jelmer Vernooij
 Bless current mapping as v1.  | 
48  | 
BzrGitMappingv1().revision_id_bzr_to_foreign(  | 
49  | 
                            "git-v1:"
 | 
|
| 
0.204.1
by James Westby
 Fix id tests to match new revid prefix.  | 
50  | 
"c6a4d8f1fa4ac650748e647c4b1b368f589a7356"))  | 
| 
0.200.258
by Jelmer Vernooij
 add tests for file id escape/unescape.  | 
51  | 
|
52  | 
||
53  | 
class FileidTests(tests.TestCase):  | 
|
54  | 
||
55  | 
def test_escape_space(self):  | 
|
56  | 
self.assertEquals("bla_s", escape_file_id("bla "))  | 
|
57  | 
||
58  | 
def test_escape_underscore(self):  | 
|
59  | 
self.assertEquals("bla__", escape_file_id("bla_"))  | 
|
60  | 
||
61  | 
def test_escape_underscore_space(self):  | 
|
62  | 
self.assertEquals("bla___s", escape_file_id("bla_ "))  | 
|
63  | 
||
64  | 
def test_unescape_underscore(self):  | 
|
65  | 
self.assertEquals("bla ", unescape_file_id("bla_s"))  | 
|
66  | 
||
67  | 
def test_unescape_underscore_space(self):  | 
|
68  | 
self.assertEquals("bla _", unescape_file_id("bla_s__"))  | 
|
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
69  | 
|
70  | 
||
71  | 
class TestImportCommit(tests.TestCase):  | 
|
72  | 
||
73  | 
def test_commit(self):  | 
|
74  | 
c = Commit()  | 
|
| 
0.200.416
by Jelmer Vernooij
 Use public properties to set git objects values.  | 
75  | 
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"  | 
76  | 
c.message = "Some message"  | 
|
77  | 
c.committer = "Committer"  | 
|
78  | 
c.commit_time = 4  | 
|
79  | 
c.author_time = 5  | 
|
| 
0.200.440
by Jelmer Vernooij
 Remove silly mapping of timezones; dulwich uses offsets now as well.  | 
80  | 
c.commit_timezone = 60 * 5  | 
81  | 
c.author_timezone = 60 * 3  | 
|
| 
0.200.416
by Jelmer Vernooij
 Use public properties to set git objects values.  | 
82  | 
c.author = "Author"  | 
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
83  | 
c.serialize()  | 
84  | 
rev = BzrGitMappingv1().import_commit(c)  | 
|
85  | 
self.assertEquals("Some message", rev.message)  | 
|
86  | 
self.assertEquals("Committer", rev.committer)  | 
|
87  | 
self.assertEquals("Author", rev.properties['author'])  | 
|
| 
0.200.368
by Jelmer Vernooij
 Cope with more granular timezones.  | 
88  | 
self.assertEquals(300, rev.timezone)  | 
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
89  | 
self.assertEquals((), rev.parent_ids)  | 
| 
0.200.351
by Jelmer Vernooij
 Add roundtrip tests.  | 
90  | 
self.assertEquals("5", rev.properties['author-timestamp'])  | 
| 
0.200.440
by Jelmer Vernooij
 Remove silly mapping of timezones; dulwich uses offsets now as well.  | 
91  | 
self.assertEquals("180", rev.properties['author-timezone'])  | 
| 
0.200.264
by Jelmer Vernooij
 Add more tests.  | 
92  | 
self.assertEquals("git-v1:" + c.id, rev.revision_id)  | 
| 
0.200.351
by Jelmer Vernooij
 Add roundtrip tests.  | 
93  | 
|
94  | 
||
95  | 
||
96  | 
class RoundtripRevisionsFromGit(tests.TestCase):  | 
|
97  | 
||
98  | 
def setUp(self):  | 
|
99  | 
super(RoundtripRevisionsFromGit, self).setUp()  | 
|
100  | 
self.mapping = BzrGitMappingv1()  | 
|
101  | 
||
102  | 
def assertRoundtripTree(self, tree):  | 
|
103  | 
raise NotImplementedError(self.assertRoundtripTree)  | 
|
104  | 
||
105  | 
def assertRoundtripBlob(self, blob):  | 
|
106  | 
raise NotImplementedError(self.assertRoundtripBlob)  | 
|
107  | 
||
108  | 
def assertRoundtripCommit(self, commit1):  | 
|
109  | 
commit1.serialize()  | 
|
110  | 
rev = self.mapping.import_commit(commit1)  | 
|
| 
0.242.1
by Jelmer Vernooij
 Add support for parsing hg-git metadata in the experimental mappings.  | 
111  | 
commit2 = self.mapping.export_commit(rev, "12341212121212", None)  | 
| 
0.200.351
by Jelmer Vernooij
 Add roundtrip tests.  | 
112  | 
self.assertEquals(commit1.committer, commit2.committer)  | 
113  | 
self.assertEquals(commit1.commit_time, commit2.commit_time)  | 
|
| 
0.200.362
by Jelmer Vernooij
 Fix tests.  | 
114  | 
self.assertEquals(commit1.commit_timezone, commit2.commit_timezone)  | 
| 
0.200.351
by Jelmer Vernooij
 Add roundtrip tests.  | 
115  | 
self.assertEquals(commit1.author, commit2.author)  | 
116  | 
self.assertEquals(commit1.author_time, commit2.author_time)  | 
|
| 
0.200.362
by Jelmer Vernooij
 Fix tests.  | 
117  | 
self.assertEquals(commit1.author_timezone, commit2.author_timezone)  | 
| 
0.200.351
by Jelmer Vernooij
 Add roundtrip tests.  | 
118  | 
self.assertEquals(commit1.message, commit2.message)  | 
119  | 
||
120  | 
def test_commit(self):  | 
|
121  | 
c = Commit()  | 
|
| 
0.200.416
by Jelmer Vernooij
 Use public properties to set git objects values.  | 
122  | 
c.tree = "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"  | 
123  | 
c.message = "Some message"  | 
|
124  | 
c.committer = "Committer <Committer>"  | 
|
125  | 
c.commit_time = 4  | 
|
| 
0.200.440
by Jelmer Vernooij
 Remove silly mapping of timezones; dulwich uses offsets now as well.  | 
126  | 
c.commit_timezone = -60 * 3  | 
| 
0.200.416
by Jelmer Vernooij
 Use public properties to set git objects values.  | 
127  | 
c.author_time = 5  | 
| 
0.200.440
by Jelmer Vernooij
 Remove silly mapping of timezones; dulwich uses offsets now as well.  | 
128  | 
c.author_timezone = 60 * 2  | 
| 
0.200.416
by Jelmer Vernooij
 Use public properties to set git objects values.  | 
129  | 
c.author = "Author <author>"  | 
| 
0.200.351
by Jelmer Vernooij
 Add roundtrip tests.  | 
130  | 
self.assertRoundtripCommit(c)  | 
131  | 
||
| 
0.200.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
132  | 
|
133  | 
class DirectoryToTreeTests(tests.TestCase):  | 
|
134  | 
||
135  | 
def test_empty(self):  | 
|
136  | 
ie = InventoryDirectory('foo', 'foo', 'foo')  | 
|
137  | 
t = directory_to_tree(ie, None, {})  | 
|
| 
0.200.589
by Jelmer Vernooij
 Fix handling of empty trees.  | 
138  | 
self.assertEquals(None, t)  | 
| 
0.200.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
139  | 
|
140  | 
def test_empty_dir(self):  | 
|
141  | 
ie = InventoryDirectory('foo', 'foo', 'foo')  | 
|
142  | 
child_ie = InventoryDirectory('bar', 'bar', 'bar')  | 
|
143  | 
ie.children['bar'] = child_ie  | 
|
| 
0.200.589
by Jelmer Vernooij
 Fix handling of empty trees.  | 
144  | 
t = directory_to_tree(ie, lambda x: None, {})  | 
145  | 
self.assertEquals(None, t)  | 
|
146  | 
||
147  | 
def test_empty_root(self):  | 
|
148  | 
ie = InventoryDirectory('foo', 'foo', None)  | 
|
149  | 
child_ie = InventoryDirectory('bar', 'bar', 'bar')  | 
|
150  | 
ie.children['bar'] = child_ie  | 
|
151  | 
t = directory_to_tree(ie, lambda x: None, {})  | 
|
| 
0.200.588
by Jelmer Vernooij
 Cope with empty directories that are not allowed in git.  | 
152  | 
self.assertEquals(Tree(), t)  | 
153  | 
||
154  | 
def test_with_file(self):  | 
|
155  | 
ie = InventoryDirectory('foo', 'foo', 'foo')  | 
|
156  | 
child_ie = InventoryFile('bar', 'bar', 'bar')  | 
|
157  | 
ie.children['bar'] = child_ie  | 
|
158  | 
b = Blob.from_string("bla")  | 
|
159  | 
t1 = directory_to_tree(ie, lambda x: b.id, {})  | 
|
160  | 
t2 = Tree()  | 
|
161  | 
t2.add(0100644, "bar", b.id)  | 
|
162  | 
self.assertEquals(t1, t2)  |