Commit 061c1e06 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 443d47b9
......@@ -18,12 +18,39 @@
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Program treedelta-genallstructs generates subset of all possible tree changes
in between two trees that represent two specified key->value dicts.
"""Program treegen provides infrastructure to generate ZODB BTree states.
It is used as helper for ΔBTree tests.
Usage: treedelta-genallstructs <zurl> <n> <kv1> <kv2>
Treegen provides the following subcommands:
- `trees` generates trees specified as arguments,
- `allstructs` generates subset of all possible tree changes in between to
trees represented by two key->value dicts.
trees
-----
`treegen trees` ...
# tree1 (with values)
# tree2
# ...
# | treegen
# a zodb tree goes through tree states
# every state is committed as separate transaction & printed in the same
# format as treedelta-genallstructs.py does
allstructs
----------
`treegen allstructs` generates subset of all possible tree changes
in between two trees that represent two specified key->value dicts.
Usage: treegen allstructs <zurl> <n> <kv1> <kv2>
It generates ZODB commits with <tree1> -> <tree2> changes for subset of all
possible tree topologies tree1 and tree2 that can represent kv1 and kv2
......@@ -73,10 +100,10 @@ from BTrees import LOBTree
LOBTree.LOBTree = XLOTree
# treedeltaGenAllStructs generates subset of all possible tree changes in
# AllStructs generates subset of all possible tree changes in
# between kv1 and kv2. See top-level documentation for details.
@func
def treedeltaGenAllStructs(zstor, kv1txt, kv2txt, n, seed=None):
def AllStructs(zstor, kv1txt, kv2txt, n, seed=None):
db = DB(zstor); defer(db.close)
zconn = db.open(); defer(zconn.close)
root = zconn.root()
......@@ -270,23 +297,37 @@ def commit(description): # -> tid
# treetxt returns text representation of a tree.
def treetxt(ztree): # -> txt
return xbtree.TopoEncode(xbtree.StructureOf(ztree), vencode=...) # FIXME include values
return xbtree.TopoEncode(xbtree.StructureOf(ztree), vencode=lambda v:1/0) # FIXME include values
@func
def main():
if len(sys.argv) != 5:
print("Usage: %s <zurl> <n> <kv1> <kv2>" % sys.argv[0], file=sys.stderr)
def cmd_allstructs(argv):
if len(argv) != 4:
print("Usage: treegen allstructs <zurl> <n> <kv1> <kv2>", file=sys.stderr)
sys.exit(1)
zurl = sys.argv[1]
n = int(sys.argv[2])
kv1, kv2 = sys.argv[3:]
zurl = argv[0]
n = int(sys.argv[1])
kv1, kv2 = sys.argv[2:]
zstor = storageFromURL(zurl)
defer(zstor.close)
AllStructs(zstor, kv1, kv2, n)
cmdRegistry = {
'allstructs': cmd_allstructs,
'trees': cmd_trees,
}
def main():
if len(sys.argv) < 2:
print("Usage: treegen <command> ...", file=sys.stderr)
sys.exit(1)
treedeltaGenAllStructs(zstor, kv1, kv2, n)
cmd = cmdRegistry[sys.argv[1]]
argv = sys.argv[2:]
cmd(argv)
if __name__ == '__main__':
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Program treegen generates tree states ..."""
# XXX -> treecommit ?
# XXX input of known tricky cases from ΔBTree test driver
# tree1 (with values)
# tree2
# ...
# | treegen
#
# a zodb tree goes through tree states
# every state is committed as separate transaction & printed in the same
# format as treedelta-genallstructs.py does
# XXX move all into treegen? ex. `treegen allstructs n kv1 kv2`
# `treegen trees tree1 tree2 ... or stdin` ?
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