~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Martin Pool
  • Date: 2006-03-08 07:55:41 UTC
  • mto: This revision was merged to the branch mainline in revision 1602.
  • Revision ID: mbp@sourcefrog.net-20060308075541-c0c015c8d40cad69
BzrDirFormat subclasses can now control what kind of overall lock is used.

meta-1 split out bzr dirs now use a LockDir as the top-level lock

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import bzrlib
29
29
import bzrlib.errors as errors
30
30
from bzrlib.lockable_files import LockableFiles, TransportLock
 
31
from bzrlib.lockdir import LockDir
31
32
from bzrlib.osutils import safe_unicode
32
33
from bzrlib.osutils import (
33
34
                            abspath,
535
536
    def __init__(self, _transport, _format):
536
537
        """See BzrDir.__init__."""
537
538
        super(BzrDirPreSplitOut, self).__init__(_transport, _format)
 
539
        assert self._format._lock_class == TransportLock
 
540
        assert self._format._lock_file_name == 'branch-lock'
538
541
        self._control_files = LockableFiles(self.get_branch_transport(None),
539
 
                                            'branch-lock',
540
 
                                            TransportLock)
 
542
                                            self._format._lock_file_name,
 
543
                                            self._format._lock_class)
541
544
 
542
545
    def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
543
546
        """See BzrDir.clone()."""
828
831
    _formats = {}
829
832
    """The known formats."""
830
833
 
 
834
    _lock_file_name = 'branch-lock'
 
835
 
 
836
    # _lock_class must be set in subclasses to the lock type, typ.
 
837
    # TransportLock or LockDir
 
838
 
831
839
    @classmethod
832
840
    def find_format(klass, transport):
833
841
        """Return the format registered for URL."""
876
884
        del temp_control
877
885
        mutter('created control directory in ' + t.base)
878
886
        control = t.clone('.bzr')
879
 
        lock_file = 'branch-lock'
880
887
        utf8_files = [('README', 
881
888
                       "This is a Bazaar-NG control directory.\n"
882
889
                       "Do not change any files in this directory.\n"),
883
890
                      ('branch-format', self.get_format_string()),
884
891
                      ]
885
892
        # NB: no need to escape relative paths that are url safe.
886
 
        control_files = LockableFiles(control, lock_file, TransportLock)
 
893
        control_files = LockableFiles(control, self._lock_file_name, self._lock_class)
887
894
        control_files.create_lock()
888
895
        control_files.lock_write()
889
896
        try:
950
957
    removed in format 5; write support for this format has been removed.
951
958
    """
952
959
 
 
960
    _lock_class = TransportLock
 
961
 
953
962
    def get_format_string(self):
954
963
        """See BzrDirFormat.get_format_string()."""
955
964
        return "Bazaar-NG branch, format 0.0.4\n"
994
1003
       Unhashed stores in the repository.
995
1004
    """
996
1005
 
 
1006
    _lock_class = TransportLock
 
1007
 
997
1008
    def get_format_string(self):
998
1009
        """See BzrDirFormat.get_format_string()."""
999
1010
        return "Bazaar-NG branch, format 5\n"
1039
1050
     - Format 6 repositories [always]
1040
1051
    """
1041
1052
 
 
1053
    _lock_class = TransportLock
 
1054
 
1042
1055
    def get_format_string(self):
1043
1056
        """See BzrDirFormat.get_format_string()."""
1044
1057
        return "Bazaar-NG branch, format 6\n"
1090
1103
     - Format 7 repositories [optional]
1091
1104
    """
1092
1105
 
 
1106
    _lock_class = LockDir
 
1107
 
1093
1108
    def get_converter(self, format=None):
1094
1109
        """See BzrDirFormat.get_converter()."""
1095
1110
        if format is None: