You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/01/22 00:52:22 UTC

svn commit: r1436694 - in /subversion/trunk/subversion: libsvn_wc/update_editor.c tests/cmdline/lock_tests.py

Author: rhuijben
Date: Mon Jan 21 23:52:22 2013
New Revision: 1436694

URL: http://svn.apache.org/viewvc?rev=1436694&view=rev
Log:
Resolve issue #3378, by using a bit more of the WC-NG power. We now only
delete locks when switching to a new location.

This makes the original locks re-appear when switching back to the original
location.

* subversion/libsvn_wc/update_editor.c
  (close_file): Don't delete locks when switching.

* subversion/tests/cmdline/lock_tests.py
  (lock_multi_wc): New test, verify (un)locking of paths in multiple WCs at
    one. (Issue #3105)
  (locks_stick_over_switch): Verify lock handling during switching.
    (issue #3378)

Modified:
    subversion/trunk/subversion/libsvn_wc/update_editor.c
    subversion/trunk/subversion/tests/cmdline/lock_tests.py

Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1436694&r1=1436693&r2=1436694&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Mon Jan 21 23:52:22 2013
@@ -4125,11 +4125,18 @@ close_file(void *file_baton,
            and we should likewise remove our cached copy of it.  */
         if (! strcmp(prop->name, SVN_PROP_ENTRY_LOCK_TOKEN))
           {
-            SVN_ERR_ASSERT(prop->value == NULL);
-            SVN_ERR(svn_wc__db_lock_remove(eb->db, fb->local_abspath,
-                                           scratch_pool));
+            /* If we lose the lock, but not because we are switching to
+               another url, remove the state lock from the wc */
+            if (! eb->switch_relpath 
+                || strcmp(fb->new_relpath, fb->old_repos_relpath) == 0)
+              {
+                SVN_DBG(("%s:%s\n", fb->new_relpath, fb->old_repos_relpath));
+                SVN_ERR_ASSERT(prop->value == NULL);
+                SVN_ERR(svn_wc__db_lock_remove(eb->db, fb->local_abspath,
+                                               scratch_pool));
 
-            lock_state = svn_wc_notify_lock_state_unlocked;
+                lock_state = svn_wc_notify_lock_state_unlocked;
+              }
             break;
           }
       }

Modified: subversion/trunk/subversion/tests/cmdline/lock_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/lock_tests.py?rev=1436694&r1=1436693&r2=1436694&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/lock_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/lock_tests.py Mon Jan 21 23:52:22 2013
@@ -1708,6 +1708,86 @@ def lock_invalid_token(sbox):
                                       ".*scheme.*'opaquelocktoken'", 0,
                                       'lock', '-m', '', file_path)
 
+@Issue(3105)
+def lock_multi_wc(sbox):
+  "obtain locks in multiple working copies in one go"
+
+  sbox.build()
+
+  sbox2 = sbox.clone_dependent(copy_wc=True)
+
+  wc_name = os.path.basename(sbox.wc_dir)
+  wc2_name = os.path.basename(sbox2.wc_dir)
+
+  expected_output = svntest.verify.UnorderedOutput([
+    '\'%s\' locked by user \'jrandom\'.\n' % os.path.join(wc_name, 'iota'),
+    '\'%s\' locked by user \'jrandom\'.\n' % os.path.join(wc2_name, 'A', 'mu'),
+  ])
+
+  svntest.actions.run_and_verify_svn(None, expected_output, [],
+                                     'lock', sbox.ospath('iota'),
+                                             sbox2.ospath('A/mu'))
+
+  expected_output = svntest.verify.UnorderedOutput([
+    '\'%s\' unlocked.\n' % os.path.join(wc_name, 'iota'),
+    '\'%s\' unlocked.\n' % os.path.join(wc2_name, 'A', 'mu'),
+  ])
+  svntest.actions.run_and_verify_svn(None, expected_output, [],
+                                     'unlock', sbox.ospath('iota'),
+                                               sbox2.ospath('A/mu'))
+
+@Issue(3378)
+def locks_stick_over_switch(sbox):
+  "locks are kept alive over switching"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  repo_url = sbox.repo_url
+
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'cp', sbox.ospath('A'), repo_url + '/AA',
+                                     '-m', '')
+
+  expected_output = svntest.verify.UnorderedOutput([
+    '\'iota\' locked by user \'jrandom\'.\n',
+    '\'A\D\H\chi\' locked by user \'jrandom\'.\n',
+    '\'A\mu\' locked by user \'jrandom\'.\n',
+  ])
+  svntest.actions.run_and_verify_svn(None, expected_output, [],
+                                     'lock', sbox.ospath('A/D/H/chi'),
+                                             sbox.ospath('A/mu'),
+                                             sbox.ospath('iota'))
+
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.tweak('A/D/H/chi', 'A/mu', 'iota', writelocked='K')
+
+  # Make sure the file is still locked
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+  expected_output = svntest.wc.State(wc_dir, {
+  })
+
+  expected_status.tweak(wc_rev=2)
+  expected_status.tweak('', wc_rev=1)
+  expected_status.tweak('iota', writelocked='K', wc_rev=1)
+
+  switched_status = expected_status.copy()
+  switched_status.tweak(writelocked=None)
+  switched_status.tweak('iota', writelocked='K')
+  switched_status.tweak('A', switched='S')
+
+  svntest.actions.run_and_verify_switch(wc_dir, sbox.ospath('A'), 
+                                        repo_url + '/AA',
+                                        expected_output, None, switched_status)
+
+  # And now switch back to verify that the locks reappear
+  expected_output = svntest.wc.State(wc_dir, {
+  })
+  svntest.actions.run_and_verify_switch(wc_dir, sbox.ospath('A'), 
+                                        repo_url + '/A',
+                                        expected_output, None, expected_status)
+
+
 
 ########################################################################
 # Run the tests
@@ -1757,6 +1837,8 @@ test_list = [ None,
               update_locked_deleted,
               block_unlock_if_pre_unlock_hook_fails,
               lock_invalid_token,
+              lock_multi_wc,
+              locks_stick_over_switch,
             ]
 
 if __name__ == '__main__':