Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
061c1e06
Commit
061c1e06
authored
May 25, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
443d47b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
49 deletions
+54
-49
wcfs/testprog/treegen.py
wcfs/testprog/treegen.py
+54
-13
wcfs/testprog/treegen.py.4merge
wcfs/testprog/treegen.py.4merge
+0
-36
No files found.
wcfs/testprog/treegen.py
View file @
061c1e06
...
...
@@ -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
#
treedeltaGen
AllStructs 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
treedeltaGen
AllStructs
(
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__'
:
...
...
wcfs/testprog/treegen.py.4merge
deleted
100644 → 0
View file @
443d47b9
#!/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` ?
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment