Author: danielsh
Date: Sat Sep 26 00:29:20 2015
New Revision: 1705390

URL: http://svn.apache.org/viewvc?rev=1705390&view=rev
Log:
On the patch-exec branch, support diffs having both mode lines and tree lines.

* subversion/tests/libsvn_diff/parse-diff-test.c
  (git_tree_and_text_unidiff, test_parse_git_tree_and_text_diff):
    Test this.

* subversion/libsvn_diff/parse-diff.c
  (parse_state.state_git_mode_seen): New state enumerator.
  (transitions): Add transitions for the new state.
  (git_new_mode): Change to the new state.
  (svn_diff_parse_next_patch): Update end-of-diff-header detection logic.

* BRANCH-README: Mark this task done.

Modified:
    subversion/branches/patch-exec/BRANCH-README
    subversion/branches/patch-exec/subversion/libsvn_diff/parse-diff.c
    
subversion/branches/patch-exec/subversion/tests/libsvn_diff/parse-diff-test.c

Modified: subversion/branches/patch-exec/BRANCH-README
URL: 
http://svn.apache.org/viewvc/subversion/branches/patch-exec/BRANCH-README?rev=1705390&r1=1705389&r2=1705390&view=diff
==============================================================================
--- subversion/branches/patch-exec/BRANCH-README (original)
+++ subversion/branches/patch-exec/BRANCH-README Sat Sep 26 00:29:20 2015
@@ -11,7 +11,7 @@ Steps:
 - [DONE] Handle svn:executable and 'new mode' lines both present
 - [DONE] parser: Review handling of modes other than 0644/0755
                  Consider checking "mode & 0111"
-- [TODO] check rename/copy with mode change; ensure test coverage
+- [DONE] check rename/copy with mode change; ensure test coverage
 - [TODO] ensure binary diff & mode changes interact properly
 - [TODO] Teach 'svn diff --git' to emit mode information (executability)
   - In addition to the standard propchange form used for all user properties,

Modified: subversion/branches/patch-exec/subversion/libsvn_diff/parse-diff.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/patch-exec/subversion/libsvn_diff/parse-diff.c?rev=1705390&r1=1705389&r2=1705390&view=diff
==============================================================================
--- subversion/branches/patch-exec/subversion/libsvn_diff/parse-diff.c 
(original)
+++ subversion/branches/patch-exec/subversion/libsvn_diff/parse-diff.c Sat Sep 
26 00:29:20 2015
@@ -1352,6 +1352,7 @@ enum parse_state
    state_git_minus_seen,    /* --- /dev/null; or --- a/ */
    state_git_plus_seen,     /* +++ /dev/null; or +++ a/ */
    state_old_mode_seen,     /* old mode 100644 */
+   state_git_mode_seen,     /* new mode 100644 */
    state_move_from_seen,    /* rename from foo.c */
    state_copy_from_seen,    /* copy from foo.c */
    state_minus_seen,        /* --- foo.c */
@@ -1659,7 +1660,7 @@ git_new_mode(enum parse_state *new_state
 
   /* Don't touch patch->operation. */
 
-  *new_state = state_git_tree_seen;
+  *new_state = state_git_mode_seen;
   return SVN_NO_ERROR;
 }
 
@@ -2007,7 +2008,9 @@ static struct transition transitions[] =
 
   {"diff --git",        state_start,            git_start},
   {"--- a/",            state_git_diff_seen,    git_minus},
+  {"--- a/",            state_git_mode_seen,    git_minus},
   {"--- a/",            state_git_tree_seen,    git_minus},
+  {"--- /dev/null",     state_git_mode_seen,    git_minus},
   {"--- /dev/null",     state_git_tree_seen,    git_minus},
   {"+++ b/",            state_git_minus_seen,   git_plus},
   {"+++ /dev/null",     state_git_minus_seen,   git_plus},
@@ -2016,9 +2019,11 @@ static struct transition transitions[] =
   {"new mode ",         state_old_mode_seen,    git_new_mode},
 
   {"rename from ",      state_git_diff_seen,    git_move_from},
+  {"rename from ",      state_git_mode_seen,    git_move_from},
   {"rename to ",        state_move_from_seen,   git_move_to},
 
   {"copy from ",        state_git_diff_seen,    git_copy_from},
+  {"copy from ",        state_git_mode_seen,    git_copy_from},
   {"copy to ",          state_copy_from_seen,   git_copy_to},
 
   {"new file ",         state_git_diff_seen,    git_new_file},
@@ -2100,7 +2105,8 @@ svn_diff_parse_next_patch(svn_patch_t **
           /* We have a valid diff header, yay! */
           break;
         }
-      else if (state == state_git_tree_seen && line_after_tree_header_read
+      else if ((state == state_git_tree_seen || state == state_git_mode_seen)
+               && line_after_tree_header_read
                && !valid_header_line)
         {
           /* git patches can contain an index line after the file mode line */
@@ -2115,7 +2121,8 @@ svn_diff_parse_next_patch(svn_patch_t **
             break;
           }
         }
-      else if (state == state_git_tree_seen)
+      else if (state == state_git_tree_seen
+               || state == state_git_mode_seen)
         {
           line_after_tree_header_read = TRUE;
         }

Modified: 
subversion/branches/patch-exec/subversion/tests/libsvn_diff/parse-diff-test.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/patch-exec/subversion/tests/libsvn_diff/parse-diff-test.c?rev=1705390&r1=1705389&r2=1705390&view=diff
==============================================================================
--- 
subversion/branches/patch-exec/subversion/tests/libsvn_diff/parse-diff-test.c 
(original)
+++ 
subversion/branches/patch-exec/subversion/tests/libsvn_diff/parse-diff-test.c 
Sat Sep 26 00:29:20 2015
@@ -88,6 +88,8 @@ static const char *git_tree_and_text_uni
   "Index: iota.copied"                                                  NL
   "===================================================================" NL
   "diff --git a/iota b/iota.copied"                                     NL
+  "old mode 100644"                                                     NL
+  "new mode 100755"                                                     NL
   "copy from iota"                                                      NL
   "copy to iota.copied"                                                 NL
   "--- a/iota\t(revision 2)"                                            NL
@@ -98,6 +100,8 @@ static const char *git_tree_and_text_uni
   "Index: A/mu.moved"                                                   NL
   "===================================================================" NL
   "diff --git a/A/mu b/A/mu.moved"                                      NL
+  "old mode 100644"                                                     NL
+  "new mode 100755"                                                     NL
   "rename from A/mu"                                                    NL
   "rename to A/mu.moved"                                                NL
   "--- a/A/mu\t(revision 2)"                                            NL
@@ -531,6 +535,8 @@ test_parse_git_tree_and_text_diff(apr_po
   SVN_TEST_ASSERT(patch);
   SVN_TEST_STRING_ASSERT(patch->old_filename, "iota");
   SVN_TEST_STRING_ASSERT(patch->new_filename, "iota.copied");
+  SVN_TEST_ASSERT(patch->old_executable_p = svn_tristate_false);
+  SVN_TEST_ASSERT(patch->new_executable_p = svn_tristate_true);
   SVN_TEST_ASSERT(patch->operation == svn_diff_op_copied);
   SVN_TEST_ASSERT(patch->hunks->nelts == 1);
 
@@ -553,6 +559,8 @@ test_parse_git_tree_and_text_diff(apr_po
   SVN_TEST_ASSERT(patch);
   SVN_TEST_STRING_ASSERT(patch->old_filename, "A/mu");
   SVN_TEST_STRING_ASSERT(patch->new_filename, "A/mu.moved");
+  SVN_TEST_ASSERT(patch->old_executable_p = svn_tristate_false);
+  SVN_TEST_ASSERT(patch->new_executable_p = svn_tristate_true);
   SVN_TEST_ASSERT(patch->operation == svn_diff_op_moved);
   SVN_TEST_ASSERT(patch->hunks->nelts == 1);
 


Reply via email to