Rev 4683: Remove get_key and treat things more directly as a tuple. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-memory-consumption

John Arbash Meinel john at arbash-meinel.com
Tue Sep 8 22:23:37 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-memory-consumption

------------------------------------------------------------
revno: 4683
revision-id: john at arbash-meinel.com-20090908212324-qk7t0b3vtkio8bmg
parent: john at arbash-meinel.com-20090908211758-zc31c61v7jf142zs
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-memory-consumption
timestamp: Tue 2009-09-08 16:23:24 -0500
message:
  Remove get_key and treat things more directly as a tuple.
-------------- next part --------------
=== modified file 'bzrlib/_keys_type_c.c'
--- a/bzrlib/_keys_type_c.c	2009-09-08 21:17:58 +0000
+++ b/bzrlib/_keys_type_c.c	2009-09-08 21:23:24 +0000
@@ -127,7 +127,14 @@
 }
 
 static char Keys_doc[] =
-    "C implementation of a Keys structure";
+    "C implementation of a Keys structure."
+    "\n This is used as Keys(width, key_bit_1, key_bit_2, key_bit_3, ...)"
+    "\n For example, to do a single entry, you would do:"
+    "\n  Keys(1, 'foo')"
+    "\n For a file-key style entry you would do:"
+    "\n  Keys(2, 'file-id', 'revision-id')"
+    "\n For a parents list of file keys you would do:"
+    "\n  Keys(2, 'file-id', 'rev-id1', 'file-id', 'rev-id2')";
 
 
 static Py_ssize_t
@@ -162,27 +169,9 @@
 }
 
 
-static PyObject *
-Keys_get_key(Keys *self, PyObject *args) {
-    long offset;
-    PyObject *tpl = NULL, *obj = NULL;
-
-    /* We should use "n" to indicate Py_ssize_t, however 'l' is good enough,
-     * and 'n' doesn't exist in python 2.4.
-     */
-    if (!PyArg_ParseTuple(args, "l", &offset)) {
-        return NULL;
-    }
-    return Keys_item(self, offset);
-}
-
 static char Keys_get_key_doc[] = "get_keys(offset)";
 
 static PyMethodDef Keys_methods[] = {
-    {"get_key",
-     (PyCFunction)Keys_get_key,
-     METH_VARARGS,
-     Keys_get_key_doc},
     {NULL, NULL} /* sentinel */
 };
 

=== modified file 'bzrlib/tests/test__keys_type.py'
--- a/bzrlib/tests/test__keys_type.py	2009-09-08 21:17:58 +0000
+++ b/bzrlib/tests/test__keys_type.py	2009-09-08 21:23:24 +0000
@@ -85,14 +85,14 @@
         del k
         self.assertEqual(n_ref, sys.getrefcount(s))
 
-    def test_get_key(self):
+    def test_get_item(self):
         f = 'fo' + 'o'
         k = self.module.Keys(1, f, 'bar')
-        self.assertEqual(('foo',), k.get_key(0))
-        self.assertEqual(('bar',), k.get_key(1))
-        self.assertRaises(IndexError, k.get_key, 2)
+        self.assertEqual(('foo',), k[0])
+        self.assertEqual(('bar',), k[1])
+        self.assertRaises(IndexError, k.__getitem__, 2)
         n_refs = sys.getrefcount(f)
-        f_key = k.get_key(0)
+        f_key = k[0]
         self.assertEqual(n_refs + 1, sys.getrefcount(f))
         del f_key
         self.assertEqual(n_refs, sys.getrefcount(f))
@@ -100,9 +100,6 @@
 
     def test_get_wide_key(self):
         k = self.module.Keys(2, 'foo', 'bar', 'baz', 'bing')
-        self.assertEqual(('foo', 'bar'), k.get_key(0))
-        self.assertEqual(('baz', 'bing'), k.get_key(1))
-        self.assertRaises(IndexError, k.get_key, 2)
         self.assertEqual(('foo', 'bar'), k[0])
         self.assertEqual(('baz', 'bing'), k[1])
         self.assertRaises(IndexError, k.__getitem__, 2)



More information about the bazaar-commits mailing list