Commit 000f662b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f21ee047
......@@ -2,6 +2,22 @@
# -*- 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 treedelta-genallstructs commits subset of all possible tree changes
in between two trees specified key->value sets.
......@@ -15,8 +31,8 @@ correspondingly.
For every made commit it prints to stdout:
# <tree1> -> <tree2>
tid <tid>
tid <tid> # <tree1> -> <tree2>
tree <oid>
δ
<LF>
......@@ -28,6 +44,44 @@ XXX
from __future__ import print_function, absolute_import
import sys
from ZODB import DB
import transaction
from wendelin.wcfs.internal import xbtree
# init initializes ...
@func
def init(zstor):
db = DB(zstor); defer(db.close)
zconn = db.open(); defer(zconn.close)
root = zconn.root()
# valdict is {} for values
# {} v -> ZBlk(v)
valdict = root.setdefault('treedelta/values', {})
for v in b'abcdefghi':
valdict[v] = ZBlk(v)
transaction.commit()
# XXX
#
# kv: k₁:v₁,k₂:v₂,...
@func
def treedeltaGenAllStructs(zstor, kv1, kv2, n):
db = DB(zstor); defer(db.close)
zconn = db.open(); defer(zconn.close)
root = zconn.root()
valdict = root['treedelta/values']
# vdecode decodes value text into value object, e.g. 'a' -> ZBlk(a)
def vdecode(vtxt): # -> vobj
return valdict[vtxt]
# vencode encodes value object into value text, e.g. ZBlk(a) -> 'a'
def vencode(vobj): # -> vtxt
for (k,v) in valdict.items():
if v is vobj:
return k
raise KeyError("%r not found in value registry" % (vobj,))
def main():
......@@ -36,8 +90,7 @@ def main():
sys.exit(1)
n = int(sys.argv[1])
zurl, kv1, kv2 = sys.argv[2:]
zurl, kv1, kv2 = sys.argv[2:] # XXX kv decode
if __name__ == '__main__':
......
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