~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Deprecate LockableFiles.put_utf8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1532
1532
            win32utils.set_file_attr_hidden(transport._abspath('.bzr'))
1533
1533
        file_mode = temp_control._file_mode
1534
1534
        del temp_control
1535
 
        mutter('created control directory in ' + transport.base)
1536
 
        control = transport.clone('.bzr')
1537
 
        utf8_files = [('README', 
 
1535
        bzrdir_transport = transport.clone('.bzr')
 
1536
        utf8_files = [('README',
1538
1537
                       "This is a Bazaar control directory.\n"
1539
1538
                       "Do not change any files in this directory.\n"
1540
1539
                       "See http://bazaar-vcs.org/ for more information about Bazaar.\n"),
1541
1540
                      ('branch-format', self.get_format_string()),
1542
1541
                      ]
1543
1542
        # NB: no need to escape relative paths that are url safe.
1544
 
        control_files = lockable_files.LockableFiles(control,
1545
 
                            self._lock_file_name, self._lock_class)
 
1543
        control_files = lockable_files.LockableFiles(bzrdir_transport,
 
1544
            self._lock_file_name, self._lock_class)
1546
1545
        control_files.create_lock()
1547
1546
        control_files.lock_write()
1548
1547
        try:
1549
 
            for file, content in utf8_files:
1550
 
                control_files.put_utf8(file, content)
 
1548
            for (filename, content) in utf8_files:
 
1549
                bzrdir_transport.put_bytes(filename, content)
1551
1550
        finally:
1552
1551
            control_files.unlock()
1553
1552
        return self.open(transport, _found=True)
1999
1998
        self.pb.note('  %6d revisions not present', len(self.absent_revisions))
2000
1999
        self.pb.note('  %6d texts', self.text_count)
2001
2000
        self._cleanup_spare_files_after_format4()
2002
 
        self.branch.control_files.put_utf8('branch-format', BzrDirFormat5().get_format_string())
 
2001
        self.branch.control_files._transport.put_bytes(
 
2002
            'branch-format',
 
2003
            BzrDirFormat5().get_format_string(),
 
2004
            mode=self.branch.control_files._file_mode)
2003
2005
 
2004
2006
    def _cleanup_spare_files_after_format4(self):
2005
2007
        # FIXME working tree upgrade foo.
2250
2252
                except errors.NoSuchFile: # catches missing dirs strangely enough
2251
2253
                    store_transport.mkdir(prefix_dir)
2252
2254
                    store_transport.move(filename, prefix_dir + '/' + filename)
2253
 
        self.bzrdir._control_files.put_utf8('branch-format', BzrDirFormat6().get_format_string())
 
2255
        self.bzrdir.transport.put_bytes(
 
2256
            'branch-format',
 
2257
            BzrDirFormat6().get_format_string(),
 
2258
            mode=self.bzrdir._control_files._file_mode)
2254
2259
 
2255
2260
 
2256
2261
class ConvertBzrDir6ToMeta(Converter):
2267
2272
        self.garbage_inventories = []
2268
2273
 
2269
2274
        self.pb.note('starting upgrade from format 6 to metadir')
2270
 
        self.bzrdir._control_files.put_utf8('branch-format', "Converting to format 6")
 
2275
        self.dir_mode = self.bzrdir._control_files._dir_mode
 
2276
        self.file_mode = self.bzrdir._control_files._file_mode
 
2277
        self.bzrdir.transport.put_bytes(
 
2278
                'branch-format',
 
2279
                "Converting to format 6",
 
2280
                mode=self.file_mode)
2271
2281
        # its faster to move specific files around than to open and use the apis...
2272
2282
        # first off, nuke ancestry.weave, it was never used.
2273
2283
        try:
2283
2293
            if name.startswith('basis-inventory.'):
2284
2294
                self.garbage_inventories.append(name)
2285
2295
        # create new directories for repository, working tree and branch
2286
 
        self.dir_mode = self.bzrdir._control_files._dir_mode
2287
 
        self.file_mode = self.bzrdir._control_files._file_mode
2288
2296
        repository_names = [('inventory.weave', True),
2289
2297
                            ('revision-store', True),
2290
2298
                            ('weaves', True)]
2338
2346
            for entry in checkout_files:
2339
2347
                self.move_entry('checkout', entry)
2340
2348
            if last_revision is not None:
2341
 
                self.bzrdir._control_files.put_utf8(
 
2349
                self.bzrdir.transport.put_bytes(
2342
2350
                    'checkout/last-revision', last_revision)
2343
 
        self.bzrdir._control_files.put_utf8(
2344
 
            'branch-format', BzrDirMetaFormat1().get_format_string())
 
2351
        self.bzrdir.transport.put_bytes(
 
2352
            'branch-format',
 
2353
            BzrDirMetaFormat1().get_format_string(),
 
2354
            mode=self.file_mode)
2345
2355
        return BzrDir.open(self.bzrdir.root_transport.base)
2346
2356
 
2347
2357
    def make_lock(self, name):
2365
2375
                raise
2366
2376
 
2367
2377
    def put_format(self, dirname, format):
2368
 
        self.bzrdir._control_files.put_utf8('%s/format' % dirname, format.get_format_string())
 
2378
        self.bzrdir.transport.put_bytes('%s/format' % dirname,
 
2379
            format.get_format_string(),
 
2380
            self.file_mode)
2369
2381
 
2370
2382
 
2371
2383
class ConvertMetaToMeta(Converter):