You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2011/04/04 15:09:43 UTC

svn commit: r1088609 - in /subversion/trunk/subversion: libsvn_wc/adm_ops.c tests/cmdline/special_tests.py

Author: philip
Date: Mon Apr  4 13:09:43 2011
New Revision: 1088609

URL: http://svn.apache.org/viewvc?rev=1088609&view=rev
Log:
Improve new revert symlink handling.

* subversion/libsvn_wc/adm_ops.c
  (revert_restore): Handle file/symlink mismatch.

* subversion/tests/cmdline/special_tests.py
  (merge_symlink_into_file): Add Issue marker, tweak comment.
  (symlink_destination_change): New.
  (test_list): Add symlink_destination_change.

Modified:
    subversion/trunk/subversion/libsvn_wc/adm_ops.c
    subversion/trunk/subversion/tests/cmdline/special_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=1088609&r1=1088608&r2=1088609&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Mon Apr  4 13:09:43 2011
@@ -1436,58 +1436,72 @@ revert_restore(svn_wc__db_t *db,
       else if (on_disk == svn_node_file)
         {
           svn_boolean_t modified, executable, read_only;
+          apr_hash_t *props;
+          svn_string_t *special_prop;
 
-          SVN_ERR(svn_wc__internal_file_modified_p(&modified, &executable,
-                                                   &read_only,
-                                                   db, local_abspath,
-                                                   FALSE, FALSE, scratch_pool));
-          if (modified)
+          SVN_ERR(svn_wc__db_read_pristine_props(&props, db, local_abspath,
+                                                 scratch_pool, scratch_pool));
+
+          special_prop = apr_hash_get(props, SVN_PROP_SPECIAL,
+                                      APR_HASH_KEY_STRING);
+
+          if ((special_prop != NULL) != special)
             {
+              /* File/symlink mismatch. */
               SVN_ERR(svn_io_remove_file2(local_abspath, FALSE, scratch_pool));
               on_disk = svn_node_none;
             }
           else
             {
-              apr_hash_t *props;
-              svn_string_t *needs_lock_prop;
-#if !defined(WIN32) && !defined(__OS2__)
-              svn_string_t *executable_prop;
-#endif
-
-              SVN_ERR(svn_wc__db_read_pristine_props(&props, db, local_abspath,
-                                                     scratch_pool,
-                                                     scratch_pool));
-              needs_lock_prop = apr_hash_get(props, SVN_PROP_NEEDS_LOCK,
-                                             APR_HASH_KEY_STRING);
-              if (needs_lock_prop && !read_only)
+              SVN_ERR(svn_wc__internal_file_modified_p(&modified, &executable,
+                                                       &read_only,
+                                                       db, local_abspath,
+                                                       FALSE, FALSE,
+                                                       scratch_pool));
+              if (modified)
                 {
-                  SVN_ERR(svn_io_set_file_read_only(local_abspath,
-                                                    FALSE, scratch_pool));
-                  notify_required = TRUE;
+                  SVN_ERR(svn_io_remove_file2(local_abspath, FALSE,
+                                              scratch_pool));
+                  on_disk = svn_node_none;
                 }
-              else if (!needs_lock_prop && read_only)
+              else
                 {
-                  SVN_ERR(svn_io_set_file_read_write(local_abspath,
-                                                     FALSE, scratch_pool));
-                  notify_required = TRUE;
-                }
+                  svn_string_t *needs_lock_prop;
+#if !defined(WIN32) && !defined(__OS2__)
+                  svn_string_t *executable_prop;
+#endif
+                  needs_lock_prop = apr_hash_get(props, SVN_PROP_NEEDS_LOCK,
+                                                 APR_HASH_KEY_STRING);
+                  if (needs_lock_prop && !read_only)
+                    {
+                      SVN_ERR(svn_io_set_file_read_only(local_abspath,
+                                                        FALSE, scratch_pool));
+                      notify_required = TRUE;
+                    }
+                  else if (!needs_lock_prop && read_only)
+                    {
+                      SVN_ERR(svn_io_set_file_read_write(local_abspath,
+                                                         FALSE, scratch_pool));
+                      notify_required = TRUE;
+                    }
 
 #if !defined(WIN32) && !defined(__OS2__)
-              executable_prop = apr_hash_get(props, SVN_PROP_EXECUTABLE,
-                                             APR_HASH_KEY_STRING);
-              if (executable_prop && !executable)
-                {
-                  SVN_ERR(svn_io_set_file_executable(local_abspath, TRUE,
-                                                     FALSE, scratch_pool));
-                  notify_required = TRUE;
-                }
-              else if (!executable_prop && executable)
-                {
-                  SVN_ERR(svn_io_set_file_executable(local_abspath, FALSE,
-                                                     FALSE, scratch_pool));
-                  notify_required = TRUE;
-                }
+                  executable_prop = apr_hash_get(props, SVN_PROP_EXECUTABLE,
+                                                 APR_HASH_KEY_STRING);
+                  if (executable_prop && !executable)
+                    {
+                      SVN_ERR(svn_io_set_file_executable(local_abspath, TRUE,
+                                                         FALSE, scratch_pool));
+                      notify_required = TRUE;
+                    }
+                  else if (!executable_prop && executable)
+                    {
+                      SVN_ERR(svn_io_set_file_executable(local_abspath, FALSE,
+                                                         FALSE, scratch_pool));
+                      notify_required = TRUE;
+                    }
 #endif
+                }
             }
         }
     }

Modified: subversion/trunk/subversion/tests/cmdline/special_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/special_tests.py?rev=1088609&r1=1088608&r2=1088609&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/special_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/special_tests.py Mon Apr  4 13:09:43 2011
@@ -366,6 +366,7 @@ def remove_symlink(sbox):
 
 @SkipUnless(svntest.main.is_posix_os)
 @SkipUnless(server_has_mergeinfo)
+@Issue(2530)
 def merge_symlink_into_file(sbox):
   "merge symlink into file"
 
@@ -411,7 +412,7 @@ def merge_symlink_into_file(sbox):
                        'merge', '-r', '2:4', dprime_url,
                        os.path.join(wc_dir, 'A', 'D'))
 
-  # now revert, and we'll get a strange error
+  # now revert, we once got a strange error
   svntest.main.run_svn(None, 'revert', '-R', wc_dir)
 
   # assuming we got past the revert because someone fixed that bug, lets
@@ -701,6 +702,43 @@ def unrelated_changed_special_status(sbo
                                      '-m', 'psi changed special status')
 
 
+@SkipUnless(svntest.main.is_posix_os)
+def symlink_destination_change(sbox):
+  "revert a symlink destination change"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Create a new symlink and commit it.
+  newfile_path = os.path.join(wc_dir, 'newfile')
+  os.symlink('linktarget', newfile_path)
+  svntest.main.run_svn(None, 'add', newfile_path)
+
+  expected_output = svntest.wc.State(wc_dir, {
+    'newfile' : Item(verb='Adding'),
+    })
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.add({
+    'newfile' : Item(status='  ', wc_rev=2),
+    })
+
+  svntest.actions.run_and_verify_commit(wc_dir, expected_output,
+                                        expected_status, None, wc_dir)
+
+  # Modify the symlink to point somewhere else
+  os.remove(newfile_path)
+  os.symlink('linktarget2', newfile_path)
+
+  expected_status.tweak('newfile', status='M ')
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+  # Revert should restore the symlink to point to the original destination
+  svntest.main.run_svn(None, 'revert', '-R', wc_dir)
+  expected_status.tweak('newfile', status='  ')
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+  # Now replace the symlink with a normal file and try to commit, we
 ########################################################################
 # Run the tests
 
@@ -723,6 +761,7 @@ test_list = [ None,
               warn_on_reserved_name,
               propvalue_normalized,
               unrelated_changed_special_status,
+              symlink_destination_change,
              ]
 
 if __name__ == '__main__':



Re: svn commit: r1088609 - in /subversion/trunk/subversion: libsvn_wc/adm_ops.c tests/cmdline/special_tests.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
philip@apache.org wrote on Mon, Apr 04, 2011 at 13:09:43 -0000:
> +@SkipUnless(svntest.main.is_posix_os)
> +def symlink_destination_change(sbox):
> +  "revert a symlink destination change"
...
> +  # Now replace the symlink with a normal file and try to commit, we

You didn't commit the rest of the sentence.

Re: svn commit: r1088609 - in /subversion/trunk/subversion: libsvn_wc/adm_ops.c tests/cmdline/special_tests.py

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
philip@apache.org wrote on Mon, Apr 04, 2011 at 13:09:43 -0000:
> +@SkipUnless(svntest.main.is_posix_os)
> +def symlink_destination_change(sbox):
> +  "revert a symlink destination change"
...
> +  # Now replace the symlink with a normal file and try to commit, we

You didn't commit the rest of the sentence.