[PATCH 5 of 7 V2] fncache: move fncache writing to be in a transaction

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Mar 31 20:25:50 CDT 2014



On 03/31/2014 04:19 PM, Durham Goode wrote:
> -    def _write(self, files, atomictemp):
> -        fp = self.vfs('fncache', mode='wb', atomictemp=atomictemp)
> -        if files:
> -            fp.write(encodedir('\n'.join(files) + '\n'))
> -        fp.close()
> -        self._dirty = False
> -
> -    def write(self):
> +    def write(self, tr):
>           if self._dirty:
> -            self._write(self.entries, True)
> +            tr.addbackup('fncache')
> +            fp = self.vfs('fncache', mode='wb', atomictemp=True)
> +            if self.entries:
> +                fp.write(encodedir('\n'.join(self.entries) + '\n'))
> +            fp.close()
> +            self._dirty = False


there was both a `_write` and a `write` function before. It not very 
clear why you are droping it (nor it is very clear why it existed in the 
first place.

Also, not that you looked at it for one week, consider documenting the 
on disk format.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list