util: fix crash converting an invalid future date to string stable
authorKevin Gessner <kevin@fogcreek.com>
Fri, 23 Sep 2011 09:02:27 -0700
branchstable
changeset 15157 c208dcd0f709
parent 15152 94b200a11cf7
child 15158 7ce7177e029a
util: fix crash converting an invalid future date to string Post-2038 timestamps cannot be handled on 32-bit architectures. Clamp such dates to the maximum 32-bit timestamp.
mercurial/util.py
--- a/mercurial/util.py	Wed Sep 21 22:52:00 2011 +0200
+++ b/mercurial/util.py	Fri Sep 23 09:02:27 2011 -0700
@@ -891,7 +891,12 @@
         minutes = abs(tz) // 60
         format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
         format = format.replace("%2", "%02d" % (minutes % 60))
-    s = time.strftime(format, time.gmtime(float(t) - tz))
+    try:
+        t = time.gmtime(float(t) - tz)
+    except ValueError:
+        # time was out of range
+        t = time.gmtime(sys.maxint)
+    s = time.strftime(format, t)
     return s
 
 def shortdate(date=None):