# HG changeset patch # User Adrian Buehlmann # Date 2010-11-24 18:31:43 # Node ID e1002cf9fe54c8aa7d4b588c2239e23c8011e6bf # Parent 7e734ddad2e7ee1c9ef6f0ab59ef29c722dc9ab0 parsedate: abort on negative dates (issue2513) catches "hg commit -d '-7654321 3600'" (example) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1116,6 +1116,8 @@ def parsedate(date, formats=None, defaul # to UTC+14 if abs(when) > 0x7fffffff: raise Abort(_('date exceeds 32 bits: %d') % when) + if when < 0: + raise Abort(_('negative date value: %d') % when) if offset < -50400 or offset > 43200: raise Abort(_('impossible time zone offset: %d') % offset) return when, offset diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -22,6 +22,9 @@ commit date test $ hg commit -d '111111111111 0' -m commit-7 abort: date exceeds 32 bits: 111111111111 [255] + $ hg commit -d '-7654321 3600' -m commit-7 + abort: negative date value: -7654321 + [255] commit added file that has been deleted