# HG changeset patch # User Florent Gallaire # Date 1460413828 -7200 # Node ID b0811a9fe67c0c3858ce607f236f8693e7b96af0 # Parent 6e06fbee9244dcfaa75bebe848913e4ab09ad54c date: fix boundary check of negative integer diff -r 6e06fbee9244 -r b0811a9fe67c mercurial/util.py --- a/mercurial/util.py Sun Apr 10 22:00:34 2016 +0100 +++ b/mercurial/util.py Tue Apr 12 00:30:28 2016 +0200 @@ -1595,8 +1595,8 @@ 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 @@ # 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 -r 6e06fbee9244 -r b0811a9fe67c tests/test-commit.t --- a/tests/test-commit.t Sun Apr 10 22:00:34 2016 +0100 +++ b/tests/test-commit.t Tue Apr 12 00:30:28 2016 +0200 @@ -31,17 +31,17 @@ 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 @@ dir/file committing manifest committing changelog - committed changeset 4:76aab26859d7 + committed changeset 4:1957363f1ced $ echo > dir.file $ hg add @@ -91,7 +91,7 @@ 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 @@ dir/file committing manifest committing changelog - committed changeset 6:4b4c75bf422d + committed changeset 6:32d054c9d085 An empty date was interpreted as epoch origin