You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/12/23 16:17:47 UTC
svn commit: r1425472 [6/6] -
/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/
Added: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h?rev=1425472&view=auto
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h (added)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.h Sun Dec 23 15:17:47 2012
@@ -0,0 +1,288 @@
+/* transaction.h --- transaction-related functions of FSFS
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ */
+
+#ifndef SVN_LIBSVN_FS__TRANSACTION_H
+#define SVN_LIBSVN_FS__TRANSACTION_H
+
+#include "fs.h"
+
+/* Obtain a write lock on the filesystem FS in a subpool of POOL, call
+ BODY with BATON and that subpool, destroy the subpool (releasing the write
+ lock) and return what BODY returned. */
+svn_error_t *
+svn_fs_fs__with_write_lock(svn_fs_t *fs,
+ svn_error_t *(*body)(void *baton,
+ apr_pool_t *pool),
+ void *baton,
+ apr_pool_t *pool);
+
+/* Store NODEREV as the node-revision for the node whose id is ID in
+ FS, after setting its is_fresh_txn_root to FRESH_TXN_ROOT. Do any
+ necessary temporary allocation in POOL. */
+svn_error_t *
+svn_fs_fs__put_node_revision(svn_fs_t *fs,
+ const svn_fs_id_t *id,
+ node_revision_t *noderev,
+ svn_boolean_t fresh_txn_root,
+ apr_pool_t *pool);
+
+/* Find the paths which were changed in transaction TXN_ID of
+ filesystem FS and store them in *CHANGED_PATHS_P.
+ Get any temporary allocations from POOL. */
+svn_error_t *
+svn_fs_fs__txn_changes_fetch(apr_hash_t **changed_paths_p,
+ svn_fs_t *fs,
+ const char *txn_id,
+ apr_pool_t *pool);
+
+/* Find the paths which were changed in revision REV of filesystem FS
+ and store them in *CHANGED_PATHS_P. Cached copyfrom information
+ will be stored in *COPYFROM_CACHE. Get any temporary allocations
+ from POOL. */
+svn_error_t *
+svn_fs_fs__paths_changed(apr_hash_t **changed_paths_p,
+ svn_fs_t *fs,
+ svn_revnum_t rev,
+ apr_hash_t *copyfrom_cache,
+ apr_pool_t *pool);
+
+/* Create a new transaction in filesystem FS, based on revision REV,
+ and store it in *TXN_P. Allocate all necessary variables from
+ POOL. */
+svn_error_t *
+svn_fs_fs__create_txn(svn_fs_txn_t **txn_p,
+ svn_fs_t *fs,
+ svn_revnum_t rev,
+ apr_pool_t *pool);
+
+/* Set the transaction property NAME to the value VALUE in transaction
+ TXN. Perform temporary allocations from POOL. */
+svn_error_t *
+svn_fs_fs__change_txn_prop(svn_fs_txn_t *txn,
+ const char *name,
+ const svn_string_t *value,
+ apr_pool_t *pool);
+
+/* Change transaction properties in transaction TXN based on PROPS.
+ Perform temporary allocations from POOL. */
+svn_error_t *
+svn_fs_fs__change_txn_props(svn_fs_txn_t *txn,
+ const apr_array_header_t *props,
+ apr_pool_t *pool);
+
+/* Store a transaction record in *TXN_P for the transaction identified
+ by TXN_ID in filesystem FS. Allocate everything from POOL. */
+svn_error_t *
+svn_fs_fs__get_txn(transaction_t **txn_p,
+ svn_fs_t *fs,
+ const char *txn_id,
+ apr_pool_t *pool);
+
+/* Return the next available copy_id in *COPY_ID for the transaction
+ TXN_ID in filesystem FS. Allocate space in POOL. */
+svn_error_t *
+svn_fs_fs__reserve_copy_id(const char **copy_id_p,
+ svn_fs_t *fs,
+ const char *txn_id,
+ apr_pool_t *pool);
+
+/* Create an entirely new mutable node in the filesystem FS, whose
+ node-revision is NODEREV. Set *ID_P to the new node revision's ID.
+ Use POOL for any temporary allocation. COPY_ID is the copy_id to
+ use in the node revision ID. TXN_ID is the Subversion transaction
+ under which this occurs. */
+svn_error_t *
+svn_fs_fs__create_node(const svn_fs_id_t **id_p,
+ svn_fs_t *fs,
+ node_revision_t *noderev,
+ const char *copy_id,
+ const char *txn_id,
+ apr_pool_t *pool);
+
+/* Remove all references to the transaction TXN_ID from filesystem FS.
+ Temporary allocations are from POOL. */
+svn_error_t *
+svn_fs_fs__purge_txn(svn_fs_t *fs,
+ const char *txn_id,
+ apr_pool_t *pool);
+
+/* Abort the existing transaction TXN, performing any temporary
+ allocations in POOL. */
+svn_error_t *
+svn_fs_fs__abort_txn(svn_fs_txn_t *txn,
+ apr_pool_t *pool);
+
+/* Add or set in filesystem FS, transaction TXN_ID, in directory
+ PARENT_NODEREV a directory entry for NAME pointing to ID of type
+ KIND. Allocations are done in POOL. */
+svn_error_t *
+svn_fs_fs__set_entry(svn_fs_t *fs,
+ const char *txn_id,
+ node_revision_t *parent_noderev,
+ const char *name,
+ const svn_fs_id_t *id,
+ svn_node_kind_t kind,
+ apr_pool_t *pool);
+
+/* Add a change to the changes record for filesystem FS in transaction
+ TXN_ID. Mark path PATH, having node-id ID, as changed according to
+ the type in CHANGE_KIND. If the text representation was changed
+ set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
+ was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
+ revision and path of the copy source, otherwise they should be set
+ to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
+ from POOL. */
+svn_error_t *
+svn_fs_fs__add_change(svn_fs_t *fs,
+ const char *txn_id,
+ const char *path,
+ const svn_fs_id_t *id,
+ svn_fs_path_change_kind_t change_kind,
+ svn_boolean_t text_mod,
+ svn_boolean_t prop_mod,
+ svn_node_kind_t node_kind,
+ svn_revnum_t copyfrom_rev,
+ const char *copyfrom_path,
+ apr_pool_t *pool);
+
+/* Return a writable stream in *STREAM that allows storing the text
+ representation of node-revision NODEREV in filesystem FS.
+ Allocations are from POOL. */
+svn_error_t *
+svn_fs_fs__set_contents(svn_stream_t **stream,
+ svn_fs_t *fs,
+ node_revision_t *noderev,
+ apr_pool_t *pool);
+
+/* Create a node revision in FS which is an immediate successor of
+ OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
+ revision's ID. Use POOL for any temporary allocation.
+
+ COPY_ID, if non-NULL, is a key into the `copies' table, and
+ indicates that this new node is being created as the result of a
+ copy operation, and specifically which operation that was. If
+ COPY_ID is NULL, then re-use the copy ID from the predecessor node.
+
+ TXN_ID is the Subversion transaction under which this occurs.
+
+ After this call, the deltification code assumes that the new node's
+ contents will change frequently, and will avoid representing other
+ nodes as deltas against this node's contents. */
+svn_error_t *
+svn_fs_fs__create_successor(const svn_fs_id_t **new_id_p,
+ svn_fs_t *fs,
+ const svn_fs_id_t *old_idp,
+ node_revision_t *new_noderev,
+ const char *copy_id,
+ const char *txn_id,
+ apr_pool_t *pool);
+
+/* Write a new property list PROPLIST for node-revision NODEREV in
+ filesystem FS. Perform any temporary allocations in POOL. */
+svn_error_t *
+svn_fs_fs__set_proplist(svn_fs_t *fs,
+ node_revision_t *noderev,
+ apr_hash_t *proplist,
+ apr_pool_t *pool);
+
+/* Commit the transaction TXN in filesystem FS and return its new
+ revision number in *REV. If the transaction is out of date, return
+ the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
+ allocations. */
+svn_error_t *
+svn_fs_fs__commit(svn_revnum_t *new_rev_p,
+ svn_fs_t *fs,
+ svn_fs_txn_t *txn,
+ apr_pool_t *pool);
+
+/* Set *NAMES_P to an array of names which are all the active
+ transactions in filesystem FS. Allocate the array from POOL. */
+svn_error_t *
+svn_fs_fs__list_transactions(apr_array_header_t **names_p,
+ svn_fs_t *fs,
+ apr_pool_t *pool);
+
+/* Open the transaction named NAME in filesystem FS. Set *TXN_P to
+ * the transaction. If there is no such transaction, return
+` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
+ * POOL. */
+svn_error_t *
+svn_fs_fs__open_txn(svn_fs_txn_t **txn_p,
+ svn_fs_t *fs,
+ const char *name,
+ apr_pool_t *pool);
+
+/* Return the property list from transaction TXN and store it in
+ *PROPLIST. Allocate the property list from POOL. */
+svn_error_t *
+svn_fs_fs__txn_proplist(apr_hash_t **table_p,
+ svn_fs_txn_t *txn,
+ apr_pool_t *pool);
+
+/* Delete the mutable node-revision referenced by ID, along with any
+ mutable props or directory contents associated with it. Perform
+ temporary allocations in POOL. */
+svn_error_t *
+svn_fs_fs__delete_node_revision(svn_fs_t *fs,
+ const svn_fs_id_t *id,
+ apr_pool_t *pool);
+
+/* Retrieve information about the Subversion transaction SVN_TXN from
+ the `transactions' table of FS, allocating from POOL. Set
+ *ROOT_ID_P to the ID of the transaction's root directory. Set
+ *BASE_ROOT_ID_P to the ID of the root directory of the
+ transaction's base revision.
+
+ If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
+ the error returned.
+
+ Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
+ transaction that has already been committed.
+
+ Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL. */
+svn_error_t *
+svn_fs_fs__get_txn_ids(const svn_fs_id_t **root_id_p,
+ const svn_fs_id_t **base_root_id_p,
+ svn_fs_t *fs,
+ const char *txn_name,
+ apr_pool_t *pool);
+
+/* Find the value of the property named PROPNAME in transaction TXN.
+ Return the contents in *VALUE_P. The contents will be allocated
+ from POOL. */
+svn_error_t *
+svn_fs_fs__txn_prop(svn_string_t **value_p,
+ svn_fs_txn_t *txn,
+ const char *propname,
+ apr_pool_t *pool);
+
+/* Begin a new transaction in filesystem FS, based on existing
+ revision REV. The new transaction is returned in *TXN_P. Allocate
+ the new transaction structure from POOL. */
+svn_error_t *
+svn_fs_fs__begin_txn(svn_fs_txn_t **txn_p,
+ svn_fs_t *fs,
+ svn_revnum_t rev,
+ apr_uint32_t flags,
+ apr_pool_t *pool);
+
+#endif
\ No newline at end of file
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c?rev=1425472&r1=1425471&r2=1425472&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/tree.c Sun Dec 23 15:17:47 2012
@@ -57,6 +57,8 @@
#include "fs_fs.h"
#include "id.h"
#include "temp_serializer.h"
+#include "cached_data.h"
+#include "transaction.h"
#include "private/svn_mergeinfo_private.h"
#include "private/svn_subr_private.h"
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c?rev=1425472&r1=1425471&r2=1425472&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c Sun Dec 23 15:17:47 2012
@@ -355,15 +355,18 @@ check_file_buffer_numeric(const char *bu
svn_error_t *
read_min_unpacked_rev(svn_revnum_t *min_unpacked_rev,
- const char *path,
+ svn_fs_t *fs,
apr_pool_t *pool)
{
char buf[80];
apr_file_t *file;
apr_size_t len;
- SVN_ERR(svn_io_file_open(&file, path, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, pool));
+ SVN_ERR(svn_io_file_open(&file,
+ path_min_unpacked_rev(fs, pool),
+ APR_READ | APR_BUFFERED,
+ APR_OS_DEFAULT,
+ pool));
len = sizeof(buf);
SVN_ERR(svn_io_read_length_line(file, buf, &len, pool));
SVN_ERR(svn_io_file_close(file, pool));
@@ -379,9 +382,57 @@ update_min_unpacked_rev(svn_fs_t *fs, ap
SVN_ERR_ASSERT(ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT);
- return read_min_unpacked_rev(&ffd->min_unpacked_rev,
- path_min_unpacked_rev(fs, pool),
- pool);
+ return read_min_unpacked_rev(&ffd->min_unpacked_rev, fs, pool);
+}
+
+/* Write a file FILENAME in directory FS_PATH, containing a single line
+ * with the number REVNUM in ASCII decimal. Move the file into place
+ * atomically, overwriting any existing file.
+ *
+ * Similar to write_current(). */
+svn_error_t *
+write_revnum_file(svn_fs_t *fs,
+ svn_revnum_t revnum,
+ apr_pool_t *scratch_pool)
+{
+ const char *final_path, *tmp_path;
+ svn_stream_t *tmp_stream;
+
+ final_path = path_min_unpacked_rev(fs, scratch_pool);
+ SVN_ERR(svn_stream_open_unique(&tmp_stream, &tmp_path, fs->path,
+ svn_io_file_del_none,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_stream_printf(tmp_stream, scratch_pool, "%ld\n", revnum));
+ SVN_ERR(svn_stream_close(tmp_stream));
+ SVN_ERR(move_into_place(tmp_path, final_path, final_path, scratch_pool));
+ return SVN_NO_ERROR;
+}
+
+/* Atomically update the 'current' file to hold the specifed REV,
+ NEXT_NODE_ID, and NEXT_COPY_ID. (The two next-ID parameters are
+ ignored and may be NULL if the FS format does not use them.)
+ Perform temporary allocations in POOL. */
+svn_error_t *
+write_current(svn_fs_t *fs, svn_revnum_t rev, const char *next_node_id,
+ const char *next_copy_id, apr_pool_t *pool)
+{
+ char *buf;
+ const char *tmp_name, *name;
+ fs_fs_data_t *ffd = fs->fsap_data;
+
+ /* Now we can just write out this line. */
+ if (ffd->format >= SVN_FS_FS__MIN_NO_GLOBAL_IDS_FORMAT)
+ buf = apr_psprintf(pool, "%ld\n", rev);
+ else
+ buf = apr_psprintf(pool, "%ld %s %s\n", rev, next_node_id, next_copy_id);
+
+ name = svn_fs_fs__path_current(fs, pool);
+ SVN_ERR(svn_io_write_unique(&tmp_name,
+ svn_dirent_dirname(name, pool),
+ buf, strlen(buf),
+ svn_io_file_del_none, pool));
+
+ return move_into_place(tmp_name, name, name, pool);
}
@@ -436,6 +487,21 @@ try_stringbuf_from_file(svn_stringbuf_t
return svn_error_trace(err);
}
+/* Fetch the current offset of FILE into *OFFSET_P. */
+svn_error_t *
+get_file_offset(apr_off_t *offset_p, apr_file_t *file, apr_pool_t *pool)
+{
+ apr_off_t offset;
+
+ /* Note that, for buffered files, one (possibly surprising) side-effect
+ of this call is to flush any unwritten data to disk. */
+ offset = 0;
+ SVN_ERR(svn_io_file_seek(file, APR_CUR, &offset, pool));
+ *offset_p = offset;
+
+ return SVN_NO_ERROR;
+}
+
/* Read the 'current' file FNAME and store the contents in *BUF.
Allocations are performed in POOL. */
svn_error_t *
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h?rev=1425472&r1=1425471&r2=1425472&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h Sun Dec 23 15:17:47 2012
@@ -20,6 +20,9 @@
* ====================================================================
*/
+#ifndef SVN_LIBSVN_FS__UTIL_H
+#define SVN_LIBSVN_FS__UTIL_H
+
#include "svn_fs.h"
/* Functions for dealing with recoverable errors on mutable files
@@ -208,13 +211,33 @@ check_file_buffer_numeric(const char *bu
svn_error_t *
read_min_unpacked_rev(svn_revnum_t *min_unpacked_rev,
- const char *path,
+ svn_fs_t *fs,
apr_pool_t *pool);
svn_error_t *
update_min_unpacked_rev(svn_fs_t *fs,
apr_pool_t *pool);
+/* Write a file FILENAME in directory FS_PATH, containing a single line
+ * with the number REVNUM in ASCII decimal. Move the file into place
+ * atomically, overwriting any existing file.
+ *
+ * Similar to write_current(). */
+svn_error_t *
+write_revnum_file(svn_fs_t *fs,
+ svn_revnum_t revnum,
+ apr_pool_t *scratch_pool);
+
+/* Atomically update the 'current' file to hold the specifed REV,
+ NEXT_NODE_ID, and NEXT_COPY_ID. (The two next-ID parameters are
+ ignored and may be NULL if the FS format does not use them.)
+ Perform temporary allocations in POOL. */
+svn_error_t *
+write_current(svn_fs_t *fs,
+ svn_revnum_t rev,
+ const char *next_node_id,
+ const char *next_copy_id,
+ apr_pool_t *pool);
/* Read the file at PATH and return its content in *CONTENT. *CONTENT will
* not be modified unless the whole file was read successfully.
@@ -232,6 +255,12 @@ try_stringbuf_from_file(svn_stringbuf_t
svn_boolean_t last_attempt,
apr_pool_t *pool);
+/* Fetch the current offset of FILE into *OFFSET_P. */
+svn_error_t *
+get_file_offset(apr_off_t *offset_p,
+ apr_file_t *file,
+ apr_pool_t *pool);
+
/* Read the 'current' file FNAME and store the contents in *BUF.
Allocations are performed in POOL. */
svn_error_t *
@@ -263,3 +292,5 @@ move_into_place(const char *old_filename
const char *new_filename,
const char *perms_reference,
apr_pool_t *pool);
+
+#endif
\ No newline at end of file