~jelmer/ubuntu/maverick/bzr/2.2.5

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/test_inv.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-03-10 14:11:59 UTC
  • mfrom: (1.2.1 upstream) (3.1.68 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090310141159-lwzzo5c1fwrtzgj4
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
        self.tree.lock_read()
65
65
        self.addCleanup(self.tree.unlock)
66
66
        self.file_active = get_entry(self.tree, 'fileid')
67
 
        self.weave = self.branch.repository.weave_store.get_weave('fileid',
68
 
            self.branch.repository.get_transaction())
69
67
 
70
68
    # TODO: test two inventories with the same file revision
71
69
 
105
103
        entry = get_entry(self.tree, self.tree.path2id('symlink'))
106
104
        self.assertEqual(entry.kind, 'symlink')
107
105
        self.assertEqual(None, entry.text_size)
 
106
 
 
107
    def test_paths2ids_recursive(self):
 
108
        work_tree = self.make_branch_and_tree('tree')
 
109
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
110
        work_tree.add(['dir', 'dir/file'], ['dir-id', 'file-id'])
 
111
        tree = self._convert_tree(work_tree)
 
112
        tree.lock_read()
 
113
        self.addCleanup(tree.unlock)
 
114
        self.assertEqual(set(['dir-id', 'file-id']), tree.paths2ids(['dir']))
 
115
 
 
116
    def test_paths2ids_forget_old(self):
 
117
        work_tree = self.make_branch_and_tree('tree')
 
118
        self.build_tree(['tree/file'])
 
119
        work_tree.add('file', 'first-id')
 
120
        work_tree.commit('commit old state')
 
121
        work_tree.remove('file')
 
122
        tree = self._convert_tree(work_tree)
 
123
        tree.lock_read()
 
124
        self.addCleanup(tree.unlock)
 
125
        self.assertEqual(set([]), tree.paths2ids(['file'],
 
126
                         require_versioned=False))
 
127
 
 
128
    def _make_canonical_test_tree(self, commit=True):
 
129
        # make a tree used by all the 'canonical' tests below.
 
130
        work_tree = self.make_branch_and_tree('tree')
 
131
        self.build_tree(['tree/dir/', 'tree/dir/file'])
 
132
        work_tree.add(['dir', 'dir/file'])
 
133
        if commit:
 
134
            work_tree.commit('commit 1')
 
135
        return work_tree
 
136
 
 
137
    def test_canonical_path(self):
 
138
        work_tree = self._make_canonical_test_tree()
 
139
        self.assertEqual(work_tree.get_canonical_inventory_path('Dir/File'), 'dir/file')
 
140
 
 
141
    def test_canonical_path_before_commit(self):
 
142
        work_tree = self._make_canonical_test_tree(False)
 
143
        # note: not committed.
 
144
        self.assertEqual(work_tree.get_canonical_inventory_path('Dir/File'), 'dir/file')
 
145
 
 
146
    def test_canonical_path_dir(self):
 
147
        # check it works when asked for just the directory portion.
 
148
        work_tree = self._make_canonical_test_tree()
 
149
        self.assertEqual(work_tree.get_canonical_inventory_path('Dir'), 'dir')
 
150
 
 
151
    def test_canonical_path_root(self):
 
152
        work_tree = self._make_canonical_test_tree()
 
153
        self.assertEqual(work_tree.get_canonical_inventory_path(''), '')
 
154
        self.assertEqual(work_tree.get_canonical_inventory_path('/'), '/')
 
155
 
 
156
    def test_canonical_path_invalid_all(self):
 
157
        work_tree = self._make_canonical_test_tree()
 
158
        self.assertEqual(work_tree.get_canonical_inventory_path('foo/bar'), 'foo/bar')
 
159
 
 
160
    def test_canonical_invalid_child(self):
 
161
        work_tree = self._make_canonical_test_tree()
 
162
        self.assertEqual(work_tree.get_canonical_inventory_path('Dir/None'), 'dir/None')