[PATCH 2 of 2] match: add a subclass for dirstate normalizing of the matched patterns
Siddharth Agarwal
sid at less-broken.com
Tue Apr 14 15:31:33 CDT 2015
On 04/13/2015 07:50 PM, Matt Harbison wrote:
> Yes. It might be tricky though, because
> localrepository._checknested() checks 'prefix in ctx.substate', which
> might mean normalizing the keys in workingctx.substate.
That's fine -- could you add a note in the comments?
> Agreed. The superclass doesn't call _normalize() if exact.
>
> What this is trying to say is that _fmap needs to be updated with
> roots in the user specified case, so that m.exact('name') is testing
> against what the user provided. Otherwise, existing tests drop
> 'adding xyz' lines when only the case is different.
> matchmod.exact([a, b, c]) bypasses this new class always.
>
> I wasn't sure if both constructors should take the same parameters, in
> the same order, for sanity. If not, I can drop the 'exact' variable.
> This is only created with exact == False anyway.
Yeah, drop the exact variable I think. That makes it way less confusing
to readers (which we should optimize for over writers).
- Siddharth
>
>> Other than that this looks fine. dirstate.normalize is a little more
>> expensive than necessary but the number of patterns is usually very
>> small.
>>
>> - Siddharth
>>
>>> + self._kp = super(icasefsmatcher, self)._normalize(patterns,
>>> default,
>>> + root,
>>> cwd, auditor)
>>> + kindpats = []
>>> + for kind, pats in self._kp:
>>> + if kind not in ('re', 'relre'): # regex can't be
>>> normalized
>>> + pats = self._dsnormalize(pats)
>>> + kindpats.append((kind, pats))
>>> + return kindpats
>>> +
>>> def patkind(pattern, default=None):
>>> '''If pattern is 'kind:pat' with a known kind, return kind.'''
>>> return _patsplit(pattern, default)[0]
>>> diff --git a/tests/test-add.t b/tests/test-add.t
>>> --- a/tests/test-add.t
>>> +++ b/tests/test-add.t
>>> @@ -176,12 +176,48 @@
>>> $ mkdir CapsDir1/CapsDir/SubDir
>>> $ echo def > CapsDir1/CapsDir/SubDir/Def.txt
>>>
>>> - $ hg add -v capsdir1/capsdir
>>> + $ hg add capsdir1/capsdir
>>> adding CapsDir1/CapsDir/AbC.txt (glob)
>>> adding CapsDir1/CapsDir/SubDir/Def.txt (glob)
>>>
>>> $ hg forget capsdir1/capsdir/abc.txt
>>> removing CapsDir1/CapsDir/AbC.txt (glob)
>>> +
>>> + $ hg forget capsdir1/capsdir
>>> + removing CapsDir1/CapsDir/SubDir/Def.txt (glob)
>>> +
>>> + $ hg add capsdir1
>>> + adding CapsDir1/CapsDir/AbC.txt (glob)
>>> + adding CapsDir1/CapsDir/SubDir/Def.txt (glob)
>>> +
>>> + $ hg ci -m "AbCDef" capsdir1/capsdir
>>> +
>>> + $ hg status -A capsdir1/capsdir
>>> + C CapsDir1/CapsDir/AbC.txt
>>> + C CapsDir1/CapsDir/SubDir/Def.txt
>>> +
>>> + $ hg files capsdir1/capsdir
>>> + CapsDir1/CapsDir/AbC.txt (glob)
>>> + CapsDir1/CapsDir/SubDir/Def.txt (glob)
>>> +
>>> + $ echo xyz > CapsDir1/CapsDir/SubDir/Def.txt
>>> + $ hg ci -m xyz capsdir1/capsdir/subdir/def.txt
>>> +
>>> + $ hg revert -r '.^' capsdir1/capsdir
>>> + reverting CapsDir1/CapsDir/SubDir/Def.txt (glob)
>>> +
>>> + $ hg diff capsdir1/capsdir
>>> + diff -r 5112e00e781d CapsDir1/CapsDir/SubDir/Def.txt
>>> + --- a/CapsDir1/CapsDir/SubDir/Def.txt Thu Jan 01 00:00:00 1970
>>> +0000
>>> + +++ b/CapsDir1/CapsDir/SubDir/Def.txt * +0000 (glob)
>>> + @@ -1,1 +1,1 @@
>>> + -xyz
>>> + +def
>>> +
>>> + $ hg remove -f 'glob:**.txt' -X capsdir1/capsdir
>>> + $ hg remove -f 'glob:**.txt' -I capsdir1/capsdir
>>> + removing CapsDir1/CapsDir/AbC.txt (glob)
>>> + removing CapsDir1/CapsDir/SubDir/Def.txt (glob)
>>> #endif
>>>
>>> $ cd ..
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel at selenic.com
>>> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list