/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 bzrlib/tests/test_inv.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-08 15:08:04 UTC
  • mfrom: (1740.3.10 commit_builder)
  • Revision ID: pqm@pqm.ubuntu.com-20060608150804-a186fa90bfede9a6
(jrv,rbc,jam) Refactor commit.Commit to use a Repository specific CommitBuilder, enables foreign branch commits

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from cStringIO import StringIO
18
18
import os
 
19
import time
19
20
 
20
21
from bzrlib.branch import Branch
21
22
import bzrlib.errors as errors
23
24
from bzrlib.inventory import (Inventory, ROOT_ID, InventoryFile,
24
25
    InventoryDirectory, InventoryEntry)
25
26
import bzrlib.inventory as inventory
26
 
from bzrlib.osutils import has_symlinks, rename, pathjoin
 
27
from bzrlib.osutils import (has_symlinks, rename, pathjoin, is_inside_any, 
 
28
    is_inside_or_parent_of_any)
27
29
from bzrlib.tests import TestCase, TestCaseWithTransport
28
30
from bzrlib.transform import TreeTransform
29
31
from bzrlib.uncommit import uncommit
32
34
class TestInventory(TestCase):
33
35
 
34
36
    def test_is_within(self):
35
 
        from bzrlib.osutils import is_inside_any
36
37
 
37
38
        SRC_FOO_C = pathjoin('src', 'foo.c')
38
39
        for dirs, fn in [(['src', 'doc'], SRC_FOO_C),
44
45
        for dirs, fn in [(['src'], 'srccontrol'),
45
46
                         (['src'], 'srccontrol/foo')]:
46
47
            self.assertFalse(is_inside_any(dirs, fn))
 
48
 
 
49
    def test_is_within_or_parent(self):
 
50
        for dirs, fn in [(['src', 'doc'], 'src/foo.c'),
 
51
                         (['src'], 'src/foo.c'),
 
52
                         (['src/bar.c'], 'src'),
 
53
                         (['src/bar.c', 'bla/foo.c'], 'src'),
 
54
                         (['src'], 'src'),
 
55
                         ]:
 
56
            self.assert_(is_inside_or_parent_of_any(dirs, fn))
47
57
            
 
58
        for dirs, fn in [(['src'], 'srccontrol'),
 
59
                         (['srccontrol/foo.c'], 'src'),
 
60
                         (['src'], 'srccontrol/foo')]:
 
61
            self.assertFalse(is_inside_or_parent_of_any(dirs, fn))
 
62
 
48
63
    def test_ids(self):
49
64
        """Test detection of files within selected directories."""
50
65
        inv = Inventory()
291
306
        self.inv_1 = self.branch.repository.get_inventory('1')
292
307
        self.file_1 = self.inv_1['fileid']
293
308
        self.file_active = self.wt.inventory['fileid']
 
309
        self.builder = self.branch.get_commit_builder([], timestamp=time.time(), revision_id='2')
294
310
 
295
311
    def test_snapshot_new_revision(self):
296
312
        # This tests that a simple commit with no parents makes a new
297
313
        # revision value in the inventory entry
298
 
        self.file_active.snapshot('2', 'subdir/file', {}, self.wt, 
299
 
                                  self.branch.repository.weave_store,
300
 
                                  self.branch.get_transaction())
 
314
        self.file_active.snapshot('2', 'subdir/file', {}, self.wt, self.builder)
301
315
        # expected outcome - file_1 has a revision id of '2', and we can get
302
316
        # its text of 'file contents' out of the weave.
303
317
        self.assertEqual(self.file_1.revision, '1')
312
326
        #This tests that a simple commit does not make a new entry for
313
327
        # an unchanged inventory entry
314
328
        self.file_active.snapshot('2', 'subdir/file', {'1':self.file_1},
315
 
                                  self.wt, 
316
 
                                  self.branch.repository.weave_store,
317
 
                                  self.branch.get_transaction())
 
329
                                  self.wt, self.builder)
318
330
        self.assertEqual(self.file_1.revision, '1')
319
331
        self.assertEqual(self.file_active.revision, '1')
320
332
        vf = self.branch.repository.weave_store.get_weave(
341
353
        versionfile.clone_text('other', '1', ['1'])
342
354
        self.file_active.snapshot('2', 'subdir/file', 
343
355
                                  {'1':self.file_1, 'other':other_ie},
344
 
                                  self.wt, 
345
 
                                  self.branch.repository.weave_store,
346
 
                                  self.branch.get_transaction())
 
356
                                  self.wt, self.builder)
347
357
        self.assertEqual(self.file_active.revision, '2')
348
358
 
349
359
    def test_snapshot_changed(self):
352
362
        self.file_active.name='newname'
353
363
        rename('subdir/file', 'subdir/newname')
354
364
        self.file_active.snapshot('2', 'subdir/newname', {'1':self.file_1}, 
355
 
                                  self.wt,
356
 
                                  self.branch.repository.weave_store,
357
 
                                  self.branch.get_transaction())
 
365
                                  self.wt, self.builder)
358
366
        # expected outcome - file_1 has a revision id of '2'
359
367
        self.assertEqual(self.file_active.revision, '2')
360
368