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
This runs with TZ="GMT"
$ hg init
$ echo "test-parse-date" > a
$ hg add a
$ hg ci -d "2006-02-01 13:00:30" -m "rev 0"
$ echo "hi!" >> a
$ hg ci -d "2006-02-01 13:00:30 -0500" -m "rev 1"
$ hg tag -d "2006-04-15 13:30" "Hi"
$ hg backout --merge -d "2006-04-15 13:30 +0200" -m "rev 3" 1
reverting a
created new head
changeset 3:107ce1ee2b43 backs out changeset 1:25a1420a55f8
merging with changeset 3:107ce1ee2b43
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -d "1150000000 14400" -m "rev 4 (merge)"
$ echo "fail" >> a
$ hg ci -d "should fail" -m "fail"
abort: invalid date: 'should fail'
[255]
$ hg ci -d "100000000000000000 1400" -m "fail"
abort: date exceeds 32 bits: 100000000000000000
[255]
$ hg ci -d "100000 1400000" -m "fail"
abort: impossible time zone offset: 1400000
[255]
Check with local timezone other than GMT and with DST
$ TZ="PST+8PDT"
$ export TZ
PST=UTC-8 / PDT=UTC-7
$ hg debugrebuildstate
$ echo "a" > a
$ hg ci -d "2006-07-15 13:30" -m "summer@UTC-7"
$ hg debugrebuildstate
$ echo "b" > a
$ hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5"
$ hg debugrebuildstate
$ echo "c" > a
$ hg ci -d "2006-01-15 13:30" -m "winter@UTC-8"
$ hg debugrebuildstate
$ echo "d" > a
$ hg ci -d "2006-01-15 13:30 +0500" -m "winter@UTC+5"
$ hg log --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
Test issue1014 (fractional timezones)
$ hg debugdate "1000000000 -16200" # 0430
internal: 1000000000 -16200
standard: Sun Sep 09 06:16:40 2001 +0430
$ hg debugdate "1000000000 -15300" # 0415
internal: 1000000000 -15300
standard: Sun Sep 09 06:01:40 2001 +0415
$ hg debugdate "1000000000 -14400" # 0400
internal: 1000000000 -14400
standard: Sun Sep 09 05:46:40 2001 +0400
$ hg debugdate "1000000000 0" # GMT
internal: 1000000000 0
standard: Sun Sep 09 01:46:40 2001 +0000
$ hg debugdate "1000000000 14400" # -0400
internal: 1000000000 14400
standard: Sat Sep 08 21:46:40 2001 -0400
$ hg debugdate "1000000000 15300" # -0415
internal: 1000000000 15300
standard: Sat Sep 08 21:31:40 2001 -0415
$ hg debugdate "1000000000 16200" # -0430
internal: 1000000000 16200
standard: Sat Sep 08 21:16:40 2001 -0430
$ hg debugdate "Sat Sep 08 21:16:40 2001 +0430"
internal: 999967600 -16200
standard: Sat Sep 08 21:16:40 2001 +0430
$ hg debugdate "Sat Sep 08 21:16:40 2001 -0430"
internal: 1000000000 16200
standard: Sat Sep 08 21:16:40 2001 -0430
Test 12-hours times
$ hg debugdate "2006-02-01 1:00:30PM +0000"
internal: 1138798830 0
standard: Wed Feb 01 13:00:30 2006 +0000
$ hg debugdate "1:00:30PM" > /dev/null
Normal range
$ hg log -d -1
Negative range
$ hg log -d "--2"
abort: -2 must be nonnegative (see "hg help dates")
[255]
Whitespace only
$ hg log -d " "
abort: dates cannot consist entirely of whitespace
[255]
Test date formats with '>' or '<' accompanied by space characters
$ hg log -d '>' --template '{date|date}\n'
abort: invalid day spec, use '>DATE'
[255]
$ hg log -d '<' --template '{date|date}\n'
abort: invalid day spec, use '<DATE'
[255]
$ hg log -d ' >' --template '{date|date}\n'
abort: invalid day spec, use '>DATE'
[255]
$ hg log -d ' <' --template '{date|date}\n'
abort: invalid day spec, use '<DATE'
[255]
$ hg log -d '> ' --template '{date|date}\n'
abort: invalid day spec, use '>DATE'
[255]
$ hg log -d '< ' --template '{date|date}\n'
abort: invalid day spec, use '<DATE'
[255]
$ hg log -d ' > ' --template '{date|date}\n'
abort: invalid day spec, use '>DATE'
[255]
$ hg log -d ' < ' --template '{date|date}\n'
abort: invalid day spec, use '<DATE'
[255]
$ hg log -d '>02/01' --template '{date|date}\n'
$ hg log -d '<02/01' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d ' >02/01' --template '{date|date}\n'
$ hg log -d ' <02/01' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d '> 02/01' --template '{date|date}\n'
$ hg log -d '< 02/01' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d ' > 02/01' --template '{date|date}\n'
$ hg log -d ' < 02/01' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d '>02/01 ' --template '{date|date}\n'
$ hg log -d '<02/01 ' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d ' >02/01 ' --template '{date|date}\n'
$ hg log -d ' <02/01 ' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d '> 02/01 ' --template '{date|date}\n'
$ hg log -d '< 02/01 ' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
$ hg log -d ' > 02/01 ' --template '{date|date}\n'
$ hg log -d ' < 02/01 ' --template '{date|date}\n'
Sun Jan 15 13:30:00 2006 +0500
Sun Jan 15 13:30:00 2006 -0800
Sat Jul 15 13:30:00 2006 +0500
Sat Jul 15 13:30:00 2006 -0700
Sun Jun 11 00:26:40 2006 -0400
Sat Apr 15 13:30:00 2006 +0200
Sat Apr 15 13:30:00 2006 +0000
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
Test issue 3764 (interpreting 'today' and 'yesterday')
$ echo "hello" >> a
>>> import datetime
>>> today = datetime.date.today().strftime("%b %d")
>>> yesterday = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%b %d")
>>> dates = open('dates', 'w')
>>> dates.write(today + '\n')
>>> dates.write(yesterday + '\n')
>>> dates.close()
$ hg ci -d "`sed -n '1p' dates`" -m "today is a good day to code"
$ hg log -d today --template '{desc}\n'
today is a good day to code
$ echo "goodbye" >> a
$ hg ci -d "`sed -n '2p' dates`" -m "the time traveler's code"
$ hg log -d yesterday --template '{desc}\n'
the time traveler's code
$ echo "foo" >> a
$ hg commit -d now -m 'Explicitly committed now.'
$ hg log -d today --template '{desc}\n'
Explicitly committed now.
today is a good day to code