Rev 2537: Found a small bug in the python version of _read_dirblocks. in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex
John Arbash Meinel
john at arbash-meinel.com
Thu Jul 12 06:14:45 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex
------------------------------------------------------------
revno: 2537
revision-id: john at arbash-meinel.com-20070712051426-u9auufylv5cba940
parent: john at arbash-meinel.com-20070711234520-do3h7zw8skbathpz
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Thu 2007-07-12 00:14:26 -0500
message:
Found a small bug in the python version of _read_dirblocks.
This reveals that the code is not as directly tested as it should be.
Consider refactoring all test_dirstate to use both implementations.
Or at least at more direct tests.
modified:
bzrlib/_dirstate_helpers_py.py _dirstate_helpers_py-20070710145033-90nz6cqglsk150jy-1
bzrlib/tests/test__dirstate_helpers.py test_dirstate_helper-20070504035751-jsbn00xodv0y1eve-2
-------------- next part --------------
=== modified file 'bzrlib/_dirstate_helpers_py.py'
--- a/bzrlib/_dirstate_helpers_py.py 2007-07-11 21:49:05 +0000
+++ b/bzrlib/_dirstate_helpers_py.py 2007-07-12 05:14:26 +0000
@@ -18,6 +18,10 @@
import os
+from bzrlib import (
+ dirstate,
+ )
+
def bisect_path_left_py(paths, path):
"""Return the index where to insert path into paths.
@@ -227,7 +231,7 @@
# key=lambda blk:blk[0].split('/'))
# To convert from format 3 => format 2
# state._dirblocks = sorted(state._dirblocks)
- state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
+ state._dirblock_state = dirstate.DirState.IN_MEMORY_UNMODIFIED
def cmp_by_dirs_py(path1, path2):
=== modified file 'bzrlib/tests/test__dirstate_helpers.py'
--- a/bzrlib/tests/test__dirstate_helpers.py 2007-07-11 00:01:54 +0000
+++ b/bzrlib/tests/test__dirstate_helpers.py 2007-07-12 05:14:26 +0000
@@ -20,8 +20,10 @@
import os
from bzrlib import (
+ dirstate,
tests,
)
+from bzrlib.tests import test_dirstate
class _CompiledDirstateHelpersFeature(tests.Feature):
@@ -611,3 +613,31 @@
self.assertMemRChr(22, 'abc\0\0\0jklmabc\0\0\0ghijklm', 'm')
self.assertMemRChr(22, 'aaa\0\0\0aaaaaaa\0\0\0aaaaaaa', 'a')
self.assertMemRChr(9, '\0\0\0\0\0\0\0\0\0\0', '\0')
+
+
+class TestReadDirblocks(test_dirstate.TestCaseWithDirState):
+
+ def get_read_dirblocks(self):
+ from bzrlib._dirstate_helpers_py import _read_dirblocks_py
+ return _read_dirblocks_py
+
+ def test_smoketest(self):
+ """Make sure that we can create and read back a simple file."""
+ tree, state, expected = self.create_basic_dirstate()
+ del tree
+ state._read_header_if_needed()
+ self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
+ state._dirblock_state)
+ read_dirblocks = self.get_read_dirblocks()
+ read_dirblocks(state)
+ self.assertEqual(dirstate.DirState.IN_MEMORY_UNMODIFIED,
+ state._dirblock_state)
+
+
+class TestCompiledReadDirblocks(TestReadDirblocks):
+
+ _test_needs_features = [CompiledDirstateHelpersFeature]
+
+ def get_read_dirblocks(self):
+ from bzrlib._dirstate_helpers_c import _read_dirblocks_c
+ return _read_dirblocks_c
More information about the bazaar-commits
mailing list