diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -235,8 +235,7 @@ class localrepository(object): 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 @@ class localrepository(object): 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 @@ class localrepository(object): 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" diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -13,7 +13,7 @@ of the GNU General Public License, incor 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 @@ class revlog(object): 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") %