~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2010-05-11 08:44:59 UTC
  • mfrom: (5221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511084459-pb0uinna9zs3wu59
Merge trunk - resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1356
1356
        """
1357
1357
        # XXX: Fix the bzrdir API to allow getting the branch back from the
1358
1358
        # clone call. Or something. 20090224 RBC/spiv.
 
1359
        # XXX: Should this perhaps clone colocated branches as well, 
 
1360
        # rather than just the default branch? 20100319 JRV
1359
1361
        if revision_id is None:
1360
1362
            revision_id = self.last_revision()
1361
1363
        dir_to = self.bzrdir.clone_on_transport(to_transport,
1531
1533
        """Return the current default format."""
1532
1534
        return klass._default_format
1533
1535
 
1534
 
    def get_reference(self, a_bzrdir):
 
1536
    def get_reference(self, a_bzrdir, name=None):
1535
1537
        """Get the target reference of the branch in a_bzrdir.
1536
1538
 
1537
1539
        format probing must have been completed before calling
1539
1541
        in a_bzrdir is correct.
1540
1542
 
1541
1543
        :param a_bzrdir: The bzrdir to get the branch data from.
 
1544
        :param name: Name of the colocated branch to fetch
1542
1545
        :return: None if the branch is not a reference branch.
1543
1546
        """
1544
1547
        return None
1545
1548
 
1546
1549
    @classmethod
1547
 
    def set_reference(self, a_bzrdir, to_branch):
 
1550
    def set_reference(self, a_bzrdir, name, to_branch):
1548
1551
        """Set the target reference of the branch in a_bzrdir.
1549
1552
 
1550
1553
        format probing must have been completed before calling
1552
1555
        in a_bzrdir is correct.
1553
1556
 
1554
1557
        :param a_bzrdir: The bzrdir to set the branch reference for.
 
1558
        :param name: Name of colocated branch to set, None for default
1555
1559
        :param to_branch: branch that the checkout is to reference
1556
1560
        """
1557
1561
        raise NotImplementedError(self.set_reference)
2167
2171
        """See BranchFormat.get_format_description()."""
2168
2172
        return "Checkout reference format 1"
2169
2173
 
2170
 
    def get_reference(self, a_bzrdir):
 
2174
    def get_reference(self, a_bzrdir, name=None):
2171
2175
        """See BranchFormat.get_reference()."""
2172
 
        transport = a_bzrdir.get_branch_transport(None)
 
2176
        transport = a_bzrdir.get_branch_transport(None, name=name)
2173
2177
        return transport.get_bytes('location')
2174
2178
 
2175
 
    def set_reference(self, a_bzrdir, to_branch):
 
2179
    def set_reference(self, a_bzrdir, name, to_branch):
2176
2180
        """See BranchFormat.set_reference()."""
2177
 
        transport = a_bzrdir.get_branch_transport(None)
 
2181
        transport = a_bzrdir.get_branch_transport(None, name=name)
2178
2182
        location = transport.put_bytes('location', to_branch.base)
2179
2183
 
2180
2184
    def initialize(self, a_bzrdir, name=None, target_branch=None):
2231
2235
                raise AssertionError("wrong format %r found for %r" %
2232
2236
                    (format, self))
2233
2237
        if location is None:
2234
 
            location = self.get_reference(a_bzrdir)
 
2238
            location = self.get_reference(a_bzrdir, name)
2235
2239
        real_bzrdir = bzrdir.BzrDir.open(
2236
2240
            location, possible_transports=possible_transports)
2237
2241
        result = real_bzrdir.open_branch(name=name,