Rev 2428: Add a test that dirstate adds records in the right order. in http://bzr.arbash-meinel.com/branches/bzr/experimental/dirstate

John Arbash Meinel john at arbash-meinel.com
Tue Feb 27 01:30:35 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/experimental/dirstate

------------------------------------------------------------
revno: 2428
revision-id: john at arbash-meinel.com-20070227013027-tuqcr879a36obvx3
parent: john at arbash-meinel.com-20070227010804-nb6bg1c5fvs2nsri
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Mon 2007-02-26 19:30:27 -0600
message:
  Add a test that dirstate adds records in the right order.
modified:
  bzrlib/tests/test_dirstate.py  test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
-------------- next part --------------
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py	2007-02-27 01:08:04 +0000
+++ b/bzrlib/tests/test_dirstate.py	2007-02-27 01:30:27 +0000
@@ -898,6 +898,37 @@
             state.unlock()
 
 
+class TestDirstateSortOrder(TestCaseWithTransport):
+    """Test that DirState adds entries in the right order."""
+
+    def test_add_sorting(self):
+        """Add entries in lexicographical order, we get path sorted order."""
+        dirs = ['a', 'a-a', 'a-z',
+                'a/a', 'a/a-a', 'a/a-z', 'a/a/a', 'a/a/z',
+                'a/z', 'a/z-a', 'a/z-z', 'a/z/a', 'a/z/z',
+                'z',
+               ]
+        null_sha = ''
+        state = dirstate.DirState.initialize('dirstate')
+        self.addCleanup(state.unlock)
+
+        fake_stat = os.stat('dirstate')
+        for d in dirs:
+            d_id = d.replace('/', '_')+'-id'
+            file_path = d + '/f'
+            file_id = file_path.replace('/', '_')+'-id'
+            state.add(d, d_id, 'directory', fake_stat, null_sha)
+            state.add(file_path, file_id, 'file', fake_stat, null_sha)
+
+        expected = ['', '', 'a',
+                'a/a', 'a/a/a', 'a/a/z', 'a/a-a', 'a/a-z',
+                'a/z', 'a/z/a', 'a/z/z', 'a/z-a', 'a/z-z',
+                'a-a', 'a-z', 'z',
+               ]
+        dirblock_names = [d[0] for d in state._dirblocks]
+        self.assertEqual(expected, dirblock_names)
+
+
 class TestBisect(TestCaseWithTransport):
     """Test the ability to bisect into the disk format."""
 



More information about the bazaar-commits mailing list