On Fri, Mar 13, 2009 at 23:02, Hyrum K. Wright <hyrum_at_hyrumwright.org> wrote:
>...
> +++ trunk/subversion/libsvn_wc/entries.c     Fri Mar 13 15:02:06 2009     (r36537)
for entries.c, note that we could have a temp function to get an sdb
from the db.
>...
> @@ -1851,6 +1810,21 @@ write_entry(svn_sqlite__db_t *wc_db,
> Â Â Â base_node->changed_author = entry->cmt_author;
>
> Â Â Â SVN_ERR(insert_base_node(wc_db, base_node, scratch_pool));
> +
> + Â Â Â /* We have to insert the lock after the base node, because the node
> + Â Â Â Â must exist to lookup various bits of repos related information for
> + Â Â Â Â the abs path. */
> + Â Â Â if (entry->lock_token)
> + Â Â Â Â {
> + Â Â Â Â Â svn_wc__db_lock_t *lock = apr_pcalloc(scratch_pool, sizeof(*lock));
gah. dude. put it on the stack.
>...
> @@ -1981,9 +1963,11 @@ entries_write_body(svn_sqlite__db_t *wc_
>
> Â /* Write out "this dir" */
> Â SVN_ERR(fetch_wc_id(&wc_id, wc_db));
> - Â SVN_ERR(write_entry(wc_db, wc_id, repos_id, repos_root, this_dir,
> - Â Â Â Â Â Â Â Â Â Â Â SVN_WC_ENTRY_THIS_DIR, this_dir,
> - Â Â Â Â Â Â Â Â Â Â Â scratch_pool));
> + Â SVN_ERR(write_entry(db, wc_db, wc_id, repos_id, repos_root, this_dir,
> + Â Â Â Â Â Â Â Â Â Â Â SVN_WC_ENTRY_THIS_DIR,
> + Â Â Â Â Â Â Â Â Â Â Â svn_dirent_join(local_abspath, SVN_WC_ENTRY_THIS_DIR,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scratch_pool),
> + Â Â Â Â Â Â Â Â Â Â Â this_dir, scratch_pool));
SVN_WC_ENTRY_THIS_DIR is defined as "". no need for the join, and
(really) no need for the dumb symbol. in ancient history, we had a
name like "svn:this_dir" or somesuch when we recorded the item in the
'entries' file. it just doesn't make sense to keep the symbol.
>...
> @@ -2844,14 +2832,17 @@ svn_wc__entries_init(const char *path,
> Â Â Â Â Â Â Â Â Â || depth == svn_depth_immediates
> Â Â Â Â Â Â Â Â Â || depth == svn_depth_infinity);
>
> - Â /* Check that the entries sqlite database does not yet exist. */
> - Â SVN_ERR(svn_io_check_path(wc_db_path, &kind, scratch_pool));
> - Â if (kind != svn_node_none)
> - Â Â return svn_error_createf(SVN_ERR_WC_DB_ERROR, NULL,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â _("Existing sqlite database found at '%s'"),
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_path_local_style(wc_db_path, pool));
> -
> - Â /* Create the entries database, and start a transaction. */
> + Â /* ### chicken and egg problem: we don't have an adm_access baton to
> + Â Â ### use to open the initial entries database, we we've got to do it
> + Â Â ### manually. */
> + Â SVN_ERR(svn_wc__db_open(&db, svn_wc__db_openmode_readwrite, path,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, scratch_pool, scratch_pool));
> +
> + Â /* Open the sqlite database, and insert the REPOS and WCROOT.
> + Â Â ### this is redundant, but we currently need it for the entry
> + Â Â ### inserting API. Â DB and WC_DB should be pointing to the *same*
> + Â Â ### sqlite database, and it works fine thanks for sqlite's
> + Â Â ### concurrency handling. Â However, this should eventually disappear. */
> Â SVN_ERR(svn_sqlite__open(&wc_db, wc_db_path, svn_sqlite__mode_rwcreate,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â statements,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â SVN_WC__VERSION_EXPERIMENTAL, upgrade_sql,
could get this from the db? we could also have something like:
svn_wc__db_construct() to construct a wc for the given directory. (or
do nothing in the future, if it finds a parent directory is already a
wc)
>...
> +++ trunk/subversion/libsvn_wc/wc_db.c  Fri Mar 13 15:02:06 2009     (r36537)
>...
> @@ -2657,6 +2663,55 @@ svn_wc__db_global_commit(svn_wc__db_t *d
>
>
> Â svn_error_t *
> +svn_wc__db_lock_add(svn_wc__db_t *db,
> + Â Â Â Â Â Â Â Â Â Â const char *local_abspath,
> + Â Â Â Â Â Â Â Â Â Â const svn_wc__db_lock_t *lock,
> + Â Â Â Â Â Â Â Â Â Â apr_pool_t *scratch_pool)
> +{
> + Â svn_wc__db_pdh_t *pdh;
> + Â const char *local_relpath;
> + Â svn_sqlite__stmt_t *stmt;
> + Â const char *repos_root_url;
> + Â const char *repos_relpath;
> + Â const char *repos_uuid;
> + Â apr_int64_t repos_id;
> +
> + Â SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
> +
> + Â /* Fetch the repos root and repos uuid from the base node, we we can
> + Â Â then create or get the repos id.
> + Â Â ### is there a better way to do this? */
> + Â SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, &repos_relpath,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &repos_root_url, &repos_uuid,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, NULL, NULL, NULL, NULL, NULL,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NULL, NULL, NULL,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â db, local_abspath, scratch_pool,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scratch_pool));
Yeah, there might be a better way, but this isn't bad. It handles the
case of the row containing the data, or needing to inherit the
information. And it gets the repos_relpath.
> +
> + Â SVN_ERR(parse_local_abspath(&pdh, &local_relpath, db, local_abspath,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_sqlite__mode_readwrite,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scratch_pool, scratch_pool));
> + Â SVN_ERR(create_repos_id(&repos_id, repos_root_url, repos_uuid, pdh->sdb,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â scratch_pool));
These two lines are the best reason to find another way. base_get_info
already does a parse_local_abspath, and we want to share that. Also,
it discovered a repos_id, so we don't want to look it up again.
> + Â SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->sdb, STMT_INSERT_LOCK));
> + Â SVN_ERR(svn_sqlite__bind_int64(stmt, 1, repos_id));
> + Â SVN_ERR(svn_sqlite__bind_text(stmt, 2, repos_relpath));
> + Â SVN_ERR(svn_sqlite__bind_text(stmt, 3, lock->token));
> +
> + Â if (lock->owner != NULL)
> + Â Â SVN_ERR(svn_sqlite__bind_text(stmt, 4, lock->owner));
> +
> + Â if (lock->comment != NULL)
> + Â Â SVN_ERR(svn_sqlite__bind_text(stmt, 5, lock->comment));
> +
> + Â SVN_ERR(svn_sqlite__bind_int64(stmt, 6, lock->date));
If the date is not specified (0), then should we avoid binding this
column? Leave it null?
>...
Cheers,
-g
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1321370
Received on 2009-03-14 11:55:45 CET