diff options
Diffstat (limited to 'subversion/libsvn_wc/wc_db_private.h')
-rw-r--r-- | subversion/libsvn_wc/wc_db_private.h | 255 |
1 files changed, 248 insertions, 7 deletions
diff --git a/subversion/libsvn_wc/wc_db_private.h b/subversion/libsvn_wc/wc_db_private.h index 5a9b624..a4bf98f 100644 --- a/subversion/libsvn_wc/wc_db_private.h +++ b/subversion/libsvn_wc/wc_db_private.h @@ -36,15 +36,18 @@ struct svn_wc__db_t { /* We need the config whenever we run into a new WC directory, in order to figure out where we should look for the corresponding datastore. */ - const svn_config_t *config; + svn_config_t *config; - /* Should we attempt to automatically upgrade the database when it is + /* Should we fail with SVN_ERR_WC_UPGRADE_REQUIRED when it is opened, and found to be not-current? */ - svn_boolean_t auto_upgrade; + svn_boolean_t verify_format; /* Should we ensure the WORK_QUEUE is empty when a WCROOT is opened? */ svn_boolean_t enforce_empty_wq; + /* Should we open Sqlite databases EXCLUSIVE */ + svn_boolean_t exclusive; + /* Map a given working copy directory to its relevant data. const char *local_abspath -> svn_wc__db_wcroot_t *wcroot */ apr_hash_t *dir_data; @@ -55,7 +58,6 @@ struct svn_wc__db_t { { svn_stringbuf_t *abspath; svn_node_kind_t kind; - svn_boolean_t is_symlink; } parse_cache; /* As we grow the state of this DB, allocate that state here. */ @@ -97,7 +99,7 @@ typedef struct svn_wc__db_wcroot_t { Typically just one or two locks maximum. */ apr_array_header_t *owned_locks; - /* Map a working copy diretory to a cached adm_access baton. + /* Map a working copy directory to a cached adm_access baton. const char *local_abspath -> svn_wc_adm_access_t *adm_access */ apr_hash_t *access_cache; @@ -119,7 +121,7 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_wcroot_t **wcroot, svn_sqlite__db_t *sdb, apr_int64_t wc_id, int format, - svn_boolean_t auto_upgrade, + svn_boolean_t verify_format, svn_boolean_t enforce_empty_wq, apr_pool_t *result_pool, apr_pool_t *scratch_pool); @@ -149,6 +151,37 @@ svn_wc__db_wcroot_parse_local_abspath(svn_wc__db_wcroot_t **wcroot, #define VERIFY_USABLE_WCROOT(wcroot) SVN_ERR_ASSERT( \ (wcroot) != NULL && (wcroot)->format == SVN_WC__VERSION) +/* Check if the WCROOT is usable for light db operations such as path + calculations */ +#define CHECK_MINIMAL_WCROOT(wcroot, abspath, scratch_pool) \ + do \ + { \ + if (wcroot == NULL) \ + return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL, \ + _("The node '%s' is not in a working copy."), \ + svn_dirent_local_style(wri_abspath, \ + scratch_pool)); \ + } \ + while (0) + +/* Calculates the depth of the relpath below "" */ +APR_INLINE static int +relpath_depth(const char *relpath) +{ + int n = 1; + if (*relpath == '\0') + return 0; + + do + { + if (*relpath == '/') + n++; + } + while (*(++relpath)); + + return n; +} + /* */ svn_error_t * @@ -171,6 +204,7 @@ svn_wc__db_util_open_db(svn_sqlite__db_t **sdb, const char *dir_abspath, const char *sdb_fname, svn_sqlite__mode_t smode, + svn_boolean_t exclusive, const char *const *my_statements, apr_pool_t *result_pool, apr_pool_t *scratch_pool); @@ -179,7 +213,7 @@ svn_wc__db_util_open_db(svn_sqlite__db_t **sdb, DB+LOCAL_ABSPATH, and outputting repos ids instead of URL+UUID. */ svn_error_t * svn_wc__db_read_info_internal(svn_wc__db_status_t *status, - svn_wc__db_kind_t *kind, + svn_node_kind_t *kind, svn_revnum_t *revision, const char **repos_relpath, apr_int64_t *repos_id, @@ -208,6 +242,91 @@ svn_wc__db_read_info_internal(svn_wc__db_status_t *status, apr_pool_t *result_pool, apr_pool_t *scratch_pool); +/* Like svn_wc__db_base_get_info(), but taking WCROOT+LOCAL_RELPATH instead of + DB+LOCAL_ABSPATH and outputting REPOS_ID instead of URL+UUID. */ +svn_error_t * +svn_wc__db_base_get_info_internal(svn_wc__db_status_t *status, + svn_node_kind_t *kind, + svn_revnum_t *revision, + const char **repos_relpath, + apr_int64_t *repos_id, + svn_revnum_t *changed_rev, + apr_time_t *changed_date, + const char **changed_author, + svn_depth_t *depth, + const svn_checksum_t **checksum, + const char **target, + svn_wc__db_lock_t **lock, + svn_boolean_t *had_props, + apr_hash_t **props, + svn_boolean_t *update_root, + svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Similar to svn_wc__db_base_get_info(), but taking WCROOT+LOCAL_RELPATH + * instead of DB+LOCAL_ABSPATH, an explicit op-depth of the node to get + * information about, and outputting REPOS_ID instead of URL+UUID, and + * without the LOCK or UPDATE_ROOT outputs. + * + * OR + * + * Similar to svn_wc__db_base_get_info_internal(), but taking an explicit + * op-depth OP_DEPTH of the node to get information about, and without the + * LOCK or UPDATE_ROOT outputs. + * + * ### [JAF] TODO: Harmonize svn_wc__db_base_get_info[_internal] with + * svn_wc__db_depth_get_info -- common API, common implementation. + */ +svn_error_t * +svn_wc__db_depth_get_info(svn_wc__db_status_t *status, + svn_node_kind_t *kind, + svn_revnum_t *revision, + const char **repos_relpath, + apr_int64_t *repos_id, + svn_revnum_t *changed_rev, + apr_time_t *changed_date, + const char **changed_author, + svn_depth_t *depth, + const svn_checksum_t **checksum, + const char **target, + svn_boolean_t *had_props, + apr_hash_t **props, + svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + int op_depth, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Look up REPOS_ID in SDB and set *REPOS_ROOT_URL and/or *REPOS_UUID to + its root URL and UUID respectively. If REPOS_ID is INVALID_REPOS_ID, + use NULL for both URL and UUID. Either or both output parameters may be + NULL if not wanted. */ +svn_error_t * +svn_wc__db_fetch_repos_info(const char **repos_root_url, + const char **repos_uuid, + svn_sqlite__db_t *sdb, + apr_int64_t repos_id, + apr_pool_t *result_pool); + +/* Like svn_wc__db_read_conflict(), but with WCROOT+LOCAL_RELPATH instead of + DB+LOCAL_ABSPATH, and outputting relpaths instead of abspaths. */ +svn_error_t * +svn_wc__db_read_conflict_internal(svn_skel_t **conflict, + svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Like svn_wc__db_op_mark_conflict(), but with WCROOT+LOCAL_RELPATH instead of + DB+LOCAL_ABSPATH. */ +svn_error_t * +svn_wc__db_mark_conflict_internal(svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + const svn_skel_t *conflict_skel, + apr_pool_t *scratch_pool); + /* Transaction handling */ @@ -228,5 +347,127 @@ svn_wc__db_with_txn(svn_wc__db_wcroot_t *wcroot, void *cb_baton, apr_pool_t *scratch_pool); +/* Evaluate the expression EXPR within a transaction. + * + * Begin a transaction in WCROOT's DB; evaluate the expression EXPR, which would + * typically be a function call that does some work in DB; finally commit + * the transaction if EXPR evaluated to SVN_NO_ERROR, otherwise roll back + * the transaction. + */ +#define SVN_WC__DB_WITH_TXN(expr, wcroot) \ + SVN_SQLITE__WITH_LOCK(expr, (wcroot)->sdb) + + +/* Evaluate the expressions EXPR1..EXPR4 within a transaction, returning the + * first error if an error occurs. + * + * Begin a transaction in WCROOT's DB; evaluate the expressions, which would + * typically be function calls that do some work in DB; finally commit + * the transaction if EXPR evaluated to SVN_NO_ERROR, otherwise roll back + * the transaction. + */ +#define SVN_WC__DB_WITH_TXN4(expr1, expr2, expr3, expr4, wcroot) \ + SVN_SQLITE__WITH_LOCK4(expr1, expr2, expr3, expr4, (wcroot)->sdb) + + +/* Return CHILDREN mapping const char * names to svn_node_kind_t * for the + children of LOCAL_RELPATH at OP_DEPTH. */ +svn_error_t * +svn_wc__db_get_children_op_depth(apr_hash_t **children, + svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + int op_depth, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/* Extend any delete of the parent of LOCAL_RELPATH to LOCAL_RELPATH. + + ### What about KIND and OP_DEPTH? KIND ought to be redundant; I'm + discussing on dev@ whether we can let that be null for presence + == base-deleted. OP_DEPTH is the op-depth of what, and why? + It is used to select the lowest working node higher than OP_DEPTH, + so, in terms of the API, OP_DEPTH means ...? + + Given a wc: + + 0 1 2 3 4 + normal + A normal + A/B normal normal + A/B/C not-pres normal + A/B/C/D normal + + That is checkout, delete A/B, copy a replacement A/B, delete copied + child A/B/C, add replacement A/B/C, add A/B/C/D. + + Now an update that adds base nodes for A/B/C, A/B/C/D and A/B/C/D/E + must extend the A/B deletion: + + 0 1 2 3 4 + normal + A normal + A/B normal normal + A/B/C normal not-pres normal + A/B/C/D normal base-del normal + A/B/C/D/E normal base-del + + When adding a node if the parent has a higher working node then the + parent node is deleted (or replaced) and the delete must be extended + to cover new node. + + In the example above A/B/C/D and A/B/C/D/E are the nodes that get + the extended delete, A/B/C is already deleted. + */ +svn_error_t * +svn_wc__db_extend_parent_delete(svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + svn_node_kind_t kind, + int op_depth, + apr_pool_t *scratch_pool); + +svn_error_t * +svn_wc__db_retract_parent_delete(svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + int op_depth, + apr_pool_t *scratch_pool); + +svn_error_t * +svn_wc__db_op_depth_moved_to(const char **move_dst_relpath, + const char **move_dst_op_root_relpath, + const char **move_src_root_relpath, + const char **move_src_op_root_relpath, + int op_depth, + svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Do a post-drive revision bump for the moved-away destination for + any move sources under LOCAL_RELPATH. This is called from within + the revision bump transaction after the tree at LOCAL_RELPATH has + been bumped. */ +svn_error_t * +svn_wc__db_bump_moved_away(svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + svn_depth_t depth, + svn_wc__db_t *db, + apr_pool_t *scratch_pool); + +/* Unbreak the move from LOCAL_RELPATH on op-depth in WCROOT, by making + the destination a normal copy */ +svn_error_t * +svn_wc__db_resolve_break_moved_away_internal(svn_wc__db_wcroot_t *wcroot, + const char *local_relpath, + int op_depth, + apr_pool_t *scratch_pool); + +svn_error_t * +svn_wc__db_update_move_list_notify(svn_wc__db_wcroot_t *wcroot, + svn_revnum_t old_revision, + svn_revnum_t new_revision, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); #endif /* WC_DB_PRIVATE_H */ |