~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Robert Collins
  • Date: 2007-07-13 15:17:47 UTC
  • mto: (2592.5.3 pack-repository)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20070713151747-6q0y5y1lbsw7hstn
Allow giving KnitVersionedFile an index object to use rather than implicitly creating one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
333
333
    def __init__(self, relpath, transport, file_mode=None, access_mode=None,
334
334
                 factory=None, basis_knit=DEPRECATED_PARAMETER, delta=True,
335
335
                 create=False, create_parent_dir=False, delay_create=False,
336
 
                 dir_mode=None):
 
336
                 dir_mode=None, index=None):
337
337
        """Construct a knit at location specified by relpath.
338
338
        
339
339
        :param create: If not True, only open an existing knit.
342
342
            hash-prefixes that may not exist yet)
343
343
        :param delay_create: The calling code is aware that the knit won't 
344
344
            actually be created until the first data is stored.
 
345
        :param index: An index to use for the knit.
345
346
        """
346
347
        if deprecated_passed(basis_knit):
347
348
            warnings.warn("KnitVersionedFile.__(): The basis_knit parameter is"
359
360
 
360
361
        self._max_delta_chain = 200
361
362
 
362
 
        self._index = _KnitIndex(transport, relpath + INDEX_SUFFIX,
363
 
            access_mode, create=create, file_mode=file_mode,
364
 
            create_parent_dir=create_parent_dir, delay_create=delay_create,
365
 
            dir_mode=dir_mode)
 
363
        if index is None:
 
364
            self._index = _KnitIndex(transport, relpath + INDEX_SUFFIX,
 
365
                access_mode, create=create, file_mode=file_mode,
 
366
                create_parent_dir=create_parent_dir, delay_create=delay_create,
 
367
                dir_mode=dir_mode)
 
368
        else:
 
369
            self._index = index
366
370
        self._data = _KnitData(transport, relpath + DATA_SUFFIX,
367
371
            access_mode, create=create and not len(self), file_mode=file_mode,
368
372
            create_parent_dir=create_parent_dir, delay_create=delay_create,