diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1595,8 +1595,8 @@ def datestr(date=None, format='%a %b %d d = t - tz if d > 0x7fffffff: d = 0x7fffffff - elif d < -0x7fffffff: - d = -0x7fffffff + elif d < -0x80000000: + d = -0x80000000 # Never use time.gmtime() and datetime.datetime.fromtimestamp() # because they use the gmtime() system call which is buggy on Windows # for negative values. @@ -1720,7 +1720,7 @@ def parsedate(date, formats=None, bias=N # time zone offset. values must fit in signed 32 bits for # current 32-bit linux runtimes. timezones go from UTC-12 # to UTC+14 - if abs(when) > 0x7fffffff: + if when < -0x80000000 or when > 0x7fffffff: raise Abort(_('date exceeds 32 bits: %d') % when) if offset < -50400 or offset > 43200: raise Abort(_('impossible time zone offset: %d') % offset) diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -31,17 +31,17 @@ commit date test abort: date exceeds 32 bits: -111111111111 [255] $ echo foo >> foo - $ hg commit -d '1901-12-13 20:45:53 +0000' -m commit-7-2 + $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2 $ echo foo >> foo - $ hg commit -d '-2147483647 0' -m commit-7-3 + $ hg commit -d '-2147483648 0' -m commit-7-3 $ hg log -T '{rev} {date|isodatesec}\n' -l2 - 3 1901-12-13 20:45:53 +0000 - 2 1901-12-13 20:45:53 +0000 - $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7 - abort: date exceeds 32 bits: -2147483648 + 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 [255] - $ hg commit -d '-2147483648 0' -m commit-7 - abort: date exceeds 32 bits: -2147483648 + $ hg commit -d '-2147483649 0' -m commit-7 + abort: date exceeds 32 bits: -2147483649 [255] commit added file that has been deleted @@ -67,7 +67,7 @@ commit added file that has been deleted dir/file committing manifest committing changelog - committed changeset 4:76aab26859d7 + committed changeset 4:1957363f1ced $ echo > dir.file $ hg add @@ -91,7 +91,7 @@ commit added file that has been deleted dir/file committing manifest committing changelog - committed changeset 5:9a50557f1baf + committed changeset 5:a31d8f87544a $ cd .. $ hg commit -m commit-14 does-not-exist @@ -115,7 +115,7 @@ commit added file that has been deleted dir/file committing manifest committing changelog - committed changeset 6:4b4c75bf422d + committed changeset 6:32d054c9d085 An empty date was interpreted as epoch origin