[PATCH] util: parsedate: Update to understand 'today' and 'yesterday' (issue 3764)
Augie Fackler
raf at durin42.com
Wed Jan 23 09:01:39 CST 2013
On Tue, Jan 22, 2013 at 04:28:04PM -0800, Paul Cavallaro wrote:
> # HG changeset patch
> # User Paul Cavallaro <ptc at fb.com>
> # Date 1358900012 28800
> # Node ID 1ad84126894a6d1127a7098b605df797f9e49c12
> # Parent 1f794204abbd7dd4bc329ae0c7c4fd7ce56b33af
> util: parsedate: Update to understand 'today' and 'yesterday' (issue 3764)
> ***
> Adding support for "today" and "yesterday" to parsedate
>
> Test Plan: Use `./hg log -d today` or another command
Looks like some cruft from a previous round of these and either a
qfold or a histedit?
As Wagner mentioned, this will likely need to wait for after the code
freeze is done.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1035,6 +1035,13 @@
> if not formats:
> formats = defaultdateformats
> date = date.strip()
> +
> + if date == 'today':
> + date = datetime.date.today().strftime('%b %d')
> + elif date == 'yesterday':
> + date = (datetime.date.today() -
> + datetime.timedelta(days=1)).strftime('%b %d')
> +
> try:
> when, offset = map(int, date.split(' '))
> except ValueError:
> diff --git a/tests/test-parse-date.t b/tests/test-parse-date.t
> --- a/tests/test-parse-date.t
> +++ b/tests/test-parse-date.t
> @@ -234,3 +234,13 @@
> 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
> + $ hg ci -d "`date +'%b %d'`" -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 "`date +'%b'` $((`date +'%d'` - 1))" -m "the time traveler's code"
I feel like $(( )) is a bashism (and my brief experiment in dash
suggests my memory isn't totally crazy. Can you do this with some
inline Python (search for >>> in a .t file if you need an example)
instead of the shell tricks?
> + $ hg log -d yesterday --template '{desc}\n'
> + the time traveler's code
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list