~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-31 17:48:17 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060731174817-d829b8135e197aa5
Makefile: cross-platform actions for building installer

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
# TODO: remove unittest dependency; put that stuff inside the test suite
24
24
 
25
 
# TODO: The Format probe_transport seems a bit redundant with just trying to
26
 
# open the bzrdir. -- mbp
27
 
#
28
 
# TODO: Can we move specific formats into separate modules to make this file
29
 
# smaller?
30
 
 
 
25
from copy import deepcopy
31
26
from cStringIO import StringIO
32
27
import os
33
 
 
34
 
from bzrlib.lazy_import import lazy_import
35
 
lazy_import(globals(), """
36
 
from copy import deepcopy
37
28
from stat import S_ISDIR
38
 
import unittest
 
29
from unittest import TestSuite
39
30
 
40
31
import bzrlib
41
 
from bzrlib import (
42
 
    errors,
43
 
    lockable_files,
44
 
    lockdir,
45
 
    revision as _mod_revision,
46
 
    urlutils,
47
 
    xml4,
48
 
    xml5,
49
 
    )
 
32
import bzrlib.errors as errors
 
33
from bzrlib.lockable_files import LockableFiles, TransportLock
 
34
from bzrlib.lockdir import LockDir
50
35
from bzrlib.osutils import (
51
 
    safe_unicode,
52
 
    sha_strings,
53
 
    sha_string,
54
 
    )
 
36
                            abspath,
 
37
                            pathjoin,
 
38
                            safe_unicode,
 
39
                            sha_strings,
 
40
                            sha_string,
 
41
                            )
55
42
from bzrlib.store.revision.text import TextRevisionStore
56
43
from bzrlib.store.text import TextStore
57
44
from bzrlib.store.versioned import WeaveStore
 
45
from bzrlib.trace import mutter
58
46
from bzrlib.transactions import WriteTransaction
59
47
from bzrlib.transport import get_transport
 
48
from bzrlib.transport.local import LocalTransport
 
49
import bzrlib.urlutils as urlutils
60
50
from bzrlib.weave import Weave
61
 
""")
62
 
 
63
 
from bzrlib.trace import mutter
64
 
from bzrlib.transport.local import LocalTransport
 
51
from bzrlib.xml4 import serializer_v4
 
52
import bzrlib.xml5
65
53
 
66
54
 
67
55
class BzrDir(object):
98
86
        """Return true if this bzrdir is one whose format we can convert from."""
99
87
        return True
100
88
 
101
 
    def check_conversion_target(self, target_format):
102
 
        target_repo_format = target_format.repository_format
103
 
        source_repo_format = self._format.repository_format
104
 
        source_repo_format.check_conversion_target(target_repo_format)
105
 
 
106
89
    @staticmethod
107
90
    def _check_supported(format, allow_unsupported):
108
91
        """Check whether format is a supported format.
193
176
    def _make_tail(self, url):
194
177
        head, tail = urlutils.split(url)
195
178
        if tail and tail != '.':
196
 
            t = get_transport(head)
 
179
            t = bzrlib.transport.get_transport(head)
197
180
            try:
198
181
                t.mkdir(tail)
199
182
            except errors.FileExists:
215
198
                    "not one of %r" % cls)
216
199
        head, tail = urlutils.split(base)
217
200
        if tail and tail != '.':
218
 
            t = get_transport(head)
 
201
            t = bzrlib.transport.get_transport(head)
219
202
            try:
220
203
                t.mkdir(tail)
221
204
            except errors.FileExists:
309
292
        This will use the current default BzrDirFormat, and use whatever 
310
293
        repository format that that uses for bzrdirformat.create_repository.
311
294
 
312
 
        :param shared: Create a shared repository rather than a standalone
 
295
        ;param shared: Create a shared repository rather than a standalone
313
296
                       repository.
314
297
        The Repository object is returned.
315
298
 
330
313
        repository format that that uses for bzrdirformat.create_workingtree,
331
314
        create_branch and create_repository.
332
315
 
333
 
        :return: The WorkingTree object.
 
316
        The WorkingTree object is returned.
334
317
        """
335
318
        t = get_transport(safe_unicode(base))
336
319
        if not isinstance(t, LocalTransport):
346
329
        """
347
330
        raise NotImplementedError(self.create_workingtree)
348
331
 
349
 
    def destroy_workingtree(self):
350
 
        """Destroy the working tree at this BzrDir.
351
 
 
352
 
        Formats that do not support this may raise UnsupportedOperation.
353
 
        """
354
 
        raise NotImplementedError(self.destroy_workingtree)
355
 
 
356
 
    def destroy_workingtree_metadata(self):
357
 
        """Destroy the control files for the working tree at this BzrDir.
358
 
 
359
 
        The contents of working tree files are not affected.
360
 
        Formats that do not support this may raise UnsupportedOperation.
361
 
        """
362
 
        raise NotImplementedError(self.destroy_workingtree_metadata)
363
 
 
364
332
    def find_repository(self):
365
333
        """Find the repository that should be used for a_bzrdir.
366
334
 
492
460
        _unsupported is a private parameter to the BzrDir class.
493
461
        """
494
462
        t = get_transport(base)
495
 
        return BzrDir.open_from_transport(t, _unsupported=_unsupported)
496
 
 
497
 
    @staticmethod
498
 
    def open_from_transport(transport, _unsupported=False):
499
 
        """Open a bzrdir within a particular directory.
500
 
 
501
 
        :param transport: Transport containing the bzrdir.
502
 
        :param _unsupported: private.
503
 
        """
504
 
        format = BzrDirFormat.find_format(transport)
 
463
        mutter("trying to open %r with transport %r", base, t)
 
464
        format = BzrDirFormat.find_format(t)
505
465
        BzrDir._check_supported(format, _unsupported)
506
 
        return format.open(transport, _found=True)
 
466
        return format.open(t, _found=True)
507
467
 
508
468
    def open_branch(self, unsupported=False):
509
469
        """Open the branch object at this BzrDir if one is present.
543
503
        url = a_transport.base
544
504
        while True:
545
505
            try:
546
 
                result = BzrDir.open_from_transport(a_transport)
547
 
                return result, urlutils.unescape(a_transport.relpath(url))
 
506
                format = BzrDirFormat.find_format(a_transport)
 
507
                BzrDir._check_supported(format, False)
 
508
                return format.open(a_transport), urlutils.unescape(a_transport.relpath(url))
548
509
            except errors.NotBranchError, e:
 
510
                ## mutter('not a branch in: %r %s', a_transport.base, e)
549
511
                pass
550
512
            new_t = a_transport.clone('..')
551
513
            if new_t.base == a_transport.base:
601
563
        except errors.NoWorkingTree:
602
564
            return False
603
565
 
604
 
    def cloning_metadir(self, basis=None):
605
 
        """Produce a metadir suitable for cloning with"""
606
 
        def related_repository(bzrdir):
607
 
            try:
608
 
                branch = bzrdir.open_branch()
609
 
                return branch.repository
610
 
            except errors.NotBranchError:
611
 
                source_branch = None
612
 
                return bzrdir.open_repository()
613
 
        result_format = self._format.__class__()
614
 
        try:
615
 
            try:
616
 
                source_repository = related_repository(self)
617
 
            except errors.NoRepositoryPresent:
618
 
                if basis is None:
619
 
                    raise
620
 
                source_repository = related_repository(self)
621
 
            result_format.repository_format = source_repository._format
622
 
        except errors.NoRepositoryPresent:
623
 
            pass
624
 
        return result_format
625
 
 
626
566
    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
627
567
        """Create a copy of this bzrdir prepared for use as a new line of
628
568
        development.
638
578
            itself to download less data.
639
579
        """
640
580
        self._make_tail(url)
641
 
        cloning_format = self.cloning_metadir(basis)
642
 
        result = cloning_format.initialize(url)
 
581
        result = self._format.initialize(url)
643
582
        basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
644
583
        try:
645
584
            source_branch = self.open_branch()
676
615
                # XXX FIXME RBC 20060214 need tests for this when the basis
677
616
                # is incomplete
678
617
                result_repo.fetch(basis_repo, revision_id=revision_id)
679
 
            if source_repository is not None:
680
 
                result_repo.fetch(source_repository, revision_id=revision_id)
 
618
            result_repo.fetch(source_repository, revision_id=revision_id)
681
619
        if source_branch is not None:
682
620
            source_branch.sprout(result, revision_id=revision_id)
683
621
        else:
685
623
        # TODO: jam 20060426 we probably need a test in here in the
686
624
        #       case that the newly sprouted branch is a remote one
687
625
        if result_repo is None or result_repo.make_working_trees():
688
 
            wt = result.create_workingtree()
689
 
            if wt.inventory.root is None:
690
 
                try:
691
 
                    wt.set_root_id(self.open_workingtree.get_root_id())
692
 
                except errors.NoWorkingTree:
693
 
                    pass
 
626
            result.create_workingtree()
694
627
        return result
695
628
 
696
629
 
700
633
    def __init__(self, _transport, _format):
701
634
        """See BzrDir.__init__."""
702
635
        super(BzrDirPreSplitOut, self).__init__(_transport, _format)
703
 
        assert self._format._lock_class == lockable_files.TransportLock
 
636
        assert self._format._lock_class == TransportLock
704
637
        assert self._format._lock_file_name == 'branch-lock'
705
 
        self._control_files = lockable_files.LockableFiles(
706
 
                                            self.get_branch_transport(None),
 
638
        self._control_files = LockableFiles(self.get_branch_transport(None),
707
639
                                            self._format._lock_file_name,
708
640
                                            self._format._lock_class)
709
641
 
753
685
        # done on this format anyway. So - acceptable wart.
754
686
        result = self.open_workingtree()
755
687
        if revision_id is not None:
756
 
            if revision_id == _mod_revision.NULL_REVISION:
757
 
                result.set_parent_ids([])
758
 
            else:
759
 
                result.set_parent_ids([revision_id])
 
688
            result.set_last_revision(revision_id)
760
689
        return result
761
690
 
762
 
    def destroy_workingtree(self):
763
 
        """See BzrDir.destroy_workingtree."""
764
 
        raise errors.UnsupportedOperation(self.destroy_workingtree, self)
765
 
 
766
 
    def destroy_workingtree_metadata(self):
767
 
        """See BzrDir.destroy_workingtree_metadata."""
768
 
        raise errors.UnsupportedOperation(self.destroy_workingtree_metadata, 
769
 
                                          self)
770
 
 
771
691
    def get_branch_transport(self, branch_format):
772
692
        """See BzrDir.get_branch_transport()."""
773
693
        if branch_format is None:
813
733
        self._check_supported(format, unsupported)
814
734
        return format.open(self, _found=True)
815
735
 
816
 
    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
 
736
    def sprout(self, url, revision_id=None, basis=None):
817
737
        """See BzrDir.sprout()."""
818
738
        from bzrlib.workingtree import WorkingTreeFormat2
819
739
        self._make_tail(url)
913
833
        from bzrlib.workingtree import WorkingTreeFormat
914
834
        return WorkingTreeFormat.get_default_format().initialize(self, revision_id)
915
835
 
916
 
    def destroy_workingtree(self):
917
 
        """See BzrDir.destroy_workingtree."""
918
 
        wt = self.open_workingtree()
919
 
        repository = wt.branch.repository
920
 
        empty = repository.revision_tree(bzrlib.revision.NULL_REVISION)
921
 
        wt.revert([], old_tree=empty)
922
 
        self.destroy_workingtree_metadata()
923
 
 
924
 
    def destroy_workingtree_metadata(self):
925
 
        self.transport.delete_tree('checkout')
926
 
 
927
836
    def _get_mkdir_mode(self):
928
837
        """Figure out the mode to use when creating a bzrdir subdir."""
929
 
        temp_control = lockable_files.LockableFiles(self.transport, '',
930
 
                                     lockable_files.TransportLock)
 
838
        temp_control = LockableFiles(self.transport, '', TransportLock)
931
839
        return temp_control._dir_mode
932
840
 
933
841
    def get_branch_transport(self, branch_format):
1109
1017
        """Initialize a new bzrdir in the base directory of a Transport."""
1110
1018
        # Since we don't have a .bzr directory, inherit the
1111
1019
        # mode from the root directory
1112
 
        temp_control = lockable_files.LockableFiles(transport,
1113
 
                            '', lockable_files.TransportLock)
 
1020
        temp_control = LockableFiles(transport, '', TransportLock)
1114
1021
        temp_control._transport.mkdir('.bzr',
1115
1022
                                      # FIXME: RBC 20060121 don't peek under
1116
1023
                                      # the covers
1125
1032
                      ('branch-format', self.get_format_string()),
1126
1033
                      ]
1127
1034
        # NB: no need to escape relative paths that are url safe.
1128
 
        control_files = lockable_files.LockableFiles(control,
1129
 
                            self._lock_file_name, self._lock_class)
 
1035
        control_files = LockableFiles(control, self._lock_file_name, 
 
1036
                                      self._lock_class)
1130
1037
        control_files.create_lock()
1131
1038
        control_files.lock_write()
1132
1039
        try:
1145
1052
        """
1146
1053
        return True
1147
1054
 
1148
 
    def same_model(self, target_format):
1149
 
        return (self.repository_format.rich_root_data == 
1150
 
            target_format.rich_root_data)
1151
 
 
1152
1055
    @classmethod
1153
1056
    def known_formats(klass):
1154
1057
        """Return all the known formats.
1235
1138
    removed in format 5; write support for this format has been removed.
1236
1139
    """
1237
1140
 
1238
 
    _lock_class = lockable_files.TransportLock
 
1141
    _lock_class = TransportLock
1239
1142
 
1240
1143
    def get_format_string(self):
1241
1144
        """See BzrDirFormat.get_format_string()."""
1270
1173
    def __return_repository_format(self):
1271
1174
        """Circular import protection."""
1272
1175
        from bzrlib.repository import RepositoryFormat4
1273
 
        return RepositoryFormat4()
 
1176
        return RepositoryFormat4(self)
1274
1177
    repository_format = property(__return_repository_format)
1275
1178
 
1276
1179
 
1285
1188
       Unhashed stores in the repository.
1286
1189
    """
1287
1190
 
1288
 
    _lock_class = lockable_files.TransportLock
 
1191
    _lock_class = TransportLock
1289
1192
 
1290
1193
    def get_format_string(self):
1291
1194
        """See BzrDirFormat.get_format_string()."""
1314
1217
        result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1315
1218
        RepositoryFormat5().initialize(result, _internal=True)
1316
1219
        if not _cloning:
1317
 
            branch = BzrBranchFormat4().initialize(result)
1318
 
            try:
1319
 
                WorkingTreeFormat2().initialize(result)
1320
 
            except errors.NotLocalUrl:
1321
 
                # Even though we can't access the working tree, we need to
1322
 
                # create its control files.
1323
 
                WorkingTreeFormat2().stub_initialize_remote(branch.control_files)
 
1220
            BzrBranchFormat4().initialize(result)
 
1221
            WorkingTreeFormat2().initialize(result)
1324
1222
        return result
1325
1223
 
1326
1224
    def _open(self, transport):
1330
1228
    def __return_repository_format(self):
1331
1229
        """Circular import protection."""
1332
1230
        from bzrlib.repository import RepositoryFormat5
1333
 
        return RepositoryFormat5()
 
1231
        return RepositoryFormat5(self)
1334
1232
    repository_format = property(__return_repository_format)
1335
1233
 
1336
1234
 
1344
1242
     - Format 6 repositories [always]
1345
1243
    """
1346
1244
 
1347
 
    _lock_class = lockable_files.TransportLock
 
1245
    _lock_class = TransportLock
1348
1246
 
1349
1247
    def get_format_string(self):
1350
1248
        """See BzrDirFormat.get_format_string()."""
1373
1271
        result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1374
1272
        RepositoryFormat6().initialize(result, _internal=True)
1375
1273
        if not _cloning:
1376
 
            branch = BzrBranchFormat4().initialize(result)
 
1274
            BzrBranchFormat4().initialize(result)
1377
1275
            try:
1378
1276
                WorkingTreeFormat2().initialize(result)
1379
1277
            except errors.NotLocalUrl:
1380
 
                # Even though we can't access the working tree, we need to
1381
 
                # create its control files.
1382
 
                WorkingTreeFormat2().stub_initialize_remote(branch.control_files)
 
1278
                # emulate pre-check behaviour for working tree and silently 
 
1279
                # fail.
 
1280
                pass
1383
1281
        return result
1384
1282
 
1385
1283
    def _open(self, transport):
1389
1287
    def __return_repository_format(self):
1390
1288
        """Circular import protection."""
1391
1289
        from bzrlib.repository import RepositoryFormat6
1392
 
        return RepositoryFormat6()
 
1290
        return RepositoryFormat6(self)
1393
1291
    repository_format = property(__return_repository_format)
1394
1292
 
1395
1293
 
1404
1302
     - Format 7 repositories [optional]
1405
1303
    """
1406
1304
 
1407
 
    _lock_class = lockdir.LockDir
 
1305
    _lock_class = LockDir
1408
1306
 
1409
1307
    def get_converter(self, format=None):
1410
1308
        """See BzrDirFormat.get_converter()."""
1464
1362
        self._formats = formats
1465
1363
    
1466
1364
    def adapt(self, test):
1467
 
        result = unittest.TestSuite()
 
1365
        result = TestSuite()
1468
1366
        for format in self._formats:
1469
1367
            new_test = deepcopy(test)
1470
1368
            new_test.transport_server = self._transport_server
1568
1466
        self.bzrdir.transport.delete_tree('text-store')
1569
1467
 
1570
1468
    def _convert_working_inv(self):
1571
 
        inv = xml4.serializer_v4.read_inventory(
1572
 
                    self.branch.control_files.get('inventory'))
1573
 
        new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
 
1469
        inv = serializer_v4.read_inventory(self.branch.control_files.get('inventory'))
 
1470
        new_inv_xml = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
1574
1471
        # FIXME inventory is a working tree change.
1575
 
        self.branch.control_files.put('inventory', StringIO(new_inv_xml))
 
1472
        self.branch.control_files.put('inventory', new_inv_xml)
1576
1473
 
1577
1474
    def _write_all_weaves(self):
1578
1475
        controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
1602
1499
                                                      prefixed=False,
1603
1500
                                                      compressed=True))
1604
1501
        try:
1605
 
            transaction = WriteTransaction()
 
1502
            transaction = bzrlib.transactions.WriteTransaction()
1606
1503
            for i, rev_id in enumerate(self.converted_revs):
1607
1504
                self.pb.update('write revision', i, len(self.converted_revs))
1608
1505
                _revision_store.add_revision(self.revisions[rev_id], transaction)
1634
1531
    def _load_old_inventory(self, rev_id):
1635
1532
        assert rev_id not in self.converted_revs
1636
1533
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
1637
 
        inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
1638
 
        inv.revision_id = rev_id
 
1534
        inv = serializer_v4.read_inventory_from_string(old_inv_xml)
1639
1535
        rev = self.revisions[rev_id]
1640
1536
        if rev.inventory_sha1:
1641
1537
            assert rev.inventory_sha1 == sha_string(old_inv_xml), \
1645
1541
    def _load_updated_inventory(self, rev_id):
1646
1542
        assert rev_id in self.converted_revs
1647
1543
        inv_xml = self.inv_weave.get_text(rev_id)
1648
 
        inv = xml5.serializer_v5.read_inventory_from_string(inv_xml)
 
1544
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(inv_xml)
1649
1545
        return inv
1650
1546
 
1651
1547
    def _convert_one_rev(self, rev_id):
1661
1557
    def _store_new_weave(self, rev, inv, present_parents):
1662
1558
        # the XML is now updated with text versions
1663
1559
        if __debug__:
1664
 
            entries = inv.iter_entries()
1665
 
            entries.next()
1666
 
            for path, ie in entries:
1667
 
                assert getattr(ie, 'revision', None) is not None, \
 
1560
            for file_id in inv:
 
1561
                ie = inv[file_id]
 
1562
                if ie.kind == 'root_directory':
 
1563
                    continue
 
1564
                assert hasattr(ie, 'revision'), \
1668
1565
                    'no revision on {%s} in {%s}' % \
1669
1566
                    (file_id, rev.revision_id)
1670
 
        new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
 
1567
        new_inv_xml = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
1671
1568
        new_inv_sha1 = sha_string(new_inv_xml)
1672
1569
        self.inv_weave.add_lines(rev.revision_id, 
1673
1570
                                 present_parents,
1682
1579
        mutter('converting texts of revision {%s}',
1683
1580
               rev_id)
1684
1581
        parent_invs = map(self._load_updated_inventory, present_parents)
1685
 
        entries = inv.iter_entries()
1686
 
        entries.next()
1687
 
        for path, ie in entries:
 
1582
        for file_id in inv:
 
1583
            ie = inv[file_id]
1688
1584
            self._convert_file_version(rev, ie, parent_invs)
1689
1585
 
1690
1586
    def _convert_file_version(self, rev, ie, parent_invs):
1693
1589
        The file needs to be added into the weave if it is a merge
1694
1590
        of >=2 parents or if it's changed from its parent.
1695
1591
        """
 
1592
        if ie.kind == 'root_directory':
 
1593
            return
1696
1594
        file_id = ie.file_id
1697
1595
        rev_id = rev.revision_id
1698
1596
        w = self.text_weaves.get(file_id)
1706
1604
                                                  entry_vf=w)
1707
1605
        for old_revision in previous_entries:
1708
1606
                # if this fails, its a ghost ?
1709
 
                assert old_revision in self.converted_revs, \
1710
 
                    "Revision {%s} not in converted_revs" % old_revision
 
1607
                assert old_revision in self.converted_revs 
1711
1608
        self.snapshot_ie(previous_entries, ie, w, rev_id)
1712
1609
        del ie.text_id
1713
1610
        assert getattr(ie, 'revision', None) is not None
1848
1745
        for entry in branch_files:
1849
1746
            self.move_entry('branch', entry)
1850
1747
 
 
1748
        self.step('Upgrading working tree')
 
1749
        self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
 
1750
        self.make_lock('checkout')
 
1751
        self.put_format('checkout', bzrlib.workingtree.WorkingTreeFormat3())
 
1752
        self.bzrdir.transport.delete_multi(self.garbage_inventories, self.pb)
1851
1753
        checkout_files = [('pending-merges', True),
1852
1754
                          ('inventory', True),
1853
1755
                          ('stat-cache', False)]
1854
 
        # If a mandatory checkout file is not present, the branch does not have
1855
 
        # a functional checkout. Do not create a checkout in the converted
1856
 
        # branch.
1857
 
        for name, mandatory in checkout_files:
1858
 
            if mandatory and name not in bzrcontents:
1859
 
                has_checkout = False
1860
 
                break
1861
 
        else:
1862
 
            has_checkout = True
1863
 
        if not has_checkout:
1864
 
            self.pb.note('No working tree.')
1865
 
            # If some checkout files are there, we may as well get rid of them.
1866
 
            for name, mandatory in checkout_files:
1867
 
                if name in bzrcontents:
1868
 
                    self.bzrdir.transport.delete(name)
1869
 
        else:
1870
 
            self.step('Upgrading working tree')
1871
 
            self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
1872
 
            self.make_lock('checkout')
1873
 
            self.put_format(
1874
 
                'checkout', bzrlib.workingtree.WorkingTreeFormat3())
1875
 
            self.bzrdir.transport.delete_multi(
1876
 
                self.garbage_inventories, self.pb)
1877
 
            for entry in checkout_files:
1878
 
                self.move_entry('checkout', entry)
1879
 
            if last_revision is not None:
1880
 
                self.bzrdir._control_files.put_utf8(
1881
 
                    'checkout/last-revision', last_revision)
1882
 
        self.bzrdir._control_files.put_utf8(
1883
 
            'branch-format', BzrDirMetaFormat1().get_format_string())
 
1756
        for entry in checkout_files:
 
1757
            self.move_entry('checkout', entry)
 
1758
        if last_revision is not None:
 
1759
            self.bzrdir._control_files.put_utf8('checkout/last-revision',
 
1760
                                                last_revision)
 
1761
        self.bzrdir._control_files.put_utf8('branch-format', BzrDirMetaFormat1().get_format_string())
1884
1762
        return BzrDir.open(self.bzrdir.root_transport.base)
1885
1763
 
1886
1764
    def make_lock(self, name):
1887
1765
        """Make a lock for the new control dir name."""
1888
1766
        self.step('Make %s lock' % name)
1889
 
        ld = lockdir.LockDir(self.bzrdir.transport,
1890
 
                             '%s/lock' % name,
1891
 
                             file_modebits=self.file_mode,
1892
 
                             dir_modebits=self.dir_mode)
 
1767
        ld = LockDir(self.bzrdir.transport, 
 
1768
                     '%s/lock' % name,
 
1769
                     file_modebits=self.file_mode,
 
1770
                     dir_modebits=self.dir_mode)
1893
1771
        ld.create()
1894
1772
 
1895
1773
    def move_entry(self, new_dir, entry):