[PATCH 2 of 3] phases: make advance/retractboundary() atomic

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat May 12 04:57:36 CDT 2012


On Sat, May 12, 2012 at 11:28:11AM +0200, Patrick Mézard wrote:
> Le 12/05/12 11:16, Pierre-Yves David a écrit :
> > On Sat, May 12, 2012 at 12:49:49AM +0200, Patrick Mezard wrote:
> >> # HG changeset patch
> >> # User Patrick Mezard <patrick at mezard.eu>
> >> # Date 1336775047 -7200
> >> # Node ID a15de64e5817ca7bf105e6b56c2ffa37cd20c42b
> >> # Parent  7cd39b49030833bec83b23c25871a2a18d80ce2a
> >> phases: make advance/retractboundary() atomic
> >>
> >> Before this, if advanceboundary() failed after updating some roots but
> >> before calling retractboundary(), the phase cache would be left in an
> >> invalid state, marked dirty, and written as such. This patch approach is
> >> to turn advance/retractboundary() into phasecache methods, then operate
> >> on copies and merge them back on success.
> >>
> >> With the same technique, we can ensure the atomicity of combinations of
> >> advance/retractboundary() calls, like those performed in changegroup
> >> handling code.
> > 
> > This looks like a move in the right direction.
> > 
> >> +    phcache = repo._phasecache.copy()
> >> +    phcache.retractboundary(repo, targetphase, nodes)
> >> +    repo._phasecache.replace(phcache)
> >>  
> >>  def listphases(repo):
> >>      """List phases root for serialisation over pushkey"""
> > 
> > Are you sure replacing the whole phasecache object is a good idea ?
> 
> I don't know, what do you suggest?

Replacing the content instead of the whole object prevent error if people is
holding a relation to it. I do not have such user in mind but this is why I used
``_phaserevs[:] = ...`` when using a list.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list