[PATCH 3 of 8] Add filesystem path to dirstate.statwalk return value
mpm at selenic.com
Thu May 1 17:46:47 CDT 2008
On Thu, 2008-05-01 at 22:18 +0100, Paul Moore wrote:
> The trouble is that there are 2 things we need, the name the user
> passed and the name we actually found (think hg add a when the file is
> actually A).
When do we ever need both names? In the above case, it's perfectly ok to
convert 'a' to 'A' and forget 'a' was ever mentioned.
A more complex case is:
hg add a # actually add 'a' to dirstate
hg ci # store 'a' in manifest
echo 1 > A
hg ci a # Now what?
We've got 'a' in the dirstate and the manifest. So we ought to check in
'a', no? We shouldn't record case changes unless someone explicitly
tells us to. In other words, we need to be able to convert filenames on
disk into filenames in the dirstate. Again, we don't care about the form
the user passed, and we also don't care about the form on disk!
This suggests a hierarchy:
- the form in the dirstate, if available
- the form on disk, if available
- the form on the command line
And we only care about the highest available form.
Which suggests something like dirstate.normalize():
if not dirstate._folding or p in dirstate._map:
elif p in dirstate._folded:
And statwalk/walk/status/etc. should only ever give back that normalized
form. And we still needn't do the expensive fscase step when we're
walking the filesystem (ie most of the time), so we can be a lot smarter
than the above.
But! Something different needs to happen when we do:
hg cat -r 345 a
Here, what's on disk is not at all relevant. If I've got 'a' and 'A' in
rev345, and I ask for 'a', hg had better show me 'a' and not 'A'. So
repo.walk needs to normalize differently.
> Of course, looking at the new pattern you show above, I can get at the
> matched results before they get passed to walk, so in that form, I
> *don't* need to pass abs back up and can just return fsabs.
> I wish I'd known you were working on this refactoring when I started
> looking at statwalk :-( Is the code available anywhere public?
Not yet, I keep breaking it. I'll try to push out the working bits
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel