subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1834612 - in /subversion/branches/1.10.x-issue4758/subversion: libsvn_client/shelve.c tests/cmdline/shelve_tests.py
Date Thu, 28 Jun 2018 13:50:28 GMT
Author: julianfoad
Date: Thu Jun 28 13:50:28 2018
New Revision: 1834612

URL: http://svn.apache.org/viewvc?rev=1834612&view=rev
Log:
On the '1.10.x-issue4758' branch: Fix SVN-4758 "Unable to shelve changes
when using custom diff-cmd".

* subversion/libsvn_client/shelve.c
  (shelf_write_patch): Ignore any config file while executing the diff, so
    as to use the internal diff code.
 
* subversion/tests/cmdline/shelve_tests.py
  (shelve_unshelve_verify,
   shelve_unshelve): Allow specifying global options.
  (shelve_ignores_external_diff): New test.
  (test_list): Run it.

Modified:
    subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c
    subversion/branches/1.10.x-issue4758/subversion/tests/cmdline/shelve_tests.py

Modified: subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c?rev=1834612&r1=1834611&r2=1834612&view=diff
==============================================================================
--- subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c (original)
+++ subversion/branches/1.10.x-issue4758/subversion/libsvn_client/shelve.c Thu Jun 28 13:50:28
2018
@@ -158,6 +158,7 @@ shelf_write_patch(const char *name,
   svn_opt_revision_t peg_revision = {svn_opt_revision_unspecified, {0}};
   svn_opt_revision_t start_revision = {svn_opt_revision_base, {0}};
   svn_opt_revision_t end_revision = {svn_opt_revision_working, {0}};
+  apr_hash_t *old_config;
 
   SVN_ERR(get_patch_abspath(&patch_abspath, name, wc_root_abspath,
                             ctx, scratch_pool, scratch_pool));
@@ -185,6 +186,10 @@ shelf_write_patch(const char *name,
   SVN_ERR(svn_stream_printf(outstream, scratch_pool,
                             "--This patch was generated by 'svn shelve'--\n\n"));
 
+  /* Ensure we use internal diff, not any configured external diff-cmd. */
+  old_config = ctx->config;
+  ctx->config = NULL;
+
   for (i = 0; i < paths->nelts; i++)
     {
       const char *path = APR_ARRAY_IDX(paths, i, const char *);
@@ -216,6 +221,9 @@ shelf_write_patch(const char *name,
                      changelists,
                      ctx, iterpool));
     }
+
+  ctx->config = old_config;
+
   SVN_ERR(svn_stream_close(outstream));
   SVN_ERR(svn_stream_close(errstream));
 

Modified: subversion/branches/1.10.x-issue4758/subversion/tests/cmdline/shelve_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.10.x-issue4758/subversion/tests/cmdline/shelve_tests.py?rev=1834612&r1=1834611&r2=1834612&view=diff
==============================================================================
--- subversion/branches/1.10.x-issue4758/subversion/tests/cmdline/shelve_tests.py (original)
+++ subversion/branches/1.10.x-issue4758/subversion/tests/cmdline/shelve_tests.py Thu Jun
28 13:50:28 2018
@@ -25,7 +25,7 @@
 ######################################################################
 
 # General modules
-import shutil, stat, re, os, logging
+import shutil, stat, re, os, sys, logging
 
 logger = logging.getLogger()
 
@@ -44,7 +44,7 @@ Item = wc.StateItem
 
 #----------------------------------------------------------------------
 
-def shelve_unshelve_verify(sbox):
+def shelve_unshelve_verify(sbox, global_opts=()):
   """Round-trip: shelve; verify all changes are reverted;
      unshelve; verify all changes are restored.
   """
@@ -58,18 +58,18 @@ def shelve_unshelve_verify(sbox):
 
   # Shelve; check there are no longer any modifications
   svntest.actions.run_and_verify_svn(None, [],
-                                     'shelve', 'foo')
+                                     'shelve', 'foo', *global_opts)
   virginal_state = svntest.actions.get_virginal_state(wc_dir, 1)
   svntest.actions.run_and_verify_status(wc_dir, virginal_state)
 
   # Unshelve; check the original modifications are here again
   svntest.actions.run_and_verify_svn(None, [],
-                                     'unshelve', 'foo')
+                                     'unshelve', 'foo', *global_opts)
   svntest.actions.run_and_verify_status(wc_dir, modified_state)
 
 #----------------------------------------------------------------------
 
-def shelve_unshelve(sbox, modifier):
+def shelve_unshelve(sbox, modifier, global_opts=()):
   """Round-trip: build 'sbox'; apply changes by calling 'modifier(sbox)';
      shelve and unshelve; verify changes are fully reverted and restored.
   """
@@ -82,7 +82,7 @@ def shelve_unshelve(sbox, modifier):
   # Make some changes to the working copy
   modifier(sbox)
 
-  shelve_unshelve_verify(sbox)
+  shelve_unshelve_verify(sbox, global_opts)
 
   os.chdir(was_cwd)
 
@@ -156,6 +156,35 @@ def shelve_from_inner_path(sbox):
 
 #----------------------------------------------------------------------
 
+def shelve_ignores_external_diff(sbox):
+  "shelve ignores external diff"
+
+  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 = '..'
+
+  # Configure an external 'diff-cmd' that doesn't print a diff to stdout.
+  # (This path needs an explicit directory component to avoid searching.)
+  diff_script_path = os.path.join('.', 'diff')
+  svntest.main.create_python_hook_script(diff_script_path, 'import sys\n'
+    'for arg in sys.argv[1:]:\n  print(arg)\n')
+  if sys.platform == 'win32':
+    diff_script_path = "%s.bat" % diff_script_path
+  config_dir_path = sbox.get_tempname(prefix="config-dir")
+  os.mkdir(config_dir_path)
+  with open(os.path.join(config_dir_path, "config"), "w") as config_file:
+    config_file.write("[helpers]\n"
+                      "diff-cmd = %s\n" % diff_script_path)
+
+  modifier(sbox)
+  shelve_unshelve_verify(sbox, global_opts=("--config-dir", config_dir_path))
+
+  os.chdir(was_cwd)
+
 ########################################################################
 # Run the tests
 
@@ -166,6 +195,7 @@ test_list = [ None,
               shelve_adds,
               shelve_deletes,
               shelve_from_inner_path,
+              shelve_ignores_external_diff,
              ]
 
 if __name__ == '__main__':



Mime
View raw message