##// END OF EJS Templates
validate the resulting date in parsedate
Benoit Boissinot -
r2523:4ab59a3a default
parent child Browse files
Show More
@@ -39,16 +39,7 b' class changelog(revlog):'
39 def add(self, manifest, list, desc, transaction, p1=None, p2=None,
39 def add(self, manifest, list, desc, transaction, p1=None, p2=None,
40 user=None, date=None):
40 user=None, date=None):
41 if date:
41 if date:
42 # validate explicit (probably user-specified) date and
42 parseddate = "%d %d" % util.parsedate(date)
43 # time zone offset. values must fit in signed 32 bits for
44 # current 32-bit linux runtimes. timezones go from UTC-12
45 # to UTC+14
46 when, offset = util.parsedate(date)
47 if abs(when) > 0x7fffffff:
48 raise ValueError(_('date exceeds 32 bits: %d') % when)
49 if offset < -50400 or offset > 43200:
50 raise ValueError(_('impossible time zone offset: %d') % offset)
51 parseddate = "%d %d" % (when, offset)
52 else:
43 else:
53 parseddate = "%d %d" % util.makedate()
44 parseddate = "%d %d" % util.makedate()
54 list.sort()
45 list.sort()
@@ -882,13 +882,25 b" def parsedate(string, formats=('%Y-%m-%d"
882 formats."""
882 formats."""
883 try:
883 try:
884 when, offset = map(int, string.split(' '))
884 when, offset = map(int, string.split(' '))
885 return when, offset
885 except ValueError:
886 except ValueError: pass
886 for format in formats:
887 for format in formats:
887 try:
888 try:
888 when, offset = strdate(string, format)
889 return strdate(string, format)
889 except ValueError:
890 except ValueError: pass
890 pass
891 raise ValueError(_('invalid date: %r') % string)
891 else:
892 break
893 else:
894 raise ValueError(_('invalid date: %r') % string)
895 # validate explicit (probably user-specified) date and
896 # time zone offset. values must fit in signed 32 bits for
897 # current 32-bit linux runtimes. timezones go from UTC-12
898 # to UTC+14
899 if abs(when) > 0x7fffffff:
900 raise ValueError(_('date exceeds 32 bits: %d') % when)
901 if offset < -50400 or offset > 43200:
902 raise ValueError(_('impossible time zone offset: %d') % offset)
903 return when, offset
892
904
893 def shortuser(user):
905 def shortuser(user):
894 """Return a short representation of a user name or email address."""
906 """Return a short representation of a user name or email address."""
General Comments 0
You need to be logged in to leave comments. Login now