~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-18 22:24:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1989.
  • Revision ID: john@arbash-meinel.com-20060818222437-03dd852ab6d65995
test delay_create does the right thing

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import difflib
21
21
 
22
22
 
23
 
from bzrlib.errors import KnitError, RevisionAlreadyPresent
 
23
from bzrlib.errors import KnitError, RevisionAlreadyPresent, NoSuchFile
24
24
from bzrlib.knit import (
25
25
    KnitVersionedFile,
26
26
    KnitPlainFactory,
358
358
            "revid fulltext 0 84 .a_ghost :",
359
359
            'test.kndx')
360
360
 
 
361
    def test_create_parent_dir(self):
 
362
        """create_parent_dir can create knits in nonexistant dirs"""
 
363
        # Has no effect if we don't set 'delay_create'
 
364
        trans = get_transport('.')
 
365
        self.assertRaises(NoSuchFile, KnitVersionedFile, 'dir/test',
 
366
                          trans, access_mode='w', factory=None,
 
367
                          create=True, create_parent_dir=True)
 
368
        # Nothing should have changed yet
 
369
        knit = KnitVersionedFile('dir/test', trans, access_mode='w',
 
370
                                 factory=None, create=True,
 
371
                                 create_parent_dir=True,
 
372
                                 delay_create=True)
 
373
        self.failIfExists('dir/test.knit')
 
374
        self.failIfExists('dir/test.kndx')
 
375
        self.failIfExists('dir')
 
376
        knit.add_lines('revid', [], ['a\n'])
 
377
        self.failUnlessExists('dir')
 
378
        self.failUnlessExists('dir/test.knit')
 
379
        self.assertFileEqual(
 
380
            "# bzr knit index 8\n"
 
381
            "\n"
 
382
            "revid fulltext 0 84  :",
 
383
            'dir/test.kndx')
 
384
 
361
385
    def test_plan_merge(self):
362
386
        my_knit = self.make_test_knit(annotate=True)
363
387
        my_knit.add_lines('text1', [], split_lines(TEXT_1))