##// END OF EJS Templates
errors: use InputError for incorrectly formatted dates...
Martin von Zweigbergk -
r47147:6894c9ef default
parent child Browse files
Show More
@@ -68,7 +68,9 b' def makedate(timestamp=None):'
68 68 timestamp = time.time()
69 69 if timestamp < 0:
70 70 hint = _(b"check your clock")
71 raise error.Abort(_(b"negative timestamp: %d") % timestamp, hint=hint)
71 raise error.InputError(
72 _(b"negative timestamp: %d") % timestamp, hint=hint
73 )
72 74 delta = datetime.datetime.utcfromtimestamp(
73 75 timestamp
74 76 ) - datetime.datetime.fromtimestamp(timestamp)
@@ -328,24 +330,26 b' def matchdate(date):'
328 330 date = date.strip()
329 331
330 332 if not date:
331 raise error.Abort(_(b"dates cannot consist entirely of whitespace"))
333 raise error.InputError(
334 _(b"dates cannot consist entirely of whitespace")
335 )
332 336 elif date[0:1] == b"<":
333 337 if not date[1:]:
334 raise error.Abort(_(b"invalid day spec, use '<DATE'"))
338 raise error.InputError(_(b"invalid day spec, use '<DATE'"))
335 339 when = upper(date[1:])
336 340 return lambda x: x <= when
337 341 elif date[0:1] == b">":
338 342 if not date[1:]:
339 raise error.Abort(_(b"invalid day spec, use '>DATE'"))
343 raise error.InputError(_(b"invalid day spec, use '>DATE'"))
340 344 when = lower(date[1:])
341 345 return lambda x: x >= when
342 346 elif date[0:1] == b"-":
343 347 try:
344 348 days = int(date[1:])
345 349 except ValueError:
346 raise error.Abort(_(b"invalid day spec: %s") % date[1:])
350 raise error.InputError(_(b"invalid day spec: %s") % date[1:])
347 351 if days < 0:
348 raise error.Abort(
352 raise error.InputError(
349 353 _(b"%s must be nonnegative (see 'hg help dates')") % date[1:]
350 354 )
351 355 when = makedate()[0] - days * 3600 * 24
@@ -103,43 +103,43 b' Negative range'
103 103
104 104 $ hg log -d "--2"
105 105 abort: -2 must be nonnegative (see 'hg help dates')
106 [255]
106 [10]
107 107
108 108 Whitespace only
109 109
110 110 $ hg log -d " "
111 111 abort: dates cannot consist entirely of whitespace
112 [255]
112 [10]
113 113
114 114 Test date formats with '>' or '<' accompanied by space characters
115 115
116 116 $ hg log -d '>' --template '{date|date}\n'
117 117 abort: invalid day spec, use '>DATE'
118 [255]
118 [10]
119 119 $ hg log -d '<' --template '{date|date}\n'
120 120 abort: invalid day spec, use '<DATE'
121 [255]
121 [10]
122 122
123 123 $ hg log -d ' >' --template '{date|date}\n'
124 124 abort: invalid day spec, use '>DATE'
125 [255]
125 [10]
126 126 $ hg log -d ' <' --template '{date|date}\n'
127 127 abort: invalid day spec, use '<DATE'
128 [255]
128 [10]
129 129
130 130 $ hg log -d '> ' --template '{date|date}\n'
131 131 abort: invalid day spec, use '>DATE'
132 [255]
132 [10]
133 133 $ hg log -d '< ' --template '{date|date}\n'
134 134 abort: invalid day spec, use '<DATE'
135 [255]
135 [10]
136 136
137 137 $ hg log -d ' > ' --template '{date|date}\n'
138 138 abort: invalid day spec, use '>DATE'
139 [255]
139 [10]
140 140 $ hg log -d ' < ' --template '{date|date}\n'
141 141 abort: invalid day spec, use '<DATE'
142 [255]
142 [10]
143 143
144 144 $ hg log -d '>02/01' --template '{date|date}\n'
145 145 $ hg log -d '<02/01' --template '{date|date}\n'
General Comments 0
You need to be logged in to leave comments. Login now