dirstate.write() API

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed May 11 11:51:57 EDT 2016


At Wed, 11 May 2016 16:43:39 +0200,
Pierre-Yves David wrote:
> 
> On 05/11/2016 04:26 PM, Augie Fackler wrote:
> >> On May 11, 2016, at 10:17, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
> >>
> >> None is valid value and will remain a valid value because dirstate change do not requires a transaction. They just have to collaborate with one if present. For example `hg update` or `hg add` do not use a transaction. As you pointed out in your previous email, there is also case around the transaction code that explicitly call the write with None because it is the transaction code dirstate is collaborating with, so it is supposed to know what it is doing.
> > Aha! This is the missing piece of understanding for me: it's valid for update() (et al) codepaths to adjust dirstate without a transaction - it's only required to pass a transaction if one is in play.[1] In summary, today we have three cases:
> >
> > dirstate.write(), no active transaction -> fine
> > dirstate.write(), a transaction is active -> buggy
> > dirstate.write(tr) -> always fine
> >
> > This series is merely about disabling that middle case more formally.
> 
> The first case is also problematic. Unless you are in a very narrow set 
> of code (pretty much, the strip code that explicitly forbid transaction 
> to be in place). There is no way for any code to know if it will be use 
> within a transaction at some point. So all code using dirstate.write() 
> should call it using dirstate.write(repo.currenttransaction()) the 
> currenttransaction bit will take are of returning None or the active 
> transaction.
> 
> This construct of "dirstate.write(repo.currenttransaction())" is the 
> result of the long discussion in the middle of last year with at least 
> Foozy and I. I do not think it is worth revisiting, but if you really 
> feel like doing so, please go dig that these discussion out first.

For future reference:

    https://www.mercurial-scm.org/wiki/DirstateTransactionPlan

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list