[PATCH stable] histedit: add proper locking around repair.strip() calls
Idan Kamara
idankk86 at gmail.com
Wed Aug 1 08:27:53 CDT 2012
On Wed, Aug 1, 2012 at 4:22 PM, Augie Fackler <raf at durin42.com> wrote:
>
> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1343772411 18000
> # Branch stable
> # Node ID 07af978f9019634f1cdcdac3c3d04de992038fe4
> # Parent 98166640b356b4c44bc87ce9137c7647eb728332
> histedit: add proper locking around repair.strip() calls
Why do you need a wlock?
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -152,6 +152,7 @@
> from mercurial import discovery
> from mercurial import error
> from mercurial import hg
> +from mercurial import lock as lockmod
> from mercurial import node
> from mercurial import patch
> from mercurial import repair
> @@ -497,10 +498,17 @@
> ', '.join([node.hex(n)[:12] for n in tmpnodes]))
> for nodes in (created, tmpnodes):
> for n in reversed(nodes):
> + wlock = lock = None
You probably want these locks outside the loops.
> try:
> - repair.strip(ui, repo, n)
> - except error.LookupError:
> - pass
> + wlock = repo.wlock()
> + lock = repo.lock()
> +
> + try:
> + repair.strip(ui, repo, n)
> + except error.LookupError:
> + pass
> + finally:
> + lockmod.release(lock, wlock)
> os.unlink(os.path.join(repo.path, 'histedit-state'))
> return
> else:
> @@ -640,18 +648,30 @@
> ui.debug('should strip replaced nodes %s\n' %
> ', '.join([node.hex(n)[:12] for n in replaced]))
> for n in sorted(replaced, key=lambda x: repo[x].rev()):
> + lock = wlock = None
> + try:
> + wlock = repo.wlock()
> + lock = repo.lock()
> + try:
> + repair.strip(ui, repo, n)
> + except error.LookupError:
> + pass
> + finally:
> + lockmod.release(lock, wlock)
> +
> + ui.debug('should strip temp nodes %s\n' %
> + ', '.join([node.hex(n)[:12] for n in tmpnodes]))
> + for n in reversed(tmpnodes):
> + lock = wlock = None
> + try:
> + wlock = repo.wlock()
> + lock = repo.lock()
> try:
> repair.strip(ui, repo, n)
> except error.LookupError:
> pass
> -
> - ui.debug('should strip temp nodes %s\n' %
> - ', '.join([node.hex(n)[:12] for n in tmpnodes]))
> - for n in reversed(tmpnodes):
> - try:
> - repair.strip(ui, repo, n)
> - except error.LookupError:
> - pass
> + finally:
> + lockmod.release(lock, wlock)
> os.unlink(os.path.join(repo.path, 'histedit-state'))
> if os.path.exists(repo.sjoin('undo')):
> os.unlink(repo.sjoin('undo'))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120801/276ba9ac/attachment.html>
More information about the Mercurial-devel
mailing list