[PATCH 3 of 3] Add a normalize() method to dirstate

Paul Moore p.f.moore at gmail.com
Sat May 24 06:29:04 CDT 2008

2008/5/22 Matt Mackall <mpm at selenic.com>:
> Consider:
> $ touch a
> $ hg add a
> $ hg ci
> $ mv a A
> $ echo new > A
> $ hg ci A
> Since Mercurial wasn't explicitly told about changing 'a' to 'A', we
> need to treat all references to 'A' (whether from the command line or on
> disk) as references to 'a' because 'a' is the case of the file we've
> been told about.
> Thus, to 'normalize' the file, we have to search the dirstate in a case
> insensitive manner for the file we're interested in.

Hmm, OK. I take your point. As I personally avoid "manually" muddling
case like this, and I don't (need to) use tools that mangle case, I'm
not the best person to comment, but I see what you're getting at.

>> > I think what's needed rather than _folding or _folded is something like:
>> Well, _folding tells us if we're on a case-insensitive system where we
>> don't need any of this - so it's an optimization shortcut, and _folded
>> is simply a cache of the results, so again it's for optimization.
> And I'm taking it one step further. We only need one variable: _foldmap.
> If _foldmap == {}, folding is not in effect.
> In fact, we can do even better still: define normalize() dynamically:
> if name == "normalize":
>    if not checkfolding(...):
>        self.normalize = self._fixcase()
>    else:
>        self.normalize = lambda x: x
> And _fixcase() then never needs to check for case-sensitive filesystems,
> because it only gets called on case-folding filesystems.

OK. It's possible that we're working too hard on optimising this
before it's gone in and got a bit wider use, but it's not too hard to
add, and I'm certainly not going to argue with you over what needs to
be fast (anyway, I'd hate to be the person who caused Mercurial to
lose its "blindingly fast" reputation :-))

I'll fix this.

More information about the Mercurial-devel mailing list