~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.bzrdir import BzrDirMetaFormat1
27
27
from bzrlib.commit import Commit, NullCommitReporter
28
28
from bzrlib.config import BranchConfig
29
 
from bzrlib.errors import (
30
 
    PointlessCommit,
31
 
    BzrError,
32
 
    SigningFailed,
33
 
    LockContention,
34
 
    )
 
29
from bzrlib.errors import (PointlessCommit, BzrError, SigningFailed,
 
30
                           LockContention)
35
31
from bzrlib.tests import (
36
32
    SymlinkFeature,
37
33
    TestCaseWithTransport,
38
34
    test_foreign,
39
35
    )
40
 
from bzrlib.tests.matchers import MatchesAncestry
41
36
 
42
37
 
43
38
# TODO: Test commit with some added, and added-but-missing files
267
262
        eq(tree1.id2path('hello-id'), 'hello')
268
263
        eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
269
264
        self.assertFalse(tree1.has_filename('fruity'))
270
 
        self.check_tree_shape(tree1, ['hello'])
271
 
        eq(tree1.get_file_revision('hello-id'), 'test@rev-1')
 
265
        self.check_inventory_shape(tree1.inventory, ['hello'])
 
266
        ie = tree1.inventory['hello-id']
 
267
        eq(ie.revision, 'test@rev-1')
272
268
 
273
269
        tree2 = b.repository.revision_tree('test@rev-2')
274
270
        tree2.lock_read()
275
271
        self.addCleanup(tree2.unlock)
276
272
        eq(tree2.id2path('hello-id'), 'fruity')
277
273
        eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
278
 
        self.check_tree_shape(tree2, ['fruity'])
279
 
        eq(tree2.get_file_revision('hello-id'), 'test@rev-2')
 
274
        self.check_inventory_shape(tree2.inventory, ['fruity'])
 
275
        ie = tree2.inventory['hello-id']
 
276
        eq(ie.revision, 'test@rev-2')
280
277
 
281
278
    def test_reused_rev_id(self):
282
279
        """Test that a revision id cannot be reused in a branch"""
303
300
        wt.commit('two', rev_id=r2, allow_pointless=False)
304
301
        wt.lock_read()
305
302
        try:
306
 
            self.check_tree_shape(wt, ['a/', 'a/hello', 'b/'])
 
303
            self.check_inventory_shape(wt.read_working_inventory(),
 
304
                                       ['a/', 'a/hello', 'b/'])
307
305
        finally:
308
306
            wt.unlock()
309
307
 
312
310
        wt.commit('three', rev_id=r3, allow_pointless=False)
313
311
        wt.lock_read()
314
312
        try:
315
 
            self.check_tree_shape(wt,
 
313
            self.check_inventory_shape(wt.read_working_inventory(),
316
314
                                       ['a/', 'a/hello', 'a/b/'])
317
 
            self.check_tree_shape(b.repository.revision_tree(r3),
 
315
            self.check_inventory_shape(b.repository.get_inventory(r3),
318
316
                                       ['a/', 'a/hello', 'a/b/'])
319
317
        finally:
320
318
            wt.unlock()
324
322
        wt.commit('four', rev_id=r4, allow_pointless=False)
325
323
        wt.lock_read()
326
324
        try:
327
 
            self.check_tree_shape(wt, ['a/', 'a/b/hello', 'a/b/'])
 
325
            self.check_inventory_shape(wt.read_working_inventory(),
 
326
                                       ['a/', 'a/b/hello', 'a/b/'])
328
327
        finally:
329
328
            wt.unlock()
330
329
 
362
361
        eq = self.assertEquals
363
362
        eq(b.revision_history(), rev_ids)
364
363
        for i in range(4):
365
 
            self.assertThat(rev_ids[:i+1],
366
 
                MatchesAncestry(b.repository, rev_ids[i]))
 
364
            anc = b.repository.get_ancestry(rev_ids[i])
 
365
            eq(anc, [None] + rev_ids[:i+1])
367
366
 
368
367
    def test_commit_new_subdir_child_selective(self):
369
368
        wt = self.make_branch_and_tree('.')