[PATCH 1 of 2 STABLE] parsedate: abort on negative dates (issue2513)

Adrian Buehlmann adrian at cadifra.com
Thu Nov 25 10:09:28 CST 2010


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1290623503 -3600
# Branch stable
# Node ID a16857b286917d964e9445cccde6d13582af90d5
# Parent  dd24f3e7ca9e68a49fd7f38803e4d98469cad6e4
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
 


More information about the Mercurial-devel mailing list