Rev 2727: commit_candidates behaviour on brand new trees. in http://people.ubuntu.com/~robertc/baz2.0/commit-candidates

Robert Collins robertc at robertcollins.net
Thu Aug 23 03:41:57 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/commit-candidates

------------------------------------------------------------
revno: 2727
revision-id: robertc at robertcollins.net-20070823024154-dcw2d74cxtcmsg4b
parent: robertc at robertcollins.net-20070822055500-6co1vrzqhp8730c0
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-candidates
timestamp: Thu 2007-08-23 12:41:54 +1000
message:
  commit_candidates behaviour on brand new trees.
modified:
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
  bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py test_iter_commit_can-20070822055451-ygz697i0te0mcg8p-1
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2007-08-22 05:55:00 +0000
+++ b/bzrlib/mutabletree.py	2007-08-23 02:41:54 +0000
@@ -295,7 +295,6 @@
         #      implementation as part of Tree.iter_changes ? they are somewhat
         #      different. RBC 20070821
         specific_files = None
-        include_unchanged = True
         parent_ids = self.get_parent_ids()
         trees = [parent_trees[rev_id] for rev_id in parent_ids]
         if not trees:
@@ -309,6 +308,8 @@
         for tree in trees:
             tree.lock_read()
         parent_count = len(parent_ids)
+        # if there are multiple parents we need to compare last_modified
+        include_unchanged = parent_count > 1
         try:
             strict = False
             auto_add_delete = True

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-08-17 05:08:52 +0000
+++ b/bzrlib/tests/__init__.py	2007-08-23 02:41:54 +0000
@@ -2120,6 +2120,34 @@
         super(TestCaseWithTransport, self).setUp()
         self.__vfs_server = None
 
+    def _setup_tree_with_dir_order_corner_case_paths(self, tree):
+        """Create a tree with paths that expose differences in sort orders."""
+        base_path = get_transport('.').relpath('file://' + tree.basedir) + '/'
+        # Each directory will have a single file named 'f' inside
+        dirs = ['a',
+                'a-a',
+                'a/a',
+                'a/a-a',
+                'a/a/a',
+                'a/a/a-a',
+                'a/a/a/a',
+                'a/a/a/a-a',
+                'a/a/a/a/a',
+               ]
+        with_slashes = []
+        paths = []
+        path_ids = []
+        for d in dirs:
+            with_slashes.append(base_path + d + '/')
+            with_slashes.append(base_path + d + '/f')
+            paths.append(d)
+            paths.append(d+'/f')
+            path_ids.append(d.replace('/', '_') + '-id')
+            path_ids.append(d.replace('/', '_') + '_f-id')
+        self.build_tree(with_slashes)
+        tree.add(paths, path_ids)
+        return paths, path_ids
+
 
 class ChrootedTestCase(TestCaseWithTransport):
     """A support class that provides readonly urls outside the local namespace.

=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py	2007-04-30 17:45:10 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-08-23 02:41:54 +0000
@@ -378,7 +378,7 @@
         tree1 = self.make_branch_and_tree('tree1')
         tree2 = self.make_to_branch_and_tree('tree2')
         tree2.set_root_id(tree1.get_root_id())
-        paths, path_ids = self._create_special_names(tree2, 'tree2')
+        paths, path_ids = self._setup_tree_with_dir_order_corner_case_paths(tree2)
         tree2.commit('initial', rev_id='rev-1')
         tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
         return (tree1, tree2, paths, path_ids)
@@ -391,38 +391,11 @@
         tree1 = self.make_branch_and_tree('tree1')
         tree2 = self.make_to_branch_and_tree('tree2')
         tree2.set_root_id(tree1.get_root_id())
-        paths, path_ids = self._create_special_names(tree1, 'tree1')
-        paths, path_ids = self._create_special_names(tree2, 'tree2')
+        paths, path_ids = self._setup_tree_with_dir_order_corner_case_paths(tree1)
+        paths, path_ids = self._setup_tree_with_dir_order_corner_case_paths(tree2)
         tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
         return (tree1, tree2, paths, path_ids)
 
-    def _create_special_names(self, tree, base_path):
-        """Create a tree with paths that expose differences in sort orders."""
-        # Each directory will have a single file named 'f' inside
-        dirs = ['a',
-                'a-a',
-                'a/a',
-                'a/a-a',
-                'a/a/a',
-                'a/a/a-a',
-                'a/a/a/a',
-                'a/a/a/a-a',
-                'a/a/a/a/a',
-               ]
-        with_slashes = []
-        paths = []
-        path_ids = []
-        for d in dirs:
-            with_slashes.append(base_path + '/' + d + '/')
-            with_slashes.append(base_path + '/' + d + '/f')
-            paths.append(d)
-            paths.append(d+'/f')
-            path_ids.append(d.replace('/', '_') + '-id')
-            path_ids.append(d.replace('/', '_') + '_f-id')
-        self.build_tree(with_slashes)
-        tree.add(paths, path_ids)
-        return paths, path_ids
-
     def test_compare_empty_trees(self):
         tree1 = self.make_branch_and_tree('1')
         tree2 = self.make_to_branch_and_tree('2')

=== modified file 'bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py'
--- a/bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py	2007-08-22 05:55:00 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py	2007-08-23 02:41:54 +0000
@@ -46,6 +46,21 @@
     terms of layering, it needs to be fully defined here.
     """
 
+    def test_iter_commit_candidates_fresh_tree(self):
+        """A fresh tree may include the root."""
+        tree = self.make_branch_and_tree('tree')
+        tree.lock_write()
+        tree_root = tree.path2id('')
+        try:
+            result = list(tree.iter_commit_candidates({}))
+        finally:
+            tree.unlock()
+        if len(result) != 0:
+            self.assertEqual([
+                ((u'', tree_root, None, u'', 'directory', False, None),
+                 [(None, None, None, None, None, None)],
+                 True)], result)
+
     def test_iter_commit_candidates_empty(self):
         """With no files changes, iterating candidates yields nothing."""
         tree = self.make_branch_and_tree('tree')
@@ -101,5 +116,5 @@
 # tests to write:
 # strict
 # specific files
-# consider root
 # on directory callback
+# deleted items



More information about the bazaar-commits mailing list