~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_set_root_id.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-14 00:01:32 UTC
  • mfrom: (4957.1.1 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100114000132-3p3rabnonjw3gzqb
(jam) Merge bzr.stable, bringing in bug fixes #175839, #504390

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
import sys
20
20
 
21
 
from bzrlib import inventory
 
21
from bzrlib import errors, inventory
22
22
from bzrlib.tests import TestSkipped
23
23
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
24
24
 
53
53
        # should still be retained
54
54
        tree = tree.bzrdir.open_workingtree()
55
55
        self.assertEqual(root_id, tree.get_root_id())
 
56
        tree._validate()
 
57
 
 
58
    def test_set_root_id(self):
 
59
        tree = self.make_branch_and_tree('.')
 
60
        tree.lock_write()
 
61
        self.addCleanup(tree.unlock)
 
62
        orig_root_id = tree.get_root_id()
 
63
        self.assertNotEqual('custom-root-id', orig_root_id)
 
64
        self.assertEqual('', tree.id2path(orig_root_id))
 
65
        self.assertRaises(errors.NoSuchId, tree.id2path, 'custom-root-id')
 
66
        tree.set_root_id('custom-root-id')
 
67
        self.assertEqual('custom-root-id', tree.get_root_id())
 
68
        self.assertEqual('custom-root-id', tree.path2id(''))
 
69
        self.assertEqual('', tree.id2path('custom-root-id'))
 
70
        self.assertRaises(errors.NoSuchId, tree.id2path, orig_root_id)
 
71
        tree._validate()