/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: Alexander Belchenko
  • Date: 2008-02-20 10:36:15 UTC
  • mfrom: (3228 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3231.
  • Revision ID: bialix@ukr.net-20080220103615-uxw9jc9m6l63ea27
merge bzr.dev; update patch for 1.3

Show diffs side-by-side

added added

removed removed

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