Rev 4734: Add a direct test for set_root_id behavior, which seems correct. in http://bazaar.launchpad.net/~jameinel/bzr/2.0.4-dirstate-set-root-504390

John Arbash Meinel john at arbash-meinel.com
Tue Jan 12 20:25:49 GMT 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.0.4-dirstate-set-root-504390

------------------------------------------------------------
revno: 4734
revision-id: john at arbash-meinel.com-20100112202527-d0zy7nmx0hbqjpqa
parent: john at arbash-meinel.com-20100112181023-ibfxk7usb6eqqp4i
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.4-dirstate-set-root-504390
timestamp: Tue 2010-01-12 14:25:27 -0600
message:
  Add a direct test for set_root_id behavior, which seems correct.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_workingtree/test_set_root_id.py'
--- a/bzrlib/tests/per_workingtree/test_set_root_id.py	2009-09-10 06:32:42 +0000
+++ b/bzrlib/tests/per_workingtree/test_set_root_id.py	2010-01-12 20:25:27 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006-2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
 
 """Tests for WorkingTree.set_root_id"""
 
-from bzrlib import inventory
+from bzrlib import errors, inventory
 from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
 
 
@@ -48,3 +48,17 @@
         # should still be retained
         tree = tree.bzrdir.open_workingtree()
         self.assertEqual(root_id, tree.get_root_id())
+
+    def test_set_root_id(self):
+        tree = self.make_branch_and_tree('.')
+        tree.lock_write()
+        self.addCleanup(tree.unlock)
+        orig_root_id = tree.get_root_id()
+        self.assertNotEqual('custom-root-id', orig_root_id)
+        self.assertEqual('', tree.id2path(orig_root_id))
+        self.assertRaises(errors.NoSuchId, tree.id2path, 'custom-root-id')
+        tree.set_root_id('custom-root-id')
+        self.assertEqual('custom-root-id', tree.get_root_id())
+        self.assertEqual('custom-root-id', tree.path2id(''))
+        self.assertEqual('', tree.id2path('custom-root-id'))
+        self.assertRaises(errors.NoSuchId, tree.id2path, orig_root_id)



More information about the bazaar-commits mailing list