[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Locking errors: SVN_ERR_FS_PATH_LOCKED and SVN_ERR_FS_NO_LOCK_TOKEN

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2005-04-07 00:25:54 CEST

Max Bowsher wrote:
> Julian Foad wrote:
>> Ben Collins-Sussman wrote:
>>> On Apr 4, 2005, at 2:36 PM, Julian Foad wrote:
>>>> Aha! I have just seen that "SVN_ERR_FS_PATH_LOCKED" is tested by the
>>>> macro "SVN_ERR_IS_LOCK_ERROR", and therefore perhaps is intended only
>>>> to mean, "You can't lock this path because it is already locked". If
>>>> that's the case, may we rename it to "SVN_ERR_FS_PATH_ALREADY_LOCKED"?
>>>> Or at least document it as such.
>>>
>>> Yes, I think that's exactly the difference between the two error codes.
>>
>> Thanks for clarifying it to me. I'll stop pushing for a clarification in
>> the source code if no-one else is bothered by it.
>
> Actually, now it's been worked out what the issue is, I think this very
> much *should* be clarified.
> Preferably by changing the name to _ALREADY_LOCKED as suggested above.

Here's a patch to do so. Note that this can only be done if it is ported into
v1.2 before v1.2 is released, otherwise it would be an incompatible API change.

- Julian

Rename a locking error code for clarity.

* subversion/include/svn_error_codes.h
  (SVN_ERR_FS_PATH_LOCKED): Rename to ...
  (SVN_ERR_FS_PATH_ALREADY_LOCKED): New name; change message accordingly.

* subversion/libsvn_fs_base/err.c
* subversion/libsvn_fs_base/err.h
  (svn_fs_base__err_path_locked): Rename to ...
  (svn_fs_base__err_path_already_locked): New name; change message accordingly.

* subversion/libsvn_fs_fs/err.c
* subversion/libsvn_fs_fs/err.h
  (svn_fs_fs__err_path_locked): Rename to ...
  (svn_fs_fs__err_path_already_locked): New name; change message accordingly.

* subversion/include/svn_error.h (SVN_ERR_IS_LOCK_ERROR)
* subversion/include/svn_fs.h (svn_fs_lock)
* subversion/libsvn_fs_base/lock.c (txn_body_lock)
* subversion/libsvn_fs_fs/lock.c (lock_body)
* subversion/libsvn_ra_dav/commit.c (commit_delete_entry)
  Update call sites and comments accordingly.

Index: subversion/include/svn_error_codes.h
===================================================================
--- subversion/include/svn_error_codes.h (revision 13994)
+++ subversion/include/svn_error_codes.h (working copy)
@@ -524,9 +524,9 @@ SVN_ERROR_START
               "No user associated with filesystem")
 
   /* @since New in 1.2. */
- SVN_ERRDEF (SVN_ERR_FS_PATH_LOCKED,
+ SVN_ERRDEF (SVN_ERR_FS_PATH_ALREADY_LOCKED,
               SVN_ERR_FS_CATEGORY_START + 35,
- "Path is locked")
+ "Path is already locked")
 
   /* @since New in 1.2. */
   SVN_ERRDEF (SVN_ERR_FS_PATH_NOT_LOCKED,
Index: subversion/libsvn_fs_base/err.c
===================================================================
--- subversion/libsvn_fs_base/err.c (revision 13994)
+++ subversion/libsvn_fs_base/err.c (working copy)
@@ -308,12 +308,12 @@ svn_fs_base__err_lock_owner_mismatch (sv
 
 
 svn_error_t *
-svn_fs_base__err_path_locked (svn_fs_t *fs,
- svn_lock_t *lock)
+svn_fs_base__err_path_already_locked (svn_fs_t *fs,
+ svn_lock_t *lock)
 {
   return
     svn_error_createf
- (SVN_ERR_FS_PATH_LOCKED, 0,
- _("Path '%s' is locked by user '%s' in filesystem '%s'"),
+ (SVN_ERR_FS_PATH_ALREADY_LOCKED, 0,
+ _("Path '%s' is already locked by user '%s' in filesystem '%s'"),
      lock->path, lock->owner, fs->path);
 }
Index: subversion/libsvn_fs_base/err.h
===================================================================
--- subversion/libsvn_fs_base/err.h (revision 13994)
+++ subversion/libsvn_fs_base/err.h (working copy)
@@ -119,8 +119,9 @@ svn_error_t *svn_fs_base__err_no_lock_to
 svn_error_t *svn_fs_base__err_corrupt_lock (svn_fs_t *fs,
                                             const char *lock_token);
 
-/* SVN_ERR_FS_PATH_LOCKED: a path is locked. */
-svn_error_t *svn_fs_base__err_path_locked (svn_fs_t *fs, svn_lock_t *lock);
+/* SVN_ERR_FS_PATH_ALREADY_LOCKED: a path is already locked. */
+svn_error_t *svn_fs_base__err_path_already_locked (svn_fs_t *fs,
+ svn_lock_t *lock);
 
 /* SVN_ERR_FS_NO_SUCH_LOCK: there is no lock on PATH in FS. */
 svn_error_t *svn_fs_base__err_no_such_lock (svn_fs_t *fs, const char *path);
Index: subversion/libsvn_fs_fs/err.c
===================================================================
--- subversion/libsvn_fs_fs/err.c (revision 13994)
+++ subversion/libsvn_fs_fs/err.c (working copy)
@@ -291,12 +291,12 @@ svn_fs_fs__err_not_file (svn_fs_t *fs, c
 
 
 svn_error_t *
-svn_fs_fs__err_path_locked (svn_fs_t *fs, svn_lock_t *lock)
+svn_fs_fs__err_path_already_locked (svn_fs_t *fs, svn_lock_t *lock)
 {
   return
     svn_error_createf
- (SVN_ERR_FS_PATH_LOCKED, 0,
- _("Path '%s' is locked by user '%s' in filesystem '%s'"),
+ (SVN_ERR_FS_PATH_ALREADY_LOCKED, 0,
+ _("Path '%s' is already locked by user '%s' in filesystem '%s'"),
      lock->path, lock->owner, fs->path);
 }
 
Index: subversion/libsvn_fs_fs/err.h
===================================================================
--- subversion/libsvn_fs_fs/err.h (revision 13994)
+++ subversion/libsvn_fs_fs/err.h (working copy)
@@ -122,8 +122,9 @@ svn_error_t *svn_fs_fs__err_no_user (svn
 /* SVN_ERR_FS_NOT_FILE: PATH in FS is not a file. */
 svn_error_t *svn_fs_fs__err_not_file (svn_fs_t *fs, const char *path);
 
-/* SVN_ERR_FS_PATH_LOCKED: a path is locked. */
-svn_error_t *svn_fs_fs__err_path_locked (svn_fs_t *fs, svn_lock_t *lock);
+/* SVN_ERR_FS_PATH_ALREADY_LOCKED: a path is already locked. */
+svn_error_t *svn_fs_fs__err_path_already_locked (svn_fs_t *fs,
+ svn_lock_t *lock);
 
 /* SVN_ERR_FS_LOCK_OWNER_MISMATCH: trying to use a lock whose OWNER
    doesn't match the USERNAME associated with FS. */
Index: subversion/include/svn_error.h
===================================================================
--- subversion/include/svn_error.h (revision 13994)
+++ subversion/include/svn_error.h (working copy)
@@ -248,7 +248,7 @@ void svn_handle_warning (FILE *stream, s
  * that can be thrown when attempting to lock an item.
  */
 #define SVN_ERR_IS_LOCK_ERROR(err) \
- (err->apr_err == SVN_ERR_FS_PATH_LOCKED || \
+ (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED || \
    err->apr_err == SVN_ERR_FS_OUT_OF_DATE) \
 
 /**
Index: subversion/include/svn_fs.h
===================================================================
--- subversion/include/svn_fs.h (revision 13994)
+++ subversion/include/svn_fs.h (working copy)
@@ -1509,7 +1509,7 @@ svn_error_t *svn_fs_set_uuid (svn_fs_t *
  * @a comment is optional: it's either an xml-escapable UTF8 string
  * which describes the lock, or it is @c NULL.
  *
- * If path is already locked, then return @c SVN_ERR_FS_PATH_LOCKED,
+ * If path is already locked, then return @c SVN_ERR_FS_PATH_ALREADY_LOCKED,
  * unless @a steal_lock is true, in which case "steal" the existing
  * lock, even if the FS access-context's username does not match the
  * current lock's owner: delete the existing lock on @a path, and
Index: subversion/libsvn_fs_base/lock.c
===================================================================
--- subversion/libsvn_fs_base/lock.c (revision 13994)
+++ subversion/libsvn_fs_base/lock.c (working copy)
@@ -166,7 +166,8 @@ txn_body_lock (void *baton, trail_t *tra
       if (! args->steal_lock)
         {
           /* Sorry, the path is already locked. */
- return svn_fs_base__err_path_locked (trail->fs, existing_lock);
+ return svn_fs_base__err_path_already_locked (trail->fs,
+ existing_lock);
         }
       else
         {
Index: subversion/libsvn_fs_fs/lock.c
===================================================================
--- subversion/libsvn_fs_fs/lock.c (revision 13994)
+++ subversion/libsvn_fs_fs/lock.c (working copy)
@@ -791,7 +791,7 @@ lock_body (void *baton, apr_pool_t *pool
       if (! lb->steal_lock)
         {
           /* Sorry, the path is already locked. */
- return svn_fs_fs__err_path_locked (lb->fs, existing_lock);
+ return svn_fs_fs__err_path_already_locked (lb->fs, existing_lock);
         }
       else
         {
Index: subversion/libsvn_ra_dav/commit.c
===================================================================
--- subversion/libsvn_ra_dav/commit.c (revision 13994)
+++ subversion/libsvn_ra_dav/commit.c (working copy)
@@ -805,7 +805,7 @@ static svn_error_t * commit_delete_entry
   if (serr && ((serr->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN)
                || (serr->apr_err == SVN_ERR_FS_NO_LOCK_TOKEN)
                || (serr->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH)
- || (serr->apr_err == SVN_ERR_FS_PATH_LOCKED)))
+ || (serr->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED)))
     {
       /* Re-attempt the DELETE request as if the path were a directory.
          Discover all lock-tokens within the directory, and send them in

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Apr 7 02:07:17 2005

This is an archived mail posted to the Subversion Dev mailing list.