~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-06 20:42:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1989.
  • Revision ID: john@arbash-meinel.com-20060906204245-2c4b8481f344d692
Add ability to pass a directory mode to non_atomic_put

Show diffs side-by-side

added added

removed removed

Lines of Context:
279
279
    stored and retrieved.
280
280
    """
281
281
 
282
 
    def __init__(self, relpath, transport, file_mode=None, access_mode=None, 
 
282
    def __init__(self, relpath, transport, file_mode=None, access_mode=None,
283
283
                 factory=None, basis_knit=DEPRECATED_PARAMETER, delta=True,
284
 
                 create=False, create_parent_dir=False, delay_create=False):
 
284
                 create=False, create_parent_dir=False, delay_create=False,
 
285
                 dir_mode=None):
285
286
        """Construct a knit at location specified by relpath.
286
287
        
287
288
        :param create: If not True, only open an existing knit.
307
308
 
308
309
        self._index = _KnitIndex(transport, relpath + INDEX_SUFFIX,
309
310
            access_mode, create=create, file_mode=file_mode,
310
 
            create_parent_dir=create_parent_dir, delay_create=delay_create)
 
311
            create_parent_dir=create_parent_dir, delay_create=delay_create,
 
312
            dir_mode=dir_mode)
311
313
        self._data = _KnitData(transport, relpath + DATA_SUFFIX,
312
314
            access_mode, create=create and not len(self), file_mode=file_mode,
313
 
            create_parent_dir=create_parent_dir, delay_create=delay_create)
 
315
            create_parent_dir=create_parent_dir, delay_create=delay_create,
 
316
            dir_mode=dir_mode)
314
317
 
315
318
    def __repr__(self):
316
319
        return '%s(%s)' % (self.__class__.__name__, 
956
959
    """One of the files used to implement a knit database"""
957
960
 
958
961
    def __init__(self, transport, filename, mode, file_mode=None,
959
 
                 create_parent_dir=False):
 
962
                 create_parent_dir=False, dir_mode=None):
960
963
        self._transport = transport
961
964
        self._filename = filename
962
965
        self._mode = mode
963
966
        self._file_mode = file_mode
 
967
        self._dir_mode = dir_mode
964
968
        self._create_parent_dir = create_parent_dir
965
969
        self._need_to_create = False
966
970
 
1056
1060
                                   index)
1057
1061
 
1058
1062
    def __init__(self, transport, filename, mode, create=False, file_mode=None,
1059
 
                 create_parent_dir=False, delay_create=False):
1060
 
        _KnitComponentFile.__init__(self, transport, filename, mode, file_mode,
1061
 
                                    create_parent_dir=create_parent_dir)
 
1063
                 create_parent_dir=False, delay_create=False, dir_mode=None):
 
1064
        _KnitComponentFile.__init__(self, transport, filename, mode,
 
1065
                                    file_mode=file_mode,
 
1066
                                    create_parent_dir=create_parent_dir,
 
1067
                                    dir_mode=dir_mode)
1062
1068
        self._cache = {}
1063
1069
        # position in _history is the 'official' index for a revision
1064
1070
        # but the values may have come from a newer entry.
1268
1274
            sio.seek(0)
1269
1275
            self._transport.put_file_non_atomic(self._filename, sio,
1270
1276
                                create_parent_dir=self._create_parent_dir,
1271
 
                                mode=self._file_mode)
 
1277
                                mode=self._file_mode,
 
1278
                                dir_mode=self._dir_mode)
1272
1279
            self._need_to_create = False
1273
1280
 
1274
1281
        # cache after writing, so that a failed write leads to missing cache
1322
1329
    """Contents of the knit data file"""
1323
1330
 
1324
1331
    def __init__(self, transport, filename, mode, create=False, file_mode=None,
 
1332
                 dir_mode=None,
1325
1333
                 create_parent_dir=False, delay_create=False):
1326
1334
        _KnitComponentFile.__init__(self, transport, filename, mode,
1327
1335
                                    file_mode=file_mode,
 
1336
                                    dir_mode=dir_mode,
1328
1337
                                    create_parent_dir=create_parent_dir)
1329
1338
        self._checked = False
1330
1339
        # TODO: jam 20060713 conceptually, this could spill to disk
1388
1397
        else:
1389
1398
            self._transport.put_bytes_non_atomic(self._filename, raw_data,
1390
1399
                                   create_parent_dir=self._create_parent_dir,
1391
 
                                   mode=self._file_mode)
 
1400
                                   mode=self._file_mode,
 
1401
                                   dir_mode=self._dir_mode)
1392
1402
            self._need_to_create = False
1393
1403
            return 0
1394
1404
        
1402
1412
        else:
1403
1413
            self._transport.put_file_non_atomic(self._filename, sio,
1404
1414
                               create_parent_dir=self._create_parent_dir,
1405
 
                               mode=self._file_mode)
 
1415
                               mode=self._file_mode,
 
1416
                               dir_mode=self._dir_mode)
1406
1417
            self._need_to_create = False
1407
1418
            start_pos = 0
1408
1419
        if self._do_cache: