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