/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/repository.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    chk_map,
27
27
    config,
28
28
    debug,
 
29
    errors,
29
30
    fetch as _mod_fetch,
30
31
    fifo_cache,
31
32
    generate_ids,
52
53
from bzrlib.testament import Testament
53
54
""")
54
55
 
55
 
from bzrlib import (
56
 
    errors,
57
 
    registry,
58
 
    )
59
56
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
60
57
from bzrlib.inter import InterObject
61
58
from bzrlib.inventory import (
64
61
    ROOT_ID,
65
62
    entry_factory,
66
63
    )
67
 
from bzrlib.lock import _RelockDebugMixin, LogicalLockResult
 
64
from bzrlib.lock import _RelockDebugMixin
 
65
from bzrlib import registry
68
66
from bzrlib.trace import (
69
67
    log_exception_quietly, note, mutter, mutter_callsite, warning)
70
68
 
73
71
_deprecation_warning_done = False
74
72
 
75
73
 
76
 
class IsInWriteGroupError(errors.InternalBzrError):
77
 
 
78
 
    _fmt = "May not refresh_data of repo %(repo)s while in a write group."
79
 
 
80
 
    def __init__(self, repo):
81
 
        errors.InternalBzrError.__init__(self, repo=repo)
82
 
 
83
 
 
84
74
class CommitBuilder(object):
85
75
    """Provides an interface to build up a commit.
86
76
 
870
860
        # versioned roots do not change unless the tree found a change.
871
861
 
872
862
 
873
 
class RepositoryWriteLockResult(LogicalLockResult):
 
863
class RepositoryWriteLockResult(object):
874
864
    """The result of write locking a repository.
875
865
 
876
866
    :ivar repository_token: The token obtained from the underlying lock, or
879
869
    """
880
870
 
881
871
    def __init__(self, unlock, repository_token):
882
 
        LogicalLockResult.__init__(self, unlock)
883
872
        self.repository_token = repository_token
884
 
 
885
 
    def __repr__(self):
886
 
        return "RepositoryWriteLockResult(%s, %s)" % (self.repository_token,
887
 
            self.unlock)
 
873
        self.unlock = unlock
888
874
 
889
875
 
890
876
######################################################################
1444
1430
            for repo in self._fallback_repositories:
1445
1431
                repo.lock_read()
1446
1432
            self._refresh_data()
1447
 
        return LogicalLockResult(self.unlock)
 
1433
        return self
1448
1434
 
1449
1435
    def get_physical_lock_status(self):
1450
1436
        return self.control_files.get_physical_lock_status()
1668
1654
        return missing_keys
1669
1655
 
1670
1656
    def refresh_data(self):
1671
 
        """Re-read any data needed to synchronise with disk.
 
1657
        """Re-read any data needed to to synchronise with disk.
1672
1658
 
1673
1659
        This method is intended to be called after another repository instance
1674
1660
        (such as one used by a smart server) has inserted data into the
1675
 
        repository. On all repositories this will work outside of write groups.
1676
 
        Some repository formats (pack and newer for bzrlib native formats)
1677
 
        support refresh_data inside write groups. If called inside a write
1678
 
        group on a repository that does not support refreshing in a write group
1679
 
        IsInWriteGroupError will be raised.
 
1661
        repository. It may not be called during a write group, but may be
 
1662
        called at any other time.
1680
1663
        """
 
1664
        if self.is_in_write_group():
 
1665
            raise errors.InternalBzrError(
 
1666
                "May not refresh_data while in a write group.")
1681
1667
        self._refresh_data()
1682
1668
 
1683
1669
    def resume_write_group(self, tokens):