comparison hgext/blackbox.py @ 48599:abbecb5cd6f3

blackbox: change year in logs to ISO 8601 format AFAIK, year/month/day is not a format than anyone uses. It seems more sensible to me to use ISO 8601, as that's standard and unambiguously year-month-day. Compatibility-wise, I think it's acceptable to change the default format. It's most for human consumption. It's plausible that a few tools parse this format, but it has already changed in the past (for instance to add the current revision). Differential Revision: https://phab.mercurial-scm.org/D12006
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Mon, 17 Jan 2022 21:20:46 -0500
parents 011f5218ff2d
children 6000f5b25c9b
comparison
equal deleted inserted replaced
48598:011f5218ff2d 48599:abbecb5cd6f3
139 date = dateutil.datestr(default, dateformat) 139 date = dateutil.datestr(default, dateformat)
140 else: 140 else:
141 # We want to display milliseconds (more precision seems 141 # We want to display milliseconds (more precision seems
142 # unnecessary). Since %.3f is not supported, use %f and truncate 142 # unnecessary). Since %.3f is not supported, use %f and truncate
143 # microseconds. 143 # microseconds.
144 date = dateutil.datestr(default, b'%Y/%m/%d %H:%M:%S.%f')[:-3] 144 date = dateutil.datestr(default, b'%Y-%m-%d %H:%M:%S.%f')[:-3]
145 user = procutil.getuser() 145 user = procutil.getuser()
146 pid = b'%d' % procutil.getpid() 146 pid = b'%d' % procutil.getpid()
147 changed = b'' 147 changed = b''
148 ctx = self._repo[None] 148 ctx = self._repo[None]
149 parents = ctx.parents() 149 parents = ctx.parents()
225 output = [] 225 output = []
226 for line in reversed(lines): 226 for line in reversed(lines):
227 if count >= limit: 227 if count >= limit:
228 break 228 break
229 229
230 # count the commands by matching lines like: 2013/01/23 19:13:36 root> 230 # count the commands by matching lines like:
231 # 2013/01/23 19:13:36 root>
232 # 2013/01/23 19:13:36 root (1234)>
233 # 2013/01/23 19:13:36 root @0000000000000000000000000000000000000000 (1234)>
234 # 2013-01-23 19:13:36.000 root @0000000000000000000000000000000000000000 (1234)>
231 if re.match( 235 if re.match(
232 br'^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}(.\d*)? .*> .*', line 236 br'^\d{4}[-/]\d{2}[-/]\d{2} \d{2}:\d{2}:\d{2}(.\d*)? .*> .*', line
233 ): 237 ):
234 count += 1 238 count += 1
235 output.append(line) 239 output.append(line)
236 240
237 ui.status(b'\n'.join(reversed(output))) 241 ui.status(b'\n'.join(reversed(output)))