1 /* revs-txns.c : operations on revision and transactions
3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
25 #include <apr_tables.h>
26 #include <apr_pools.h>
28 #include "svn_pools.h"
31 #include "svn_props.h"
40 #include "revs-txns.h"
43 #include "bdb/rev-table.h"
44 #include "bdb/txn-table.h"
45 #include "bdb/copies-table.h"
46 #include "bdb/changes-table.h"
47 #include "../libsvn_fs/fs-loader.h"
49 #include "svn_private_config.h"
50 #include "private/svn_fs_util.h"
55 /* Set *txn_p to a transaction object allocated in POOL for the
56 transaction in FS whose id is TXN_ID. If EXPECT_DEAD is set, this
57 transaction must be a dead one, else an error is returned. If
58 EXPECT_DEAD is not set, the transaction must *not* be a dead one,
59 else an error is returned. */
61 get_txn(transaction_t **txn_p,
64 svn_boolean_t expect_dead,
69 SVN_ERR(svn_fs_bdb__get_txn(&txn, fs, txn_id, trail, pool));
70 if (expect_dead && (txn->kind != transaction_kind_dead))
71 return svn_error_createf(SVN_ERR_FS_TRANSACTION_NOT_DEAD, 0,
72 _("Transaction is not dead: '%s'"), txn_id);
73 if ((! expect_dead) && (txn->kind == transaction_kind_dead))
74 return svn_error_createf(SVN_ERR_FS_TRANSACTION_DEAD, 0,
75 _("Transaction is dead: '%s'"), txn_id);
81 /* This is only for symmetry with the get_txn() helper. */
82 #define put_txn svn_fs_bdb__put_txn
88 /* Return the committed transaction record *TXN_P and its ID *TXN_ID
89 (as long as those parameters aren't NULL) for the revision REV in
90 FS as part of TRAIL. */
92 get_rev_txn(transaction_t **txn_p,
102 SVN_ERR(svn_fs_bdb__get_rev(&revision, fs, rev, trail, pool));
103 if (revision->txn_id == NULL)
104 return svn_fs_base__err_corrupt_fs_revision(fs, rev);
106 SVN_ERR(get_txn(&txn, fs, revision->txn_id, FALSE, trail, pool));
107 if (txn->revision != rev)
108 return svn_fs_base__err_corrupt_txn(fs, revision->txn_id);
113 *txn_id = revision->txn_id;
119 svn_fs_base__rev_get_root(const svn_fs_id_t **root_id_p,
127 SVN_ERR(get_rev_txn(&txn, NULL, fs, rev, trail, pool));
128 if (txn->root_id == NULL)
129 return svn_fs_base__err_corrupt_fs_revision(fs, rev);
131 *root_id_p = txn->root_id;
137 svn_fs_base__rev_get_txn_id(const char **txn_id_p,
143 revision_t *revision;
145 SVN_ERR(svn_fs_bdb__get_rev(&revision, fs, rev, trail, pool));
146 if (revision->txn_id == NULL)
147 return svn_fs_base__err_corrupt_fs_revision(fs, rev);
149 *txn_id_p = revision->txn_id;
155 txn_body_youngest_rev(void *baton, trail_t *trail)
157 return svn_fs_bdb__youngest_rev(baton, trail->fs, trail, trail->pool);
162 svn_fs_base__youngest_rev(svn_revnum_t *youngest_p,
166 svn_revnum_t youngest;
167 SVN_ERR(svn_fs__check_fs(fs, TRUE));
168 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_youngest_rev, &youngest,
170 *youngest_p = youngest;
175 struct revision_proplist_args {
176 apr_hash_t **table_p;
182 txn_body_revision_proplist(void *baton, trail_t *trail)
184 struct revision_proplist_args *args = baton;
187 SVN_ERR(get_rev_txn(&txn, NULL, trail->fs, args->rev, trail, trail->pool));
188 *(args->table_p) = txn->proplist;
194 svn_fs_base__revision_proplist(apr_hash_t **table_p,
197 svn_boolean_t refresh,
198 apr_pool_t *result_pool,
199 apr_pool_t *scratch_pool)
201 struct revision_proplist_args args;
204 SVN_ERR(svn_fs__check_fs(fs, TRUE));
206 args.table_p = &table;
208 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_revision_proplist, &args,
209 FALSE, result_pool));
211 *table_p = table ? table : apr_hash_make(result_pool);
217 svn_fs_base__revision_prop(svn_string_t **value_p,
220 const char *propname,
221 svn_boolean_t refresh,
222 apr_pool_t *result_pool,
223 apr_pool_t *scratch_pool)
225 struct revision_proplist_args args;
228 SVN_ERR(svn_fs__check_fs(fs, TRUE));
230 /* Get the proplist. */
231 args.table_p = &table;
233 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_revision_proplist, &args,
234 FALSE, result_pool));
236 /* And then the prop from that list (if there was a list). */
237 *value_p = svn_hash_gets(table, propname);
244 svn_fs_base__set_rev_prop(svn_fs_t *fs,
247 const svn_string_t *const *old_value_p,
248 const svn_string_t *value,
254 const svn_string_t *present_value;
256 SVN_ERR(get_rev_txn(&txn, &txn_id, fs, rev, trail, pool));
257 present_value = svn_hash_gets(txn->proplist, name);
259 /* If there's no proplist, but we're just deleting a property, exit now. */
260 if ((! txn->proplist) && (! value))
263 /* Now, if there's no proplist, we know we need to make one. */
265 txn->proplist = apr_hash_make(pool);
267 /* Set the property. */
270 const svn_string_t *wanted_value = *old_value_p;
271 if ((!wanted_value != !present_value)
272 || (wanted_value && present_value
273 && !svn_string_compare(wanted_value, present_value)))
275 /* What we expected isn't what we found. */
276 return svn_error_createf(SVN_ERR_FS_PROP_BASEVALUE_MISMATCH, NULL,
277 _("revprop '%s' has unexpected value in "
284 /* If the prop-set is a no-op, skip the actual write. */
285 if ((!present_value && !value)
286 || (present_value && value
287 && svn_string_compare(present_value, value)))
290 svn_hash_sets(txn->proplist, name, value);
292 /* Overwrite the revision. */
293 return put_txn(fs, txn, txn_id, trail, pool);
297 struct change_rev_prop_args {
300 const svn_string_t *const *old_value_p;
301 const svn_string_t *value;
306 txn_body_change_rev_prop(void *baton, trail_t *trail)
308 struct change_rev_prop_args *args = baton;
310 return svn_fs_base__set_rev_prop(trail->fs, args->rev,
311 args->name, args->old_value_p, args->value,
317 svn_fs_base__change_rev_prop(svn_fs_t *fs,
320 const svn_string_t *const *old_value_p,
321 const svn_string_t *value,
324 struct change_rev_prop_args args;
326 SVN_ERR(svn_fs__check_fs(fs, TRUE));
330 args.old_value_p = old_value_p;
332 return svn_fs_base__retry_txn(fs, txn_body_change_rev_prop, &args,
338 /*** Transactions ***/
341 svn_fs_base__txn_make_committed(svn_fs_t *fs,
342 const char *txn_name,
343 svn_revnum_t revision,
349 SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(revision));
351 /* Make sure the TXN is not committed already. */
352 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
353 if (txn->kind != transaction_kind_normal)
354 return svn_fs_base__err_txn_not_mutable(fs, txn_name);
356 /* Convert TXN to a committed transaction. */
358 txn->revision = revision;
359 txn->kind = transaction_kind_committed;
360 return put_txn(fs, txn, txn_name, trail, pool);
365 svn_fs_base__txn_get_revision(svn_revnum_t *revision,
367 const char *txn_name,
372 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
373 *revision = txn->revision;
379 svn_fs_base__get_txn_ids(const svn_fs_id_t **root_id_p,
380 const svn_fs_id_t **base_root_id_p,
382 const char *txn_name,
388 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
389 if (txn->kind != transaction_kind_normal)
390 return svn_fs_base__err_txn_not_mutable(fs, txn_name);
392 *root_id_p = txn->root_id;
393 *base_root_id_p = txn->base_id;
399 svn_fs_base__set_txn_root(svn_fs_t *fs,
400 const char *txn_name,
401 const svn_fs_id_t *new_id,
407 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
408 if (txn->kind != transaction_kind_normal)
409 return svn_fs_base__err_txn_not_mutable(fs, txn_name);
411 if (! svn_fs_base__id_eq(txn->root_id, new_id))
413 txn->root_id = new_id;
414 SVN_ERR(put_txn(fs, txn, txn_name, trail, pool));
421 svn_fs_base__set_txn_base(svn_fs_t *fs,
422 const char *txn_name,
423 const svn_fs_id_t *new_id,
429 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
430 if (txn->kind != transaction_kind_normal)
431 return svn_fs_base__err_txn_not_mutable(fs, txn_name);
433 if (! svn_fs_base__id_eq(txn->base_id, new_id))
435 txn->base_id = new_id;
436 SVN_ERR(put_txn(fs, txn, txn_name, trail, pool));
443 svn_fs_base__add_txn_copy(svn_fs_t *fs,
444 const char *txn_name,
451 /* Get the transaction and ensure its mutability. */
452 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
453 if (txn->kind != transaction_kind_normal)
454 return svn_fs_base__err_txn_not_mutable(fs, txn_name);
456 /* Allocate a new array if this transaction has no copies. */
458 txn->copies = apr_array_make(pool, 1, sizeof(copy_id));
460 /* Add COPY_ID to the array. */
461 APR_ARRAY_PUSH(txn->copies, const char *) = copy_id;
463 /* Finally, write out the transaction. */
464 return put_txn(fs, txn, txn_name, trail, pool);
469 /* Generic transaction operations. */
471 struct txn_proplist_args {
472 apr_hash_t **table_p;
478 txn_body_txn_proplist(void *baton, trail_t *trail)
481 struct txn_proplist_args *args = baton;
483 SVN_ERR(get_txn(&txn, trail->fs, args->id, FALSE, trail, trail->pool));
484 if (txn->kind != transaction_kind_normal)
485 return svn_fs_base__err_txn_not_mutable(trail->fs, args->id);
487 *(args->table_p) = txn->proplist;
494 svn_fs_base__txn_proplist_in_trail(apr_hash_t **table_p,
498 struct txn_proplist_args args;
501 args.table_p = &table;
503 SVN_ERR(txn_body_txn_proplist(&args, trail));
505 *table_p = table ? table : apr_hash_make(trail->pool);
512 svn_fs_base__txn_proplist(apr_hash_t **table_p,
516 struct txn_proplist_args args;
518 svn_fs_t *fs = txn->fs;
520 SVN_ERR(svn_fs__check_fs(fs, TRUE));
522 args.table_p = &table;
524 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_txn_proplist, &args,
527 *table_p = table ? table : apr_hash_make(pool);
533 svn_fs_base__txn_prop(svn_string_t **value_p,
535 const char *propname,
538 struct txn_proplist_args args;
540 svn_fs_t *fs = txn->fs;
542 SVN_ERR(svn_fs__check_fs(fs, TRUE));
544 /* Get the proplist. */
545 args.table_p = &table;
547 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_txn_proplist, &args,
550 /* And then the prop from that list (if there was a list). */
551 *value_p = svn_hash_gets(table, propname);
558 struct change_txn_prop_args {
562 const svn_string_t *value;
567 svn_fs_base__set_txn_prop(svn_fs_t *fs,
568 const char *txn_name,
570 const svn_string_t *value,
576 SVN_ERR(get_txn(&txn, fs, txn_name, FALSE, trail, pool));
577 if (txn->kind != transaction_kind_normal)
578 return svn_fs_base__err_txn_not_mutable(fs, txn_name);
580 /* If there's no proplist, but we're just deleting a property, exit now. */
581 if ((! txn->proplist) && (! value))
584 /* Now, if there's no proplist, we know we need to make one. */
586 txn->proplist = apr_hash_make(pool);
588 /* Set the property. */
589 if (svn_hash_gets(txn->proplist, SVN_FS__PROP_TXN_CLIENT_DATE)
590 && !strcmp(name, SVN_PROP_REVISION_DATE))
591 svn_hash_sets(txn->proplist, SVN_FS__PROP_TXN_CLIENT_DATE,
592 svn_string_create("1", pool));
593 svn_hash_sets(txn->proplist, name, value);
595 /* Now overwrite the transaction. */
596 return put_txn(fs, txn, txn_name, trail, pool);
601 txn_body_change_txn_prop(void *baton, trail_t *trail)
603 struct change_txn_prop_args *args = baton;
604 return svn_fs_base__set_txn_prop(trail->fs, args->id, args->name,
605 args->value, trail, trail->pool);
610 svn_fs_base__change_txn_prop(svn_fs_txn_t *txn,
612 const svn_string_t *value,
615 struct change_txn_prop_args args;
616 svn_fs_t *fs = txn->fs;
618 SVN_ERR(svn_fs__check_fs(fs, TRUE));
623 return svn_fs_base__retry_txn(fs, txn_body_change_txn_prop, &args,
629 svn_fs_base__change_txn_props(svn_fs_txn_t *txn,
630 const apr_array_header_t *props,
633 apr_pool_t *iterpool = svn_pool_create(pool);
636 for (i = 0; i < props->nelts; i++)
638 svn_prop_t *prop = &APR_ARRAY_IDX(props, i, svn_prop_t);
640 svn_pool_clear(iterpool);
642 SVN_ERR(svn_fs_base__change_txn_prop(txn, prop->name,
643 prop->value, iterpool));
645 svn_pool_destroy(iterpool);
651 /* Creating a transaction */
653 static txn_vtable_t txn_vtable = {
654 svn_fs_base__commit_txn,
655 svn_fs_base__abort_txn,
656 svn_fs_base__txn_prop,
657 svn_fs_base__txn_proplist,
658 svn_fs_base__change_txn_prop,
659 svn_fs_base__txn_root,
660 svn_fs_base__change_txn_props
664 /* Allocate and return a new transaction object in POOL for FS whose
665 transaction ID is ID. ID is not copied. */
666 static svn_fs_txn_t *
667 make_txn(svn_fs_t *fs,
669 svn_revnum_t base_rev,
672 svn_fs_txn_t *txn = apr_pcalloc(pool, sizeof(*txn));
676 txn->base_rev = base_rev;
677 txn->vtable = &txn_vtable;
678 txn->fsap_data = NULL;
684 struct begin_txn_args
686 svn_fs_txn_t **txn_p;
687 svn_revnum_t base_rev;
693 txn_body_begin_txn(void *baton, trail_t *trail)
695 struct begin_txn_args *args = baton;
696 const svn_fs_id_t *root_id;
699 SVN_ERR(svn_fs_base__rev_get_root(&root_id, trail->fs, args->base_rev,
700 trail, trail->pool));
701 SVN_ERR(svn_fs_bdb__create_txn(&txn_id, trail->fs, root_id,
702 trail, trail->pool));
704 if (args->flags & SVN_FS_TXN_CHECK_OOD)
706 struct change_txn_prop_args cpargs;
707 cpargs.fs = trail->fs;
709 cpargs.name = SVN_FS__PROP_TXN_CHECK_OOD;
710 cpargs.value = svn_string_create("true", trail->pool);
712 SVN_ERR(txn_body_change_txn_prop(&cpargs, trail));
715 if (args->flags & SVN_FS_TXN_CHECK_LOCKS)
717 struct change_txn_prop_args cpargs;
718 cpargs.fs = trail->fs;
720 cpargs.name = SVN_FS__PROP_TXN_CHECK_LOCKS;
721 cpargs.value = svn_string_create("true", trail->pool);
723 SVN_ERR(txn_body_change_txn_prop(&cpargs, trail));
726 /* Put a datestamp on the newly created txn, so we always know
727 exactly how old it is. (This will help sysadmins identify
728 long-abandoned txns that may need to be manually removed.) Do
729 this before setting CLIENT_DATE so that it is not recorded as an
732 struct change_txn_prop_args cpargs;
734 cpargs.fs = trail->fs;
736 cpargs.name = SVN_PROP_REVISION_DATE;
737 date.data = svn_time_to_cstring(apr_time_now(), trail->pool);
738 date.len = strlen(date.data);
739 cpargs.value = &date;
740 SVN_ERR(txn_body_change_txn_prop(&cpargs, trail));
743 if (args->flags & SVN_FS_TXN_CLIENT_DATE)
745 struct change_txn_prop_args cpargs;
746 cpargs.fs = trail->fs;
748 cpargs.name = SVN_FS__PROP_TXN_CLIENT_DATE;
749 cpargs.value = svn_string_create("0", trail->pool);
751 SVN_ERR(txn_body_change_txn_prop(&cpargs, trail));
754 *args->txn_p = make_txn(trail->fs, txn_id, args->base_rev, trail->pool);
758 /* Note: it is acceptable for this function to call back into
759 public FS API interfaces because it does not itself use trails. */
761 svn_fs_base__begin_txn(svn_fs_txn_t **txn_p,
768 struct begin_txn_args args;
770 SVN_ERR(svn_fs__check_fs(fs, TRUE));
775 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_begin_txn, &args, FALSE, pool));
785 svn_fs_txn_t **txn_p;
791 txn_body_open_txn(void *baton, trail_t *trail)
793 struct open_txn_args *args = baton;
794 transaction_t *fstxn;
795 svn_revnum_t base_rev = SVN_INVALID_REVNUM;
798 SVN_ERR(get_txn(&fstxn, trail->fs, args->name, FALSE, trail, trail->pool));
799 if (fstxn->kind != transaction_kind_committed)
801 txn_id = svn_fs_base__id_txn_id(fstxn->base_id);
802 SVN_ERR(svn_fs_base__txn_get_revision(&base_rev, trail->fs, txn_id,
803 trail, trail->pool));
806 *args->txn_p = make_txn(trail->fs, args->name, base_rev, trail->pool);
812 svn_fs_base__open_txn(svn_fs_txn_t **txn_p,
818 struct open_txn_args args;
820 SVN_ERR(svn_fs__check_fs(fs, TRUE));
824 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_open_txn, &args, FALSE, pool));
831 struct cleanup_txn_args
833 transaction_t **txn_p;
839 txn_body_cleanup_txn(void *baton, trail_t *trail)
841 struct cleanup_txn_args *args = baton;
842 return get_txn(args->txn_p, trail->fs, args->name, TRUE,
848 txn_body_cleanup_txn_copy(void *baton, trail_t *trail)
850 const char *copy_id = *(const char **)baton;
851 svn_error_t *err = svn_fs_bdb__delete_copy(trail->fs, copy_id, trail,
854 /* Copy doesn't exist? No sweat. */
855 if (err && (err->apr_err == SVN_ERR_FS_NO_SUCH_COPY))
857 svn_error_clear(err);
860 return svn_error_trace(err);
865 txn_body_cleanup_txn_changes(void *baton, trail_t *trail)
867 const char *key = *(const char **)baton;
869 return svn_fs_bdb__changes_delete(trail->fs, key, trail, trail->pool);
873 struct get_dirents_args
875 apr_hash_t **dirents;
876 const svn_fs_id_t *id;
882 txn_body_get_dirents(void *baton, trail_t *trail)
884 struct get_dirents_args *args = baton;
888 SVN_ERR(svn_fs_base__dag_get_node(&node, trail->fs, args->id,
889 trail, trail->pool));
891 /* If immutable, do nothing and return. */
892 if (! svn_fs_base__dag_check_mutable(node, args->txn_id))
895 /* If a directory, do nothing and return. */
896 *(args->dirents) = NULL;
897 if (svn_fs_base__dag_node_kind(node) != svn_node_dir)
900 /* Else it's mutable. Get its dirents. */
901 return svn_fs_base__dag_dir_entries(args->dirents, node,
906 struct remove_node_args
908 const svn_fs_id_t *id;
914 txn_body_remove_node(void *baton, trail_t *trail)
916 struct remove_node_args *args = baton;
917 return svn_fs_base__dag_remove_node(trail->fs, args->id, args->txn_id,
923 delete_txn_tree(svn_fs_t *fs,
924 const svn_fs_id_t *id,
928 struct get_dirents_args dirent_args;
929 struct remove_node_args rm_args;
930 apr_hash_t *dirents = NULL;
931 apr_hash_index_t *hi;
934 /* If this sucker isn't mutable, there's nothing to do. */
935 if (strcmp(svn_fs_base__id_txn_id(id), txn_id) != 0)
938 /* See if the thing has dirents that need to be recursed upon. If
939 you can't find the thing itself, don't sweat it. We probably
940 already cleaned it up. */
941 dirent_args.dirents = &dirents;
943 dirent_args.txn_id = txn_id;
944 err = svn_fs_base__retry_txn(fs, txn_body_get_dirents, &dirent_args,
946 if (err && (err->apr_err == SVN_ERR_FS_ID_NOT_FOUND))
948 svn_error_clear(err);
953 /* If there are dirents upon which to recurse ... recurse. */
956 apr_pool_t *subpool = svn_pool_create(pool);
958 /* Loop over hash entries */
959 for (hi = apr_hash_first(pool, dirents); hi; hi = apr_hash_next(hi))
962 svn_fs_dirent_t *dirent;
964 svn_pool_clear(subpool);
965 apr_hash_this(hi, NULL, NULL, &val);
967 SVN_ERR(delete_txn_tree(fs, dirent->id, txn_id, subpool));
969 svn_pool_destroy(subpool);
972 /* Remove the node. */
974 rm_args.txn_id = txn_id;
975 return svn_fs_base__retry_txn(fs, txn_body_remove_node, &rm_args,
981 txn_body_delete_txn(void *baton, trail_t *trail)
983 const char *txn_id = *(const char **)baton;
985 return svn_fs_bdb__delete_txn(trail->fs, txn_id, trail, trail->pool);
990 svn_fs_base__purge_txn(svn_fs_t *fs,
994 struct cleanup_txn_args args;
997 SVN_ERR(svn_fs__check_fs(fs, TRUE));
999 /* Open the transaction, expecting it to be dead. */
1002 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_cleanup_txn, &args,
1005 /* Delete the mutable portion of the tree hanging from the
1006 transaction (which should gracefully recover if we've already
1008 SVN_ERR(delete_txn_tree(fs, txn->root_id, txn_id, pool));
1010 /* Kill the transaction's changes (which should gracefully recover
1012 SVN_ERR(svn_fs_base__retry_txn(fs, txn_body_cleanup_txn_changes,
1013 &txn_id, TRUE, pool));
1015 /* Kill the transaction's copies (which should gracefully...). */
1020 for (i = 0; i < txn->copies->nelts; i++)
1022 SVN_ERR(svn_fs_base__retry_txn
1023 (fs, txn_body_cleanup_txn_copy,
1024 &APR_ARRAY_IDX(txn->copies, i, const char *),
1029 /* Kill the transaction itself (which ... just kidding -- this has
1030 no graceful failure mode). */
1031 return svn_fs_base__retry_txn(fs, txn_body_delete_txn, &txn_id,
1036 static svn_error_t *
1037 txn_body_abort_txn(void *baton, trail_t *trail)
1039 svn_fs_txn_t *txn = baton;
1040 transaction_t *fstxn;
1042 /* Get the transaction by its id, set it to "dead", and store the
1044 SVN_ERR(get_txn(&fstxn, txn->fs, txn->id, FALSE, trail, trail->pool));
1045 if (fstxn->kind != transaction_kind_normal)
1046 return svn_fs_base__err_txn_not_mutable(txn->fs, txn->id);
1048 fstxn->kind = transaction_kind_dead;
1049 return put_txn(txn->fs, fstxn, txn->id, trail, trail->pool);
1054 svn_fs_base__abort_txn(svn_fs_txn_t *txn,
1057 SVN_ERR(svn_fs__check_fs(txn->fs, TRUE));
1059 /* Set the transaction to "dead". */
1060 SVN_ERR(svn_fs_base__retry_txn(txn->fs, txn_body_abort_txn, txn,
1063 /* Now, purge it. */
1064 SVN_ERR_W(svn_fs_base__purge_txn(txn->fs, txn->id, pool),
1065 _("Transaction aborted, but cleanup failed"));
1067 return SVN_NO_ERROR;
1071 struct list_transactions_args
1073 apr_array_header_t **names_p;
1077 static svn_error_t *
1078 txn_body_list_transactions(void* baton, trail_t *trail)
1080 struct list_transactions_args *args = baton;
1081 return svn_fs_bdb__get_txn_list(args->names_p, trail->fs,
1086 svn_fs_base__list_transactions(apr_array_header_t **names_p,
1090 apr_array_header_t *names;
1091 struct list_transactions_args args;
1093 SVN_ERR(svn_fs__check_fs(fs, TRUE));
1095 args.names_p = &names;
1097 SVN_ERR(svn_fs_base__retry(fs, txn_body_list_transactions, &args,
1101 return SVN_NO_ERROR;