~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-08-16 00:14:26 UTC
  • mto: This revision was merged to the branch mainline in revision 2735.
  • Revision ID: aaron.bentley@utoronto.ca-20070816001426-8aqbepjh4b3qu8o4
Implement Tree.extract_files

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from bzrlib import (
18
18
    errors,
19
19
    tests,
 
20
    transform,
20
21
    )
21
22
from bzrlib.tests import TestSkipped
22
23
from bzrlib.tests.tree_implementations import TestCaseWithTree
119
120
            self.assertRaises(errors.NoSuchId, tree.id2path, 'a')
120
121
        finally:
121
122
            tree.unlock()
 
123
 
 
124
 
 
125
class TestExtractFilesBytes(TestCaseWithTree):
 
126
 
 
127
    def test_extract_files_bytes(self):
 
128
        work_tree = self.make_branch_and_tree('wt')
 
129
        self.build_tree_contents([('wt/foo', 'foo'),
 
130
                                  ('wt/bar', 'bar'),
 
131
                                  ('wt/baz', 'baz')])
 
132
        work_tree.add(['foo', 'bar', 'baz'], ['foo-id', 'bar-id', 'baz-id'])
 
133
        tree = self._convert_tree(work_tree)
 
134
        tree.lock_read()
 
135
        self.addCleanup(tree.unlock)
 
136
        target = self.make_branch_and_tree('target')
 
137
        tt = transform.TreeTransform(target)
 
138
        self.addCleanup(tt.finalize)
 
139
        desired_files = []
 
140
        for path, entry in tree.iter_entries_by_dir():
 
141
            if entry.kind != 'file':
 
142
                continue
 
143
            trans_id = tt.create_path(entry.name, tt.root)
 
144
            tt.version_file(entry.file_id, trans_id)
 
145
            desired_files.append((entry.file_id, trans_id))
 
146
        tree.extract_files_bytes(tt.create_file, desired_files)
 
147
        tt.apply()
 
148
        self.assertEqual('foo', target.get_file_text('foo-id'))