~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_bzrdir/test_bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-24 18:26:21 UTC
  • mfrom: (4567 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4568.
  • Revision ID: john@arbash-meinel.com-20090724182621-68s2jhoqf3pn72n7
Merge bzr.dev 4567 to resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
from bzrlib.trace import mutter
58
58
from bzrlib.transport import get_transport
59
59
from bzrlib.transport.local import LocalTransport
 
60
from bzrlib.ui import (
 
61
    CannedInputUIFactory,
 
62
    )
60
63
from bzrlib.upgrade import upgrade
61
64
from bzrlib.remote import RemoteBzrDir, RemoteRepository
62
65
from bzrlib.repofmt import weaverepo
1774
1777
        # ours
1775
1778
        self.old_factory = bzrlib.ui.ui_factory
1776
1779
        self.addCleanup(self.restoreFactory)
1777
 
        bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1778
1780
 
1779
1781
    def restoreFactory(self):
1780
1782
        bzrlib.ui.ui_factory = self.old_factory
1800
1802
            return
1801
1803
        # only one yes needed here: it should only be unlocking
1802
1804
        # the repo
1803
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
 
1805
        bzrlib.ui.ui_factory = CannedInputUIFactory([True])
1804
1806
        try:
1805
1807
            repo.bzrdir.break_lock()
1806
1808
        except NotImplementedError:
1831
1833
            # two yes's : branch and repository. If the repo in this
1832
1834
            # dir is inappropriately accessed, 3 will be needed, and
1833
1835
            # we'll see that because the stream will be fully consumed
1834
 
            bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\n")
 
1836
            bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True])
1835
1837
            # determine if the repository will have been locked;
1836
1838
            this_repo_locked = \
1837
1839
                thisdir.open_repository().get_physical_lock_status()
1838
1840
            master.bzrdir.break_lock()
1839
1841
            if this_repo_locked:
1840
1842
                # only two ys should have been read
1841
 
                self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read())
 
1843
                self.assertEqual([True],
 
1844
                    bzrlib.ui.ui_factory.responses)
1842
1845
            else:
1843
1846
                # only one y should have been read
1844
 
                self.assertEqual("y\ny\n", bzrlib.ui.ui_factory.stdin.read())
 
1847
                self.assertEqual([True, True],
 
1848
                    bzrlib.ui.ui_factory.responses)
1845
1849
            # we should be able to lock a newly opened branch now
1846
1850
            branch = master.bzrdir.open_branch()
1847
1851
            branch.lock_write()
1865
1869
        tree = self.make_branch_and_tree('.')
1866
1870
        tree.lock_write()
1867
1871
        # three yes's : tree, branch and repository.
1868
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\ny\n")
 
1872
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True])
1869
1873
        try:
1870
1874
            tree.bzrdir.break_lock()
1871
1875
        except (NotImplementedError, errors.LockActive):
1875
1879
            # object.
1876
1880
            tree.unlock()
1877
1881
            return
1878
 
        self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read())
 
1882
        self.assertEqual([True],
 
1883
                bzrlib.ui.ui_factory.responses)
1879
1884
        lock_tree = tree.bzrdir.open_workingtree()
1880
1885
        lock_tree.lock_write()
1881
1886
        lock_tree.unlock()