util.datestr: use divmod()
We were computing the quotient and remainder of a division operation
separately. The built-in divmod() function allows us to do this with
a single function call. Do that.
--- a/mercurial/util.py Sat Nov 14 17:44:01 2015 -0800
+++ b/mercurial/util.py Sat Nov 14 17:30:10 2015 -0800
@@ -1367,9 +1367,10 @@
if "%1" in format or "%2" in format or "%z" in format:
sign = (tz > 0) and "-" or "+"
minutes = abs(tz) // 60
+ q, r = divmod(minutes, 60)
format = format.replace("%z", "%1%2")
- format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
- format = format.replace("%2", "%02d" % (minutes % 60))
+ format = format.replace("%1", "%c%02d" % (sign, q))
+ format = format.replace("%2", "%02d" % r)
try:
t = time.gmtime(float(t) - tz)
except ValueError: