/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: 2009-06-17 03:53:51 UTC
  • mto: This revision was merged to the branch mainline in revision 4452.
  • Revision ID: andrew.bennetts@canonical.com-20090617035351-09mh070abzv68feu
Move check onto base Branch class, and add a supports_set_append_revisions_only method to BranchFormat, as suggested by Robert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
520
520
        """
521
521
        raise errors.UpgradeRequired(self.base)
522
522
 
 
523
    def set_append_revisions_only(self, enabled):
 
524
        if not self._format.supports_set_append_revisions_only():
 
525
            raise errors.UpgradeRequired(self.base)
 
526
        if enabled:
 
527
            value = 'True'
 
528
        else:
 
529
            value = 'False'
 
530
        self.get_config().set_user_option('append_revisions_only', value,
 
531
            warn_masked=True)
 
532
 
523
533
    def set_reference_info(self, file_id, tree_path, branch_location):
524
534
        """Set the branch location to use for a tree reference."""
525
535
        raise errors.UnsupportedOperation(self.set_reference_info, self)
766
776
        """Older format branches cannot bind or unbind."""
767
777
        raise errors.UpgradeRequired(self.base)
768
778
 
769
 
    def set_append_revisions_only(self, enabled):
770
 
        """Older format branches are never restricted to append-only"""
771
 
        raise errors.UpgradeRequired(self.base)
772
 
 
773
779
    def last_revision(self):
774
780
        """Return last revision id, or NULL_REVISION."""
775
781
        return self.last_revision_info()[1]
1378
1384
    _formats = {}
1379
1385
    """The known formats."""
1380
1386
 
 
1387
    can_set_append_revisions_only = True
 
1388
 
1381
1389
    def __eq__(self, other):
1382
1390
        return self.__class__ is other.__class__
1383
1391
 
1536
1544
    def set_default_format(klass, format):
1537
1545
        klass._default_format = format
1538
1546
 
 
1547
    def supports_set_append_revisions_only(self):
 
1548
        """True if this format supports set_append_revisions_only."""
 
1549
        return False
 
1550
 
1539
1551
    def supports_stacking(self):
1540
1552
        """True if this format records a stacked-on branch."""
1541
1553
        return False
1823
1835
        """See bzrlib.branch.BranchFormat.make_tags()."""
1824
1836
        return BasicTags(branch)
1825
1837
 
 
1838
    def supports_set_append_revisions_only(self):
 
1839
        return True
1826
1840
 
1827
1841
 
1828
1842
class BzrBranchFormat8(BranchFormatMetadir):
1857
1871
        """See bzrlib.branch.BranchFormat.make_tags()."""
1858
1872
        return BasicTags(branch)
1859
1873
 
 
1874
    def supports_set_append_revisions_only(self):
 
1875
        return True
 
1876
 
1860
1877
    def supports_stacking(self):
1861
1878
        return True
1862
1879
 
1891
1908
        """See BranchFormat.get_format_description()."""
1892
1909
        return "Branch format 7"
1893
1910
 
 
1911
    def supports_set_append_revisions_only(self):
 
1912
        return True
 
1913
 
1894
1914
    supports_reference_locations = False
1895
1915
 
1896
1916
 
2619
2639
            raise errors.NotStacked(self)
2620
2640
        return stacked_url
2621
2641
 
2622
 
    def set_append_revisions_only(self, enabled):
2623
 
        if enabled:
2624
 
            value = 'True'
2625
 
        else:
2626
 
            value = 'False'
2627
 
        self.get_config().set_user_option('append_revisions_only', value,
2628
 
            warn_masked=True)
2629
 
 
2630
2642
    def _get_append_revisions_only(self):
2631
2643
        value = self.get_config().get_user_option('append_revisions_only')
2632
2644
        return value == 'True'