[PATCH 2 of 3 fyi] hack: lock validation

Mads Kiilerich mads at kiilerich.com
Sun Nov 17 15:04:08 CST 2013


On 11/17/2013 01:20 PM, Christian Ebert wrote:
> * Mads Kiilerich on Sunday, November 17, 2013 at 12:53:58 -0500
>> # HG changeset patch
>> # User Mads Kiilerich <mads at kiilerich.com>
>> # Date 1326326392 -3600
>> #      Thu Jan 12 00:59:52 2012 +0100
>> # Branch stable
>> # Node ID ca1828f0c90d81978daa555fdcdbe841d4fe70b3
>> # Parent  41d9e7b97f3ced21c0665253a6495165f58a2730
>> hack: lock validation
>>
>> Instrumenting critical places with these checks can help verifying compliance
>> with the locking strategy described on
>> http://mercurial.selenic.com/wiki/LockingDesign.
>>
>> Occasionally running the test suite with this patch might catch some locking
>> errors, but the checking as it is is probably too intrusive for inclusion in
>> core Mercurial.
>>
>> Essential parts of this patch had conflicts and has been left out. It should be
>> verified that the checks are reasonable complete.
>>
>> A part of this patch now lives (and dies) in contrib/lock-checker.py .
>>
>> diff --git a/hgext/keyword.py b/hgext/keyword.py
>> --- a/hgext/keyword.py
>> +++ b/hgext/keyword.py
>> @@ -439,7 +439,11 @@ def demo(ui, repo, *args, **opts):
>>      repo[None].add([fn])
>>      ui.note(_('\nkeywords written to %s:\n') % fn)
>>      ui.note(keywords)
>> -    repo.dirstate.setbranch('demobranch')
>> +    wlock = repo.wlock()
>> +    try:
>> +        repo.dirstate.setbranch('demobranch')
>> +    finally:
>> +        wlock.release()
>>      for name, cmd in ui.configitems('hooks'):
>>          if name.split('.', 1)[0].find('commit') > -1:
>>              repo.ui.setconfig('hooks', name, '')
> imho the above is unneeded, as this happens in a temporary demo
> repo with no precious data, it's part of hg kwdemo and never used
> outside that particular command.

Yes, you have made that point before.

I agree that this protocol violation don't have any real impact. But it 
do still violate the locking protocol, and this odd and stupid command 
do thus cause an overhead every time we try to validate that we do 
correct locking. Just fixing it is less overhead than working around it.

/Mads


More information about the Mercurial-devel mailing list