##// END OF EJS Templates
changelog: swap opener to switch delay modes
Matt Mackall -
r9165:07f9b2f4 default
parent child Browse files
Show More
@@ -89,20 +89,22 b' class appender(object):'
89
89
90 class changelog(revlog.revlog):
90 class changelog(revlog.revlog):
91 def __init__(self, opener):
91 def __init__(self, opener):
92 revlog.revlog.__init__(self, opener, "00changelog.i")
92 self._realopener = opener
93 self._realopener = opener
93 self._delayed = False
94 self._delayed = False
94 self._divert = False
95 self._divert = False
95 revlog.revlog.__init__(self, self._delayopener, "00changelog.i")
96
96
97 def delayupdate(self):
97 def delayupdate(self):
98 "delay visibility of index updates to other readers"
98 "delay visibility of index updates to other readers"
99 self._delayed = True
99 self._delayed = True
100 self._divert = (len(self) == 0)
100 self._divert = (len(self) == 0)
101 self._delaybuf = []
101 self._delaybuf = []
102 self.opener = self._delayopener
102
103
103 def finalize(self, tr):
104 def finalize(self, tr):
104 "finalize index updates"
105 "finalize index updates"
105 self._delayed = False
106 self._delayed = False
107 self.opener = self._realopener
106 # move redirected index data back into place
108 # move redirected index data back into place
107 if self._divert:
109 if self._divert:
108 n = self._realopener(self.indexfile).name
110 n = self._realopener(self.indexfile).name
@@ -118,7 +120,7 b' class changelog(revlog.revlog):'
118 def _delayopener(self, name, mode='r'):
120 def _delayopener(self, name, mode='r'):
119 fp = self._realopener(name, mode)
121 fp = self._realopener(name, mode)
120 # only divert the index
122 # only divert the index
121 if not self._delayed or not name == self.indexfile:
123 if not name == self.indexfile:
122 return fp
124 return fp
123 # if we're doing an initial clone, divert to another file
125 # if we're doing an initial clone, divert to another file
124 if self._divert:
126 if self._divert:
@@ -155,9 +157,8 b' class changelog(revlog.revlog):'
155 return False
157 return False
156
158
157 def checkinlinesize(self, tr, fp=None):
159 def checkinlinesize(self, tr, fp=None):
158 if self.opener == self._delayopener:
160 if not self._delayed:
159 return
161 revlog.revlog.checkinlinesize(self, tr, fp)
160 return revlog.revlog.checkinlinesize(self, tr, fp)
161
162
162 def read(self, node):
163 def read(self, node):
163 """
164 """
General Comments 0
You need to be logged in to leave comments. Login now