changeset 13063:e98581d44f0b stable

makedate: abort on negative timestamps (issue2513) catches weird clock settings
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 24 Nov 2010 19:31:43 +0100
parents e1002cf9fe54
children 487b5787fe01
files mercurial/util.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Wed Nov 24 19:31:43 2010 +0100
+++ b/mercurial/util.py	Wed Nov 24 19:31:43 2010 +0100
@@ -1015,7 +1015,11 @@
         tz = time.altzone
     else:
         tz = time.timezone
-    return time.mktime(lt), tz
+    t = time.mktime(lt)
+    if t < 0:
+        hint = _("check your clock")
+        raise Abort(_("negative timestamp: %d") % t, hint=hint)
+    return t, tz
 
 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'):
     """represent a (unixtime, offset) tuple as a localized time.