/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: 2009-03-16 05:05:52 UTC
  • mto: This revision was merged to the branch mainline in revision 4149.
  • Revision ID: robertc@robertcollins.net-20090316050552-hqcgx49ugew0facc
Add a refresh_data method on Repository allowing cleaner handling of insertions into RemoteRepository objects with _real_repository instances.

Show diffs side-by-side

added added

removed removed

Lines of Context:
884
884
 
885
885
        XXX: this docstring is duplicated in many places, e.g. lockable_files.py
886
886
        """
 
887
        locked = self.is_locked()
887
888
        result = self.control_files.lock_write(token=token)
888
889
        for repo in self._fallback_repositories:
889
890
            # Writes don't affect fallback repos
890
891
            repo.lock_read()
891
 
        self._refresh_data()
 
892
        if not locked:
 
893
            self._refresh_data()
892
894
        return result
893
895
 
894
896
    def lock_read(self):
 
897
        locked = self.is_locked()
895
898
        self.control_files.lock_read()
896
899
        for repo in self._fallback_repositories:
897
900
            repo.lock_read()
898
 
        self._refresh_data()
 
901
        if not locked:
 
902
            self._refresh_data()
899
903
 
900
904
    def get_physical_lock_status(self):
901
905
        return self.control_files.get_physical_lock_status()
1084
1088
    def suspend_write_group(self):
1085
1089
        raise errors.UnsuspendableWriteGroup(self)
1086
1090
 
 
1091
    def refresh_data(self):
 
1092
        """Re-read any data needed to to synchronise with disk.
 
1093
 
 
1094
        This method is intended to be called after another repository instance
 
1095
        (such as one used by a smart server) has inserted data into the
 
1096
        repository. It may not be called during a write group, but may be
 
1097
        called at any other time.
 
1098
        """
 
1099
        if self.is_in_write_group():
 
1100
            raise errors.InternalBzrError(
 
1101
                "May not refresh_data while in a write group.")
 
1102
        self._refresh_data()
 
1103
 
1087
1104
    def resume_write_group(self, tokens):
1088
1105
        if not self.is_write_locked():
1089
1106
            raise errors.NotWriteLocked(self)
1844
1861
        for repositories to maintain loaded indices across multiple locks
1845
1862
        by checking inside their implementation of this method to see
1846
1863
        whether their indices are still valid. This depends of course on
1847
 
        the disk format being validatable in this manner.
 
1864
        the disk format being validatable in this manner. This method is
 
1865
        also called by the refresh_data() public interface to cause a refresh
 
1866
        to occur while in a write lock so that data inserted by a smart server
 
1867
        push operation is visible on the client's instance of the physical
 
1868
        repository.
1848
1869
        """
1849
1870
 
1850
1871
    @needs_read_lock