/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: 2010-03-26 04:47:45 UTC
  • mfrom: (5116 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5117.
  • Revision ID: andrew.bennetts@canonical.com-20100326044745-ubvt5tmse1a17s1f
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1366
1366
    def supports_tags(self):
1367
1367
        return self._format.supports_tags()
1368
1368
 
 
1369
    def automatic_tag_name(self, revision_id):
 
1370
        """Try to automatically find the tag name for a revision.
 
1371
 
 
1372
        :param revision_id: Revision id of the revision.
 
1373
        :return: A tag name or None if no tag name could be determined.
 
1374
        """
 
1375
        for hook in Branch.hooks['automatic_tag_name']:
 
1376
            ret = hook(self, revision_id)
 
1377
            if ret is not None:
 
1378
                return ret
 
1379
        return None
 
1380
 
1369
1381
    def _check_if_descendant_or_diverged(self, revision_a, revision_b, graph,
1370
1382
                                         other_branch):
1371
1383
        """Ensure that revision_b is a descendant of revision_a.
1685
1697
            "multiple hooks installed for transform_fallback_location, "
1686
1698
            "all are called with the url returned from the previous hook."
1687
1699
            "The order is however undefined.", (1, 9), None))
 
1700
        self.create_hook(HookPoint('automatic_tag_name',
 
1701
            "Called to determine an automatic tag name for a revision."
 
1702
            "automatic_tag_name is called with (branch, revision_id) and "
 
1703
            "should return a tag name or None if no tag name could be "
 
1704
            "determined. The first non-None tag name returned will be used.",
 
1705
            (2, 2), None))
 
1706
 
1688
1707
 
1689
1708
 
1690
1709
# install the default hooks into the Branch class.
1759
1778
 
1760
1779
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
1761
1780
        """See BranchFormat.open()."""
1762
 
        if name is not None:
1763
 
            raise errors.NoColocatedBranchSupport(a_bzrdir)
1764
1781
        if not _found:
1765
1782
            # we are being called directly and must probe.
1766
1783
            raise NotImplementedError
1767
1784
        return BzrBranch(_format=self,
1768
1785
                         _control_files=a_bzrdir._control_files,
1769
1786
                         a_bzrdir=a_bzrdir,
 
1787
                         name=name,
1770
1788
                         _repository=a_bzrdir.open_repository())
1771
1789
 
1772
1790
    def __str__(self):
1800
1818
                                                         lockdir.LockDir)
1801
1819
            return self._branch_class()(_format=self,
1802
1820
                              _control_files=control_files,
 
1821
                              name=name,
1803
1822
                              a_bzrdir=a_bzrdir,
1804
1823
                              _repository=a_bzrdir.find_repository(),
1805
1824
                              ignore_fallbacks=ignore_fallbacks)
2100
2119
    :ivar repository: Repository for this branch.
2101
2120
    :ivar base: The url of the base directory for this branch; the one
2102
2121
        containing the .bzr directory.
 
2122
    :ivar name: Optional colocated branch name as it exists in the control
 
2123
        directory.
2103
2124
    """
2104
2125
 
2105
2126
    def __init__(self, _format=None,
2106
 
                 _control_files=None, a_bzrdir=None, _repository=None,
2107
 
                 ignore_fallbacks=False):
 
2127
                 _control_files=None, a_bzrdir=None, name=None,
 
2128
                 _repository=None, ignore_fallbacks=False):
2108
2129
        """Create new branch object at a particular location."""
2109
2130
        if a_bzrdir is None:
2110
2131
            raise ValueError('a_bzrdir must be supplied')
2111
2132
        else:
2112
2133
            self.bzrdir = a_bzrdir
2113
2134
        self._base = self.bzrdir.transport.clone('..').base
 
2135
        self.name = name
2114
2136
        # XXX: We should be able to just do
2115
2137
        #   self.base = self.bzrdir.root_transport.base
2116
2138
        # but this does not quite work yet -- mbp 20080522
2123
2145
        Branch.__init__(self)
2124
2146
 
2125
2147
    def __str__(self):
2126
 
        return '%s(%r)' % (self.__class__.__name__, self.base)
 
2148
        if self.name is None:
 
2149
            return '%s(%r)' % (self.__class__.__name__, self.base)
 
2150
        else:
 
2151
            return '%s(%r,%r)' % (self.__class__.__name__, self.base, self.name)
2127
2152
 
2128
2153
    __repr__ = __str__
2129
2154