~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
502
502
        """Return the ASCII format string that identifies this format."""
503
503
        raise NotImplementedError(self.get_format_string)
504
504
 
505
 
    def _find_modes(self, t):
506
 
        """Determine the appropriate modes for files and directories.
507
 
        
508
 
        FIXME: When this merges into, or from storage,
509
 
        this code becomes delgatable to a LockableFiles instance.
510
 
 
511
 
        For now its cribbed and returns (dir_mode, file_mode)
512
 
        """
513
 
        try:
514
 
            st = t.stat('.')
515
 
        except errors.TransportNotPossible:
516
 
            dir_mode = 0755
517
 
            file_mode = 0644
518
 
        else:
519
 
            dir_mode = st.st_mode & 07777
520
 
            # Remove the sticky and execute bits for files
521
 
            file_mode = dir_mode & ~07111
522
 
        if not BzrBranch._set_dir_mode:
523
 
            dir_mode = None
524
 
        if not BzrBranch._set_file_mode:
525
 
            file_mode = None
526
 
        return dir_mode, file_mode
527
 
 
528
505
    def initialize(self, a_bzrdir):
529
506
        """Create a branch of this format in a_bzrdir."""
530
507
        raise NotImplementedError(self.initialized)
597
574
        if not _found:
598
575
            # we are being called directly and must probe.
599
576
            raise NotImplementedError
600
 
        transport = a_bzrdir.get_branch_transport(self)
601
 
        control_files = LockableFiles(transport, 'branch-lock')
602
577
        return BzrBranch(_format=self,
603
 
                         _control_files=control_files,
604
 
                         a_bzrdir=a_bzrdir)
 
578
                         _control_files=a_bzrdir._control_files,
 
579
                         a_bzrdir=a_bzrdir,
 
580
                         _repository=a_bzrdir.open_repository())
605
581
 
606
582
 
607
583
class BzrBranchFormat5(BranchFormat):
610
586
    This format has:
611
587
     - a revision-history file.
612
588
     - a format string
613
 
     - a lock lock file.
 
589
     - a lock file.
 
590
     - works with shared repositories.
614
591
    """
615
592
 
616
593
    def get_format_string(self):
654
631
        control_files = LockableFiles(transport, 'lock')
655
632
        return BzrBranch(_format=self,
656
633
                         _control_files=control_files,
657
 
                         a_bzrdir=a_bzrdir)
 
634
                         a_bzrdir=a_bzrdir,
 
635
                         _repository=a_bzrdir.find_repository())
658
636
 
659
637
 
660
638
class BranchReferenceFormat(BranchFormat):
752
730
 
753
731
    def __init__(self, transport=DEPRECATED_PARAMETER, init=DEPRECATED_PARAMETER,
754
732
                 relax_version_check=DEPRECATED_PARAMETER, _format=None,
755
 
                 _control_files=None, a_bzrdir=None):
 
733
                 _control_files=None, a_bzrdir=None, _repository=None):
756
734
        """Create new branch object at a particular location.
757
735
 
758
736
        transport -- A Transport object, defining how to access files.
806
784
                 "Please use Branch.open, or bzrdir.open_branch().",
807
785
                 DeprecationWarning,
808
786
                 stacklevel=2)
809
 
        # TODO change this to search upwards if needed.
810
 
        self.repository = self.bzrdir.open_repository()
 
787
        self.repository = _repository
811
788
 
812
789
    def __str__(self):
813
790
        return '%s(%r)' % (self.__class__.__name__, self.base)