/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.10 by John Arbash Meinel
[merge] bzr.dev 2079
1
# Copyright (C) 2006 Canonical Ltd
1986.5.2 by Robert Collins
``WorkingTree.set_root_id(None)`` is now deprecated. Please
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for WorkingTree.set_root_id"""
18
19
from bzrlib import inventory
20
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
21
22
23
class TestSetRootId(TestCaseWithWorkingTree):
24
25
    def test_set_and_read_unicode(self):
26
        tree = self.make_branch_and_tree('a-tree')
27
        # setting the root id allows it to be read via get_root_id.
2294.1.10 by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass
28
        root_id = u'\xe5n-id'.encode('utf8')
1986.5.2 by Robert Collins
``WorkingTree.set_root_id(None)`` is now deprecated. Please
29
        tree.lock_write()
30
        try:
1986.5.3 by Robert Collins
New method ``WorkingTree.flush()`` which will write the current memory
31
            old_id = tree.get_root_id()
2294.1.10 by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass
32
            tree.set_root_id(root_id)
33
            self.assertEqual(root_id, tree.get_root_id())
1986.5.3 by Robert Collins
New method ``WorkingTree.flush()`` which will write the current memory
34
            # set root id should not have triggered a flush of the tree,
35
            # so check a new tree sees the old state.
36
            reference_tree = tree.bzrdir.open_workingtree()
37
            self.assertEqual(old_id, reference_tree.get_root_id())
1986.5.2 by Robert Collins
``WorkingTree.set_root_id(None)`` is now deprecated. Please
38
        finally:
39
            tree.unlock()
40
        # having unlocked the tree, the value should have been 
41
        # preserved into the next lock, which is an implicit read
42
        # lock around the get_root_id call.
2294.1.10 by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass
43
        self.assertEqual(root_id, tree.get_root_id())
1986.5.2 by Robert Collins
``WorkingTree.set_root_id(None)`` is now deprecated. Please
44
        # and if we get a new working tree instance, then the value
45
        # should still be retained
46
        tree = tree.bzrdir.open_workingtree()
2294.1.10 by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass
47
        self.assertEqual(root_id, tree.get_root_id())