Add pick_operation to sync with client

This commit is contained in:
WQY\qiong
2022-10-24 21:52:35 +08:00
parent 5597d3afd0
commit 8cfd22e17d
3 changed files with 14 additions and 7 deletions

View File

@@ -141,12 +141,8 @@ def _get_parents(name: str, id: int) -> list[int]:
return ids
def pick_snapshot(name: str, tag: str, discard: bool) -> ChangeSet:
if not have_snapshot(name, tag):
return ChangeSet()
target = int(read(name, f"select id from snapshot_operation where tag = '{tag}'")['id'])
def pick_operation(name: str, operation: int, discard: bool) -> ChangeSet:
target = operation
curr = get_current_operation(name)
curr_parents = _get_parents(name, curr)
@@ -183,6 +179,14 @@ def pick_snapshot(name: str, tag: str, discard: bool) -> ChangeSet:
return change.compress()
def pick_snapshot(name: str, tag: str, discard: bool) -> ChangeSet:
if not have_snapshot(name, tag):
return ChangeSet()
target = int(read(name, f"select id from snapshot_operation where tag = '{tag}'")['id'])
return pick_operation(name, target, discard)
def _get_change_set(name: str, operation: int, undo: bool) -> dict[str, Any]:
row = read(name, f'select * from operation where id = {operation}')
return eval(row['undo_cs']) if undo else eval(row['redo_cs'])