Mercurial > hg
changeset 1784:2e0a288ca93e
revalidate revlog data after locking the repo (issue132)
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 22 Feb 2006 07:26:29 +0100 |
parents | 35a05f177267 |
children | 81ca1a9bd061 |
files | mercurial/localrepo.py mercurial/revlog.py |
diffstat | 2 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Feb 22 05:21:09 2006 +0100 +++ b/mercurial/localrepo.py Wed Feb 22 07:26:29 2006 +0100 @@ -235,8 +235,7 @@ if os.path.exists(self.join("journal")): self.ui.status(_("rolling back interrupted transaction\n")) transaction.rollback(self.opener, self.join("journal")) - self.manifest = manifest.manifest(self.opener) - self.changelog = changelog.changelog(self.opener) + self.reload() return True else: self.ui.warn(_("no interrupted transaction available\n")) @@ -250,10 +249,20 @@ self.ui.status(_("rolling back last transaction\n")) transaction.rollback(self.opener, self.join("undo")) util.rename(self.join("undo.dirstate"), self.join("dirstate")) - self.dirstate.read() + self.reload() + self.wreload() else: self.ui.warn(_("no undo information available\n")) + def wreload(self): + self.dirstate.read() + + def reload(self): + self.changelog.load() + self.manifest.load() + self.tagscache = None + self.nodetagscache = None + def do_lock(self, lockname, wait, releasefn=None, acquirefn=None): try: l = lock.lock(self.join(lockname), 0, releasefn) @@ -267,12 +276,12 @@ return l def lock(self, wait=1): - return self.do_lock("lock", wait) + return self.do_lock("lock", wait, acquirefn=self.reload) def wlock(self, wait=1): return self.do_lock("wlock", wait, self.dirstate.write, - self.dirstate.read) + self.wreload) def checkfilemerge(self, filename, text, filelog, manifest1, manifest2): "determine whether a new filenode is needed"
--- a/mercurial/revlog.py Wed Feb 22 05:21:09 2006 +0100 +++ b/mercurial/revlog.py Wed Feb 22 07:26:29 2006 +0100 @@ -13,7 +13,7 @@ from node import * from i18n import gettext as _ from demandload import demandload -demandload(globals(), "binascii errno heapq mdiff sha struct zlib") +demandload(globals(), "binascii errno heapq mdiff os sha struct zlib") def hash(text, p1, p2): """generate a hash from the given text and its parent hashes @@ -187,15 +187,33 @@ self.indexfile = indexfile self.datafile = datafile self.opener = opener + + self.indexstat = None self.cache = None self.chunkcache = None + self.load() + def load(self): try: - i = self.opener(self.indexfile).read() + f = self.opener(self.indexfile) except IOError, inst: if inst.errno != errno.ENOENT: raise i = "" + else: + try: + st = os.fstat(f.fileno()) + except AttributeError, inst: + st = None + else: + oldst = self.indexstat + if (oldst and st.st_dev == oldst.st_dev + and st.st_ino == oldst.st_ino + and st.st_mtime == oldst.st_mtime + and st.st_ctime == oldst.st_ctime): + return + self.indexstat = st + i = f.read() if i and i[:4] != "\0\0\0\0": raise RevlogError(_("incompatible revlog signature on %s") %