/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: Andrew Bennetts
  • Date: 2008-02-07 03:47:24 UTC
  • mfrom: (3218 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3220.
  • Revision ID: andrew.bennetts@canonical.com-20080207034724-p3zhr7zp9kow4nax
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1820
1820
        return None
1821
1821
 
1822
1822
 
1823
 
class BzrBranchExperimental(BzrBranch5):
1824
 
    """Bzr experimental branch format
1825
 
 
1826
 
    This format has:
1827
 
     - a revision-history file.
1828
 
     - a format string
1829
 
     - a lock dir guarding the branch itself
1830
 
     - all of this stored in a branch/ subdirectory
1831
 
     - works with shared repositories.
1832
 
     - a tag dictionary in the branch
1833
 
 
1834
 
    This format is new in bzr 0.15, but shouldn't be used for real data, 
1835
 
    only for testing.
1836
 
 
1837
 
    This class acts as it's own BranchFormat.
1838
 
    """
1839
 
 
1840
 
    _matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1841
 
 
1842
 
    @classmethod
1843
 
    def get_format_string(cls):
1844
 
        """See BranchFormat.get_format_string()."""
1845
 
        return "Bazaar-NG branch format experimental\n"
1846
 
 
1847
 
    @classmethod
1848
 
    def get_format_description(cls):
1849
 
        """See BranchFormat.get_format_description()."""
1850
 
        return "Experimental branch format"
1851
 
 
1852
 
    @classmethod
1853
 
    def get_reference(cls, a_bzrdir):
1854
 
        """Get the target reference of the branch in a_bzrdir.
1855
 
 
1856
 
        format probing must have been completed before calling
1857
 
        this method - it is assumed that the format of the branch
1858
 
        in a_bzrdir is correct.
1859
 
 
1860
 
        :param a_bzrdir: The bzrdir to get the branch data from.
1861
 
        :return: None if the branch is not a reference branch.
1862
 
        """
1863
 
        return None
1864
 
 
1865
 
    @classmethod
1866
 
    def set_reference(self, a_bzrdir, to_branch):
1867
 
        """Set the target reference of the branch in a_bzrdir.
1868
 
 
1869
 
        format probing must have been completed before calling
1870
 
        this method - it is assumed that the format of the branch
1871
 
        in a_bzrdir is correct.
1872
 
 
1873
 
        :param a_bzrdir: The bzrdir to set the branch reference for.
1874
 
        :param to_branch: branch that the checkout is to reference
1875
 
        """
1876
 
        raise NotImplementedError(self.set_reference)
1877
 
 
1878
 
    @classmethod
1879
 
    def _initialize_control_files(cls, a_bzrdir, utf8_files, lock_filename,
1880
 
            lock_class):
1881
 
        branch_transport = a_bzrdir.get_branch_transport(cls)
1882
 
        control_files = lockable_files.LockableFiles(branch_transport,
1883
 
            lock_filename, lock_class)
1884
 
        control_files.create_lock()
1885
 
        control_files.lock_write()
1886
 
        try:
1887
 
            for filename, content in utf8_files:
1888
 
                control_files.put_utf8(filename, content)
1889
 
        finally:
1890
 
            control_files.unlock()
1891
 
        
1892
 
    @classmethod
1893
 
    def initialize(cls, a_bzrdir):
1894
 
        """Create a branch of this format in a_bzrdir."""
1895
 
        utf8_files = [('format', cls.get_format_string()),
1896
 
                      ('revision-history', ''),
1897
 
                      ('branch-name', ''),
1898
 
                      ('tags', ''),
1899
 
                      ]
1900
 
        cls._initialize_control_files(a_bzrdir, utf8_files,
1901
 
            'lock', lockdir.LockDir)
1902
 
        return cls.open(a_bzrdir, _found=True)
1903
 
 
1904
 
    @classmethod
1905
 
    def open(cls, a_bzrdir, _found=False):
1906
 
        """Return the branch object for a_bzrdir
1907
 
 
1908
 
        _found is a private parameter, do not use it. It is used to indicate
1909
 
               if format probing has already be done.
1910
 
        """
1911
 
        if not _found:
1912
 
            format = BranchFormat.find_format(a_bzrdir)
1913
 
            assert format.__class__ == cls
1914
 
        transport = a_bzrdir.get_branch_transport(None)
1915
 
        control_files = lockable_files.LockableFiles(transport, 'lock',
1916
 
                                                     lockdir.LockDir)
1917
 
        return cls(_format=cls,
1918
 
            _control_files=control_files,
1919
 
            a_bzrdir=a_bzrdir,
1920
 
            _repository=a_bzrdir.find_repository())
1921
 
 
1922
 
    @classmethod
1923
 
    def is_supported(cls):
1924
 
        return True
1925
 
 
1926
 
    def _make_tags(self):
1927
 
        return BasicTags(self)
1928
 
 
1929
 
    @classmethod
1930
 
    def supports_tags(cls):
1931
 
        return True
1932
 
 
1933
 
 
1934
 
BranchFormat.register_format(BzrBranchExperimental)
1935
 
 
1936
 
 
1937
1823
class BzrBranch6(BzrBranch5):
1938
1824
 
1939
1825
    @needs_read_lock