Rev 3924: Fix chk_map/_chk_map_py[x] imports. in file:///home/vila/src/bzr/experimental/brisbane-core/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Apr 3 14:27:50 BST 2009


At file:///home/vila/src/bzr/experimental/brisbane-core/

------------------------------------------------------------
revno: 3924
revision-id: v.ladeuil+lp at free.fr-20090403132749-rsydl9nj2kk8q08l
parent: ian.clatworthy at canonical.com-20090403015639-8sk03abc8lt4dq1p
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: brisbane-core
timestamp: Fri 2009-04-03 15:27:49 +0200
message:
  Fix chk_map/_chk_map_py[x] imports.
  
  * bzrlib/_chk_map_pyx.pyx: 
  Import the needed chk_map symbols right from the start.
  (_deserialise_leaf_node, _deserialise_internal_node): No need to
  import the symbols here.
  
  
  * bzrlib/_chk_map_py.py: 
  Import the needed chk_map symbols right from the start.
  (_deserialise_leaf_node, _deserialise_internal_node): No need to
  import the symbols here.
-------------- next part --------------
=== modified file 'bzrlib/_chk_map_py.py'
--- a/bzrlib/_chk_map_py.py	2009-03-31 16:04:31 +0000
+++ b/bzrlib/_chk_map_py.py	2009-04-03 13:27:49 +0000
@@ -19,9 +19,12 @@
 import zlib
 import struct
 
-_LeafNode = None
-_InternalNode = None
-_unknown = None
+from bzrlib.chk_map import (
+    InternalNode as _InternalNode,
+    LeafNode as _LeafNode,
+    _unknown,
+    )
+
 
 def _crc32(bit):
     # Depending on python version and platform, zlib.crc32 will return either a
@@ -59,12 +62,6 @@
     :param bytes: The bytes of the node.
     :param key: The key that the serialised node has.
     """
-    global _unknown, _LeafNode, _InternalNode
-    if _LeafNode is None:
-        from bzrlib import chk_map
-        _unknown = chk_map._unknown
-        _LeafNode = chk_map.LeafNode
-        _InternalNode = chk_map.InternalNode
     result = _LeafNode(search_key_func=search_key_func)
     # Splitlines can split on '\r' so don't use it, split('\n') adds an
     # extra '' if the bytes ends in a final newline.
@@ -117,12 +114,6 @@
 
 
 def _deserialise_internal_node(bytes, key, search_key_func=None):
-    global _unknown, _LeafNode, _InternalNode
-    if _InternalNode is None:
-        from bzrlib import chk_map
-        _unknown = chk_map._unknown
-        _LeafNode = chk_map.LeafNode
-        _InternalNode = chk_map.InternalNode
     result = _InternalNode(search_key_func=search_key_func)
     # Splitlines can split on '\r' so don't use it, remove the extra ''
     # from the result of split('\n') because we should have a trailing

=== modified file 'bzrlib/_chk_map_pyx.pyx'
--- a/bzrlib/_chk_map_pyx.pyx	2009-03-24 20:02:26 +0000
+++ b/bzrlib/_chk_map_pyx.pyx	2009-04-03 13:27:49 +0000
@@ -14,6 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
+from bzrlib.chk_map import InternalNode as _InternalNode, LeafNode as _LeafNode, _unknown
 
 cdef extern from *:
     ctypedef unsigned int size_t
@@ -55,10 +56,6 @@
     uLong crc32(uLong crc, Bytef *buf, uInt len)
 
 
-_LeafNode = None
-_InternalNode = None
-_unknown = None
-
 # We shouldn't just copy this from _dirstate_helpers_c
 cdef void* _my_memrchr(void *s, int c, size_t n):
     # memrchr seems to be a GNU extension, so we have to implement it ourselves
@@ -191,12 +188,6 @@
     cdef char *next_null, *last_null, *line_start
     cdef char *c_entry, *entry_start
 
-    if _LeafNode is None:
-        from bzrlib import chk_map
-        _LeafNode = chk_map.LeafNode
-        _InternalNode = chk_map.InternalNode
-        _unknown = chk_map._unknown
-
     result = _LeafNode(search_key_func=search_key_func)
     # Splitlines can split on '\r' so don't use it, split('\n') adds an
     # extra '' if the bytes ends in a final newline.
@@ -331,11 +322,6 @@
     cdef int maximum_size, width, length, i, prefix_tail_len
     cdef char *prefix, *line_prefix, *next_null, *c_item_prefix
 
-    if _InternalNode is None:
-        from bzrlib import chk_map
-        _LeafNode = chk_map.LeafNode
-        _InternalNode = chk_map.InternalNode
-        _unknown = chk_map._unknown
     result = _InternalNode(search_key_func=search_key_func)
 
     if not PyString_CheckExact(bytes):



More information about the bazaar-commits mailing list