/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@3883

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
    def get_config(self):
149
149
        return BranchConfig(self)
150
150
 
151
 
    def _get_nick(self, possible_transports=None):
 
151
    def _get_nick(self, local=False, possible_transports=None):
152
152
        config = self.get_config()
153
 
        if not config.has_explicit_nickname(): # explicit overrides master
 
153
        # explicit overrides master, but don't look for master if local is True
 
154
        if not local and not config.has_explicit_nickname():
154
155
            try:
155
156
                master = self.get_master_branch(possible_transports)
156
157
                if master is not None:
157
158
                    # return the master branch value
158
 
                    config = master.get_config()
 
159
                    return master.nick
159
160
            except errors.BzrError, e:
160
161
                # Silently fall back to local implicit nick if the master is
161
162
                # unavailable
709
710
        """Synchronize last revision and revision history between branches.
710
711
 
711
712
        This version is most efficient when the destination is also a
712
 
        BzrBranch5, but works for BzrBranch6 as long as the revision
713
 
        history is the true lefthand parent history, and all of the revisions
714
 
        are in the destination's repository.  If not, set_revision_history
715
 
        will fail.
 
713
        BzrBranch6, but works for BzrBranch5, as long as the destination's
 
714
        repository contains all the lefthand ancestors of the intended
 
715
        last_revision.  If not, set_last_revision_info will fail.
716
716
 
717
717
        :param destination: The branch to copy the history into
718
718
        :param revision_id: The revision-id to truncate history at.  May
719
719
          be None to copy complete history.
720
720
        """
721
 
        if revision_id == _mod_revision.NULL_REVISION:
722
 
            new_history = []
 
721
        source_revno, source_revision_id = self.last_revision_info()
 
722
        if revision_id is None:
 
723
            revno, revision_id = source_revno, source_revision_id
 
724
        elif source_revision_id == revision_id:
 
725
            # we know the revno without needing to walk all of history
 
726
            revno = source_revno
723
727
        else:
724
 
            new_history = self.revision_history()
725
 
        if revision_id is not None and new_history != []:
726
 
            try:
727
 
                new_history = new_history[:new_history.index(revision_id) + 1]
728
 
            except ValueError:
729
 
                rev = self.repository.get_revision(revision_id)
730
 
                new_history = rev.get_history(self.repository)[1:]
731
 
        destination.set_revision_history(new_history)
732
 
 
 
728
            # To figure out the revno for a random revision, we need to build
 
729
            # the revision history, and count its length.
 
730
            # We don't care about the order, just how long it is.
 
731
            # Alternatively, we could start at the current location, and count
 
732
            # backwards. But there is no guarantee that we will find it since
 
733
            # it may be a merged revision.
 
734
            revno = len(list(self.repository.iter_reverse_revision_history(
 
735
                                                                revision_id)))
 
736
        destination.set_last_revision_info(revno, revision_id)
 
737
    
733
738
    @needs_read_lock
734
739
    def copy_content_into(self, destination, revision_id=None):
735
740
        """Copy the content of self into destination.
1264
1269
    def __init__(self):
1265
1270
        super(BranchFormatMetadir, self).__init__()
1266
1271
        self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
 
1272
        self._matchingbzrdir.set_branch_format(self)
1267
1273
 
1268
1274
    def supports_tags(self):
1269
1275
        return True
1419
1425
    def __init__(self):
1420
1426
        super(BranchReferenceFormat, self).__init__()
1421
1427
        self._matchingbzrdir = bzrdir.BzrDirMetaFormat1()
 
1428
        self._matchingbzrdir.set_branch_format(self)
1422
1429
 
1423
1430
    def _make_reference_clone_function(format, a_branch):
1424
1431
        """Create a clone() routine for a branch dynamically."""
1594
1601
        if Branch.hooks['post_change_branch_tip']:
1595
1602
            self._run_post_change_branch_tip_hooks(old_revno, old_revid)
1596
1603
 
 
1604
    def _synchronize_history(self, destination, revision_id):
 
1605
        """Synchronize last revision and revision history between branches.
 
1606
 
 
1607
        This version is most efficient when the destination is also a
 
1608
        BzrBranch5, but works for BzrBranch6 as long as the revision
 
1609
        history is the true lefthand parent history, and all of the revisions
 
1610
        are in the destination's repository.  If not, set_revision_history
 
1611
        will fail.
 
1612
 
 
1613
        :param destination: The branch to copy the history into
 
1614
        :param revision_id: The revision-id to truncate history at.  May
 
1615
          be None to copy complete history.
 
1616
        """
 
1617
        if revision_id == _mod_revision.NULL_REVISION:
 
1618
            new_history = []
 
1619
        else:
 
1620
            new_history = self.revision_history()
 
1621
        if revision_id is not None and new_history != []:
 
1622
            try:
 
1623
                new_history = new_history[:new_history.index(revision_id) + 1]
 
1624
            except ValueError:
 
1625
                rev = self.repository.get_revision(revision_id)
 
1626
                new_history = rev.get_history(self.repository)[1:]
 
1627
        destination.set_revision_history(new_history)
 
1628
 
1597
1629
    def _run_pre_change_branch_tip_hooks(self, new_revno, new_revid):
1598
1630
        """Run the pre_change_branch_tip hooks."""
1599
1631
        hooks = Branch.hooks['pre_change_branch_tip']
2098
2130
        self._last_revision_info_cache = revno, revision_id
2099
2131
        self._run_post_change_branch_tip_hooks(old_revno, old_revid)
2100
2132
 
 
2133
    def _synchronize_history(self, destination, revision_id):
 
2134
        """Synchronize last revision and revision history between branches.
 
2135
        
 
2136
        :see: Branch._synchronize_history
 
2137
        """
 
2138
        # XXX: The base Branch has a fast implementation of this method based
 
2139
        # on set_last_revision_info, but BzrBranch/BzrBranch5 have a slower one
 
2140
        # that uses set_revision_history.  This class inherits from BzrBranch5,
 
2141
        # but wants the fast implementation, so it calls
 
2142
        # Branch._synchronize_history directly.
 
2143
        Branch._synchronize_history(self, destination, revision_id)
 
2144
 
2101
2145
    def _check_history_violation(self, revision_id):
2102
2146
        last_revision = _mod_revision.ensure_null(self.last_revision())
2103
2147
        if _mod_revision.is_null(last_revision):
2252
2296
        value = self.get_config().get_user_option('append_revisions_only')
2253
2297
        return value == 'True'
2254
2298
 
2255
 
    def _synchronize_history(self, destination, revision_id):
2256
 
        """Synchronize last revision and revision history between branches.
2257
 
 
2258
 
        This version is most efficient when the destination is also a
2259
 
        BzrBranch6, but works for BzrBranch5, as long as the destination's
2260
 
        repository contains all the lefthand ancestors of the intended
2261
 
        last_revision.  If not, set_last_revision_info will fail.
2262
 
 
2263
 
        :param destination: The branch to copy the history into
2264
 
        :param revision_id: The revision-id to truncate history at.  May
2265
 
          be None to copy complete history.
2266
 
        """
2267
 
        source_revno, source_revision_id = self.last_revision_info()
2268
 
        if revision_id is None:
2269
 
            revno, revision_id = source_revno, source_revision_id
2270
 
        elif source_revision_id == revision_id:
2271
 
            # we know the revno without needing to walk all of history
2272
 
            revno = source_revno
2273
 
        else:
2274
 
            # To figure out the revno for a random revision, we need to build
2275
 
            # the revision history, and count its length.
2276
 
            # We don't care about the order, just how long it is.
2277
 
            # Alternatively, we could start at the current location, and count
2278
 
            # backwards. But there is no guarantee that we will find it since
2279
 
            # it may be a merged revision.
2280
 
            revno = len(list(self.repository.iter_reverse_revision_history(
2281
 
                                                                revision_id)))
2282
 
        destination.set_last_revision_info(revno, revision_id)
2283
 
 
2284
2299
    def _make_tags(self):
2285
2300
        return BasicTags(self)
2286
2301