Rev 2496: Switch the layout to use a matching _knit_load_data_py.py and _knit_load_data_c.pyx in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 29 01:10:54 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex
------------------------------------------------------------
revno: 2496
revision-id: john at arbash-meinel.com-20070629001013-puyhbgbq0pgzvezu
parent: john at arbash-meinel.com-20070628235539-ozvr23tlntgb7jhx
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: knit_index_pyrex
timestamp: Thu 2007-06-28 19:10:13 -0500
message:
Switch the layout to use a matching _knit_load_data_py.py and _knit_load_data_c.pyx
added:
bzrlib/_knit_load_data_py.py _knit_load_data_py.p-20070629000948-9a0nh4s118bi5y8n-1
renamed:
bzrlib/knit_c.pyx => bzrlib/_knit_load_data_c.pyx knit_c.pyx-20070509143944-u42gy8w387a10m0j-1
modified:
.bzrignore bzrignore-20050311232317-81f7b71efa2db11a
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
setup.py setup.py-20050314065409-02f8a0a6e3f9bc70
-------------- next part --------------
=== added file 'bzrlib/_knit_load_data_py.py'
--- a/bzrlib/_knit_load_data_py.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/_knit_load_data_py.py 2007-06-29 00:10:13 +0000
@@ -0,0 +1,84 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+from bzrlib import errors
+
+
+def _load_data_py(kndx, fp):
+ """Read in a knit index."""
+ cache = kndx._cache
+ history = kndx._history
+
+ kndx.check_header(fp)
+ # readlines reads the whole file at once:
+ # bad for transports like http, good for local disk
+ # we save 60 ms doing this one change (
+ # from calling readline each time to calling
+ # readlines once.
+ # probably what we want for nice behaviour on
+ # http is a incremental readlines that yields, or
+ # a check for local vs non local indexes,
+ history_top = len(history) - 1
+ for line in fp.readlines():
+ rec = line.split()
+ if len(rec) < 5 or rec[-1] != ':':
+ # corrupt line.
+ # FIXME: in the future we should determine if its a
+ # short write - and ignore it
+ # or a different failure, and raise. RBC 20060407
+ continue
+
+ try:
+ parents = []
+ for value in rec[4:-1]:
+ if value[0] == '.':
+ # uncompressed reference
+ parent_id = value[1:]
+ else:
+ parent_id = history[int(value)]
+ parents.append(parent_id)
+ except (IndexError, ValueError), e:
+ # The parent could not be decoded to get its parent row. This
+ # at a minimum will cause this row to have wrong parents, or
+ # even to apply a delta to the wrong base and decode
+ # incorrectly. its therefore not usable, and because we have
+ # encountered a situation where a new knit index had this
+ # corrupt we can't asssume that no other rows referring to the
+ # index of this record actually mean the subsequent uncorrupt
+ # one, so we error.
+ raise errors.KnitCorrupt(self._filename,
+ "line %r: %s" % (rec, e))
+
+ version_id, options, pos, size = rec[:4]
+ version_id = version_id
+
+ # See kndx._cache_version
+ # only want the _history index to reference the 1st
+ # index entry for version_id
+ if version_id not in cache:
+ history_top += 1
+ index = history_top
+ history.append(version_id)
+ else:
+ index = cache[version_id][5]
+ cache[version_id] = (version_id,
+ options.split(','),
+ int(pos),
+ int(size),
+ parents,
+ index)
+ # end kndx._cache_version
=== renamed file 'bzrlib/knit_c.pyx' => 'bzrlib/_knit_load_data_c.pyx'
=== modified file '.bzrignore'
--- a/.bzrignore 2007-06-28 23:55:39 +0000
+++ b/.bzrignore 2007-06-29 00:10:13 +0000
@@ -36,4 +36,4 @@
./api
doc/**/*.htm
doc/developers/performance.png
-bzrlib/knit_c.c
+bzrlib/_knit_load_data_c.c
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2007-06-28 23:55:39 +0000
+++ b/bzrlib/knit.py 2007-06-29 00:10:13 +0000
@@ -1899,76 +1899,7 @@
return besti, bestj, bestsize
-def _load_data_py(knit, fp):
- cache = knit._cache
- history = knit._history
-
- knit.check_header(fp)
- # readlines reads the whole file at once:
- # bad for transports like http, good for local disk
- # we save 60 ms doing this one change (
- # from calling readline each time to calling
- # readlines once.
- # probably what we want for nice behaviour on
- # http is a incremental readlines that yields, or
- # a check for local vs non local indexes,
- history_top = len(history) - 1
- for line in fp.readlines():
- rec = line.split()
- if len(rec) < 5 or rec[-1] != ':':
- # corrupt line.
- # FIXME: in the future we should determine if its a
- # short write - and ignore it
- # or a different failure, and raise. RBC 20060407
- continue
-
- try:
- parents = []
- for value in rec[4:-1]:
- if value[0] == '.':
- # uncompressed reference
- parent_id = value[1:]
- else:
- parent_id = history[int(value)]
- parents.append(parent_id)
- except (IndexError, ValueError), e:
- # The parent could not be decoded to get its parent row. This
- # at a minimum will cause this row to have wrong parents, or
- # even to apply a delta to the wrong base and decode
- # incorrectly. its therefore not usable, and because we have
- # encountered a situation where a new knit index had this
- # corrupt we can't asssume that no other rows referring to the
- # index of this record actually mean the subsequent uncorrupt
- # one, so we error.
- raise errors.KnitCorrupt(self._filename,
- "line %r: %s" % (rec, e))
-
- version_id, options, pos, size = rec[:4]
- version_id = version_id
-
- # See knit._cache_version
- # only want the _history index to reference the 1st
- # index entry for version_id
- if version_id not in cache:
- history_top += 1
- index = history_top
- history.append(version_id)
- else:
- index = cache[version_id][5]
- cache[version_id] = (version_id,
- options.split(','),
- int(pos),
- int(size),
- parents,
- index)
- # end knit._cache_version
-
-_load_data = _load_data_py
-
-
try:
- from bzrlib.knit_c import _load_data_c
+ from bzrlib._knit_load_data_c import _load_data_c as _load_data
except ImportError:
- pass
-else:
- _load_data = _load_data_c
+ from bzrlib._knit_load_data_py import _load_data_py as _load_data
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-05-09 18:22:08 +0000
+++ b/bzrlib/tests/test_knit.py 2007-06-29 00:10:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -52,13 +52,13 @@
def _probe(self):
try:
- import bzrlib.knit_c
+ import bzrlib._knit_load_data_c
except ImportError:
return False
return True
def feature_name(self):
- return 'bzrlib.knit_c'
+ return 'bzrlib._knit_load_data_c'
CompiledKnitFeature = _CompiledKnitFeature()
@@ -262,7 +262,8 @@
def reset():
knit._load_data = orig
self.addCleanup(reset)
- knit._load_data = knit._load_data_py
+ from bzrlib._knit_load_data_py import _load_data_py
+ knit._load_data = _load_data_py
return _KnitIndex(*args, **kwargs)
def test_no_such_file(self):
@@ -707,7 +708,8 @@
def reset():
knit._load_data = orig
self.addCleanup(reset)
- knit._load_data = knit._load_data_c
+ from bzrlib._knit_load_data_c import _load_data_c
+ knit._load_data = _load_data_c
return _KnitIndex(*args, **kwargs)
=== modified file 'setup.py'
--- a/setup.py 2007-06-28 23:55:39 +0000
+++ b/setup.py 2007-06-29 00:10:13 +0000
@@ -160,12 +160,14 @@
from distutils.extension import Extension
#ext_modules.append(
# Extension("bzrlib.modulename", ["bzrlib/foo.c"], libraries = []))
+ ext_modules.append(
+ Extension("bzrlib._knit_load_data_c", ["bzrlib/_knit_load_data_c.c"]))
else:
from distutils.extension import Extension
#ext_modules.append(
# Extension("bzrlib.modulename", ["bzrlib/foo.pyx"], libraries = []))
ext_modules.append(
- Extension("bzrlib.knit_c", ["bzrlib/knit_c.pyx"]))
+ Extension("bzrlib._knit_load_data_c", ["bzrlib/_knit_load_data_c.pyx"]))
command_classes['build_ext'] = build_ext
if 'bdist_wininst' in sys.argv:
More information about the bazaar-commits
mailing list