diff tests/test-commit.t @ 32496:bb18728ea617

util: raise ParseError when parsing dates (BC) a7dce526c462 refactored util.parsedate in order to raise ValueError instead of Abort for using with ui.configwith. It causes several problems, putting arbitrary bytes in ValueError can cause issues with Python 3. Moreover, we added a function to convert ValueError exceptions back to Abort. A better approach would be to make parsedate raises ParseError, removing the convert function and update configwith to also catch ParseError. The side-effect is that error message when giving an invalid date in CLI change from: abort: invalid date: 'foo bar' to: hg: parse error: invalid date: 'foo bar' I'm not sure if it's an acceptable change, I found personally the error message more clear but more verbose too.
author Boris Feld <boris.feld@octobus.net>
date Wed, 24 May 2017 17:50:17 +0200
parents f94d7e3e46a0
children 6d88468d435b
line wrap: on
line diff
--- a/tests/test-commit.t	Tue May 16 14:31:21 2017 -0700
+++ b/tests/test-commit.t	Wed May 24 17:50:17 2017 +0200
@@ -15,20 +15,20 @@
   $ hg commit -d '0 0' -m commit-1
   $ echo foo >> foo
   $ hg commit -d '1 4444444' -m commit-3
-  abort: impossible time zone offset: 4444444
+  hg: parse error: impossible time zone offset: 4444444
   [255]
   $ hg commit -d '1	15.1' -m commit-4
-  abort: invalid date: '1\t15.1'
+  hg: parse error: invalid date: '1\t15.1'
   [255]
   $ hg commit -d 'foo bar' -m commit-5
-  abort: invalid date: 'foo bar'
+  hg: parse error: invalid date: 'foo bar'
   [255]
   $ hg commit -d ' 1 4444' -m commit-6
   $ hg commit -d '111111111111 0' -m commit-7
-  abort: date exceeds 32 bits: 111111111111
+  hg: parse error: date exceeds 32 bits: 111111111111
   [255]
   $ hg commit -d '-111111111111 0' -m commit-7
-  abort: date exceeds 32 bits: -111111111111
+  hg: parse error: date exceeds 32 bits: -111111111111
   [255]
   $ echo foo >> foo
   $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2
@@ -38,10 +38,10 @@
   3 1901-12-13 20:45:52 +0000
   2 1901-12-13 20:45:52 +0000
   $ hg commit -d '1901-12-13 20:45:51 +0000' -m commit-7
-  abort: date exceeds 32 bits: -2147483649
+  hg: parse error: date exceeds 32 bits: -2147483649
   [255]
   $ hg commit -d '-2147483649 0' -m commit-7
-  abort: date exceeds 32 bits: -2147483649
+  hg: parse error: date exceeds 32 bits: -2147483649
   [255]
 
 commit added file that has been deleted