/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: Canonical.com Patch Queue Manager
  • Date: 2009-12-21 06:03:07 UTC
  • mfrom: (4665.7.3 serve-init)
  • Revision ID: pqm@pqm.ubuntu.com-20091221060307-uvja3vdy1o6dzzy0
(mbp) example debian init script

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
 
49
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
50
50
from bzrlib.hooks import HookPoint, Hooks
51
51
from bzrlib.inter import InterObject
 
52
from bzrlib.lock import _RelockDebugMixin
52
53
from bzrlib import registry
53
54
from bzrlib.symbol_versioning import (
54
55
    deprecated_in,
502
503
                left_parent = stop_rev.parent_ids[0]
503
504
            else:
504
505
                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 = []
505
510
            for node in rev_iter:
506
511
                rev_id = node.key[-1]
507
512
                if rev_id == left_parent:
 
513
                    # reached the left parent after the stop_revision
508
514
                    return
509
 
                yield (rev_id, node.merge_depth, node.revno,
 
515
                if (not reached_stop_revision_id or
 
516
                        rev_id in revision_id_whitelist):
 
517
                    yield (rev_id, node.merge_depth, node.revno,
510
518
                       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)
511
525
        else:
512
526
            raise ValueError('invalid stop_rule %r' % stop_rule)
513
527
 
1284
1298
        # clone call. Or something. 20090224 RBC/spiv.
1285
1299
        if revision_id is None:
1286
1300
            revision_id = self.last_revision()
1287
 
        try:
1288
 
            dir_to = self.bzrdir.clone_on_transport(to_transport,
1289
 
                revision_id=revision_id, stacked_on=stacked_on,
1290
 
                create_prefix=create_prefix, use_existing_dir=use_existing_dir)
1291
 
        except errors.FileExists:
1292
 
            if not use_existing_dir:
1293
 
                raise
1294
 
        except errors.NoSuchFile:
1295
 
            if not create_prefix:
1296
 
                raise
 
1301
        dir_to = self.bzrdir.clone_on_transport(to_transport,
 
1302
            revision_id=revision_id, stacked_on=stacked_on,
 
1303
            create_prefix=create_prefix, use_existing_dir=use_existing_dir)
1297
1304
        return dir_to.open_branch()
1298
1305
 
1299
1306
    def create_checkout(self, to_location, revision_id=None,
1439
1446
        """Return the format for the branch object in a_bzrdir."""
1440
1447
        try:
1441
1448
            transport = a_bzrdir.get_branch_transport(None)
1442
 
            format_string = transport.get("format").read()
 
1449
            format_string = transport.get_bytes("format")
1443
1450
            return klass._formats[format_string]
1444
1451
        except errors.NoSuchFile:
1445
1452
            raise errors.NotBranchError(path=transport.base)
1978
1985
    def get_reference(self, a_bzrdir):
1979
1986
        """See BranchFormat.get_reference()."""
1980
1987
        transport = a_bzrdir.get_branch_transport(None)
1981
 
        return transport.get('location').read()
 
1988
        return transport.get_bytes('location')
1982
1989
 
1983
1990
    def set_reference(self, a_bzrdir, to_branch):
1984
1991
        """See BranchFormat.set_reference()."""
2079
2086
    _legacy_formats[0].network_name(), _legacy_formats[0].__class__)
2080
2087
 
2081
2088
 
2082
 
class BzrBranch(Branch):
 
2089
class BzrBranch(Branch, _RelockDebugMixin):
2083
2090
    """A branch stored in the actual filesystem.
2084
2091
 
2085
2092
    Note that it's "local" in the context of the filesystem; it doesn't
2131
2138
        return self.control_files.is_locked()
2132
2139
 
2133
2140
    def lock_write(self, token=None):
 
2141
        if not self.is_locked():
 
2142
            self._note_lock('w')
2134
2143
        # All-in-one needs to always unlock/lock.
2135
2144
        repo_control = getattr(self.repository, 'control_files', None)
2136
2145
        if self.control_files == repo_control or not self.is_locked():
 
2146
            self.repository._warn_if_deprecated(self)
2137
2147
            self.repository.lock_write()
2138
2148
            took_lock = True
2139
2149
        else:
2146
2156
            raise
2147
2157
 
2148
2158
    def lock_read(self):
 
2159
        if not self.is_locked():
 
2160
            self._note_lock('r')
2149
2161
        # All-in-one needs to always unlock/lock.
2150
2162
        repo_control = getattr(self.repository, 'control_files', None)
2151
2163
        if self.control_files == repo_control or not self.is_locked():
 
2164
            self.repository._warn_if_deprecated(self)
2152
2165
            self.repository.lock_read()
2153
2166
            took_lock = True
2154
2167
        else:
2160
2173
                self.repository.unlock()
2161
2174
            raise
2162
2175
 
 
2176
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2163
2177
    def unlock(self):
2164
2178
        try:
2165
2179
            self.control_files.unlock()