Accept Merge Request #60: (pick_operation -> master)
Merge Request: Add pick_operation to sync with client Created By: @王琼钰 Accepted By: @王琼钰 URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/60
This commit is contained in:
@@ -9,7 +9,7 @@ from .operation import ChangeSet
|
|||||||
from .operation import get_current_operation
|
from .operation import get_current_operation
|
||||||
from .operation import execute_undo, execute_redo
|
from .operation import execute_undo, execute_redo
|
||||||
from .operation import have_snapshot, take_snapshot, pick_snapshot
|
from .operation import have_snapshot, take_snapshot, pick_snapshot
|
||||||
from .operation import sync_with_server
|
from .operation import pick_operation, sync_with_server
|
||||||
|
|
||||||
from .command import execute_batch_commands
|
from .command import execute_batch_commands
|
||||||
|
|
||||||
|
|||||||
@@ -129,12 +129,8 @@ def _get_parents(name: str, id: int) -> list[int]:
|
|||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
|
||||||
def pick_snapshot(name: str, tag: str, discard: bool) -> ChangeSet:
|
def pick_operation(name: str, operation: int, discard: bool) -> ChangeSet:
|
||||||
if not have_snapshot(name, tag):
|
target = operation
|
||||||
return ChangeSet()
|
|
||||||
|
|
||||||
target = int(read(name, f"select id from snapshot_operation where tag = '{tag}'")['id'])
|
|
||||||
|
|
||||||
curr = get_current_operation(name)
|
curr = get_current_operation(name)
|
||||||
|
|
||||||
curr_parents = _get_parents(name, curr)
|
curr_parents = _get_parents(name, curr)
|
||||||
@@ -171,6 +167,14 @@ def pick_snapshot(name: str, tag: str, discard: bool) -> ChangeSet:
|
|||||||
return change.compress()
|
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]:
|
def _get_change_set(name: str, operation: int, undo: bool) -> dict[str, Any]:
|
||||||
row = read(name, f'select * from operation where id = {operation}')
|
row = read(name, f'select * from operation where id = {operation}')
|
||||||
return eval(row['undo_cs']) if undo else eval(row['redo_cs'])
|
return eval(row['undo_cs']) if undo else eval(row['redo_cs'])
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ def take_snapshot(name: str, tag: str) -> int | None:
|
|||||||
def pick_snapshot(name: str, tag: str, discard: bool = False) -> ChangeSet:
|
def pick_snapshot(name: str, tag: str, discard: bool = False) -> ChangeSet:
|
||||||
return api.pick_snapshot(name, tag, discard)
|
return api.pick_snapshot(name, tag, discard)
|
||||||
|
|
||||||
|
def pick_operation(name: str, operation: int, discard: bool = False) -> ChangeSet:
|
||||||
|
return api.pick_operation(name, operation, discard)
|
||||||
|
|
||||||
def sync_with_server(name: str, operation: int) -> ChangeSet:
|
def sync_with_server(name: str, operation: int) -> ChangeSet:
|
||||||
return api.sync_with_server(name, operation)
|
return api.sync_with_server(name, operation)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user