Commit 773bfa97 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Julien Muchembled

neoctl: Change the expected tid-or-timestamp format

Before this change, the only distinction between a timestamp and a TID was
the presence of the decimal separator, ".". As a result, a timestamp
mistakenly provided without a decimal separator would be interpreted as a
TID, which will be somewhere in January 1900 (as TIDs are 64bits with much
finer accuracy than timestamps). When used to truncate a database, and in
the absence of sanity checks, this would simply wipe the database.

So, instead of just relying on a decimal separator, require a longer
string. Make it a prefix for readability. Also, TIDs are more niche than
timestamp, require them to have a mark, and do not require anything from
timestamps.
parent eb3a3937
# -*- coding: utf-8 -*-
#
# Copyright (C) 2006-2019 Nexedi SA
#
......@@ -70,9 +71,9 @@ class TerminalNeoCTL(object):
return getattr(ClusterStates, value.upper())
def asTID(self, value):
if '.' in value:
if value.lower().startswith('tid:'):
return p64(int(value[4:], 0))
return tidFromTime(float(value))
return p64(int(value, 0))
asNode = staticmethod(uuid_int)
......@@ -386,7 +387,8 @@ class Application(object):
def usage(self):
output_list = ('Available commands:', self._usage(action_dict),
"TID arguments can be either integers or timestamps as floats,"
" e.g. '257684787499560686', '0x3937af2eeeeeeee' or '1325421296.'"
" for 2012-01-01 12:34:56 UTC")
"The syntax of « TID » arguments is either tid:<integer>"
" (case insensitive) for a TID or <float> for a UNIX timestamp,"
" e.g. 'tid:257684787499560686', 'tid:0x3937af2eeeeeeee' or"
" '1325421296' for 2012-01-01 12:34:56 UTC.")
return '\n'.join(output_list)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment