Rev 2450: Fix set_reference_revision on dirstate format trees. in http://bazaar.launchpad.net/~bzr/bzr/dirstate

Robert Collins robertc at robertcollins.net
Tue Mar 6 00:54:56 GMT 2007


At http://bazaar.launchpad.net/~bzr/bzr/dirstate

------------------------------------------------------------
revno: 2450
revision-id: robertc at robertcollins.net-20070306005352-axjk5vdian1wnyx9
parent: robertc at robertcollins.net-20070306002836-59i29dpv57h6i8a3
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate.dogfood
timestamp: Tue 2007-03-06 11:53:52 +1100
message:
  Fix set_reference_revision on dirstate format trees.
added:
  bzrlib/tests/workingtree_implementations/test_nested_specifics.py test_nested_specific-20070306004443-qut978c488jr11sg-1
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== added file 'bzrlib/tests/workingtree_implementations/test_nested_specifics.py'
--- a/bzrlib/tests/workingtree_implementations/test_nested_specifics.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_nested_specifics.py	2007-03-06 00:53:52 +0000
@@ -0,0 +1,39 @@
+# Copyright (C) 2007 Canonical Ltd
+# Authors:  Robert Collins <robert.collins at canonical.com>
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+from bzrlib.transform import TreeTransform
+from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
+
+
+class TestNestedSupport(TestCaseWithWorkingTree):
+
+    def test_set_get_tree_reference(self):
+        """This tests that setting a tree reference is persistent."""
+        tree = self.make_branch_and_tree('.')
+        if not tree.supports_tree_reference():
+            return
+        transform = TreeTransform(tree)
+        trans_id = transform.new_directory('reference', transform.root,
+            'subtree-id')
+        transform.set_tree_reference('subtree-revision', trans_id)
+        transform.apply()
+        tree = tree.bzrdir.open_workingtree()
+        tree.lock_read()
+        self.addCleanup(tree.unlock)
+        self.assertEqual('subtree-revision',
+            tree.inventory['subtree-id'].reference_revision)

=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2007-03-05 00:40:01 +0000
+++ b/bzrlib/dirstate.py	2007-03-06 00:53:52 +0000
@@ -1959,6 +1959,10 @@
                 new_entry_key = (new_dirname, new_basename, new_id)
                 current_new_minikind = \
                     DirState._kind_to_minikind[current_new[1].kind]
+                if current_new_minikind == 't':
+                    fingerprint = current_new[1].reference_revision
+                else:
+                    fingerprint = ''
             else:
                 # for safety disable variables
                 new_path_utf8 = new_dirname = new_basename = new_id = new_entry_key = None
@@ -1968,7 +1972,7 @@
                 # old is finished: insert current_new into the state.
                 self.update_minimal(new_entry_key, current_new_minikind,
                     executable=current_new[1].executable,
-                    path_utf8=new_path_utf8)
+                    path_utf8=new_path_utf8, fingerprint=fingerprint)
                 current_new = advance(new_iterator)
             elif not current_new:
                 # new is finished
@@ -1983,7 +1987,7 @@
                     current_old[1][0][0] != current_new_minikind):
                     self.update_minimal(current_old[0], current_new_minikind,
                         executable=current_new[1].executable,
-                        path_utf8=new_path_utf8)
+                        path_utf8=new_path_utf8, fingerprint=fingerprint)
                 # both sides are dealt with, move on
                 current_old = advance(old_iterator)
                 current_new = advance(new_iterator)
@@ -1992,7 +1996,7 @@
                 # add a entry for this and advance new
                 self.update_minimal(new_entry_key, current_new_minikind,
                     executable=current_new[1].executable,
-                    path_utf8=new_path_utf8)
+                    path_utf8=new_path_utf8, fingerprint=fingerprint)
                 current_new = advance(new_iterator)
             else:
                 # old comes before:

=== modified file 'bzrlib/tests/workingtree_implementations/__init__.py'
--- a/bzrlib/tests/workingtree_implementations/__init__.py	2007-02-27 05:51:36 +0000
+++ b/bzrlib/tests/workingtree_implementations/__init__.py	2007-03-06 00:53:52 +0000
@@ -65,6 +65,7 @@
         'bzrlib.tests.workingtree_implementations.test_merge_from_branch',
         'bzrlib.tests.workingtree_implementations.test_mkdir',
         'bzrlib.tests.workingtree_implementations.test_move',
+        'bzrlib.tests.workingtree_implementations.test_nested_specifics',
         'bzrlib.tests.workingtree_implementations.test_parents',
         'bzrlib.tests.workingtree_implementations.test_paths2ids',
         'bzrlib.tests.workingtree_implementations.test_pull',

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-03-06 00:28:36 +0000
+++ b/bzrlib/workingtree_4.py	2007-03-06 00:53:52 +0000
@@ -336,7 +336,7 @@
                     # add this entry to the parent map.
                     parent_ies[(dirname + '/' + name).strip('/')] = inv_entry
                 elif kind == 'tree-reference':
-                    inv_entry.reference_revision = fingerprint
+                    inv_entry.reference_revision = link_or_sha1
                 else:
                     assert 'unknown kind'
                 # These checks cost us around 40ms on a 55k entry tree



More information about the bazaar-commits mailing list