/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: 2008-11-13 07:51:02 UTC
  • mto: This revision was merged to the branch mainline in revision 3853.
  • Revision ID: andrew.bennetts@canonical.com-20081113075102-lvpvgrjsavzwbg7a
Get rid of revision_history() call during copy_content_into.

Show diffs side-by-side

added added

removed removed

Lines of Context:
709
709
        """Synchronize last revision and revision history between branches.
710
710
 
711
711
        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.
 
712
        BzrBranch6, but works for BzrBranch5, as long as the destination's
 
713
        repository contains all the lefthand ancestors of the intended
 
714
        last_revision.  If not, set_last_revision_info will fail.
716
715
 
717
716
        :param destination: The branch to copy the history into
718
717
        :param revision_id: The revision-id to truncate history at.  May
719
718
          be None to copy complete history.
720
719
        """
721
 
        if revision_id == _mod_revision.NULL_REVISION:
722
 
            new_history = []
 
720
        source_revno, source_revision_id = self.last_revision_info()
 
721
        if revision_id is None:
 
722
            revno, revision_id = source_revno, source_revision_id
 
723
        elif source_revision_id == revision_id:
 
724
            # we know the revno without needing to walk all of history
 
725
            revno = source_revno
723
726
        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
 
 
 
727
            # To figure out the revno for a random revision, we need to build
 
728
            # the revision history, and count its length.
 
729
            # We don't care about the order, just how long it is.
 
730
            # Alternatively, we could start at the current location, and count
 
731
            # backwards. But there is no guarantee that we will find it since
 
732
            # it may be a merged revision.
 
733
            revno = len(list(self.repository.iter_reverse_revision_history(
 
734
                                                                revision_id)))
 
735
        destination.set_last_revision_info(revno, revision_id)
 
736
    
733
737
    @needs_read_lock
734
738
    def copy_content_into(self, destination, revision_id=None):
735
739
        """Copy the content of self into destination.
2252
2256
        value = self.get_config().get_user_option('append_revisions_only')
2253
2257
        return value == 'True'
2254
2258
 
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
2259
    def _make_tags(self):
2285
2260
        return BasicTags(self)
2286
2261