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.
--- 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):