show undo diff (#3213)

Exposes undo operations via the C API, and uses those to show a (new, differently formatted) diff before committing the undo.
This commit is contained in:
ryneeverett
2024-02-09 22:11:14 -05:00
committed by GitHub
parent 89df80c9f0
commit 34c0e67469
18 changed files with 646 additions and 66 deletions

View File

@@ -25,7 +25,8 @@ static void test_replica_undo_empty(void) {
TCReplica *rep = tc_replica_new_in_memory();
TEST_ASSERT_NULL(tc_replica_error(rep).ptr);
int undone;
int rv = tc_replica_undo(rep, &undone);
TCReplicaOpList undo_ops = tc_replica_get_undo_ops(rep);
int rv = tc_replica_commit_undo_ops(rep, undo_ops, &undone);
TEST_ASSERT_EQUAL(TC_RESULT_OK, rv);
TEST_ASSERT_EQUAL(0, undone);
TEST_ASSERT_NULL(tc_replica_error(rep).ptr);
@@ -114,11 +115,12 @@ static void test_replica_working_set(void) {
tc_replica_free(rep);
}
// When tc_replica_undo is passed NULL for undone_out, it still succeeds
// When tc_replica_commit_undo_ops is passed NULL for undone_out, it still succeeds
static void test_replica_undo_empty_null_undone_out(void) {
TCReplica *rep = tc_replica_new_in_memory();
TEST_ASSERT_NULL(tc_replica_error(rep).ptr);
int rv = tc_replica_undo(rep, NULL);
TCReplicaOpList undo_ops = tc_replica_get_undo_ops(rep);
int rv = tc_replica_commit_undo_ops(rep, undo_ops, NULL);
TEST_ASSERT_EQUAL(TC_RESULT_OK, rv);
TEST_ASSERT_NULL(tc_replica_error(rep).ptr);
tc_replica_free(rep);
@@ -156,7 +158,6 @@ static void test_replica_task_creation(void) {
tc_replica_free(rep);
}
// When tc_replica_undo is passed NULL for undone_out, it still succeeds
static void test_replica_sync_local(void) {
TCReplica *rep = tc_replica_new_in_memory();
TEST_ASSERT_NULL(tc_replica_error(rep).ptr);
@@ -182,7 +183,6 @@ static void test_replica_sync_local(void) {
tc_string_free(&err);
}
// When tc_replica_undo is passed NULL for undone_out, it still succeeds
static void test_replica_remote_server(void) {
TCString err;
TCServer *server = tc_server_new_sync(