/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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib.lazy_import import lazy_import
21
21
lazy_import(globals(), """
22
 
from copy import deepcopy
23
 
from unittest import TestSuite
24
22
from warnings import warn
25
23
 
26
24
import bzrlib
174
172
        return self.get_config().get_nickname()
175
173
 
176
174
    def _set_nick(self, nick):
177
 
        self.get_config().set_user_option('nickname', nick)
 
175
        self.get_config().set_user_option('nickname', nick, warn_masked=True)
178
176
 
179
177
    nick = property(_get_nick, _set_nick)
180
178
 
507
505
 
508
506
    def revision_id_to_revno(self, revision_id):
509
507
        """Given a revision id, return its revno"""
510
 
        if revision_id is None:
 
508
        if _mod_revision.is_null(revision_id):
511
509
            return 0
512
510
        revision_id = osutils.safe_revision_id(revision_id)
513
511
        history = self.revision_history()
586
584
            url = ''
587
585
        elif make_relative:
588
586
            url = urlutils.relative_url(self.base, url)
589
 
        config.set_user_option(name, url)
 
587
        config.set_user_option(name, url, warn_masked=True)
590
588
 
591
589
    def _get_config_location(self, name, config=None):
592
590
        if config is None:
612
610
        pattern is that the user can override it by specifying a
613
611
        location.
614
612
        """
615
 
        self.get_config().set_user_option('submit_branch', location)
 
613
        self.get_config().set_user_option('submit_branch', location,
 
614
            warn_masked=True)
616
615
 
617
616
    def get_public_branch(self):
618
617
        """Return the public location of the branch.
702
701
        :param revision_id: The revision-id to truncate history at.  May
703
702
          be None to copy complete history.
704
703
        """
 
704
        if revision_id == _mod_revision.NULL_REVISION:
 
705
            new_history = []
705
706
        new_history = self.revision_history()
706
 
        if revision_id is not None:
 
707
        if revision_id is not None and new_history != []:
707
708
            revision_id = osutils.safe_revision_id(revision_id)
708
709
            try:
709
710
                new_history = new_history[:new_history.index(revision_id) + 1]
1405
1406
                          other_branch=None):
1406
1407
        # stop_revision must be a descendant of last_revision
1407
1408
        stop_graph = self.repository.get_revision_graph(revision_id)
1408
 
        if last_rev is not None and last_rev not in stop_graph:
 
1409
        if (last_rev is not None and last_rev != _mod_revision.NULL_REVISION
 
1410
            and last_rev not in stop_graph):
1409
1411
            # our previous tip is not merged into stop_revision
1410
1412
            raise errors.DivergedBranches(self, other_branch)
1411
1413
        # make a new revision history from the graph
1450
1452
                stop_revision = osutils.safe_revision_id(stop_revision)
1451
1453
            # whats the current last revision, before we fetch [and change it
1452
1454
            # possibly]
1453
 
            last_rev = self.last_revision()
 
1455
            last_rev = _mod_revision.ensure_null(self.last_revision())
1454
1456
            # we fetch here regardless of whether we need to so that we pickup
1455
1457
            # filled in ghosts.
1456
1458
            self.fetch(other, stop_revision)
1780
1782
        # last_rev is not in the other_last_rev history, AND
1781
1783
        # other_last_rev is not in our history, and do it without pulling
1782
1784
        # history around
1783
 
        last_rev = self.last_revision()
1784
 
        if last_rev is not None:
 
1785
        last_rev = _mod_revision.ensure_null(self.last_revision())
 
1786
        if last_rev != _mod_revision.NULL_REVISION:
1785
1787
            other.lock_read()
1786
1788
            try:
1787
1789
                other_last_rev = other.last_revision()
1788
 
                if other_last_rev is not None:
 
1790
                if not _mod_revision.is_null(other_last_rev):
1789
1791
                    # neither branch is new, we have to do some work to
1790
1792
                    # ascertain diversion.
1791
1793
                    remote_graph = other.repository.get_revision_graph(
1814
1816
        if master is not None:
1815
1817
            old_tip = self.last_revision()
1816
1818
            self.pull(master, overwrite=True)
1817
 
            if old_tip in self.repository.get_ancestry(self.last_revision(),
1818
 
                                                       topo_sorted=False):
 
1819
            if old_tip in self.repository.get_ancestry(
 
1820
                _mod_revision.ensure_null(self.last_revision()),
 
1821
                topo_sorted=False):
1819
1822
                return None
1820
1823
            return old_tip
1821
1824
        return None
1962
1965
        self._clear_cached_state()
1963
1966
 
1964
1967
    def _check_history_violation(self, revision_id):
1965
 
        last_revision = self.last_revision()
1966
 
        if last_revision is None:
 
1968
        last_revision = _mod_revision.ensure_null(self.last_revision())
 
1969
        if _mod_revision.is_null(last_revision):
1967
1970
            return
1968
1971
        if last_revision not in self._lefthand_history(revision_id):
1969
1972
            raise errors.AppendRevisionsOnlyViolation(self.base)
2033
2036
            if config.get_user_option('bound') != 'True':
2034
2037
                return False
2035
2038
            else:
2036
 
                config.set_user_option('bound', 'False')
 
2039
                config.set_user_option('bound', 'False', warn_masked=True)
2037
2040
                return True
2038
2041
        else:
2039
2042
            self._set_config_location('bound_location', location,
2040
2043
                                      config=config)
2041
 
            config.set_user_option('bound', 'True')
 
2044
            config.set_user_option('bound', 'True', warn_masked=True)
2042
2045
        return True
2043
2046
 
2044
2047
    def _get_bound_location(self, bound):
2064
2067
            value = 'True'
2065
2068
        else:
2066
2069
            value = 'False'
2067
 
        self.get_config().set_user_option('append_revisions_only', value)
 
2070
        self.get_config().set_user_option('append_revisions_only', value,
 
2071
            warn_masked=True)
2068
2072
 
2069
2073
    def _get_append_revisions_only(self):
2070
2074
        value = self.get_config().get_user_option('append_revisions_only')
2099
2103
        return BasicTags(self)
2100
2104
 
2101
2105
 
2102
 
class BranchTestProviderAdapter(object):
2103
 
    """A tool to generate a suite testing multiple branch formats at once.
2104
 
 
2105
 
    This is done by copying the test once for each transport and injecting
2106
 
    the transport_server, transport_readonly_server, and branch_format
2107
 
    classes into each copy. Each copy is also given a new id() to make it
2108
 
    easy to identify.
2109
 
    """
2110
 
 
2111
 
    def __init__(self, transport_server, transport_readonly_server, formats,
2112
 
        vfs_transport_factory=None):
2113
 
        self._transport_server = transport_server
2114
 
        self._transport_readonly_server = transport_readonly_server
2115
 
        self._formats = formats
2116
 
    
2117
 
    def adapt(self, test):
2118
 
        result = TestSuite()
2119
 
        for branch_format, bzrdir_format in self._formats:
2120
 
            new_test = deepcopy(test)
2121
 
            new_test.transport_server = self._transport_server
2122
 
            new_test.transport_readonly_server = self._transport_readonly_server
2123
 
            new_test.bzrdir_format = bzrdir_format
2124
 
            new_test.branch_format = branch_format
2125
 
            def make_new_test_id():
2126
 
                # the format can be either a class or an instance
2127
 
                name = getattr(branch_format, '__name__',
2128
 
                        branch_format.__class__.__name__)
2129
 
                new_id = "%s(%s)" % (new_test.id(), name)
2130
 
                return lambda: new_id
2131
 
            new_test.id = make_new_test_id()
2132
 
            result.addTest(new_test)
2133
 
        return result
2134
 
 
2135
 
 
2136
2106
######################################################################
2137
2107
# results of operations
2138
2108