/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: Aaron Bentley
  • Date: 2008-02-24 16:42:13 UTC
  • mfrom: (3234 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3235.
  • Revision ID: aaron@aaronbentley.com-20080224164213-eza1lzru5bwuwmmj
Merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
                                      zero_eight, zero_nine, zero_sixteen,
63
63
                                      zero_ninetyone,
64
64
                                      )
65
 
from bzrlib.trace import mutter, mutter_callsite, note
 
65
from bzrlib.trace import mutter, mutter_callsite, note, is_quiet
66
66
 
67
67
 
68
68
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
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.
1828
1824
        return None
1829
1825
 
1830
1826
 
1831
 
class BzrBranchExperimental(BzrBranch5):
1832
 
    """Bzr experimental branch format
1833
 
 
1834
 
    This format has:
1835
 
     - a revision-history file.
1836
 
     - a format string
1837
 
     - a lock dir guarding the branch itself
1838
 
     - all of this stored in a branch/ subdirectory
1839
 
     - works with shared repositories.
1840
 
     - a tag dictionary in the branch
1841
 
 
1842
 
    This format is new in bzr 0.15, but shouldn't be used for real data, 
1843
 
    only for testing.
1844
 
 
1845
 
    This class acts as it's own BranchFormat.
1846
 
    """
1847
 
 
1848
 
    _matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1849
 
 
1850
 
    @classmethod
1851
 
    def get_format_string(cls):
1852
 
        """See BranchFormat.get_format_string()."""
1853
 
        return "Bazaar-NG branch format experimental\n"
1854
 
 
1855
 
    @classmethod
1856
 
    def get_format_description(cls):
1857
 
        """See BranchFormat.get_format_description()."""
1858
 
        return "Experimental branch format"
1859
 
 
1860
 
    @classmethod
1861
 
    def get_reference(cls, a_bzrdir):
1862
 
        """Get the target reference of the branch in a_bzrdir.
1863
 
 
1864
 
        format probing must have been completed before calling
1865
 
        this method - it is assumed that the format of the branch
1866
 
        in a_bzrdir is correct.
1867
 
 
1868
 
        :param a_bzrdir: The bzrdir to get the branch data from.
1869
 
        :return: None if the branch is not a reference branch.
1870
 
        """
1871
 
        return None
1872
 
 
1873
 
    @classmethod
1874
 
    def set_reference(self, a_bzrdir, to_branch):
1875
 
        """Set the target reference of the branch in a_bzrdir.
1876
 
 
1877
 
        format probing must have been completed before calling
1878
 
        this method - it is assumed that the format of the branch
1879
 
        in a_bzrdir is correct.
1880
 
 
1881
 
        :param a_bzrdir: The bzrdir to set the branch reference for.
1882
 
        :param to_branch: branch that the checkout is to reference
1883
 
        """
1884
 
        raise NotImplementedError(self.set_reference)
1885
 
 
1886
 
    @classmethod
1887
 
    def _initialize_control_files(cls, a_bzrdir, utf8_files, lock_filename,
1888
 
            lock_class):
1889
 
        branch_transport = a_bzrdir.get_branch_transport(cls)
1890
 
        control_files = lockable_files.LockableFiles(branch_transport,
1891
 
            lock_filename, lock_class)
1892
 
        control_files.create_lock()
1893
 
        control_files.lock_write()
1894
 
        try:
1895
 
            for filename, content in utf8_files:
1896
 
                control_files.put_utf8(filename, content)
1897
 
        finally:
1898
 
            control_files.unlock()
1899
 
        
1900
 
    @classmethod
1901
 
    def initialize(cls, a_bzrdir):
1902
 
        """Create a branch of this format in a_bzrdir."""
1903
 
        utf8_files = [('format', cls.get_format_string()),
1904
 
                      ('revision-history', ''),
1905
 
                      ('branch-name', ''),
1906
 
                      ('tags', ''),
1907
 
                      ]
1908
 
        cls._initialize_control_files(a_bzrdir, utf8_files,
1909
 
            'lock', lockdir.LockDir)
1910
 
        return cls.open(a_bzrdir, _found=True)
1911
 
 
1912
 
    @classmethod
1913
 
    def open(cls, a_bzrdir, _found=False):
1914
 
        """Return the branch object for a_bzrdir
1915
 
 
1916
 
        _found is a private parameter, do not use it. It is used to indicate
1917
 
               if format probing has already be done.
1918
 
        """
1919
 
        if not _found:
1920
 
            format = BranchFormat.find_format(a_bzrdir)
1921
 
            assert format.__class__ == cls
1922
 
        transport = a_bzrdir.get_branch_transport(None)
1923
 
        control_files = lockable_files.LockableFiles(transport, 'lock',
1924
 
                                                     lockdir.LockDir)
1925
 
        return cls(_format=cls,
1926
 
            _control_files=control_files,
1927
 
            a_bzrdir=a_bzrdir,
1928
 
            _repository=a_bzrdir.find_repository())
1929
 
 
1930
 
    @classmethod
1931
 
    def is_supported(cls):
1932
 
        return True
1933
 
 
1934
 
    def _make_tags(self):
1935
 
        return BasicTags(self)
1936
 
 
1937
 
    @classmethod
1938
 
    def supports_tags(cls):
1939
 
        return True
1940
 
 
1941
 
 
1942
 
BranchFormat.register_format(BzrBranchExperimental)
1943
 
 
1944
 
 
1945
1827
class BzrBranch6(BzrBranch5):
1946
1828
 
1947
1829
    @needs_read_lock
1952
1834
        revno = int(revno)
1953
1835
        return revno, revision_id
1954
1836
 
1955
 
    def last_revision(self):
1956
 
        """Return last revision id, or None"""
1957
 
        revision_id = self.last_revision_info()[1]
1958
 
        return revision_id
1959
 
 
1960
1837
    def _write_last_revision_info(self, revno, revision_id):
1961
1838
        """Simply write out the revision id, with no checks.
1962
1839
 
2133
2010
        return self.new_revno - self.old_revno
2134
2011
 
2135
2012
    def report(self, to_file):
2136
 
        if self.old_revid == self.new_revid:
2137
 
            to_file.write('No revisions to pull.\n')
2138
 
        else:
2139
 
            to_file.write('Now on revision %d.\n' % self.new_revno)
 
2013
        if not is_quiet():
 
2014
            if self.old_revid == self.new_revid:
 
2015
                to_file.write('No revisions to pull.\n')
 
2016
            else:
 
2017
                to_file.write('Now on revision %d.\n' % self.new_revno)
2140
2018
        self._show_tag_conficts(to_file)
2141
2019
 
2142
2020