/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_git_repository.py

Reimplement GitRepository.get_inventory, simpler and faster.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import subprocess
20
20
 
21
21
from bzrlib import (
 
22
    inventory,
22
23
    repository,
23
24
    revision,
24
25
    )
102
103
        rev = repo.get_revision(revid)
103
104
        self.assertIsInstance(rev, revision.Revision)
104
105
 
 
106
    def test_get_inventory(self):
 
107
        # GitRepository.get_inventory gives a GitInventory object with
 
108
        # plausible entries for typical cases.
 
109
 
 
110
        # Create a git repository with some interesting files in a revision.
 
111
        tests.run_git('init')
 
112
        builder = tests.GitBranchBuilder()
 
113
        builder.set_file('data', 'text\n', False)
 
114
        builder.set_file('executable', 'content', True)
 
115
        builder.set_link('link', 'broken')
 
116
        builder.set_file('subdir/subfile', 'subdir text\n', False)
 
117
        commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
 
118
        mapping = builder.finish()
 
119
        commit_id = mapping[commit_handle]
 
120
 
 
121
        # Get the corresponding Inventory object.
 
122
        revid = ids.convert_revision_id_git_to_bzr(commit_id)
 
123
        repo = repository.Repository.open('.')
 
124
        inv = repo.get_inventory(revid)
 
125
        self.assertIsInstance(inv, inventory.Inventory)
 
126
        entries = list(inv.iter_entries())
 
127
        printed_inv = '\n'.join(
 
128
            repr((path, entry.executable, entry))
 
129
            for path, entry in inv.iter_entries())
 
130
        self.assertEqualDiff(
 
131
            printed_inv,
 
132
            "('', False, InventoryDirectory('TREE_ROOT', u'', parent_id=None,"
 
133
            " revision=None))\n"
 
134
            "(u'data', False, InventoryFile('data', u'data',"
 
135
            " parent_id='TREE_ROOT',"
 
136
            " sha1='8e27be7d6154a1f68ea9160ef0e18691d20560dc', len=None))\n"
 
137
            "(u'executable', True, InventoryFile('executable', u'executable',"
 
138
            " parent_id='TREE_ROOT',"
 
139
            " sha1='6b584e8ece562ebffc15d38808cd6b98fc3d97ea', len=None))\n"
 
140
            "(u'link', False, InventoryLink('link', u'link',"
 
141
            " parent_id='TREE_ROOT', revision=None))\n"
 
142
            "(u'subdir', False, InventoryDirectory('subdir', u'subdir',"
 
143
            " parent_id='TREE_ROOT', revision=None))\n"
 
144
            "(u'subdir/subfile', False, InventoryFile('subdir/subfile',"
 
145
            " u'subfile', parent_id='subdir',"
 
146
            " sha1='0ddb53cbe2dd209f550dd8d7f1287a5ed9b1ee8b', len=None))")
 
147
 
105
148
 
106
149
class TestGitRepositoryParseRev(tests.TestCase):
107
150
    """Unit tests for GitRepository._parse_rev."""