Rev 4719: Switch away from the name Key instead start branding as StaticTuple. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple

John Arbash Meinel john at arbash-meinel.com
Wed Sep 30 18:43:40 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple

------------------------------------------------------------
revno: 4719
revision-id: john at arbash-meinel.com-20090930174333-8fhh5nqlk0yzq8bb
parent: john at arbash-meinel.com-20090930173804-3y2bossnkug69k8m
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-static-tuple
timestamp: Wed 2009-09-30 12:43:33 -0500
message:
  Switch away from the name Key instead start branding as StaticTuple.
-------------- next part --------------
=== modified file 'bzrlib/_btree_serializer_pyx.pyx'
--- a/bzrlib/_btree_serializer_pyx.pyx	2009-09-30 04:55:00 +0000
+++ b/bzrlib/_btree_serializer_pyx.pyx	2009-09-30 17:43:33 +0000
@@ -55,13 +55,13 @@
     # void *memrchr(void *s, int c, size_t n)
     int strncmp(char *s1, char *s2, size_t n)
 
-cdef extern from "_keys_type_c.h":
-    cdef struct Key:
-        pass
-    object Key_New(Py_ssize_t)
-    # Steals a reference and Val must be a PyStringObject, no checking is done
-    void Key_SET_ITEM(object key, Py_ssize_t offset, object val)
-    object Key_GET_ITEM(object key, Py_ssize_t offset)
+## cdef extern from "_keys_type_c.h":
+##     cdef struct Key:
+##         pass
+##     object Key_New(Py_ssize_t)
+##     # Steals a reference and Val must be a PyStringObject, no checking is done
+##     void Key_SET_ITEM(object key, Py_ssize_t offset, object val)
+##     object Key_GET_ITEM(object key, Py_ssize_t offset)
 
 
 # TODO: Find some way to import this from _dirstate_helpers
@@ -153,7 +153,7 @@
         cdef char *temp_ptr
         cdef int loop_counter
         # keys are tuples
-        key = Key_New(self.key_length)# PyTuple_New(self.key_length)
+        key = PyTuple_New(self.key_length)# PyTuple_New(self.key_length)
         for loop_counter from 0 <= loop_counter < self.key_length:
             # grab a key segment
             temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
@@ -177,9 +177,9 @@
             self._start = temp_ptr + 1
             Py_INCREF(key_element)
             # PyTuple_SET_ITEM(key, loop_counter, key_element)
-            Key_SET_ITEM(key, loop_counter, key_element)
+            PyTuple_SET_ITEM(key, loop_counter, key_element)
         # return _keys_type_c.Key(*key)
-        return key.intern()
+        return key
 
     cdef int process_line(self) except -1:
         """Process a line in the bytes."""

=== renamed file 'bzrlib/_keys_type_c.c' => 'bzrlib/_static_tuple_c.c'
--- a/bzrlib/_keys_type_c.c	2009-09-30 17:38:04 +0000
+++ b/bzrlib/_static_tuple_c.c	2009-09-30 17:43:33 +0000
@@ -15,14 +15,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/* Must be defined before importing _keys_type_c.h so that we get the right
+/* Must be defined before importing _static_tuple_c.h so that we get the right
  * linkage.
  */
 #if defined(_WIN32)
 #  define KeysAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
 #endif
 
-#include "_keys_type_c.h"
+#include "_static_tuple_c.h"
 
 #include "python-compat.h"
 
@@ -971,7 +971,7 @@
 
 
 PyMODINIT_FUNC
-init_keys_type_c(void)
+init_static_tuple_c(void)
 {
     PyObject* m;
 
@@ -982,7 +982,7 @@
     if (PyType_Ready(&KeyIntern_Type) < 0)
         return;
 
-    m = Py_InitModule3("_keys_type_c", keys_type_c_methods,
+    m = Py_InitModule3("_static_tuple_c", keys_type_c_methods,
                        "C implementation of a Keys structure");
     if (m == NULL)
       return;

=== renamed file 'bzrlib/_keys_type_c.h' => 'bzrlib/_static_tuple_c.h'
=== renamed file 'bzrlib/_keys_type_py.py' => 'bzrlib/_static_tuple_py.py'
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-09-08 20:43:04 +0000
+++ b/bzrlib/tests/__init__.py	2009-09-30 17:43:33 +0000
@@ -3511,9 +3511,9 @@
         'bzrlib.tests.test__chk_map',
         'bzrlib.tests.test__dirstate_helpers',
         'bzrlib.tests.test__groupcompress',
-        'bzrlib.tests.test__keys_type',
         'bzrlib.tests.test__known_graph',
         'bzrlib.tests.test__rio',
+        'bzrlib.tests.test__static_tuple',
         'bzrlib.tests.test__walkdirs_win32',
         'bzrlib.tests.test_ancestry',
         'bzrlib.tests.test_annotate',

=== renamed file 'bzrlib/tests/test__keys_type.py' => 'bzrlib/tests/test__static_tuple.py'
--- a/bzrlib/tests/test__keys_type.py	2009-09-30 17:31:10 +0000
+++ b/bzrlib/tests/test__static_tuple.py	2009-09-30 17:43:33 +0000
@@ -20,7 +20,7 @@
 import sys
 
 from bzrlib import (
-    _keys_type_py,
+    _static_tuple_py,
     errors,
     osutils,
     tests,
@@ -30,12 +30,12 @@
 def load_tests(standard_tests, module, loader):
     """Parameterize tests for all versions of groupcompress."""
     scenarios = [
-        ('python', {'module': _keys_type_py}),
+        ('python', {'module': _static_tuple_py}),
     ]
     suite = loader.suiteClass()
     if CompiledKeysType.available():
-        from bzrlib import _keys_type_c
-        scenarios.append(('C', {'module': _keys_type_c}))
+        from bzrlib import _static_tuple_c
+        scenarios.append(('C', {'module': _static_tuple_c}))
     else:
         # the compiled module isn't available, so we add a failing test
         class FailWithoutFeature(tests.TestCase):
@@ -50,13 +50,13 @@
 
     def _probe(self):
         try:
-            import bzrlib._keys_type_c
+            import bzrlib._static_tuple_c
         except ImportError:
             return False
         return True
 
     def feature_name(self):
-        return 'bzrlib._keys_type_c'
+        return 'bzrlib._static_tuple_c'
 
 CompiledKeysType = _CompiledKeysType()
 
@@ -222,10 +222,10 @@
         from meliae import scanner
         strs = ['foo', 'bar', 'baz', 'bing']
         k = self.module.Key(*strs)
-        if isinstance(k, _keys_type_py.Key):
+        if isinstance(k, _static_tuple_py.Key):
             # The python version references objects slightly different than the
             # compiled version
-            self.assertEqual([k._tuple, _keys_type_py.Key],
+            self.assertEqual([k._tuple, _static_tuple_py.Key],
                              scanner.get_referents(k))
         else:
             self.assertEqual(sorted(strs), sorted(scanner.get_referents(k)))
@@ -363,7 +363,7 @@
         self.assertIs(key, key2)
 
     def test__c_intern_handles_refcount(self):
-        if self.module is _keys_type_py:
+        if self.module is _static_tuple_py:
             return # Not applicable
         unique_str1 = 'unique str ' + osutils.rand_chars(20)
         unique_str2 = 'unique str ' + osutils.rand_chars(20)
@@ -390,7 +390,7 @@
         self.assertIs(key, key2)
 
     def test__c_keys_are_not_immortal(self):
-        if self.module is _keys_type_py:
+        if self.module is _static_tuple_py:
             return # Not applicable
         unique_str1 = 'unique str ' + osutils.rand_chars(20)
         unique_str2 = 'unique str ' + osutils.rand_chars(20)

=== modified file 'setup.py'
--- a/setup.py	2009-09-14 04:42:22 +0000
+++ b/setup.py	2009-09-30 17:43:33 +0000
@@ -294,11 +294,9 @@
 add_pyrex_extension('bzrlib._chk_map_pyx', libraries=[z_lib])
 ext_modules.append(Extension('bzrlib._patiencediff_c',
                              ['bzrlib/_patiencediff_c.c']))
-ext_modules.append(Extension('bzrlib._keys_type_c',
-                             ['bzrlib/_keys_type_c.c']))
-add_pyrex_extension('bzrlib._btree_serializer_pyx',
-                    libraries=['_keys_type_c'])
-ext_modules[-1].library_dirs.append('build/temp.win32-2.6/Release/bzrlib')
+ext_modules.append(Extension('bzrlib._static_tuple_c',
+                             ['bzrlib/_static_tuple_c.c']))
+add_pyrex_extension('bzrlib._btree_serializer_pyx')
 
 
 if unavailable_files:



More information about the bazaar-commits mailing list