##// 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 class localrepository(object):
235 235 if os.path.exists(self.join("journal")):
236 236 self.ui.status(_("rolling back interrupted transaction\n"))
237 237 transaction.rollback(self.opener, self.join("journal"))
238 self.manifest = manifest.manifest(self.opener)
239 self.changelog = changelog.changelog(self.opener)
238 self.reload()
240 239 return True
241 240 else:
242 241 self.ui.warn(_("no interrupted transaction available\n"))
@@ -250,10 +249,20 class localrepository(object):
250 249 self.ui.status(_("rolling back last transaction\n"))
251 250 transaction.rollback(self.opener, self.join("undo"))
252 251 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
253 self.dirstate.read()
252 self.reload()
253 self.wreload()
254 254 else:
255 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 266 def do_lock(self, lockname, wait, releasefn=None, acquirefn=None):
258 267 try:
259 268 l = lock.lock(self.join(lockname), 0, releasefn)
@@ -267,12 +276,12 class localrepository(object):
267 276 return l
268 277
269 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 281 def wlock(self, wait=1):
273 282 return self.do_lock("wlock", wait,
274 283 self.dirstate.write,
275 self.dirstate.read)
284 self.wreload)
276 285
277 286 def checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
278 287 "determine whether a new filenode is needed"
@@ -13,7 +13,7 of the GNU General Public License, incor
13 13 from node import *
14 14 from i18n import gettext as _
15 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 18 def hash(text, p1, p2):
19 19 """generate a hash from the given text and its parent hashes
@@ -187,15 +187,33 class revlog(object):
187 187 self.indexfile = indexfile
188 188 self.datafile = datafile
189 189 self.opener = opener
190
191 self.indexstat = None
190 192 self.cache = None
191 193 self.chunkcache = None
194 self.load()
192 195
196 def load(self):
193 197 try:
194 i = self.opener(self.indexfile).read()
198 f = self.opener(self.indexfile)
195 199 except IOError, inst:
196 200 if inst.errno != errno.ENOENT:
197 201 raise
198 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 218 if i and i[:4] != "\0\0\0\0":
201 219 raise RevlogError(_("incompatible revlog signature on %s") %
General Comments 0
You need to be logged in to leave comments. Login now