Rev 2408: Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/dirstate/

Robert Collins robertc at robertcollins.net
Mon Feb 26 02:20:28 GMT 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/dirstate/

------------------------------------------------------------
revno: 2408
revision-id: robertc at robertcollins.net-20070226021929-4t98ucfojjx6udtr
parent: john at arbash-meinel.com-20070226021126-m31pb4ci3lxrjha8
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate
timestamp: Mon 2007-02-26 13:19:29 +1100
message:
  Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes.
modified:
  bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
  bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py	2007-02-26 01:32:38 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py	2007-02-26 02:19:29 +0000
@@ -19,6 +19,7 @@
 import os
 
 from bzrlib import errors
+from bzrlib.osutils import file_kind
 from bzrlib.tests.intertree_implementations import TestCaseWithTwoTrees
 
 # TODO: test diff unversioned dir that exists
@@ -28,7 +29,6 @@
 # TODO: test that renaming a directory x-> does not emit a rename for the child
 #        x/a -> y/a when a supplied_files argument gives either 'x/' or 'y/a'
 #        -> that is, when the renamed parent is not processed by the function.
-# TODO: include unknowns in the diff output.
 # TODO: include dangling in the diff output.
 # TODO: test items are only emitted once when a specific_files list names a dir
 #       whose parent is now a child.
@@ -319,16 +319,24 @@
         entry = tree.inventory[file_id]
         path = tree.id2path(file_id)
         return (file_id, path, True, (False, True), (None, entry.parent_id),
-                (None, entry.name), (None, entry.kind), 
+                (None, entry.name), (None, entry.kind),
                 (None, entry.executable))
 
     def deleted(self, tree, file_id):
         entry = tree.inventory[file_id]
         path = tree.id2path(file_id)
         return (file_id, path, True, (True, False), (entry.parent_id, None),
-                (entry.name, None), (entry.kind, None), 
+                (entry.name, None), (entry.kind, None),
                 (entry.executable, None))
 
+    def unversioned(self, tree, path):
+        """Create an unversioned result."""
+        _, basename = os.path.split(path)
+        kind = file_kind(tree.abspath(path))
+        return (None, path, False, (False, False), (None, None),
+                (None, basename), (None, kind),
+                (None, False))
+
     def test_empty_to_abc_content(self):
         tree1 = self.make_branch_and_tree('1')
         tree2 = self.make_to_branch_and_tree('2')
@@ -498,3 +506,54 @@
                           (root_id, root_id), ('a', 'd'), ('file', 'file'),
                           (False, False)), unchanged('c-id')]),
                          self.do_iter_changes(tree1, tree2, include_unchanged=True))
+
+    def _todo_test_unversioned_paths_in_tree(self):
+        tree1 = self.make_branch_and_tree('tree1')
+        tree2 = self.make_to_branch_and_tree('tree2')
+        self.build_tree(['tree2/file', 'tree2/dir'])
+        # try:
+        os.symlink('target', 'tree2/link')
+        links_supported = True
+        # except ???:
+        #   links_supported = False
+        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
+        root_id = tree1.path2id('')
+        tree1.lock_read()
+        self.addCleanup(tree1.unlock)
+        tree2.lock_read()
+        self.addCleanup(tree2.unlock)
+        expected = [
+            self.unversioned(tree2, 'file'),
+            self.unversioned(tree2, 'dir'),
+            ]
+        if links_supported:
+            expected.append(self.unversioned(tree2, 'link'))
+        expected = sorted(expected)
+        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+
+    def _todo_test_unversioned_paths_in_tree_specific_files(self):
+        tree1 = self.make_branch_and_tree('tree1')
+        tree2 = self.make_to_branch_and_tree('tree2')
+        self.build_tree(['tree2/file', 'tree2/dir'])
+        # try:
+        os.symlink('target', 'tree2/link')
+        links_supported = True
+        # except ???:
+        #   links_supported = False
+        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
+        root_id = tree1.path2id('')
+        tree1.lock_read()
+        self.addCleanup(tree1.unlock)
+        tree2.lock_read()
+        self.addCleanup(tree2.unlock)
+        expected = [
+            self.unversioned(tree2, 'file'),
+            self.unversioned(tree2, 'dir'),
+            ]
+        specific_files=['file', 'dir']
+        if links_supported:
+            expected.append(self.unversioned(tree2, 'link'))
+            specific_files.append('link')
+        expected = sorted(expected)
+        self.assertEqual(expected, self.do_iter_changes(tree1, tree2,
+            specific_files=specific_files))

=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2007-02-26 01:06:36 +0000
+++ b/bzrlib/tree.py	2007-02-26 02:19:29 +0000
@@ -673,7 +673,7 @@
                     self.target.get_file_sha1(file_id, to_path, to_stat)):
                     changed_content = True
             elif from_kind == 'symlink':
-                if (self.source.get_symlink_target(file_id) != 
+                if (self.source.get_symlink_target(file_id) !=
                     self.target.get_symlink_target(file_id)):
                     changed_content = True
             parent = (from_parent, to_entry.parent_id)
@@ -681,7 +681,7 @@
             executable = (from_executable, to_executable)
             if pb is not None:
                 pb.update('comparing files', entry_count, num_entries)
-            if (changed_content is not False or versioned[0] != versioned[1] 
+            if (changed_content is not False or versioned[0] != versioned[1]
                 or parent[0] != parent[1] or name[0] != name[1] or 
                 executable[0] != executable[1] or include_unchanged):
                 yield (file_id, to_path, changed_content, versioned, parent,



More information about the bazaar-commits mailing list