# HG changeset patch # User timeless # Date 1300242536 -3600 # Node ID c49cddce0a819bb7a940c6dda4e597967163f4c2 # Parent e798e430c5e5f6434c063fa24015beda407e2238 templates: provide granularity for future values for age filter diff -r e798e430c5e5 -r c49cddce0a81 mercurial/templatefilters.py --- a/mercurial/templatefilters.py Wed Mar 16 23:09:14 2011 +0100 +++ b/mercurial/templatefilters.py Wed Mar 16 03:28:56 2011 +0100 @@ -36,16 +36,22 @@ now = time.time() then = date[0] + future = False if then > now: - return 'in the future' - - delta = max(1, int(now - then)) - if delta > agescales[0][1] * 2: - return util.shortdate(date) + future = True + delta = max(1, int(then - now)) + if delta > agescales[0][1] * 30: + return 'in the distant future' + else: + delta = max(1, int(now - then)) + if delta > agescales[0][1] * 2: + return util.shortdate(date) for t, s in agescales: n = delta // s if n >= 2 or s == 1: + if future: + return '%s from now' % fmt(t, n) return '%s ago' % fmt(t, n) def basename(path): diff -r e798e430c5e5 -r c49cddce0a81 tests/test-command-template.t --- a/tests/test-command-template.t Wed Mar 16 23:09:14 2011 +0100 +++ b/tests/test-command-template.t Wed Mar 16 03:28:56 2011 +0100 @@ -1115,7 +1115,7 @@ $ hg log --template '{date|age}\n' > /dev/null || exit 1 $ hg log -l1 --template '{date|age}\n' - in the future + 8 years from now $ hg log --template '{date|date}\n' Wed Jan 01 10:01:00 2020 +0000 Mon Jan 12 13:46:40 1970 +0000