some python versionstamp api tweaks
This commit is contained in:
parent
381928535c
commit
396434794d
|
@ -95,11 +95,11 @@ class RandomGenerator(object):
|
|||
tup.append(self.random_tuple(length))
|
||||
elif choice == 'versionstamp':
|
||||
if incomplete_versionstamps and random.random() < 0.5:
|
||||
commit_version = fdb.tuple.Versionstamp._UNSET_TR_VERSION
|
||||
tr_version = fdb.tuple.Versionstamp._UNSET_TR_VERSION
|
||||
else:
|
||||
commit_version = self.random_string(10)
|
||||
tr_version = self.random_string(10)
|
||||
user_version = random.randint(0, 0xffff)
|
||||
tup.append(fdb.tuple.Versionstamp(commit_version, user_version))
|
||||
tup.append(fdb.tuple.Versionstamp(tr_version, user_version))
|
||||
else:
|
||||
assert false
|
||||
|
||||
|
|
|
@ -145,6 +145,10 @@ class Versionstamp(object):
|
|||
self.tr_version = tr_version
|
||||
self.user_version = user_version
|
||||
|
||||
@staticmethod
|
||||
def incomplete(user_version=0):
|
||||
return Versionstamp(user_version=user_version)
|
||||
|
||||
@classmethod
|
||||
def from_bytes(cls, v, start=0):
|
||||
if not isinstance(v, bytes):
|
||||
|
@ -212,7 +216,7 @@ class Versionstamp(object):
|
|||
return hash(self.tr_version) * 37 ^ hash(self.user_version)
|
||||
|
||||
def __nonzero__(self):
|
||||
return bool(self.tr_version) or bool(self.user_version)
|
||||
return self.is_complete()
|
||||
|
||||
def _decode(v, pos):
|
||||
code = six.indexbytes(v, pos)
|
||||
|
|
Loading…
Reference in New Issue