~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-03 06:02:49 UTC
  • mfrom: (5672.1.7 branch-revs-to-fetch)
  • Revision ID: pqm@pqm.ubuntu.com-20110303060249-l2zou9i59742nrqf
(spiv) Add Branch.heads_to_fetch API and HPSS request. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1531
1531
        else:
1532
1532
            raise AssertionError("invalid heads: %r" % (heads,))
1533
1533
 
 
1534
    def heads_to_fetch(self):
 
1535
        """Return the heads that must and that should be fetched to copy this
 
1536
        branch into another repo.
 
1537
 
 
1538
        :returns: a 2-tuple of (must_fetch, if_present_fetch).  must_fetch is a
 
1539
            set of heads that must be fetched.  if_present_fetch is a set of
 
1540
            heads that must be fetched if present, but no error is necessary if
 
1541
            they are not present.
 
1542
        """
 
1543
        # For bzr native formats must_fetch is just the tip, and if_present_fetch
 
1544
        # are the tags.
 
1545
        must_fetch = set([self.last_revision()])
 
1546
        try:
 
1547
            if_present_fetch = set(self.tags.get_reverse_tag_dict())
 
1548
        except errors.TagsNotSupported:
 
1549
            if_present_fetch = set()
 
1550
        must_fetch.discard(_mod_revision.NULL_REVISION)
 
1551
        if_present_fetch.discard(_mod_revision.NULL_REVISION)
 
1552
        return must_fetch, if_present_fetch
 
1553
 
1534
1554
 
1535
1555
class BranchFormat(controldir.ControlComponentFormat):
1536
1556
    """An encapsulation of the initialization and open routines for a format.