Rev 2627: Allow giving KnitVersionedFile an index object to use rather than implicitly creating one. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Fri Jul 13 16:17:50 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2627
revision-id: robertc at robertcollins.net-20070713151747-6q0y5y1lbsw7hstn
parent: robertc at robertcollins.net-20070713150536-hqtkufys7aiqxl1t
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sat 2007-07-14 01:17:47 +1000
message:
Allow giving KnitVersionedFile an index object to use rather than implicitly creating one.
modified:
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2007-06-29 00:10:13 +0000
+++ b/bzrlib/knit.py 2007-07-13 15:17:47 +0000
@@ -333,7 +333,7 @@
def __init__(self, relpath, transport, file_mode=None, access_mode=None,
factory=None, basis_knit=DEPRECATED_PARAMETER, delta=True,
create=False, create_parent_dir=False, delay_create=False,
- dir_mode=None):
+ dir_mode=None, index=None):
"""Construct a knit at location specified by relpath.
:param create: If not True, only open an existing knit.
@@ -342,6 +342,7 @@
hash-prefixes that may not exist yet)
:param delay_create: The calling code is aware that the knit won't
actually be created until the first data is stored.
+ :param index: An index to use for the knit.
"""
if deprecated_passed(basis_knit):
warnings.warn("KnitVersionedFile.__(): The basis_knit parameter is"
@@ -359,10 +360,13 @@
self._max_delta_chain = 200
- self._index = _KnitIndex(transport, relpath + INDEX_SUFFIX,
- access_mode, create=create, file_mode=file_mode,
- create_parent_dir=create_parent_dir, delay_create=delay_create,
- dir_mode=dir_mode)
+ if index is None:
+ self._index = _KnitIndex(transport, relpath + INDEX_SUFFIX,
+ access_mode, create=create, file_mode=file_mode,
+ create_parent_dir=create_parent_dir, delay_create=delay_create,
+ dir_mode=dir_mode)
+ else:
+ self._index = index
self._data = _KnitData(transport, relpath + DATA_SUFFIX,
access_mode, create=create and not len(self), file_mode=file_mode,
create_parent_dir=create_parent_dir, delay_create=delay_create,
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-07-05 19:39:28 +0000
+++ b/bzrlib/tests/test_knit.py 2007-07-13 15:17:47 +0000
@@ -33,6 +33,7 @@
RevisionNotPresent,
NoSuchFile,
)
+from bzrlib.index import *
from bzrlib.knit import (
KnitContent,
KnitVersionedFile,
@@ -865,6 +866,12 @@
"""Construct empty k"""
self.make_test_knit()
+ def test_make_explicit_index(self):
+ """We can supply an index to use."""
+ knit = KnitVersionedFile('test', get_transport('.'),
+ index='strangelove')
+ self.assertEqual(knit._index, 'strangelove')
+
def test_knit_add(self):
"""Store one text in knit and retrieve"""
k = self.make_test_knit()
More information about the bazaar-commits
mailing list