/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-23 19:23:14 UTC
  • mfrom: (2446 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2456.
  • Revision ID: john@arbash-meinel.com-20070423192314-y2x7sr7yupacqglk
[merge] bzr.dev 2446

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
    def get_physical_lock_status(self):
196
196
        raise NotImplementedError(self.get_physical_lock_status)
197
197
 
 
198
    def leave_lock_in_place(self):
 
199
        """Tell this branch object not to release the physical lock when this
 
200
        object is unlocked.
 
201
        
 
202
        If lock_write doesn't return a token, then this method is not supported.
 
203
        """
 
204
        self.control_files.leave_in_place()
 
205
 
 
206
    def dont_leave_lock_in_place(self):
 
207
        """Tell this branch object to release the physical lock when this
 
208
        object is unlocked, even if it didn't originally acquire it.
 
209
 
 
210
        If lock_write doesn't return a token, then this method is not supported.
 
211
        """
 
212
        self.control_files.dont_leave_in_place()
 
213
 
198
214
    def abspath(self, name):
199
215
        """Return absolute filename for something in the branch
200
216
        
563
579
 
564
580
    def get_push_location(self):
565
581
        """Return the None or the location to push this branch to."""
566
 
        raise NotImplementedError(self.get_push_location)
 
582
        push_loc = self.get_config().get_user_option('push_location')
 
583
        return push_loc
567
584
 
568
585
    def set_push_location(self, location):
569
586
        """Set a new push location for this branch."""
691
708
 
692
709
    def _get_checkout_format(self):
693
710
        """Return the most suitable metadir for a checkout of this branch.
694
 
        Weaves are used if this branch's repostory uses weaves.
 
711
        Weaves are used if this branch's repository uses weaves.
695
712
        """
696
713
        if isinstance(self.bzrdir, bzrdir.BzrDirPreSplitOut):
697
714
            from bzrlib.repofmt import weaverepo
797
814
        """Return the current default format."""
798
815
        return klass._default_format
799
816
 
 
817
    def get_reference(self, a_bzrdir):
 
818
        """Get the target reference of the branch in a_bzrdir.
 
819
 
 
820
        format probing must have been completed before calling
 
821
        this method - it is assumed that the format of the branch
 
822
        in a_bzrdir is correct.
 
823
 
 
824
        :param a_bzrdir: The bzrdir to get the branch data from.
 
825
        :return: None if the branch is not a reference branch.
 
826
        """
 
827
        return None
 
828
 
800
829
    def get_format_string(self):
801
830
        """Return the ASCII format string that identifies this format."""
802
831
        raise NotImplementedError(self.get_format_string)
1033
1062
        if not _found:
1034
1063
            format = BranchFormat.find_format(a_bzrdir)
1035
1064
            assert format.__class__ == self.__class__
1036
 
        transport = a_bzrdir.get_branch_transport(None)
1037
 
        control_files = lockable_files.LockableFiles(transport, 'lock',
1038
 
                                                     lockdir.LockDir)
1039
 
        return BzrBranch5(_format=self,
1040
 
                          _control_files=control_files,
1041
 
                          a_bzrdir=a_bzrdir,
1042
 
                          _repository=a_bzrdir.find_repository())
 
1065
        try:
 
1066
            transport = a_bzrdir.get_branch_transport(None)
 
1067
            control_files = lockable_files.LockableFiles(transport, 'lock',
 
1068
                                                         lockdir.LockDir)
 
1069
            return BzrBranch5(_format=self,
 
1070
                              _control_files=control_files,
 
1071
                              a_bzrdir=a_bzrdir,
 
1072
                              _repository=a_bzrdir.find_repository())
 
1073
        except NoSuchFile:
 
1074
            raise NotBranchError(path=transport.base)
1043
1075
 
1044
1076
 
1045
1077
class BzrBranchFormat6(BzrBranchFormat5):
1109
1141
        """See BranchFormat.get_format_description()."""
1110
1142
        return "Checkout reference format 1"
1111
1143
        
 
1144
    def get_reference(self, a_bzrdir):
 
1145
        """See BranchFormat.get_reference()."""
 
1146
        transport = a_bzrdir.get_branch_transport(None)
 
1147
        return transport.get('location').read()
 
1148
 
1112
1149
    def initialize(self, a_bzrdir, target_branch=None):
1113
1150
        """Create a branch of this format in a_bzrdir."""
1114
1151
        if target_branch is None:
1136
1173
            # emit some sort of warning/error to the caller ?!
1137
1174
        return clone
1138
1175
 
1139
 
    def open(self, a_bzrdir, _found=False):
 
1176
    def open(self, a_bzrdir, _found=False, location=None):
1140
1177
        """Return the branch that the branch reference in a_bzrdir points at.
1141
1178
 
1142
1179
        _found is a private parameter, do not use it. It is used to indicate
1145
1182
        if not _found:
1146
1183
            format = BranchFormat.find_format(a_bzrdir)
1147
1184
            assert format.__class__ == self.__class__
1148
 
        transport = a_bzrdir.get_branch_transport(None)
1149
 
        real_bzrdir = bzrdir.BzrDir.open(transport.get('location').read())
 
1185
        if location is None:
 
1186
            location = self.get_reference(a_bzrdir)
 
1187
        real_bzrdir = bzrdir.BzrDir.open(location)
1150
1188
        result = real_bzrdir.open_branch()
1151
1189
        # this changes the behaviour of result.clone to create a new reference
1152
1190
        # rather than a copy of the content of the branch.
1223
1261
    def is_locked(self):
1224
1262
        return self.control_files.is_locked()
1225
1263
 
1226
 
    def lock_write(self):
1227
 
        self.repository.lock_write()
 
1264
    def lock_write(self, token=None):
 
1265
        repo_token = self.repository.lock_write()
1228
1266
        try:
1229
 
            self.control_files.lock_write()
 
1267
            token = self.control_files.lock_write(token=token)
1230
1268
        except:
1231
1269
            self.repository.unlock()
1232
1270
            raise
 
1271
        return token
1233
1272
 
1234
1273
    def lock_read(self):
1235
1274
        self.repository.lock_read()
1484
1523
        except errors.InvalidURLJoin, e:
1485
1524
            raise errors.InaccessibleParent(parent, self.base)
1486
1525
 
1487
 
    def get_push_location(self):
1488
 
        """See Branch.get_push_location."""
1489
 
        push_loc = self.get_config().get_user_option('push_location')
1490
 
        return push_loc
1491
 
 
1492
1526
    def set_push_location(self, location):
1493
1527
        """See Branch.set_push_location."""
1494
1528
        self.get_config().set_user_option(
1728
1762
        return "Experimental branch format"
1729
1763
 
1730
1764
    @classmethod
 
1765
    def get_reference(cls, a_bzrdir):
 
1766
        """Get the target reference of the branch in a_bzrdir.
 
1767
 
 
1768
        format probing must have been completed before calling
 
1769
        this method - it is assumed that the format of the branch
 
1770
        in a_bzrdir is correct.
 
1771
 
 
1772
        :param a_bzrdir: The bzrdir to get the branch data from.
 
1773
        :return: None if the branch is not a reference branch.
 
1774
        """
 
1775
        return None
 
1776
 
 
1777
    @classmethod
1731
1778
    def _initialize_control_files(cls, a_bzrdir, utf8_files, lock_filename,
1732
1779
            lock_class):
1733
1780
        branch_transport = a_bzrdir.get_branch_transport(cls)
1965
2012
    easy to identify.
1966
2013
    """
1967
2014
 
1968
 
    def __init__(self, transport_server, transport_readonly_server, formats):
 
2015
    def __init__(self, transport_server, transport_readonly_server, formats,
 
2016
        vfs_transport_factory=None):
1969
2017
        self._transport_server = transport_server
1970
2018
        self._transport_readonly_server = transport_readonly_server
1971
2019
        self._formats = formats