match: add a subclass for dirstate normalizing of the matched patterns
This class is only needed on case insensitive filesystems, and only
for wdir context matches. It allows the user to not match the case of
the items in the filesystem- especially for naming directories, which
dirstate doesn't handle[1]. Making dirstate handle mismatched
directory cases is too expensive[2].
Since dirstate doesn't apply to committed csets, this is only created by
overriding basectx.match() in workingctx, and only on icasefs. The default
arguments have been dropped, because the ctx must be passed to the matcher in
order to function.
For operations that can apply to both wdir and some other context, this ends up
normalizing the filename to the case as it exists in the filesystem, and using
that case for the lookup in the other context. See the diff example in the
test.
Previously, given a directory with an inexact case:
- add worked as expected
- diff, forget and status would silently ignore the request
- files would exit with 1
- commit, revert and remove would fail (even when the commands leading up to
them worked):
$ hg ci -m "AbCDef" capsdir1/capsdir
abort: CapsDir1/CapsDir: no match under directory!
$ hg revert -r '.^' capsdir1/capsdir
capsdir1\capsdir: no such file in rev
64dae27060b7
$ hg remove capsdir1/capsdir
not removing capsdir1\capsdir: no tracked files
[1]
Globs are normalized, so that the -I and -X don't need to be specified with a
case match. Without that, the second last remove (with -X) removes the files,
leaving nothing for the last remove. However, specifying the files as
'glob:**.Txt' does not work. Perhaps this requires 're.IGNORECASE'?
There are only a handful of places that create matchers directly, instead of
being routed through the context.match() method. Some may benefit from changing
over to using ctx.match() as a factory function:
revset.checkstatus()
revset.contains()
revset.filelog()
revset._matchfiles()
localrepository._loadfilter()
ignore.ignore()
fileset.subrepo()
filemerge._picktool()
overrides.addlargefiles()
lfcommands.lfconvert()
kwtemplate.__init__()
eolfile.__init__()
eolfile.checkrev()
acl.buildmatch()
Currently, a toplevel subrepo can be named with an inexact case. However, the
path auditor gets in the way of naming _anything_ in the subrepo if the top
level case doesn't match. That is trickier to handle, because there's the user
provided case, the case in the filesystem, and the case stored in .hgsub. This
can be fixed next cycle.
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -170,8 +170,15 @@
R sub1/sub2/test.txt
$ hg update -Cq
$ touch sub1/sub2/folder/bar
+#if icasefs
+ $ hg addremove Sub1/sub2
+ abort: path 'Sub1\sub2' is inside nested repo 'Sub1'
+ [255]
+ $ hg -q addremove sub1/sub2
+#else
$ hg addremove sub1/sub2
adding sub1/sub2/folder/bar (glob)
+#endif
$ hg status -S
A sub1/sub2/folder/bar
? foo/bar/abc
The narrowmatcher class may need to be tweaked when that is fixed.
[1] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068183.html
[2] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068191.html
#require svn svn-bindings
$ cat >> $HGRCPATH <<EOF
> [extensions]
> convert =
> EOF
$ svnadmin create svn-repo
$ svnadmin load -q svn-repo < "$TESTDIR/svn/branches.svndump"
Convert trunk and branches
$ cat > branchmap <<EOF
> old3 newbranch
>
>
> EOF
$ hg convert --branchmap=branchmap --datesort -r 10 svn-repo A-hg
initializing destination A-hg repository
scanning source...
sorting...
converting...
10 init projA
9 hello
8 branch trunk, remove c and dir
7 change a
6 change b
5 move and update c
4 move and update c
3 change b again
2 move to old2
1 move back to old
0 last change to a
Test template keywords
$ hg -R A-hg log --template '{rev} {svnuuid}{svnpath}@{svnrev}\n'
10 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@10
9 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@9
8 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old2@8
7 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@7
6 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@6
5 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@6
4 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@5
3 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@4
2 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@3
1 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@2
0 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@1
Convert again
$ hg convert --branchmap=branchmap --datesort svn-repo A-hg
scanning source...
sorting...
converting...
0 branch trunk@1 into old3
$ cd A-hg
$ hg log -G --template 'branch={branches} {rev} {desc|firstline} files: {files}\n'
o branch=newbranch 11 branch trunk@1 into old3 files:
|
| o branch= 10 last change to a files: a
| |
| | o branch=old 9 move back to old files:
| | |
| | o branch=old2 8 move to old2 files:
| | |
| | o branch=old 7 change b again files: b
| | |
| o | branch= 6 move and update c files: b
| | |
| | o branch=old 5 move and update c files: c
| | |
| | o branch=old 4 change b files: b
| | |
| o | branch= 3 change a files: a
| | |
| | o branch=old 2 branch trunk, remove c and dir files: c
| |/
| o branch= 1 hello files: a b c dir/e
|/
o branch= 0 init projA files:
$ hg branches
newbranch 11:a6d7cc050ad1
default 10:6e2b33404495
old 9:93c4b0f99529
old2 8:b52884d7bead (inactive)
$ hg tags -q
tip
$ cd ..
Test hg failing to call itself
$ HG=foobar hg convert svn-repo B-hg 2>&1 | grep abort
abort: Mercurial failed to run itself, check hg executable is in PATH
Convert 'trunk' to branch other than 'default'
$ cat > branchmap <<EOF
> None hgtrunk
>
>
> EOF
$ hg convert --branchmap=branchmap --datesort -r 10 svn-repo C-hg
initializing destination C-hg repository
scanning source...
sorting...
converting...
10 init projA
9 hello
8 branch trunk, remove c and dir
7 change a
6 change b
5 move and update c
4 move and update c
3 change b again
2 move to old2
1 move back to old
0 last change to a
$ cd C-hg
$ hg branches
hgtrunk 10:745f063703b4
old 9:aa50d7b8d922
old2 8:c85a22267b6e (inactive)
$ cd ..