[PATCH 1 of 5] amend: lock the repository during the whole process

Matt Mackall mpm at selenic.com
Fri Aug 24 15:43:52 CDT 2012


On Fri, 2012-08-24 at 22:51 +0300, Idan Kamara wrote:
> On Fri, Aug 24, 2012 at 10:17 PM, Pierre-Yves David <
> pierre-yves.david at ens-lyon.org> wrote:
> >
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> > # Date 1345827562 -7200
> > # Node ID 3159d224951b36bf11edc49885e616ec72759c6f
> > # Parent  a0cf8f4cd38ba8c35132379b680ebf6d0e900e3d
> > amend: lock the repository during the whole process
> >
> > Without this changes another writer can lock the repository in the middle
> > the
> > amend process. The resulting mess can be pretty ugly.
> >
> > This changeset only ensure that the repository is locked during the whole
> > amend
> > by wrapping the code with a try, except. No changes to the wrapped code is
> > made
> > beside:
> >
> > - the indentation,
> > - docstring wrapping,
> > - removal of a dedicated locking around the stripping of old changesets.
> 
> The usual pattern for both locks seems to be:
> 
> wlock = lock = None
> try:
>   wlock = repo.wlock()
>   lock = repo.lock()
>   ...
> finally:
>   release(wlock, lock) # this is imported from lock.py

..as documented here:

http://mercurial.selenic.com/wiki/LockingDesign

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list