[PATCH STABLE] localrepo: clear filecache correctly on destroyed()

Matt Mackall mpm at selenic.com
Tue Nov 20 13:41:16 CST 2012


On Tue, 2012-11-20 at 11:33 -0500, Hao Lian wrote:
> > A test for the behaviour you mention above would be really good due
> > to the buggy past of this piece of code.
> 
> I was working off an hg convert of this SVN repository:
> https://beyondcvs.svn.sourceforge.net/svnroot/beyondcvs/
> 
> It's too large (5 MB) and it's other people's code so I didn't include
> it as a test.

Yes, that's definitely not something we want.

>  I would investigate creating a synthetic repo with empty
> revisions but I'm afraid I'm swamped right now.

You should probably aim to test it more directly. You've outlined this
series of steps:

* P is deleted from R's filecache.
* The underlying file that P corresponds to is updated.
* Someone attempts to access P.
* Because the stale P is in __dict__, storecache returns stale P.

While it's hard to drive these steps from the command line, it's pretty
easy to do from Python:

 import os
 from mercurial import hg, ui

 u = ui.ui()
 r = hg.repository(u, 'a', create=1)

 print len(r.changelog)  # prime cache
 r.invalidate()          # try to drop cache

 os.system("echo a > a/a")
 os.system("hg -R a ci -Am0") # modify data on disk

 print len(r.changelog) # check for new data


This doesn't actually trigger a bug for me though.


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list