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