subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svn-r...@apache.org
Subject svn commit: r1589575 - in /subversion/branches/1.8.x: ./ subversion/libsvn_client/merge.c subversion/tests/cmdline/merge_tests.py
Date Thu, 24 Apr 2014 04:01:50 GMT
Author: svn-role
Date: Thu Apr 24 04:01:49 2014
New Revision: 1589575

URL: http://svn.apache.org/r1589575
Log:
Merge the 1.8.x-r1577151 branch:

 * r1577151
   Make 'svn merge' honor the 'preserved-conflict-file-exts' setting.
   Justification:
     While really a behavior change that doesn't belong in a patch release
     I'm guessing nobody knew that we didn't implement this flag in this
     scenario.
   Branch:
     ^/subversion/branches/1.8.x-r1577151
   Votes:
     +1: rhuijben, steveking, stefan2

Modified:
    subversion/branches/1.8.x/   (props changed)
    subversion/branches/1.8.x/subversion/libsvn_client/merge.c
    subversion/branches/1.8.x/subversion/tests/cmdline/merge_tests.py

Propchange: subversion/branches/1.8.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1577151
  Merged /subversion/branches/1.8.x-r1577151:r1589064-1589574

Modified: subversion/branches/1.8.x/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/libsvn_client/merge.c?rev=1589575&r1=1589574&r2=1589575&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/1.8.x/subversion/libsvn_client/merge.c Thu Apr 24 04:01:49 2014
@@ -322,6 +322,10 @@ typedef struct merge_cmd_baton_t {
   const char *diff3_cmd;
   const apr_array_header_t *merge_options;
 
+  /* Array of file extension patterns to preserve as extensions in
+     generated conflict files. */
+  const apr_array_header_t *ext_patterns;
+
   /* RA sessions used throughout a merge operation.  Opened/re-parented
      as needed.
 
@@ -2023,17 +2027,36 @@ merge_file_changed(const char *relpath,
     {
       svn_boolean_t has_local_mods;
       enum svn_wc_merge_outcome_t content_outcome;
+      const char *target_label;
+      const char *left_label;
+      const char *right_label;
+      const char *path_ext = "";
+
+      if (merge_b->ext_patterns && merge_b->ext_patterns->nelts)
+        {
+          svn_path_splitext(NULL, &path_ext, local_abspath, scratch_pool);
+          if (! (*path_ext
+                 && svn_cstring_match_glob_list(path_ext,
+                                                merge_b->ext_patterns)))
+            {
+              path_ext = "";
+            }
+        }
 
       /* xgettext: the '.working', '.merge-left.r%ld' and
          '.merge-right.r%ld' strings are used to tag onto a file
          name in case of a merge conflict */
-      const char *target_label = _(".working");
-      const char *left_label = apr_psprintf(scratch_pool,
-                                            _(".merge-left.r%ld"),
-                                            left_source->revision);
-      const char *right_label = apr_psprintf(scratch_pool,
-                                             _(".merge-right.r%ld"),
-                                             right_source->revision);
+
+      target_label = apr_psprintf(scratch_pool, _(".working%s%s"),
+                                  *path_ext ? "." : "", path_ext);
+      left_label = apr_psprintf(scratch_pool,
+                                _(".merge-left.r%ld%s%s"),
+                                left_source->revision,
+                                *path_ext ? "." : "", path_ext);
+      right_label = apr_psprintf(scratch_pool,
+                                 _(".merge-right.r%ld%s%s"),
+                                 right_source->revision,
+                                 *path_ext ? "." : "", path_ext);
 
       SVN_ERR(svn_wc_text_modified_p2(&has_local_mods, ctx->wc_ctx,
                                       local_abspath, FALSE, scratch_pool));
@@ -9670,6 +9693,7 @@ do_merge(apr_hash_t **modified_subtrees,
   merge_cmd_baton_t merge_cmd_baton = { 0 };
   svn_config_t *cfg;
   const char *diff3_cmd;
+  const char *preserved_exts_str;
   int i;
   svn_boolean_t checked_mergeinfo_capability = FALSE;
   svn_ra_session_t *ra_session1 = NULL, *ra_session2 = NULL;
@@ -9730,6 +9754,11 @@ do_merge(apr_hash_t **modified_subtrees,
   if (diff3_cmd != NULL)
     SVN_ERR(svn_path_cstring_to_utf8(&diff3_cmd, diff3_cmd, scratch_pool));
 
+    /* See which files the user wants to preserve the extension of when
+     conflict files are made. */
+  svn_config_get(cfg, &preserved_exts_str, SVN_CONFIG_SECTION_MISCELLANY,
+                 SVN_CONFIG_OPTION_PRESERVED_CF_EXTS, "");
+
   /* Build the merge context baton (or at least the parts of it that
      don't need to be reset for each merge source).  */
   merge_cmd_baton.force_delete = force_delete;
@@ -9745,6 +9774,11 @@ do_merge(apr_hash_t **modified_subtrees,
   merge_cmd_baton.pool = iterpool;
   merge_cmd_baton.merge_options = merge_options;
   merge_cmd_baton.diff3_cmd = diff3_cmd;
+  merge_cmd_baton.ext_patterns = *preserved_exts_str
+                          ? svn_cstring_split(preserved_exts_str, "\n\r\t\v ",
+                                              FALSE, scratch_pool)
+                          : NULL;
+
   merge_cmd_baton.use_sleep = use_sleep;
 
   /* Do we already know the specific subtrees with mergeinfo we want

Modified: subversion/branches/1.8.x/subversion/tests/cmdline/merge_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/tests/cmdline/merge_tests.py?rev=1589575&r1=1589574&r2=1589575&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/tests/cmdline/merge_tests.py (original)
+++ subversion/branches/1.8.x/subversion/tests/cmdline/merge_tests.py Thu Apr 24 04:01:49
2014
@@ -19167,6 +19167,135 @@ def merge_dir_delete_force(sbox):
                                      'merge', '-c2', '^/', sbox.wc_dir,
                                      '--ignore-ancestry', '--force')
 
+def conflict_naming(sbox):
+  "verify conflict file naming"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  sbox.simple_append('file.txt', 'This is the initial content\n')
+  sbox.simple_add('file.txt')
+  sbox.simple_commit()
+
+  sbox.simple_append('file.txt', 'This is the new content\n', truncate=True)
+  sbox.simple_commit()
+
+  sbox.simple_append('file.txt', 'This is conflicting content\n', truncate=True)
+
+  # Update - no preserve ext
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
+  expected_disk = svntest.main.greek_state.copy()
+  expected_output = svntest.wc.State(wc_dir, {
+    'file.txt' : Item(status='C ')
+  })
+  expected_status.add({
+    'file.txt' : Item(status='C ', wc_rev='2')
+  })
+
+  expected_disk.add({
+    'file.txt.r3'       : Item(contents="This is the new content\n"),
+    'file.txt.r2'       : Item(contents="This is the initial content\n"),
+    'file.txt'          : Item(contents="<<<<<<< .mine\n" \
+                               "This is conflicting content\n" \
+                               "=======\n" \
+                               "This is the initial content\n" \
+                               ">>>>>>> .r2\n"),
+    'file.txt.mine'     : Item(contents="This is conflicting content\n"),
+  })
+  svntest.actions.run_and_verify_update(wc_dir,
+                                        expected_output, expected_disk,
+                                        expected_status,
+                                        None, None, None,
+                                        None, None, None,
+                                        wc_dir, '-r', '2')
+
+  sbox.simple_revert('file.txt')
+  sbox.simple_update('', revision=3)
+  sbox.simple_append('file.txt', 'This is conflicting content\n', truncate=True)
+
+  # Update - preserve ext
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
+  expected_disk = svntest.main.greek_state.copy()
+  expected_output = svntest.wc.State(wc_dir, {
+    'file.txt' : Item(status='C ')
+  })
+  expected_status.add({
+    'file.txt' : Item(status='C ', wc_rev='2')
+  })
+
+  expected_disk.add({
+    'file.txt.r3.txt'   : Item(contents="This is the new content\n"),
+    'file.txt.r2.txt'   : Item(contents="This is the initial content\n"),
+    'file.txt'          : Item(contents="<<<<<<< .mine.txt\n" \
+                               "This is conflicting content\n" \
+                               "=======\n" \
+                               "This is the initial content\n" \
+                               ">>>>>>> .r2.txt\n"),
+    'file.txt.mine.txt' : Item(contents="This is conflicting content\n"),
+  })
+  svntest.actions.run_and_verify_update(
+                      wc_dir,
+                      expected_output, expected_disk, expected_status,
+                      None, None, None, None, None, None,
+                      wc_dir, '-r', '2',
+                      '--config-option',
+                      'config:miscellany:preserved-conflict-file-exts=' +
+                      'c txt h')
+
+  sbox.simple_revert('file.txt')
+  sbox.simple_update('', revision=3)
+  sbox.simple_append('file.txt', 'This is conflicting content\n', truncate=True)
+
+  # Merge - no preserve ext
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
+  expected_disk = svntest.main.greek_state.copy()
+  expected_status.add({
+    'file.txt' : Item(status='C ', wc_rev='3')
+  })
+  expected_disk.add({
+    'file.txt.merge-left.r3' : Item(contents="This is the new content\n"),
+    'file.txt.merge-right.r2': Item(contents="This is the initial content\n"),
+    'file.txt'               : Item(contents="<<<<<<< .working\n" \
+                                    "This is conflicting content\n" \
+                                    "=======\n" \
+                                    "This is the initial content\n" \
+                                    ">>>>>>> .merge-right.r2\n"),
+    'file.txt.working'       : Item(contents="This is conflicting content\n"),
+  })
+
+  svntest.actions.run_and_verify_svn(wc_dir, None, [],
+                                     'merge', '-c-3', '^/', sbox.ospath(''))
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+  svntest.actions.verify_disk(wc_dir, expected_disk)
+
+  sbox.simple_revert('file.txt')
+  sbox.simple_append('file.txt', 'This is conflicting content\n', truncate=True)
+
+  # Merge - preserve ext
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 3)
+  expected_disk = svntest.main.greek_state.copy()
+  expected_status.add({
+    'file.txt' : Item(status='C ', wc_rev='3')
+  })
+  expected_disk.add({
+    'file.txt.merge-left.r3.txt' : Item(contents="This is the new content\n"),
+    'file.txt.merge-right.r2.txt': Item(contents="This is the initial content\n"),
+    'file.txt'                   : Item(contents="<<<<<<< .working.txt\n"
\
+                                        "This is conflicting content\n" \
+                                        "=======\n" \
+                                        "This is the initial content\n" \
+                                        ">>>>>>> .merge-right.r2.txt\n"),
+    'file.txt.working.txt'       : Item(contents="This is conflicting content\n"),
+  })
+
+  svntest.actions.run_and_verify_svn(
+                           wc_dir, None, [],
+                           'merge', '-c-3', '^/', sbox.ospath(''),
+                           '--config-option',
+                           'config:miscellany:preserved-conflict-file-exts=' +
+                           'c txt h')
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+  svntest.actions.verify_disk(wc_dir, expected_disk)
+
 ########################################################################
 # Run the tests
 
@@ -19313,6 +19442,7 @@ test_list = [ None,
               conflicted_split_merge_with_resolve,
               merge_to_empty_target_merge_to_infinite_target,
               merge_dir_delete_force,
+              conflict_naming,
              ]
 
 if __name__ == '__main__':



Mime
View raw message