hgtime: fix corner case of date range parsing

Summary: The docs promise that both `<` and `>` bounds are inclusive, so let's fix that.

Reviewed By: markbt

Differential Revision: D19580840

fbshipit-source-id: 13770a8e9351fe62f58e9a701b526a167752543a
This commit is contained in:
Kostia Balytskyi 2020-01-27 09:34:48 -08:00 committed by Facebook Github Bot
parent c000642937
commit 6bf47a9f5a
2 changed files with 8 additions and 3 deletions

View File

@ -181,9 +181,9 @@ impl HgTime {
date if date.starts_with("since ") => {
Self::parse(&date[6..]).map(|start| start..Self::max_value())
}
date if date.starts_with("<") => {
Self::parse(&date[1..]).map(|end| Self::min_value()..end)
}
date if date.starts_with("<") => Self::parse(&date[1..])
.and_then(|end| end + 1)
.map(|end| Self::min_value()..end),
date if date.starts_with("-") => {
// This does not really make much sense. But is supported by hg
// (see 'hg help dates').

View File

@ -246,6 +246,11 @@ Test date formats with '>' or '<' accompanied by space characters
Wed Feb 01 13:00:30 2006 -0500
Wed Feb 01 13:00:30 2006 +0000
Test that '<' and '>' are inclusive
$ THISCOMMIT=$(hg log -r . -T "{date|hgdate}")
$ hg log -r "date(\"<$THISCOMMIT\") & date(\">$THISCOMMIT\")" -T "{node}"
cefbcc8b3dc9345a744a11713abfe40a53d4fc9d (no-eol)
Test issue 3764 (interpreting 'today' and 'yesterday')
$ echo "hello" >> a
>>> import datetime