You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2012/05/07 21:20:29 UTC

svn commit: r1335208 - /subversion/trunk/subversion/libsvn_fs/editor.c

Author: gstein
Date: Mon May  7 19:20:29 2012
New Revision: 1335208

URL: http://svn.apache.org/viewvc?rev=1335208&view=rev
Log:
Relax some of the constraints around providing a revision to certain
editor functions. The target node may be new to this transaction, and
(thus) have no revision yet.

* subversion/libsvn_fs/editor.c:
  (can_modify): allow all changes to mutable nodes. for unmutable
    nodes, require the caller to provide a revision.
  (alter_directory_cb, alter_file_cb, delete_cb, copy_cb, move_cb):
    remove the check mandating a revision. can_modify() will determine
    that for us.

Modified:
    subversion/trunk/subversion/libsvn_fs/editor.c

Modified: subversion/trunk/subversion/libsvn_fs/editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/editor.c?rev=1335208&r1=1335207&r2=1335208&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/editor.c (original)
+++ subversion/trunk/subversion/libsvn_fs/editor.c Mon May  7 19:20:29 2012
@@ -173,12 +173,30 @@ can_modify(svn_fs_root_t *txn_root,
   SVN_ERR(svn_fs_node_created_rev(&created_rev, txn_root, fspath,
                                   scratch_pool));
 
-  /* If CREATED_REV is invalid, that means it's already mutable in the
+  /* Uncommitted nodes (eg. a descendent of a copy/move/rotate destination)
+     have no (committed) revision number. Let the caller go ahead and
+     modify these nodes.
+
+     Note: strictly speaking, they might be performeing an "illegal" edit
+     in certain cases, but let's just assume they're Good Little Boys.
+
+     If CREATED_REV is invalid, that means it's already mutable in the
      txn, which means it has already passed this out-of-dateness check.
      (Usually, this happens when looking at a parent directory of an
      already-modified node)  */
-  if (SVN_IS_VALID_REVNUM(created_rev) && revision != created_rev)
-    {
+  if (!SVN_IS_VALID_REVNUM(created_rev))
+    return SVN_NO_ERROR;
+
+  /* If the node is immutable (has a revision), then the caller should
+     have supplied a valid revision number [that they expect to change].
+     The checks further below will determine the out-of-dateness of the
+     specified revision.  */
+  if (!SVN_IS_VALID_REVNUM(revision))
+    /* ### use a custom error code?  */
+    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
+                             N_("Revision for modifying '%s' is required"),
+                             fspath);
+
       if (revision < created_rev)
         {
           /* We asked to change a node that is *older* than what we found
@@ -188,7 +206,7 @@ can_modify(svn_fs_root_t *txn_root,
                                    fspath);
         }
 
-      /* revision > created_rev  */
+    if (revision > created_rev)
       {
         /* We asked to change a node that is *newer* than what we found
            in the transaction. Given that the transaction was based off
@@ -226,7 +244,6 @@ can_modify(svn_fs_root_t *txn_root,
                                      fspath);
           }
       }
-    }
 
   return SVN_NO_ERROR;
 }
@@ -370,13 +387,6 @@ alter_directory_cb(void *baton,
   /* Note: we ignore CHILDREN. We have no "incomplete" state to worry about,
      so we don't need to be aware of what children will be created.  */
 
-  if (!SVN_IS_VALID_REVNUM(revision))
-    /* ### use a custom error code?  */
-    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
-                             N_("Revision for modification of '%s' "
-                                "is required"),
-                             fspath);
-
   SVN_ERR(get_root(&root, eb));
   SVN_ERR(can_modify(root, fspath, revision, scratch_pool));
 
@@ -400,13 +410,6 @@ alter_file_cb(void *baton,
   const char *fspath = FSPATH(relpath, scratch_pool);
   svn_fs_root_t *root;
 
-  if (!SVN_IS_VALID_REVNUM(revision))
-    /* ### use a custom error code?  */
-    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
-                             N_("Revision for modification of '%s' "
-                                "is required"),
-                             fspath);
-
   SVN_ERR(get_root(&root, eb));
   SVN_ERR(can_modify(root, fspath, revision, scratch_pool));
 
@@ -452,13 +455,6 @@ delete_cb(void *baton,
   const char *fspath = FSPATH(relpath, scratch_pool);
   svn_fs_root_t *root;
 
-  if (!SVN_IS_VALID_REVNUM(revision))
-    /* ### use a custom error code?  */
-    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
-                             N_("Revision for deletion of '%s' "
-                                "is required"),
-                             fspath);
-
   SVN_ERR(get_root(&root, eb));
   SVN_ERR(can_modify(root, fspath, revision, scratch_pool));
 
@@ -483,13 +479,6 @@ copy_cb(void *baton,
   svn_fs_root_t *root;
   svn_fs_root_t *src_root;
 
-  if (!SVN_IS_VALID_REVNUM(src_revision))
-    /* ### use a custom error code?  */
-    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
-                             N_("Source revision for copy of '%s' "
-                                "is required"),
-                             src_fspath);
-
   SVN_ERR(get_root(&root, eb));
 
   /* Check if we can we replace the maybe-specified destination (revision).  */
@@ -523,13 +512,6 @@ move_cb(void *baton,
   svn_fs_root_t *root;
   svn_fs_root_t *src_root;
 
-  if (!SVN_IS_VALID_REVNUM(src_revision))
-    /* ### use a custom error code?  */
-    return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
-                             N_("Source revision for move of '%s' "
-                                "is required"),
-                             src_fspath);
-
   SVN_ERR(get_root(&root, eb));
 
   /* Check if we delete the specified source (revision), and can we replace