[PATCH 2 of 4] debugdirstate: add option to drop or add files to dirstate

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Nov 13 19:08:57 CST 2015



On 11/13/2015 05:57 AM, Yuya Nishihara wrote:
> On Wed, 11 Nov 2015 22:17:56 -0800, cdelahousse at fb.com wrote:
>> # HG changeset patch
>> # User Christian Delahousse <cdelahousse at fb.com>
>> # Date 1446522845 28800
>> #      Mon Nov 02 19:54:05 2015 -0800
>> # Node ID cb5481344592d2a38f1a6724324542a3d2708ec0
>> # Parent  88237bdf95f715685488ba0260a27d6dd5dd5bb2
>> debugdirstate: add option to drop or add files to dirstate
>>
>> Debugging the dirstate helps if you have options to add files for normal lookup
>> or drop them form the dirstate. This patch adds flags to the debugdirstate
>> command to do just that.
>>
>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>> --- a/mercurial/commands.py
>> +++ b/mercurial/commands.py
>> @@ -3158,12 +3158,42 @@
>>       finally:
>>           wlock.release()
>>
>> +def _moddirstate(repo, filestolookup=None, filestodrop=None):
>> +    '''Manually add or drop a file to the dirstate'''
>> +    wlock = repo.wlock()
>> +    lock = repo.lock()
>> +    try:
>> +        tr = repo.transaction('dirstate')
>> +        if filestolookup:
>> +            for file in filestolookup:
>> +                repo.dirstate.normallookup(file)
>> +        else:
>> +            for file in filestodrop:
>> +                repo.dirstate.drop(file)
>> +        repo.dirstate.write(tr)
>> +        tr.close()
>> +    finally:
>> +        lock.release()
>> +        wlock.release()
>
> Not sure if we need a transaction (and repo.lock) just to modify dirstate.

We do not to create a transaction for dirstate. We need to pass the 
current transaction if it exist that is all.

We only need repo.wlock. the repo.lock will be taken but third party 
code creating the transaction if one exists.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list