14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrlib.inventory import (
22
17
from dulwich.objects import (
28
21
from bzrlib.plugins.git import tests
29
22
from bzrlib.plugins.git.mapping import (
108
101
def assertRoundtripCommit(self, commit1):
109
102
commit1.serialize()
110
103
rev = self.mapping.import_commit(commit1)
111
commit2 = self.mapping.export_commit(rev, "12341212121212", None)
104
commit2 = revision_to_commit(rev, "12341212121212", None)
112
105
self.assertEquals(commit1.committer, commit2.committer)
113
106
self.assertEquals(commit1.commit_time, commit2.commit_time)
114
107
self.assertEquals(commit1.commit_timezone, commit2.commit_timezone)
129
122
c.author = "Author <author>"
130
123
self.assertRoundtripCommit(c)
133
class DirectoryToTreeTests(tests.TestCase):
135
def test_empty(self):
136
ie = InventoryDirectory('foo', 'foo', 'foo')
137
t = directory_to_tree(ie, None, {})
138
self.assertEquals(None, t)
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
144
t = directory_to_tree(ie, lambda x: None, {})
145
self.assertEquals(None, t)
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, {})
152
self.assertEquals(Tree(), t)
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, {})
161
t2.add(0100644, "bar", b.id)
162
self.assertEquals(t1, t2)