~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Joe Julian
  • Date: 2010-01-10 02:25:31 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: joe@julianfamily.org-20100110022531-wqk61rsagz8xsiga
Added MANIFEST.in to allow bdist_rpm to have all the required include files and tools. bdist_rpm will still fail to build correctly on some distributions due to a disttools bug http://bugs.python.org/issue644744

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    )
47
47
""")
48
48
 
49
 
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
 
49
from bzrlib.decorators import needs_read_lock, needs_write_lock
50
50
from bzrlib.hooks import HookPoint, Hooks
51
51
from bzrlib.inter import InterObject
52
 
from bzrlib.lock import _RelockDebugMixin
53
52
from bzrlib import registry
54
53
from bzrlib.symbol_versioning import (
55
54
    deprecated_in,
503
502
                left_parent = stop_rev.parent_ids[0]
504
503
            else:
505
504
                left_parent = _mod_revision.NULL_REVISION
506
 
            # left_parent is the actual revision we want to stop logging at,
507
 
            # since we want to show the merged revisions after the stop_rev too
508
 
            reached_stop_revision_id = False
509
 
            revision_id_whitelist = []
510
505
            for node in rev_iter:
511
506
                rev_id = node.key[-1]
512
507
                if rev_id == left_parent:
513
 
                    # reached the left parent after the stop_revision
514
508
                    return
515
 
                if (not reached_stop_revision_id or
516
 
                        rev_id in revision_id_whitelist):
517
 
                    yield (rev_id, node.merge_depth, node.revno,
 
509
                yield (rev_id, node.merge_depth, node.revno,
518
510
                       node.end_of_merge)
519
 
                    if reached_stop_revision_id or rev_id == stop_revision_id:
520
 
                        # only do the merged revs of rev_id from now on
521
 
                        rev = self.repository.get_revision(rev_id)
522
 
                        if rev.parent_ids:
523
 
                            reached_stop_revision_id = True
524
 
                            revision_id_whitelist.extend(rev.parent_ids)
525
511
        else:
526
512
            raise ValueError('invalid stop_rule %r' % stop_rule)
527
513
 
1103
1089
        params = ChangeBranchTipParams(
1104
1090
            self, old_revno, new_revno, old_revid, new_revid)
1105
1091
        for hook in hooks:
1106
 
            hook(params)
 
1092
            try:
 
1093
                hook(params)
 
1094
            except errors.TipChangeRejected:
 
1095
                raise
 
1096
            except Exception:
 
1097
                exc_info = sys.exc_info()
 
1098
                hook_name = Branch.hooks.get_hook_name(hook)
 
1099
                raise errors.HookFailed(
 
1100
                    'pre_change_branch_tip', hook_name, exc_info)
1107
1101
 
1108
1102
    @needs_write_lock
1109
1103
    def update(self):
1438
1432
        """Return the format for the branch object in a_bzrdir."""
1439
1433
        try:
1440
1434
            transport = a_bzrdir.get_branch_transport(None)
1441
 
            format_string = transport.get_bytes("format")
 
1435
            format_string = transport.get("format").read()
1442
1436
            return klass._formats[format_string]
1443
1437
        except errors.NoSuchFile:
1444
 
            raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
 
1438
            raise errors.NotBranchError(path=transport.base)
1445
1439
        except KeyError:
1446
1440
            raise errors.UnknownFormatError(format=format_string, kind='branch')
1447
1441
 
1796
1790
                              _repository=a_bzrdir.find_repository(),
1797
1791
                              ignore_fallbacks=ignore_fallbacks)
1798
1792
        except errors.NoSuchFile:
1799
 
            raise errors.NotBranchError(path=transport.base, bzrdir=a_bzrdir)
 
1793
            raise errors.NotBranchError(path=transport.base)
1800
1794
 
1801
1795
    def __init__(self):
1802
1796
        super(BranchFormatMetadir, self).__init__()
1977
1971
    def get_reference(self, a_bzrdir):
1978
1972
        """See BranchFormat.get_reference()."""
1979
1973
        transport = a_bzrdir.get_branch_transport(None)
1980
 
        return transport.get_bytes('location')
 
1974
        return transport.get('location').read()
1981
1975
 
1982
1976
    def set_reference(self, a_bzrdir, to_branch):
1983
1977
        """See BranchFormat.set_reference()."""
2078
2072
    _legacy_formats[0].network_name(), _legacy_formats[0].__class__)
2079
2073
 
2080
2074
 
2081
 
class BzrBranch(Branch, _RelockDebugMixin):
 
2075
class BzrBranch(Branch):
2082
2076
    """A branch stored in the actual filesystem.
2083
2077
 
2084
2078
    Note that it's "local" in the context of the filesystem; it doesn't
2130
2124
        return self.control_files.is_locked()
2131
2125
 
2132
2126
    def lock_write(self, token=None):
2133
 
        if not self.is_locked():
2134
 
            self._note_lock('w')
2135
2127
        # All-in-one needs to always unlock/lock.
2136
2128
        repo_control = getattr(self.repository, 'control_files', None)
2137
2129
        if self.control_files == repo_control or not self.is_locked():
2138
 
            self.repository._warn_if_deprecated(self)
2139
2130
            self.repository.lock_write()
2140
2131
            took_lock = True
2141
2132
        else:
2148
2139
            raise
2149
2140
 
2150
2141
    def lock_read(self):
2151
 
        if not self.is_locked():
2152
 
            self._note_lock('r')
2153
2142
        # All-in-one needs to always unlock/lock.
2154
2143
        repo_control = getattr(self.repository, 'control_files', None)
2155
2144
        if self.control_files == repo_control or not self.is_locked():
2156
 
            self.repository._warn_if_deprecated(self)
2157
2145
            self.repository.lock_read()
2158
2146
            took_lock = True
2159
2147
        else:
2165
2153
                self.repository.unlock()
2166
2154
            raise
2167
2155
 
2168
 
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2169
2156
    def unlock(self):
2170
2157
        try:
2171
2158
            self.control_files.unlock()