##// END OF EJS Templates
revisions: allow "x123" to refer to nodeid prefix "123"...
revisions: allow "x123" to refer to nodeid prefix "123" When resolving "123" to a revision, we try to interpret it as revnum before we try to interpret it as a nodeid hex prefix. This can lead to the shortest valid prefix being longer than necessary. This patch lets us write such nodeids in a shorter form by prefixing them with "x" instead of adding more hex digits until they're longer than the longest decimal revnum. On my hg repo with almost 69k revisions, turning this feature on saves on average 0.4% on the average nodeid length. That clearly doesn't justify this patch. However, it becomes more usefule when combined with the earlier patches in this series that let you disambiguate nodeid prefixes within a configured revset. Note that we attempt to resolve symbols as nodeid prefixes after we've exhausted all other posibilities, so this is a backwards compatible change (only queries that would previously fail may now succeed). I've still hidden this feature behind an experiemntal config option so we can roll it back if needed. Differential Revision: https://phab.mercurial-scm.org/D4041

File last commit:

r38091:0a10f142 default
r38891:7848f284 default
Show More
test-parse-date.t
294 lines | 9.1 KiB | text/troff | Tads3Lexer
/ tests / test-parse-date.t
Nicolas Dumazet
tests: unify test-parse-date
r12123 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"
Boris Feld
util: raise ParseError when parsing dates (BC)...
r32462 hg: parse error: invalid date: 'should fail'
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123 $ hg ci -d "100000000000000000 1400" -m "fail"
Boris Feld
util: raise ParseError when parsing dates (BC)...
r32462 hg: parse error: date exceeds 32 bits: 100000000000000000
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123 $ hg ci -d "100000 1400000" -m "fail"
Boris Feld
util: raise ParseError when parsing dates (BC)...
r32462 hg: parse error: impossible time zone offset: 1400000
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123
Check with local timezone other than GMT and with DST
Sébastien Brissaud
test-parse-date: defines explicit start/end dates for DST...
r28441 $ TZ="PST+8PDT+7,M4.1.0/02:00:00,M10.5.0/02:00:00"
Nicolas Dumazet
tests: unify test-parse-date
r12123 $ export TZ
PST=UTC-8 / PDT=UTC-7
Sébastien Brissaud
test-parse-date: defines explicit start/end dates for DST...
r28441 Summer time begins on April's first Sunday at 2:00am,
and ends on October's last Sunday at 2:00am.
Nicolas Dumazet
tests: unify test-parse-date
r12123
$ 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
Matt Mackall
tests: cleanup exit code handling in unified tests
r12365 $ hg debugdate "1:00:30PM" > /dev/null
Nicolas Dumazet
tests: unify test-parse-date
r12123
Martin Geisler
test-parse-date: move remaining date parsing tests from test-log
r16923 Normal range
$ hg log -d -1
Negative range
$ hg log -d "--2"
timeless
util: use single quotes in use warning
r29977 abort: -2 must be nonnegative (see 'hg help dates')
Martin Geisler
test-parse-date: move remaining date parsing tests from test-log
r16923 [255]
Whitespace only
$ hg log -d " "
abort: dates cannot consist entirely of whitespace
[255]
Nicolas Dumazet
tests: unify test-parse-date
r12123 Test date formats with '>' or '<' accompanied by space characters
$ hg log -d '>' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '>DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Martin Geisler
test-parse-date: remove cruft from 8c6f823efcc9...
r16921 $ hg log -d '<' --template '{date|date}\n'
abort: invalid day spec, use '<DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123
$ hg log -d ' >' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '>DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123 $ hg log -d ' <' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '<DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123
$ hg log -d '> ' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '>DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123 $ hg log -d '< ' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '<DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123
$ hg log -d ' > ' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '>DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123 $ hg log -d ' < ' --template '{date|date}\n'
Martin Geisler
help/dates: use DATE as place-holder in help and abort texts...
r13886 abort: invalid day spec, use '<DATE'
Matt Mackall
date: fixup breakage from ">" fix
r13869 [255]
Nicolas Dumazet
tests: unify test-parse-date
r12123
$ 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
Paul Cavallaro
dates: support 'today' and 'yesterday' in parsedate (issue3764)...
r18537
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')
Pulkit Goyal
py3: suppress the output from .write() calls in few tests...
r38091 >>> dates.write(today + '\n') and None
>>> dates.write(yesterday + '\n') and None
Paul Cavallaro
dates: support 'today' and 'yesterday' in parsedate (issue3764)...
r18537 >>> 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
Augie Fackler
parsedate: understand "now" as a shortcut for the current time
r18614 $ 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
Matt Mackall
date: accept broader range of ISO 8601 time specs...
r29638
Test parsing various ISO8601 forms
$ hg debugdate "2016-07-27T12:10:21"
internal: 1469646621 * (glob)
standard: Wed Jul 27 12:10:21 2016 -0700
$ hg debugdate "2016-07-27T12:10:21Z"
internal: 1469621421 0
standard: Wed Jul 27 12:10:21 2016 +0000
$ hg debugdate "2016-07-27T12:10:21+00:00"
internal: 1469621421 0
standard: Wed Jul 27 12:10:21 2016 +0000
$ hg debugdate "2016-07-27T121021Z"
internal: 1469621421 0
standard: Wed Jul 27 12:10:21 2016 +0000
$ hg debugdate "2016-07-27 12:10:21"
internal: 1469646621 * (glob)
standard: Wed Jul 27 12:10:21 2016 -0700
$ hg debugdate "2016-07-27 12:10:21Z"
internal: 1469621421 0
standard: Wed Jul 27 12:10:21 2016 +0000
$ hg debugdate "2016-07-27 12:10:21+00:00"
internal: 1469621421 0
standard: Wed Jul 27 12:10:21 2016 +0000
$ hg debugdate "2016-07-27 121021Z"
internal: 1469621421 0
standard: Wed Jul 27 12:10:21 2016 +0000
Jun Wu
date: fix parsing months...
r36252
Test parsing months
$ for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
> hg log -d "$i 2018" -r null
> done