##// END OF EJS Templates
revalidate revlog data after locking the repo (issue132)
Benoit Boissinot -
r1784:2e0a288c default
parent child Browse files
Show More
@@ -235,8 +235,7 b' class localrepository(object):'
235 if os.path.exists(self.join("journal")):
235 if os.path.exists(self.join("journal")):
236 self.ui.status(_("rolling back interrupted transaction\n"))
236 self.ui.status(_("rolling back interrupted transaction\n"))
237 transaction.rollback(self.opener, self.join("journal"))
237 transaction.rollback(self.opener, self.join("journal"))
238 self.manifest = manifest.manifest(self.opener)
238 self.reload()
239 self.changelog = changelog.changelog(self.opener)
240 return True
239 return True
241 else:
240 else:
242 self.ui.warn(_("no interrupted transaction available\n"))
241 self.ui.warn(_("no interrupted transaction available\n"))
@@ -250,10 +249,20 b' class localrepository(object):'
250 self.ui.status(_("rolling back last transaction\n"))
249 self.ui.status(_("rolling back last transaction\n"))
251 transaction.rollback(self.opener, self.join("undo"))
250 transaction.rollback(self.opener, self.join("undo"))
252 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
251 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
253 self.dirstate.read()
252 self.reload()
253 self.wreload()
254 else:
254 else:
255 self.ui.warn(_("no undo information available\n"))
255 self.ui.warn(_("no undo information available\n"))
256
256
257 def wreload(self):
258 self.dirstate.read()
259
260 def reload(self):
261 self.changelog.load()
262 self.manifest.load()
263 self.tagscache = None
264 self.nodetagscache = None
265
257 def do_lock(self, lockname, wait, releasefn=None, acquirefn=None):
266 def do_lock(self, lockname, wait, releasefn=None, acquirefn=None):
258 try:
267 try:
259 l = lock.lock(self.join(lockname), 0, releasefn)
268 l = lock.lock(self.join(lockname), 0, releasefn)
@@ -267,12 +276,12 b' class localrepository(object):'
267 return l
276 return l
268
277
269 def lock(self, wait=1):
278 def lock(self, wait=1):
270 return self.do_lock("lock", wait)
279 return self.do_lock("lock", wait, acquirefn=self.reload)
271
280
272 def wlock(self, wait=1):
281 def wlock(self, wait=1):
273 return self.do_lock("wlock", wait,
282 return self.do_lock("wlock", wait,
274 self.dirstate.write,
283 self.dirstate.write,
275 self.dirstate.read)
284 self.wreload)
276
285
277 def checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
286 def checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
278 "determine whether a new filenode is needed"
287 "determine whether a new filenode is needed"
@@ -13,7 +13,7 b' of the GNU General Public License, incor'
13 from node import *
13 from node import *
14 from i18n import gettext as _
14 from i18n import gettext as _
15 from demandload import demandload
15 from demandload import demandload
16 demandload(globals(), "binascii errno heapq mdiff sha struct zlib")
16 demandload(globals(), "binascii errno heapq mdiff os sha struct zlib")
17
17
18 def hash(text, p1, p2):
18 def hash(text, p1, p2):
19 """generate a hash from the given text and its parent hashes
19 """generate a hash from the given text and its parent hashes
@@ -187,15 +187,33 b' class revlog(object):'
187 self.indexfile = indexfile
187 self.indexfile = indexfile
188 self.datafile = datafile
188 self.datafile = datafile
189 self.opener = opener
189 self.opener = opener
190
191 self.indexstat = None
190 self.cache = None
192 self.cache = None
191 self.chunkcache = None
193 self.chunkcache = None
194 self.load()
192
195
196 def load(self):
193 try:
197 try:
194 i = self.opener(self.indexfile).read()
198 f = self.opener(self.indexfile)
195 except IOError, inst:
199 except IOError, inst:
196 if inst.errno != errno.ENOENT:
200 if inst.errno != errno.ENOENT:
197 raise
201 raise
198 i = ""
202 i = ""
203 else:
204 try:
205 st = os.fstat(f.fileno())
206 except AttributeError, inst:
207 st = None
208 else:
209 oldst = self.indexstat
210 if (oldst and st.st_dev == oldst.st_dev
211 and st.st_ino == oldst.st_ino
212 and st.st_mtime == oldst.st_mtime
213 and st.st_ctime == oldst.st_ctime):
214 return
215 self.indexstat = st
216 i = f.read()
199
217
200 if i and i[:4] != "\0\0\0\0":
218 if i and i[:4] != "\0\0\0\0":
201 raise RevlogError(_("incompatible revlog signature on %s") %
219 raise RevlogError(_("incompatible revlog signature on %s") %
General Comments 0
You need to be logged in to leave comments. Login now