Patchwork [1,of,4,V2] streamclone: force @filecache properties to be reloaded from file

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Sept. 11, 2016, 6:11 p.m.
Message ID <a348b1f1c04a9aa2fe05.1473617513@feefifofum>
Download mbox | patch
Permalink /patch/16587/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Sept. 11, 2016, 6:11 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1473617188 -32400
#      Mon Sep 12 03:06:28 2016 +0900
# Node ID a348b1f1c04a9aa2fe05205d3026b1f9d530ed48
# Parent  8a658b8b795aaea5e9fe34ae26a49b4656c594cb
streamclone: force @filecache properties to be reloaded from file

Before this patch, consumev1() invokes repo.invalidate() after closing
transaction, to force @filecache properties to be reloaded from files
at next access, because streamclone writes data into files directly.

But this doesn't work as expected in the case below:

  1. at closing transaction, repo._refreshfilecachestats() refreshes
     file stat of each @filecache properties with streamclone-ed files

     This means that in-memory properties are treated as valid.

  2. but streamclone doesn't changes in-memory properties

     This means that in-memory properties are actually invalid.

  3. repo.invalidate() just forces to examine file stat of @filecache
     properties at the first access after it

     Such examination should concludes that reloading from file isn't
     needed, because file stat was already refreshed at (1).

     Therefore, invalid in-memory cached properties (2) are
     unintentionally treated as valid (1).

This patch invokes repo.invalidate() with clearfilecache=True, to
force @filecache properties to be reloaded from file at next access.

BTW, it is accidental that repo.invalidate() without
clearfilecache=True in streamclone case seems to work as expected
before this patch.

If transaction is started via "filtered repo" object,
repo._refreshfilecachestats() tries to refresh file stat of each
@filecache properties on "filtered repo" object, even though all of
them are stored into "unfiltered repo" object.

In this case, repo._refreshfilecachestats() does nothing
unintentionally, but this unexpected behavior causes reloading
@filecache properties after repo.invalidate().

This is reason why this patch should be applied before making
_refreshfilecachestats() correctly refresh file stat of @filecache
properties.

Patch

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -323,7 +323,7 @@  def consumev1(repo, fp, filecount, bytec
                             ofp.write(chunk)
 
         # Writing straight to files circumvented the inmemory caches
-        repo.invalidate()
+        repo.invalidate(clearfilecache=True)
 
         elapsed = time.time() - start
         if elapsed <= 0: