You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2018/01/02 11:34:53 UTC

svn commit: r1819804 - in /subversion/trunk/subversion: libsvn_client/shelve.c tests/cmdline/shelve_tests.py

Author: julianfoad
Date: Tue Jan  2 11:34:53 2018
New Revision: 1819804

URL: http://svn.apache.org/viewvc?rev=1819804&view=rev
Log:
Fix 'shelve' when the current working directory is not the WC root.

This makes the diff paths in the patch file be relative to the WC root, as
intended.

Found by: jamessan

* subversion/libsvn_client/shelve.c,
  (svn_client_shelf_write_patch): Make the diff use paths relative to WC root.

* subversion/tests/cmdline/shelve_tests.py
  (shelve_unshelve_verify): New; extracted from shelve_unshelve().
  (shelve_from_inner_path): New test.
  (test_list): Run it.

Modified:
    subversion/trunk/subversion/libsvn_client/shelve.c
    subversion/trunk/subversion/tests/cmdline/shelve_tests.py

Modified: subversion/trunk/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/shelve.c?rev=1819804&r1=1819803&r2=1819804&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/shelve.c (original)
+++ subversion/trunk/subversion/libsvn_client/shelve.c Tue Jan  2 11:34:53 2018
@@ -128,6 +128,7 @@ svn_client_shelf_write_patch(const char
       if (svn_path_is_url(path))
         return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
                                  _("'%s' is not a local path"), path);
+      SVN_ERR(svn_dirent_get_absolute(&path, path, scratch_pool));
 
       SVN_ERR(svn_client_diff_peg6(
                      NULL /*options*/,
@@ -135,7 +136,7 @@ svn_client_shelf_write_patch(const char
                      &peg_revision,
                      &start_revision,
                      &end_revision,
-                     NULL,
+                     wc_root_abspath,
                      depth,
                      TRUE /*notice_ancestry*/,
                      FALSE /*no_diff_added*/,

Modified: subversion/trunk/subversion/tests/cmdline/shelve_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/shelve_tests.py?rev=1819804&r1=1819803&r2=1819804&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/shelve_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/shelve_tests.py Tue Jan  2 11:34:53 2018
@@ -44,21 +44,16 @@ Item = wc.StateItem
 
 #----------------------------------------------------------------------
 
-def shelve_unshelve(sbox, modifier):
-  "Round-trip: shelve and unshelve"
+def shelve_unshelve_verify(sbox):
+  """Round-trip: shelve; verify all changes are reverted;
+     unshelve; verify all changes are restored.
+  """
 
-  sbox.build()
-  was_cwd = os.getcwd()
-  os.chdir(sbox.wc_dir)
-  sbox.wc_dir = ''
-  wc_dir = ''
-
-  # Make some changes to the working copy
-  modifier(sbox)
+  wc_dir = sbox.wc_dir
 
   # Save the modified state
   _, output, _ = svntest.main.run_svn(None, 'status', '-v', '-u', '-q',
-                                      sbox.wc_dir)
+                                      wc_dir)
   modified_state = svntest.wc.State.from_status(output, wc_dir)
 
   # Shelve; check there are no longer any modifications
@@ -72,6 +67,23 @@ def shelve_unshelve(sbox, modifier):
                                      'unshelve', 'foo')
   svntest.actions.run_and_verify_status(wc_dir, modified_state)
 
+#----------------------------------------------------------------------
+
+def shelve_unshelve(sbox, modifier):
+  """Round-trip: build 'sbox'; apply changes by calling 'modifier(sbox)';
+     shelve and unshelve; verify changes are fully reverted and restored.
+  """
+
+  sbox.build()
+  was_cwd = os.getcwd()
+  os.chdir(sbox.wc_dir)
+  sbox.wc_dir = ''
+
+  # Make some changes to the working copy
+  modifier(sbox)
+
+  shelve_unshelve_verify(sbox)
+
   os.chdir(was_cwd)
 
 ######################################################################
@@ -126,6 +138,23 @@ def shelve_deletes(sbox):
 
 #----------------------------------------------------------------------
 
+def shelve_from_inner_path(sbox):
+  "shelve from inner path"
+
+  def modifier(sbox):
+    sbox.simple_append('A/mu', 'appended mu text')
+
+  sbox.build()
+  was_cwd = os.getcwd()
+  os.chdir(sbox.ospath('A'))
+  sbox.wc_dir = '..'
+
+  modifier(sbox)
+  shelve_unshelve_verify(sbox)
+
+  os.chdir(was_cwd)
+
+#----------------------------------------------------------------------
 
 ########################################################################
 # Run the tests
@@ -136,6 +165,7 @@ test_list = [ None,
               shelve_prop_changes,
               shelve_adds,
               shelve_deletes,
+              shelve_from_inner_path,
              ]
 
 if __name__ == '__main__':