On Tue, Jun 2, 2009 at 19:17, Hyrum K. Wright<hyrum_at_hyrumwright.org> wrote:
>...
> +++ trunk/subversion/libsvn_client/locking_commands.c  Tue Jun  2 10:17:27 2009     (r37912)
> @@ -38,9 +38,10 @@
> Â /* For use with store_locks_callback, below. */
> Â struct lock_baton
> Â {
> - Â svn_wc_adm_access_t *adm_access;
> + Â const char *base_path;
> Â apr_hash_t *urls_to_paths;
> Â svn_client_ctx_t *ctx;
> + Â svn_wc_context_t *wc_ctx;
> Â apr_pool_t *pool;
> Â };
>
> @@ -49,7 +50,7 @@ struct lock_baton
> Â * BATON is a 'struct lock_baton *', PATH is the path being locked,
> Â * and LOCK is the lock itself.
> Â *
> - * If BATON->adm_access is not null, then this function either stores
> + * If BATON->base_path is not null, then this function either stores
> Â * the LOCK on REL_URL or removes any lock tokens from REL_URL
> Â * (depending on whether DO_LOCK is true or false respectively), but
> Â * only if RA_ERR is null, or (in the unlock case) is something other
> @@ -63,8 +64,6 @@ store_locks_callback(void *baton,
> Â Â Â Â Â Â Â Â Â Â Â svn_error_t *ra_err, apr_pool_t *pool)
> Â {
> Â struct lock_baton *lb = baton;
> - Â svn_wc_adm_access_t *adm_access;
> - Â const char *abs_path;
> Â svn_wc_notify_t *notify;
>
> Â /* Create the notify struct first, so we can tweak it below. */
> @@ -80,25 +79,21 @@ store_locks_callback(void *baton,
> Â notify->lock = lock;
> Â notify->err = ra_err;
>
> - Â if (lb->adm_access)
> + Â if (lb->base_path)
> Â Â {
> - Â Â Â const char *base_path = svn_wc_adm_access_path(lb->adm_access);
> Â Â Â char *path = apr_hash_get(lb->urls_to_paths, rel_url,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â APR_HASH_KEY_STRING);
> - Â Â Â abs_path = svn_path_join(base_path, path, lb->pool);
> -
> - Â Â Â SVN_ERR(svn_wc_adm_probe_retrieve(&adm_access, lb->adm_access,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â abs_path, lb->pool));
> + Â Â Â const char *abs_path = svn_path_join(lb->base_path, path, lb->pool);
>
> Â Â Â /* Notify a valid working copy path */
> Â Â Â notify->path = abs_path;
> - Â Â Â notify->path_prefix = base_path;
> + Â Â Â notify->path_prefix = lb->base_path;
>
> Â Â Â if (do_lock)
> Â Â Â Â {
> Â Â Â Â Â if (!ra_err)
> Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â SVN_ERR(svn_wc_add_lock(abs_path, lock, adm_access, lb->pool));
> + Â Â Â Â Â Â Â SVN_ERR(svn_wc_add_lock2(lb->wc_ctx, abs_path, lock, lb->pool));
This is incorrect. abs_path is NOT an absolute path. Total misnomer.
> Â Â Â Â Â Â Â notify->lock_state = svn_wc_notify_lock_state_locked;
> Â Â Â Â Â Â }
> Â Â Â Â Â else
> @@ -114,7 +109,7 @@ store_locks_callback(void *baton,
> Â Â Â Â Â if (!ra_err ||
> Â Â Â Â Â Â Â (ra_err && (ra_err->apr_err != SVN_ERR_FS_LOCK_OWNER_MISMATCH)))
> Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â SVN_ERR(svn_wc_remove_lock(abs_path, adm_access, lb->pool));
> + Â Â Â Â Â Â Â SVN_ERR(svn_wc_remove_lock2(lb->wc_ctx, abs_path, lb->pool));
Same problem.
> Â Â Â Â Â Â Â notify->lock_state = svn_wc_notify_lock_state_unlocked;
> Â Â Â Â Â Â }
> Â Â Â Â Â else
> @@ -425,14 +420,20 @@ svn_client_lock(const apr_array_header_t
> Â Â Â Â Â Â adm_access, NULL, FALSE, FALSE, ctx, pool));
>
> Â cb.pool = pool;
> - Â cb.adm_access = adm_access;
> + Â if (adm_access)
> + Â Â cb.base_path = svn_wc_adm_access_path(adm_access);
You could use svn_wc__adm_access_abspath() here.
> + Â else
> + Â Â cb.base_path = NULL;
> Â cb.urls_to_paths = urls_to_paths;
> Â cb.ctx = ctx;
> + Â SVN_ERR(svn_wc_context_create(&cb.wc_ctx, NULL /* config */, pool, pool));
>
> Â /* Lock the paths. */
> Â SVN_ERR(svn_ra_lock(ra_session, path_revs, comment,
> Â Â Â Â Â Â Â Â Â Â Â steal_lock, store_locks_callback, &cb, pool));
>
> + Â SVN_ERR(svn_wc_context_destroy(cb.wc_ctx));
> +
> Â /* Unlock the wc. */
> Â if (adm_access)
> Â Â return svn_wc_adm_close2(adm_access, pool);
> @@ -473,14 +474,20 @@ svn_client_unlock(const apr_array_header
> Â Â SVN_ERR(fetch_tokens(ra_session, path_tokens, pool));
>
> Â cb.pool = pool;
> - Â cb.adm_access = adm_access;
> + Â if (adm_access)
> + Â Â cb.base_path = svn_wc_adm_access_path(adm_access);
And here.
>...
> +++ trunk/subversion/libsvn_wc/adm_ops.c     Tue Jun  2 10:17:27 2009     (r37912)
> @@ -3082,21 +3082,21 @@ svn_wc_resolved_conflict4(const char *pa
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cancel_func, cancel_baton, pool);
> Â }
>
> -svn_error_t *svn_wc_add_lock(const char *path, const svn_lock_t *lock,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_wc_adm_access_t *adm_access, apr_pool_t *pool)
> +svn_error_t *
> +svn_wc_add_lock2(svn_wc_context_t *wc_ctx,
> + Â Â Â Â Â Â Â Â const char *local_abspath,
> + Â Â Â Â Â Â Â Â const svn_lock_t *lock,
> + Â Â Â Â Â Â Â Â apr_pool_t *scratch_pool)
> Â {
> - Â svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
> - Â const char *local_abspath;
> Â svn_wc__db_lock_t db_lock;
> Â svn_error_t *err;
> Â const svn_string_t *needs_lock;
>
> - Â SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
For safety, and to catch bugs (like above, where abs_path is anything
but), you could/should add an assertion here.
> Â db_lock.token = lock->token;
> Â db_lock.owner = lock->owner;
> Â db_lock.comment = lock->comment;
> Â db_lock.date = lock->creation_date;
> - Â err = svn_wc__db_lock_add(db, local_abspath, &db_lock, pool);
> + Â err = svn_wc__db_lock_add(wc_ctx->db, local_abspath, &db_lock, scratch_pool);
> Â if (err)
> Â Â {
> Â Â Â if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
> @@ -3106,29 +3106,29 @@ svn_error_t *svn_wc_add_lock(const char
> Â Â Â svn_error_clear(err);
> Â Â Â return svn_error_createf(SVN_ERR_ENTRY_NOT_FOUND, NULL,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â _("'%s' is not under version control"),
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_path_local_style(path, pool));
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_path_local_style(local_abspath,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scratch_pool));
> Â Â }
You've rev'd the API, so this error remapping should move to deprecated.c.
>...
> Â {
> - Â svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
> - Â const char *local_abspath;
> Â svn_error_t *err;
> Â const svn_string_t *needs_lock;
>
> - Â SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
Another assertion.
> - Â err = svn_wc__db_lock_remove(db, local_abspath, pool);
> + Â err = svn_wc__db_lock_remove(wc_ctx->db, local_abspath, scratch_pool);
> Â if (err)
> Â Â {
> Â Â Â if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
Another remap to move.
>...
> +++ trunk/subversion/libsvn_wc/deprecated.c   Tue Jun  2 10:17:27 2009     (r37912)
> @@ -528,6 +528,39 @@ svn_wc_resolved_conflict3(const char *pa
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cancel_baton, pool);
> Â }
>
> +svn_error_t *
> +svn_wc_add_lock(const char *path,
> + Â Â Â Â Â Â Â Â const svn_lock_t *lock,
> + Â Â Â Â Â Â Â Â svn_wc_adm_access_t *adm_access,
> + Â Â Â Â Â Â Â Â apr_pool_t *pool)
> +{
> + Â const char *local_abspath;
> + Â svn_wc_context_t *wc_ctx;
> +
> + Â SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
> + Â SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_wc__adm_get_db(adm_access),
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pool));
> +
> + Â return svn_error_return(svn_wc_add_lock2(wc_ctx, local_abspath, lock, pool));
The context is not destroyed, which could mean dangling open-handles on SDBs.
> +}
> +
> +svn_error_t *
> +svn_wc_remove_lock(const char *path,
> + Â Â Â Â Â Â Â Â Â svn_wc_adm_access_t *adm_access,
> + Â Â Â Â Â Â Â Â Â apr_pool_t *pool)
> +{
> + Â const char *local_abspath;
> + Â svn_wc_context_t *wc_ctx;
> +
> + Â SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
> + Â SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â svn_wc__adm_get_db(adm_access),
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pool));
> +
> + Â return svn_error_return(svn_wc_remove_lock2(wc_ctx, local_abspath, pool));
Likewise.
>...
Cheers,
-g
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2368886
Received on 2009-07-07 17:36:20 CEST