/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/workingtree_implementations/test_commit.py

  • Committer: Marius Kruger
  • Date: 2007-08-12 08:15:15 UTC
  • mfrom: (2695 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2979.
  • Revision ID: amanic@gmail.com-20070812081515-vgekipfhohcuj6rn
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
import os
20
20
 
21
 
from bzrlib import branch, bzrdir, errors, ui, workingtree
 
21
from bzrlib import (
 
22
    branch,
 
23
    bzrdir,
 
24
    errors,
 
25
    revision as _mod_revision,
 
26
    ui,
 
27
    uncommit,
 
28
    workingtree,
 
29
    )
22
30
from bzrlib.errors import (NotBranchError, NotVersionedError, 
23
31
                           UnsupportedOperation)
24
32
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
60
68
    def update(self, message, count=None, total=None):
61
69
        """See progress.ProgressBar.update()."""
62
70
        if self.depth == 1:
63
 
            self._calls.append(("update", count, total))
 
71
            self._calls.append(("update", count, total, message))
64
72
 
65
73
 
66
74
class TestCapturingUI(TestCase):
75
83
        pb2.update('foo', 0, 1)
76
84
        pb2.finished()
77
85
        pb1.finished()
78
 
        self.assertEqual([("update", 0, 1)], factory._calls)
 
86
        self.assertEqual([("update", 0, 1, 'foo')], factory._calls)
79
87
 
80
88
 
81
89
class TestCommit(TestCaseWithWorkingTree):
152
160
            return
153
161
        tree.commit('foo', rev_id='foo', local=True)
154
162
        self.failIf(master.repository.has_revision('foo'))
155
 
        self.assertEqual(None, master.last_revision())
 
163
        self.assertEqual(_mod_revision.NULL_REVISION,
 
164
                         (_mod_revision.ensure_null(master.last_revision())))
156
165
 
157
166
    def test_record_initial_ghost(self):
158
167
        """The working tree needs to record ghosts during commit."""
345
354
        # into the factory for this test - just make the test ui factory
346
355
        # pun as a reporter. Then we can check the ordering is right.
347
356
        tree.commit('second post', specific_files=['b'])
348
 
        # 9 steps: 1 for rev, 2 for inventory, 1 for finishing. 2 for root
349
 
        # and 6 for inventory files.
350
 
        # 2 steps don't trigger an update, as 'a' and 'c' are not 
351
 
        # committed.
352
 
        self.assertEqual(
353
 
            [("update", 0, 9),
354
 
             ("update", 1, 9),
355
 
             ("update", 2, 9),
356
 
             ("update", 3, 9),
357
 
             ("update", 4, 9),
358
 
             ("update", 5, 9),
359
 
             ("update", 6, 9),
360
 
             ("update", 7, 9)],
361
 
            factory._calls
362
 
           )
 
357
        # 4 steps, the first of which is reported 2 times, once per dir
 
358
        self.assertEqual(
 
359
            [('update', 1, 4, 'Collecting changes [Directory 0] - Stage'),
 
360
             ('update', 1, 4, 'Collecting changes [Directory 1] - Stage'),
 
361
             ('update', 2, 4, 'Saving data locally - Stage'),
 
362
             ('update', 3, 4, 'Updating the working tree - Stage'),
 
363
             ('update', 4, 4, 'Running post commit hooks - Stage')],
 
364
            factory._calls
 
365
           )
 
366
 
 
367
    def test_commit_progress_shows_hook_names(self):
 
368
        tree = self.make_branch_and_tree('.')
 
369
        # set a progress bar that captures the calls so we can see what is 
 
370
        # emitted
 
371
        self.old_ui_factory = ui.ui_factory
 
372
        self.addCleanup(self.restoreDefaults)
 
373
        factory = CapturingUIFactory()
 
374
        ui.ui_factory = factory
 
375
        def a_hook(_, _2, _3, _4, _5, _6):
 
376
            pass
 
377
        branch.Branch.hooks.install_hook('post_commit', a_hook)
 
378
        branch.Branch.hooks.name_hook(a_hook, 'hook name')
 
379
        tree.commit('first post')
 
380
        self.assertEqual(
 
381
            [('update', 1, 4, 'Collecting changes [Directory 0] - Stage'),
 
382
             ('update', 1, 4, 'Collecting changes [Directory 1] - Stage'),
 
383
             ('update', 2, 4, 'Saving data locally - Stage'),
 
384
             ('update', 3, 4, 'Updating the working tree - Stage'),
 
385
             ('update', 4, 4, 'Running post commit hooks - Stage'),
 
386
             ('update', 4, 4, 'Running post commit hooks [hook name] - Stage'),
 
387
             ],
 
388
            factory._calls
 
389
           )
 
390
 
 
391
 
 
392