[PATCH 1 of 2] vfs: add the possibility to have a "ward" to check vfs usage

Yuya Nishihara yuya at tcha.org
Sun Aug 14 08:30:08 EDT 2016


On Sun, 14 Aug 2016 13:47:38 +0200, Pierre-Yves David wrote:
> On 08/14/2016 05:03 AM, Yuya Nishihara wrote:
> > On Thu, 11 Aug 2016 12:52:24 +0200, Pierre-Yves David wrote:
> >> @@ -583,6 +589,8 @@ class vfs(abstractvfs):
> >>                          self._trustnlink = nlink > 1 or util.checknlink(f)
> >>                      if nlink > 1 or not self._trustnlink:
> >>                          util.rename(util.mktempcopy(f), f)
> >> +        if self._ward is not None:
> >> +            self._ward(f, mode)
> >>          fp = util.posixfile(f, mode)
> >
> > Do you have an idea to extend this to the other operations and open of
> > atomictemp files? I doubt it wouldn't be as simple as a callback function.
> 
> Simple callback should do for the other operation, as they are also 
> performed through vfs.

Something like ward('open', f, mode), ward('unlink', f), etc., or wardopen(),
wardunlink(), etc. ?

> For atomictmp, we probably want to channel their usage through as vfs to
> be able to cover them.

I mean atomictemp=True is handled before calling ward(). And I think atomic
operation should be allowed without taking a lock, but ward() should be called
no matter if operation is atomic or not.


More information about the Mercurial-devel mailing list