Rev 2535: Finish fixing DirState._bisect and the bisect tests in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

John Arbash Meinel john at arbash-meinel.com
Thu Jul 12 00:00:05 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

------------------------------------------------------------
revno: 2535
revision-id: john at arbash-meinel.com-20070711225935-llcal92udviwxfp4
parent: john at arbash-meinel.com-20070711215705-x6l2fdioh050zxzp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Wed 2007-07-11 17:59:35 -0500
message:
  Finish fixing DirState._bisect and the bisect tests
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/test_dirstate.py  test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2007-07-11 00:01:54 +0000
+++ b/bzrlib/dirstate.py	2007-07-11 22:59:35 +0000
@@ -715,7 +715,7 @@
                 # after this first record.
                 after = start
                 first_dir = first_fields[1]
-                first_loc = bisect_path_left(cur_dirs, first_dir)
+                first_loc = bisect.bisect_left(cur_dirs, first_dir)
 
                 # These exist before the current location
                 pre = cur_dirs[:first_loc]
@@ -739,7 +739,7 @@
                     after = mid + len(block)
 
                 last_dir = last_fields[1]
-                last_loc = bisect_path_right(post, last_dir)
+                last_loc = bisect.bisect_right(post, last_dir)
 
                 middle_files = post[:last_loc]
                 post = post[last_loc:]
@@ -838,11 +838,8 @@
                             if dir_name[0] in pending_dirs:
                                 # This entry will be found in the dir search
                                 continue
-                            # TODO: We need to check if this entry has
-                            #       already been found. Otherwise we might be
-                            #       hitting infinite recursion.
                             if dir_name not in found_dir_names:
-                                paths_to_search.add(dir_name)
+                                paths_to_search.add(tree_info[1])
             # Now we have a list of paths to look for directly, and
             # directory blocks that need to be read.
             # newly_found is mixing the keys between (dir, name) and path

=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py	2007-07-11 00:01:54 +0000
+++ b/bzrlib/tests/test_dirstate.py	2007-07-11 22:59:35 +0000
@@ -1843,11 +1843,10 @@
         # Bisect should be capable of finding multiple entries at the same time
         self.assertBisect(expected, [['a'], ['b'], ['f']],
                           state, ['a', 'b', 'f'])
-        # ('', 'f') sorts before the others
         self.assertBisect(expected, [['f'], ['b/d'], ['b/d/e']],
-                          state, ['b/d', 'b/d/e', 'f'])
-        self.assertBisect(expected, [['b'], ['b/c'], ['b-c']],
-                          state, ['b', 'b/c', 'b-c'])
+                          state, ['f', 'b/d', 'b/d/e'])
+        self.assertBisect(expected, [['b'], ['b-c'], ['b/c']],
+                          state, ['b', 'b-c', 'b/c'])
 
     def test_bisect_one_page(self):
         """Test bisect when there is only 1 page to read"""
@@ -1863,8 +1862,7 @@
         self.assertBisect(expected,[['f']], state, ['f'])
         self.assertBisect(expected,[['a'], ['b'], ['f']],
                           state, ['a', 'b', 'f'])
-        # ('', 'f') sorts before the others
-        self.assertBisect(expected, [['f'], ['b/d'], ['b/d/e']],
+        self.assertBisect(expected, [['b/d'], ['b/d/e'], ['f']],
                           state, ['b/d', 'b/d/e', 'f'])
         self.assertBisect(expected, [['b'], ['b/c'], ['b-c']],
                           state, ['b', 'b/c', 'b-c'])
@@ -1958,7 +1956,7 @@
                                    state, ['b/d'])
         self.assertBisectRecursive(expected, ['b', 'b/c', 'b/d', 'b/d/e'],
                                    state, ['b'])
-        self.assertBisectRecursive(expected, ['', 'a', 'b', 'f', 'b/c',
+        self.assertBisectRecursive(expected, ['', 'a', 'b', 'b-c', 'f', 'b/c',
                                               'b/d', 'b/d/e'],
                                    state, [''])
 



More information about the bazaar-commits mailing list