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

  • Committer: Robert Collins
  • Date: 2007-04-19 02:27:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2426.
  • Revision ID: robertc@robertcollins.net-20070419022744-pfdqz42kp1wizh43
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""This module provides a transactional facility.
19
19
 
30
30
write ordering approach we use for consistency 'dirty' is a misleading term.
31
31
A dirty object is one we have modified.
32
32
 
33
 
Both read and write transactions *may* flush unchanged objects out of
34
 
memory, unless they are marked as 'precious' which indicates that
 
33
Both read and write transactions *may* flush unchanged objects out of 
 
34
memory, unless they are marked as 'precious' which indicates that 
35
35
repeated reads cannot be obtained if the object is ejected, or that
36
36
the object is an expensive one for obtaining.
37
37
"""
38
38
 
39
39
import sys
40
40
 
41
 
from . import errors as errors
42
 
from .identitymap import IdentityMap, NullIdentityMap
43
 
from .trace import mutter
 
41
import bzrlib.errors as errors
 
42
from bzrlib.identitymap import IdentityMap, NullIdentityMap
 
43
from bzrlib.trace import mutter
44
44
 
45
45
 
46
46
class ReadOnlyTransaction(object):
63
63
 
64
64
    def register_clean(self, an_object, precious=False):
65
65
        """Register an_object as being clean.
66
 
 
 
66
        
67
67
        If the precious hint is True, the object will not
68
68
        be ejected from the object identity map ever.
69
69
        """
79
79
 
80
80
    def set_cache_size(self, size):
81
81
        """Set a new cache size."""
82
 
        if size < -1:
83
 
            raise ValueError(size)
 
82
        assert -1 <= size
84
83
        self._limit = size
85
84
        self._trim()
86
85
 
99
98
            # _clean_objects
100
99
            # _clean_queue
101
100
            # 1 missing ?
102
 
            if (sys.getrefcount(self._clean_queue[offset]) <= 7
103
 
                    and not self._clean_queue[offset] in self._precious_objects):
 
101
            if (sys.getrefcount(self._clean_queue[offset]) <= 7 and
 
102
                not self._clean_queue[offset] in self._precious_objects):
104
103
                removed = self._clean_queue[offset]
105
104
                self._clean_objects.remove(removed)
106
105
                del self._clean_queue[offset]
139
138
 
140
139
    def register_dirty(self, an_object):
141
140
        """Register an_object as being dirty.
142
 
 
 
141
        
143
142
        Dirty objects are not ejected from the identity map
144
143
        until the transaction finishes and get informed
145
144
        when the transaction finishes.
154
153
        """Write transactions allow writes."""
155
154
        return True
156
155
 
157
 
 
 
156
        
158
157
class PassThroughTransaction(object):
159
158
    """A pass through transaction
160
 
 
 
159
    
161
160
    - nothing is cached.
162
161
    - nothing ever gets into the identity map.
163
162
    """
176
175
 
177
176
    def register_clean(self, an_object, precious=False):
178
177
        """Register an_object as being clean.
179
 
 
 
178
        
180
179
        Note that precious is only a hint, and PassThroughTransaction
181
180
        ignores it.
182
181
        """
183
182
 
184
183
    def register_dirty(self, an_object):
185
184
        """Register an_object as being dirty.
186
 
 
 
185
        
187
186
        Dirty objects get informed
188
187
        when the transaction finishes.
189
188
        """