Skip to content
  • Katsunori FUJIWARA's avatar
    scmutil: add file object wrapper class to check ambiguity at closing · 57830bd0e787
    Katsunori FUJIWARA authored
    In Mercurial source tree, opening a file in "a"/"a+" mode like below
    doesn't specify atomictemp=True for vfs, and this avoids file stat
    ambiguity check by atomictempfile.
    
      - writing changes out in revlog layer uses "a+" mode
      - truncation in repair.strip() uses "a" mode
      - truncation in transaction._playback() uses "a" mode
    
    If steps below occurs at "the same time in sec", all of mtime, ctime
    and size are same between (1) and (3).
    
      1. append data to revlog-style file (and close transaction)
      2. discard appended data by truncation (strip or rollback)
      3. append same size but different data to revlog-style file again
    
    Therefore, cache validation doesn't work after (3) as expected.
    
    This patch adds file object wrapper class checkambigatclosing to check
    (and get rid of) ambiguity at closing. It is used by vfs in subsequent
    patch.
    
    This is a part of ExactCacheValidationPlan.
    
        https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
    
    BTW, checkambigatclosing is tested in test-filecache.py, even though
    it doesn't use filecache itself, because filecache assumes that file
    stat ambiguity never occurs (and there is no another test-*.py related
    to filecache).
    57830bd0e787