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 2016/10/11 09:11:54 UTC

svn commit: r1764214 [11/21] - in /subversion/branches/ra-git: ./ build/ build/ac-macros/ build/generator/ build/win32/ contrib/client-side/ contrib/client-side/svnmerge/ contrib/hook-scripts/ contrib/server-side/ contrib/server-side/fsfsfixer/fixer/ c...

Modified: subversion/branches/ra-git/subversion/libsvn_subr/utf_validate.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/utf_validate.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/utf_validate.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/utf_validate.c Tue Oct 11 09:11:50 2016
@@ -258,24 +258,7 @@ static const char machine [9][14] = {
 static const char *
 first_non_fsm_start_char(const char *data, apr_size_t max_len)
 {
-#if !SVN_UNALIGNED_ACCESS_IS_OK
-
-  /* On some systems, we need to make sure that buf is properly aligned
-   * for chunky data access.
-   */
-  if ((apr_uintptr_t)data & (sizeof(apr_uintptr_t)-1))
-    {
-      apr_size_t len = (~(apr_uintptr_t)data) & (sizeof(apr_uintptr_t)-1);
-      if (len > max_len)
-        len = max_len;
-      max_len -= len;
-
-      for (; len > 0; ++data, --len)
-        if ((unsigned char)*data >= 0x80)
-          return data;
-    }
-
-#endif
+#if SVN_UNALIGNED_ACCESS_IS_OK
 
   /* Scan the input one machine word at a time. */
   for (; max_len > sizeof(apr_uintptr_t)
@@ -283,55 +266,11 @@ first_non_fsm_start_char(const char *dat
     if (*(const apr_uintptr_t *)data & SVN__BIT_7_SET)
       break;
 
-  /* The remaining odd bytes will be examined the naive way: */
-  for (; max_len > 0; ++data, --max_len)
-    if ((unsigned char)*data >= 0x80)
-      break;
-
-  return data;
-}
-
-/* Scan the C string in *DATA for chars that are not in the octet
- * category 0 (FSM_START).  Return the position of either the such
- * char or of the terminating NUL.
- */
-static const char *
-first_non_fsm_start_char_cstring(const char *data)
-{
-  /* We need to make sure that BUF is properly aligned for chunky data
-   * access because we don't know the string's length. Unaligned chunk
-   * read access beyond the NUL terminator could therefore result in a
-   * segfault.
-   */
-  for (; (apr_uintptr_t)data & (sizeof(apr_uintptr_t)-1); ++data)
-    if (*data == 0 || (unsigned char)*data >= 0x80)
-      return data;
-
-  /* Scan the input one machine word at a time. */
-#ifndef SVN_UTF_NO_UNINITIALISED_ACCESS
-  /* This may read allocated but uninitialised bytes beyond the
-     terminating null.  Any such bytes are always readable and this
-     code operates correctly whatever the uninitialised values happen
-     to be.  However memory checking tools such as valgrind and GCC
-     4.8's address santitizer will object so this bit of code can be
-     disabled at compile time. */
-  for (; ; data += sizeof(apr_uintptr_t))
-    {
-      /* Check for non-ASCII chars: */
-      apr_uintptr_t chunk = *(const apr_uintptr_t *)data;
-      if (chunk & SVN__BIT_7_SET)
-        break;
-
-      /* This is the well-known strlen test: */
-      chunk |= (chunk & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
-      if ((chunk & SVN__BIT_7_SET) != SVN__BIT_7_SET)
-        break;
-    }
 #endif
 
   /* The remaining odd bytes will be examined the naive way: */
-  for (; ; ++data)
-    if (*data == 0 || (unsigned char)*data >= 0x80)
+  for (; max_len > 0; ++data, --max_len)
+    if ((unsigned char)*data >= 0x80)
       break;
 
   return data;
@@ -359,20 +298,10 @@ svn_utf__last_valid(const char *data, ap
 svn_boolean_t
 svn_utf__cstring_is_valid(const char *data)
 {
-  int state = FSM_START;
-
   if (!data)
     return FALSE;
 
-  data = first_non_fsm_start_char_cstring(data);
-
-  while (*data)
-    {
-      unsigned char octet = *data++;
-      int category = octet_category[octet];
-      state = machine[state][category];
-    }
-  return state == FSM_START;
+  return svn_utf__is_valid(data, strlen(data));
 }
 
 svn_boolean_t

Modified: subversion/branches/ra-git/subversion/libsvn_subr/version.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/version.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/version.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/version.c Tue Oct 11 09:11:50 2016
@@ -143,7 +143,7 @@ svn_version_extended(svn_boolean_t verbo
   info->build_time = __TIME__;
   info->build_host = SVN_BUILD_HOST;
   info->copyright = apr_pstrdup
-    (pool, _("Copyright (C) 2015 The Apache Software Foundation.\n"
+    (pool, _("Copyright (C) 2016 The Apache Software Foundation.\n"
              "This software consists of contributions made by many people;\n"
              "see the NOTICE file for more information.\n"
              "Subversion is open source software, see "

Modified: subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt.c Tue Oct 11 09:11:50 2016
@@ -43,7 +43,7 @@ typedef int win32_crashrpt__dummy;
 #include "win32_crashrpt_dll.h"
 
 /*** Global variables ***/
-HANDLE dbghelp_dll = INVALID_HANDLE_VALUE;
+static HANDLE dbghelp_dll = INVALID_HANDLE_VALUE;
 
 /* Email address where the crash reports should be sent too. */
 #define CRASHREPORT_EMAIL "users@subversion.apache.org"
@@ -84,32 +84,33 @@ convert_wbcs_to_ansi(const wchar_t *str)
 static const char *
 exception_string(int exception)
 {
-#define EXCEPTION(x) case EXCEPTION_##x: return (#x);
+#define EXCEPTION(x) case x: return (#x);
 
   switch (exception)
     {
-      EXCEPTION(ACCESS_VIOLATION)
-      EXCEPTION(DATATYPE_MISALIGNMENT)
-      EXCEPTION(BREAKPOINT)
-      EXCEPTION(SINGLE_STEP)
-      EXCEPTION(ARRAY_BOUNDS_EXCEEDED)
-      EXCEPTION(FLT_DENORMAL_OPERAND)
-      EXCEPTION(FLT_DIVIDE_BY_ZERO)
-      EXCEPTION(FLT_INEXACT_RESULT)
-      EXCEPTION(FLT_INVALID_OPERATION)
-      EXCEPTION(FLT_OVERFLOW)
-      EXCEPTION(FLT_STACK_CHECK)
-      EXCEPTION(FLT_UNDERFLOW)
-      EXCEPTION(INT_DIVIDE_BY_ZERO)
-      EXCEPTION(INT_OVERFLOW)
-      EXCEPTION(PRIV_INSTRUCTION)
-      EXCEPTION(IN_PAGE_ERROR)
-      EXCEPTION(ILLEGAL_INSTRUCTION)
-      EXCEPTION(NONCONTINUABLE_EXCEPTION)
-      EXCEPTION(STACK_OVERFLOW)
-      EXCEPTION(INVALID_DISPOSITION)
-      EXCEPTION(GUARD_PAGE)
-      EXCEPTION(INVALID_HANDLE)
+      EXCEPTION(EXCEPTION_ACCESS_VIOLATION)
+      EXCEPTION(EXCEPTION_DATATYPE_MISALIGNMENT)
+      EXCEPTION(EXCEPTION_BREAKPOINT)
+      EXCEPTION(EXCEPTION_SINGLE_STEP)
+      EXCEPTION(EXCEPTION_ARRAY_BOUNDS_EXCEEDED)
+      EXCEPTION(EXCEPTION_FLT_DENORMAL_OPERAND)
+      EXCEPTION(EXCEPTION_FLT_DIVIDE_BY_ZERO)
+      EXCEPTION(EXCEPTION_FLT_INEXACT_RESULT)
+      EXCEPTION(EXCEPTION_FLT_INVALID_OPERATION)
+      EXCEPTION(EXCEPTION_FLT_OVERFLOW)
+      EXCEPTION(EXCEPTION_FLT_STACK_CHECK)
+      EXCEPTION(EXCEPTION_FLT_UNDERFLOW)
+      EXCEPTION(EXCEPTION_INT_DIVIDE_BY_ZERO)
+      EXCEPTION(EXCEPTION_INT_OVERFLOW)
+      EXCEPTION(EXCEPTION_PRIV_INSTRUCTION)
+      EXCEPTION(EXCEPTION_IN_PAGE_ERROR)
+      EXCEPTION(EXCEPTION_ILLEGAL_INSTRUCTION)
+      EXCEPTION(EXCEPTION_NONCONTINUABLE_EXCEPTION)
+      EXCEPTION(EXCEPTION_STACK_OVERFLOW)
+      EXCEPTION(EXCEPTION_INVALID_DISPOSITION)
+      EXCEPTION(EXCEPTION_GUARD_PAGE)
+      EXCEPTION(EXCEPTION_INVALID_HANDLE)
+      EXCEPTION(STATUS_NO_MEMORY)
 
       default:
         return "UNKNOWN_ERROR";
@@ -171,7 +172,7 @@ write_module_info_callback(void *data,
       MINIDUMP_MODULE_CALLBACK module = callback_input->Module;
 
       char *buf = convert_wbcs_to_ansi(module.FullPath);
-      fprintf(log_file, FORMAT_PTR, (INT_PTR)module.BaseOfImage);
+      fprintf(log_file, FORMAT_PTR, (UINT_PTR)module.BaseOfImage);
       fprintf(log_file, "  %s", buf);
       free(buf);
 
@@ -260,18 +261,19 @@ write_process_info(EXCEPTION_RECORD *exc
 #endif
 }
 
-/* Formats the value at address based on the specified basic type
- * (char, int, long ...). */
+/* Writes the value at address based on the specified basic type
+ * (char, int, long ...) to LOG_FILE. */
 static void
-format_basic_type(char *buf, DWORD basic_type, DWORD64 length, void *address)
+write_basic_type(FILE *log_file, DWORD basic_type, DWORD64 length,
+                 void *address)
 {
   switch(length)
     {
       case 1:
-        sprintf(buf, "0x%02x", (int)*(unsigned char *)address);
+        fprintf(log_file, "0x%02x", (int)*(unsigned char *)address);
         break;
       case 2:
-        sprintf(buf, "0x%04x", (int)*(unsigned short *)address);
+        fprintf(log_file, "0x%04x", (int)*(unsigned short *)address);
         break;
       case 4:
         switch(basic_type)
@@ -279,38 +281,38 @@ format_basic_type(char *buf, DWORD basic
             case 2:  /* btChar */
               {
                 if (!IsBadStringPtr(*(PSTR*)address, 32))
-                  sprintf(buf, "\"%.31s\"", *(const char **)address);
+                  fprintf(log_file, "\"%.31s\"", *(const char **)address);
                 else
-                  sprintf(buf, FORMAT_PTR, *(DWORD_PTR *)address);
+                  fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)address);
               }
             case 6:  /* btInt */
-              sprintf(buf, "%d", *(int *)address);
+              fprintf(log_file, "%d", *(int *)address);
               break;
             case 8:  /* btFloat */
-              sprintf(buf, "%f", *(float *)address);
+              fprintf(log_file, "%f", *(float *)address);
               break;
             default:
-              sprintf(buf, FORMAT_PTR, *(DWORD_PTR *)address);
+              fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)address);
               break;
           }
         break;
       case 8:
         if (basic_type == 8) /* btFloat */
-          sprintf(buf, "%lf", *(double *)address);
+          fprintf(log_file, "%lf", *(double *)address);
         else
-          sprintf(buf, "0x%016I64X", *(unsigned __int64 *)address);
+          fprintf(log_file, "0x%016I64X", *(unsigned __int64 *)address);
         break;
       default:
-        sprintf(buf, "[unhandled type 0x%08x of length " FORMAT_PTR "]",
-                     basic_type, (INT_PTR)length);
+        fprintf(log_file, "[unhandled type 0x%08x of length " FORMAT_PTR "]",
+                basic_type, (UINT_PTR)length);
         break;
     }
 }
 
-/* Formats the value at address based on the type (pointer, user defined,
- * basic type). */
+/* Writes the value at address based on the type (pointer, user defined,
+ * basic type) to LOG_FILE. */
 static void
-format_value(char *value_str, DWORD64 mod_base, DWORD type, void *value_addr)
+write_value(FILE *log_file, DWORD64 mod_base, DWORD type, void *value_addr)
 {
   DWORD tag = 0;
   int ptr = 0;
@@ -340,19 +342,19 @@ format_value(char *value_str, DWORD64 mo
               LocalFree(type_name_wbcs);
 
               if (ptr == 0)
-                sprintf(value_str, "(%s) " FORMAT_PTR,
-                        type_name, (INT_PTR)(DWORD_PTR *)value_addr);
+                fprintf(log_file, "(%s) " FORMAT_PTR,
+                        type_name, (UINT_PTR)(DWORD_PTR *)value_addr);
               else if (ptr == 1)
-                sprintf(value_str, "(%s *) " FORMAT_PTR,
+                fprintf(log_file, "(%s *) " FORMAT_PTR,
                         type_name, *(DWORD_PTR *)value_addr);
               else
-                sprintf(value_str, "(%s **) " FORMAT_PTR,
+                fprintf(log_file, "(%s **) " FORMAT_PTR,
                         type_name, *(DWORD_PTR *)value_addr);
 
               free(type_name);
             }
           else
-            sprintf(value_str, "[no symbol tag]");
+            fprintf(log_file, "[no symbol tag]");
         }
         break;
       case 16: /* SymTagBaseType */
@@ -364,27 +366,27 @@ format_value(char *value_str, DWORD64 mo
           /* print a char * as a string */
           if (ptr == 1 && length == 1)
             {
-              sprintf(value_str, FORMAT_PTR " \"%s\"",
+              fprintf(log_file, FORMAT_PTR " \"%s\"",
                       *(DWORD_PTR *)value_addr, *(const char **)value_addr);
             }
           else if (ptr >= 1)
             {
-              sprintf(value_str, FORMAT_PTR, *(DWORD_PTR *)value_addr);
+              fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)value_addr);
             }
           else if (SymGetTypeInfo_(proc, mod_base, type, TI_GET_BASETYPE, &bt))
             {
-              format_basic_type(value_str, bt, length, value_addr);
+              write_basic_type(log_file, bt, length, value_addr);
             }
         }
         break;
       case 12: /* SymTagEnum */
-          sprintf(value_str, "%d", *(DWORD_PTR *)value_addr);
+          fprintf(log_file, "%d", *(DWORD_PTR *)value_addr);
           break;
       case 13: /* SymTagFunctionType */
-          sprintf(value_str, FORMAT_PTR, *(DWORD_PTR *)value_addr);
+          fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)value_addr);
           break;
       default:
-          sprintf(value_str, "[unhandled tag: %d]", tag);
+          fprintf(log_file, "[unhandled tag: %d]", tag);
           break;
     }
 }
@@ -408,7 +410,6 @@ write_var_values(PSYMBOL_INFO sym_info,
   FILE *log_file   = ((symbols_baton_t*)baton)->log_file;
   int nr_of_frame = ((symbols_baton_t*)baton)->nr_of_frame;
   BOOL log_params = ((symbols_baton_t*)baton)->log_params;
-  char value_str[256] = "";
 
   /* get the variable's data */
   if (sym_info->Flags & SYMFLAG_REGREL)
@@ -426,17 +427,17 @@ write_var_values(PSYMBOL_INFO sym_info,
       else
         last_nr_of_frame = nr_of_frame;
 
-      format_value(value_str, sym_info->ModBase, sym_info->TypeIndex,
-                   (void *)var_data);
-      fprintf(log_file, "%.*s=%s", (int)sym_info->NameLen, sym_info->Name,
-              value_str);
+      fprintf(log_file, "%.*s=", (int)sym_info->NameLen, sym_info->Name);
+      write_value(log_file, sym_info->ModBase, sym_info->TypeIndex,
+                  (void *)var_data);
     }
   if (!log_params && sym_info->Flags & SYMFLAG_LOCAL)
     {
-      format_value(value_str, sym_info->ModBase, sym_info->TypeIndex,
-                   (void *)var_data);
-      fprintf(log_file, "        %.*s = %s\n", (int)sym_info->NameLen,
-              sym_info->Name, value_str);
+      fprintf(log_file, "        %.*s = ", (int)sym_info->NameLen,
+              sym_info->Name);
+      write_value(log_file, sym_info->ModBase, sym_info->TypeIndex,
+                  (void *)var_data);
+      fprintf(log_file, "\n");
     }
 
   return TRUE;
@@ -598,20 +599,7 @@ write_stacktrace(CONTEXT *context, FILE
 static BOOL
 is_debugger_present()
 {
-  HANDLE kernel32_dll = LoadLibrary("kernel32.dll");
-  BOOL result;
-
-  ISDEBUGGERPRESENT IsDebuggerPresent_ =
-          (ISDEBUGGERPRESENT)GetProcAddress(kernel32_dll, "IsDebuggerPresent");
-
-  if (IsDebuggerPresent_ && IsDebuggerPresent_())
-    result = TRUE;
-  else
-    result = FALSE;
-
-  FreeLibrary(kernel32_dll);
-
-  return result;
+  return IsDebuggerPresent();
 }
 
 /* Load the dbghelp.dll file, try to find a version that matches our
@@ -620,7 +608,7 @@ static BOOL
 load_dbghelp_dll()
 {
   dbghelp_dll = LoadLibrary(DBGHELP_DLL);
-  if (dbghelp_dll != INVALID_HANDLE_VALUE)
+  if (dbghelp_dll != NULL)
     {
       DWORD opts;
 

Modified: subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt_dll.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt_dll.h?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt_dll.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/win32_crashrpt_dll.h Tue Oct 11 09:11:50 2016
@@ -69,9 +69,6 @@ typedef PVOID (WINAPI * SYMFUNCTIONTABLE
 
 typedef DWORD64 (WINAPI * SYMGETMODULEBASE64)(HANDLE hProcess, DWORD64 dwAddr);
 
-/* public functions in kernel32.dll */
-typedef BOOL  (WINAPI * ISDEBUGGERPRESENT)(VOID);
-
 /* function pointers */
 MINIDUMPWRITEDUMP        MiniDumpWriteDump_;
 SYMINITIALIZE            SymInitialize_;

Modified: subversion/branches/ra-git/subversion/libsvn_subr/x509info.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/x509info.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/x509info.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/x509info.c Tue Oct 11 09:11:50 2016
@@ -311,7 +311,7 @@ svn_x509_certinfo_get_valid_from(const s
   return certinfo->valid_from;
 }
 
-const apr_time_t
+apr_time_t
 svn_x509_certinfo_get_valid_to(const svn_x509_certinfo_t *certinfo)
 {
   return certinfo->valid_to;

Modified: subversion/branches/ra-git/subversion/libsvn_wc/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/conflicts.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/conflicts.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/conflicts.c Tue Oct 11 09:11:50 2016
@@ -50,6 +50,7 @@
 
 #include "private/svn_wc_private.h"
 #include "private/svn_skel.h"
+#include "private/svn_sorts_private.h"
 #include "private/svn_string_private.h"
 
 #include "svn_private_config.h"
@@ -1622,7 +1623,14 @@ build_text_conflict_resolve_items(svn_sk
         }
       case svn_wc_conflict_choose_mine_full:
         {
-          install_from_abspath = mine_abspath;
+          /* In case of selecting to resolve the conflict choosing the full
+             own file, allow the text conflict resolution to just take the
+             existing local file if no merged file was present (case: binary
+             file conflicts do not generate a locally merge file).
+          */
+          install_from_abspath = mine_abspath
+                                   ? mine_abspath
+                                   : local_abspath;
           break;
         }
       case svn_wc_conflict_choose_theirs_conflict:
@@ -1633,6 +1641,15 @@ build_text_conflict_resolve_items(svn_sk
                 ? svn_diff_conflict_display_latest
                 : svn_diff_conflict_display_modified;
 
+          if (mine_abspath == NULL)
+            return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                                     _("Conflict on '%s' cannot be resolved to "
+                                       "'theirs-conflict' or 'mine-conflict' "
+                                       "because a merged version of the file "
+                                       "cannot be created."),
+                                     svn_dirent_local_style(local_abspath,
+                                                            scratch_pool));
+
           SVN_ERR(merge_showing_conflicts(&install_from_abspath,
                                           db, local_abspath,
                                           style, merge_options,
@@ -2693,8 +2710,9 @@ resolve_tree_conflict_on_node(svn_boolea
             {
               svn_skel_t *new_conflicts;
 
-              /* Raise moved-away conflicts on any children moved out of
-               * this directory, and leave this directory as-is.
+              /* Raise local moved-away vs. incoming edit conflicts on
+               * any children moved out of this directory, and leave
+               * this directory as-is.
                *
                * The newly conflicted moved-away children will be updated
                * if they are resolved with 'mine_conflict' as well. */
@@ -2723,7 +2741,7 @@ resolve_tree_conflict_on_node(svn_boolea
               if (!new_conflicts || !tree_conflicted)
                 {
                   /* TC is marked resolved by calling
-                     svn_wc__db_resolve_delete_raise_moved_away */
+                     svn_wc__db_op_raise_moved_away */
                   *did_resolve = TRUE;
                   return SVN_NO_ERROR;
                 }
@@ -2970,12 +2988,13 @@ conflict_status_walker(void *baton,
 {
   struct conflict_status_walker_baton *cswb = baton;
   svn_wc__db_t *db = cswb->db;
-
+  svn_wc_notify_action_t notify_action = svn_wc_notify_resolved;
   const apr_array_header_t *conflicts;
   apr_pool_t *iterpool;
   int i;
   svn_boolean_t resolved = FALSE;
   svn_skel_t *conflict;
+  const svn_wc_conflict_description2_t *cd;
 
   if (!status->conflicted)
     return SVN_NO_ERROR;
@@ -2990,7 +3009,6 @@ conflict_status_walker(void *baton,
 
   for (i = 0; i < conflicts->nelts; i++)
     {
-      const svn_wc_conflict_description2_t *cd;
       svn_boolean_t did_resolve;
       svn_wc_conflict_choice_t my_choice = cswb->conflict_choice;
       svn_wc_conflict_result_t *result = NULL;
@@ -3042,7 +3060,10 @@ conflict_status_walker(void *baton,
                                                   iterpool));
 
             if (did_resolve)
-              resolved = TRUE;
+              {
+                resolved = TRUE;
+                notify_action = svn_wc_notify_resolved_tree;
+              }
             break;
 
           case svn_wc_conflict_kind_text:
@@ -3066,6 +3087,8 @@ conflict_status_walker(void *baton,
             SVN_ERR(svn_wc__wq_run(db, local_abspath,
                                    cswb->cancel_func, cswb->cancel_baton,
                                    iterpool));
+            if (resolved)
+                notify_action = svn_wc_notify_resolved_text;
             break;
 
           case svn_wc_conflict_kind_property:
@@ -3086,7 +3109,10 @@ conflict_status_walker(void *baton,
                                                   iterpool));
 
             if (did_resolve)
-              resolved = TRUE;
+              {
+                resolved = TRUE;
+                notify_action = svn_wc_notify_resolved_prop;
+              }
             break;
 
           default:
@@ -3097,12 +3123,33 @@ conflict_status_walker(void *baton,
 
   /* Notify */
   if (cswb->notify_func && resolved)
-    cswb->notify_func(cswb->notify_baton,
-                      svn_wc_create_notify(local_abspath,
-                                           svn_wc_notify_resolved,
-                                           iterpool),
-                      iterpool);
+    {
+      svn_wc_notify_t *notify;
 
+      /* If our caller asked for all conflicts to be resolved,
+       * send a general 'resolved' notification. */
+      if (cswb->resolve_text && cswb->resolve_tree &&
+          (cswb->resolve_prop == NULL || cswb->resolve_prop[0] == '\0'))
+        notify_action = svn_wc_notify_resolved;
+
+      /* If we resolved a property conflict, but no specific property was
+       * requested by the caller, send a general 'resolved' notification. */
+      if (notify_action == svn_wc_notify_resolved_prop &&
+          (cswb->resolve_prop == NULL || cswb->resolve_prop[0] == '\0'))
+        notify_action = svn_wc_notify_resolved;
+
+      notify = svn_wc_create_notify(local_abspath, notify_action, iterpool);
+
+      /* Add the property name for property-specific notifications. */
+      if (notify_action == svn_wc_notify_resolved_prop)
+        {
+          notify->prop_name = cd->property_name;
+          SVN_ERR_ASSERT(strlen(notify->prop_name) > 0);
+        }
+
+      cswb->notify_func(cswb->notify_baton, notify, iterpool);
+
+    }
   if (resolved)
     cswb->resolved_one = TRUE;
 
@@ -3303,8 +3350,528 @@ svn_wc_create_conflict_result(svn_wc_con
   result->choice = choice;
   result->merged_file = apr_pstrdup(pool, merged_file);
   result->save_merged = FALSE;
+  result->merged_value = NULL;
 
   /* If we add more fields to svn_wc_conflict_result_t, add them here. */
 
   return result;
 }
+
+svn_error_t *
+svn_wc__conflict_text_mark_resolved(svn_wc_context_t *wc_ctx,
+                                    const char *local_abspath,
+                                    svn_wc_conflict_choice_t choice,
+                                    svn_cancel_func_t cancel_func,
+                                    void *cancel_baton,
+                                    svn_wc_notify_func2_t notify_func,
+                                    void *notify_baton,
+                                    apr_pool_t *scratch_pool)
+{
+  svn_skel_t *work_items;
+  svn_skel_t *conflict;
+  svn_boolean_t did_resolve;
+
+  SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL, NULL,
+                                   wc_ctx->db, local_abspath,
+                                   scratch_pool, scratch_pool));
+
+  if (!conflict)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(build_text_conflict_resolve_items(&work_items, &did_resolve,
+                                            wc_ctx->db, local_abspath,
+                                            conflict, choice,
+                                            NULL, FALSE, NULL,
+                                            cancel_func, cancel_baton,
+                                            scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_wc__db_op_mark_resolved(wc_ctx->db, local_abspath,
+                                      TRUE, FALSE, FALSE,
+                                      work_items, scratch_pool));
+
+  SVN_ERR(svn_wc__wq_run(wc_ctx->db, local_abspath,
+                         cancel_func, cancel_baton,
+                         scratch_pool));
+
+  if (did_resolve && notify_func)
+    notify_func(notify_baton,
+                svn_wc_create_notify(local_abspath,
+                                     svn_wc_notify_resolved_text,
+                                     scratch_pool),
+                scratch_pool);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__conflict_prop_mark_resolved(svn_wc_context_t *wc_ctx,
+                                    const char *local_abspath,
+                                    const char *propname,
+                                    svn_wc_conflict_choice_t choice,
+                                    const svn_string_t *merged_value,
+                                    svn_wc_notify_func2_t notify_func,
+                                    void *notify_baton,
+                                    apr_pool_t *scratch_pool)
+{
+  svn_boolean_t did_resolve;
+  svn_skel_t *conflicts;
+
+  SVN_ERR(svn_wc__db_read_conflict(&conflicts, NULL, NULL,
+                                   wc_ctx->db, local_abspath,
+                                   scratch_pool, scratch_pool));
+
+  if (!conflicts)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(resolve_prop_conflict_on_node(&did_resolve, wc_ctx->db,
+                                        local_abspath, conflicts,
+                                        propname, choice, NULL, merged_value,
+                                        NULL, NULL, scratch_pool));
+
+  if (did_resolve && notify_func)
+    {
+      svn_wc_notify_t *notify;
+
+      /* Send a general notification if no specific property was requested. */
+      if (propname == NULL || propname[0] == '\0')
+        {
+          notify = svn_wc_create_notify(local_abspath,
+                                        svn_wc_notify_resolved,
+                                        scratch_pool);
+        }
+      else
+        {
+          notify = svn_wc_create_notify(local_abspath,
+                                        svn_wc_notify_resolved_prop,
+                                        scratch_pool);
+          notify->prop_name = propname;
+        }
+
+      notify_func(notify_baton, notify, scratch_pool);
+    }
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__conflict_tree_update_break_moved_away(svn_wc_context_t *wc_ctx,
+                                              const char *local_abspath,
+                                              svn_cancel_func_t cancel_func,
+                                              void *cancel_baton,
+                                              svn_wc_notify_func2_t notify_func,
+                                              void *notify_baton,
+                                              apr_pool_t *scratch_pool)
+{
+  svn_wc_conflict_reason_t reason;
+  svn_wc_conflict_action_t action;
+  svn_wc_operation_t operation;
+  svn_boolean_t tree_conflicted;
+  const char *src_op_root_abspath;
+  const apr_array_header_t *conflicts;
+  svn_skel_t *conflict_skel;
+
+  SVN_ERR(svn_wc__read_conflicts(&conflicts, &conflict_skel,
+                                 wc_ctx->db, local_abspath,
+                                 FALSE, /* no tempfiles */
+                                 FALSE, /* only tree conflicts */
+                                 scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_wc__conflict_read_info(&operation, NULL, NULL, NULL,
+                                     &tree_conflicted, wc_ctx->db,
+                                     local_abspath, conflict_skel,
+                                     scratch_pool, scratch_pool));
+  if (!tree_conflicted)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(svn_wc__conflict_read_tree_conflict(&reason, &action,
+                                              &src_op_root_abspath,
+                                              wc_ctx->db, local_abspath,
+                                              conflict_skel,
+                                              scratch_pool, scratch_pool));
+
+  /* Make sure the expected conflict is recorded. */
+  if (operation != svn_wc_operation_update &&
+      operation != svn_wc_operation_switch)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict operation '%s' on '%s'"),
+                             svn_token__to_word(operation_map, operation),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (reason != svn_wc_conflict_reason_deleted &&
+      reason != svn_wc_conflict_reason_replaced &&
+      reason != svn_wc_conflict_reason_moved_away)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict reason '%s' on '%s'"),
+                             svn_token__to_word(reason_map, reason),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  /* Break moves for any children moved out of this directory,
+   * and leave this directory deleted. */
+  if (action != svn_wc_conflict_action_delete)
+    {
+      SVN_ERR(svn_wc__db_op_break_moved_away(
+                      wc_ctx->db, local_abspath, src_op_root_abspath, TRUE,
+                      notify_func, notify_baton, scratch_pool));
+      /* Conflict was marked resolved by db_op_break_moved_away() call .*/
+
+      if (notify_func)
+        notify_func(notify_baton,
+                    svn_wc_create_notify(local_abspath,
+                                         svn_wc_notify_resolved_tree,
+                                         scratch_pool),
+                    scratch_pool);
+      return SVN_NO_ERROR;
+    }
+  /* else # The move is/moves are already broken */
+
+  SVN_ERR(svn_wc__db_op_mark_resolved(wc_ctx->db, local_abspath,
+                                      FALSE, FALSE, TRUE,
+                                      NULL, scratch_pool));
+  SVN_ERR(svn_wc__wq_run(wc_ctx->db, local_abspath, cancel_func, cancel_baton,
+                         scratch_pool));
+
+  if (notify_func)
+    notify_func(notify_baton,
+                svn_wc_create_notify(local_abspath,
+                                     svn_wc_notify_resolved_tree,
+                                     scratch_pool),
+                scratch_pool);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__conflict_tree_update_raise_moved_away(svn_wc_context_t *wc_ctx,
+                                              const char *local_abspath,
+                                              svn_cancel_func_t cancel_func,
+                                              void *cancel_baton,
+                                              svn_wc_notify_func2_t notify_func,
+                                              void *notify_baton,
+                                              apr_pool_t *scratch_pool)
+{
+  svn_wc_conflict_reason_t reason;
+  svn_wc_conflict_action_t action;
+  svn_wc_operation_t operation;
+  svn_boolean_t tree_conflicted;
+  const apr_array_header_t *conflicts;
+  svn_skel_t *conflict_skel;
+
+  SVN_ERR(svn_wc__read_conflicts(&conflicts, &conflict_skel,
+                                 wc_ctx->db, local_abspath,
+                                 FALSE, /* no tempfiles */
+                                 FALSE, /* only tree conflicts */
+                                 scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_wc__conflict_read_info(&operation, NULL, NULL, NULL,
+                                     &tree_conflicted, wc_ctx->db,
+                                     local_abspath, conflict_skel,
+                                     scratch_pool, scratch_pool));
+  if (!tree_conflicted)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(svn_wc__conflict_read_tree_conflict(&reason, &action, NULL,
+                                              wc_ctx->db, local_abspath,
+                                              conflict_skel,
+                                              scratch_pool, scratch_pool));
+
+  /* Make sure the expected conflict is recorded. */
+  if (operation != svn_wc_operation_update &&
+      operation != svn_wc_operation_switch)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict operation '%s' on '%s'"),
+                             svn_token__to_word(operation_map, operation),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (reason != svn_wc_conflict_reason_deleted &&
+      reason != svn_wc_conflict_reason_replaced)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict reason '%s' on '%s'"),
+                             svn_token__to_word(reason_map, reason),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (action != svn_wc_conflict_action_edit)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict action '%s' on '%s'"),
+                             svn_token__to_word(action_map, action),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  /* Raise local moved-away vs. incoming edit conflicts on any children
+   * moved out of this directory, and leave this directory as-is.
+   * The user may choose to update newly conflicted moved-away children
+   * when resolving them. If this function raises an error, the conflict
+   * cannot be resolved yet because other conflicts or obstructions
+   * prevent us from propagating the conflict to moved-away children. */
+  SVN_ERR(svn_wc__db_op_raise_moved_away(wc_ctx->db, local_abspath,
+                                         notify_func, notify_baton,
+                                         scratch_pool));
+
+  /* The conflict was marked resolved by svn_wc__db_op_raise_moved_away(). */
+  if (notify_func)
+    notify_func(notify_baton,
+                svn_wc_create_notify(local_abspath,
+                                     svn_wc_notify_resolved_tree,
+                                     scratch_pool),
+                scratch_pool);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__conflict_tree_update_moved_away_node(svn_wc_context_t *wc_ctx,
+                                             const char *local_abspath,
+                                             svn_cancel_func_t cancel_func,
+                                             void *cancel_baton,
+                                             svn_wc_notify_func2_t notify_func,
+                                             void *notify_baton,
+                                             apr_pool_t *scratch_pool)
+{
+  svn_wc_conflict_reason_t reason;
+  svn_wc_conflict_action_t action;
+  svn_wc_operation_t operation;
+  svn_boolean_t tree_conflicted;
+  const char *src_op_root_abspath;
+  const apr_array_header_t *conflicts;
+  svn_skel_t *conflict_skel;
+
+  SVN_ERR(svn_wc__read_conflicts(&conflicts, &conflict_skel,
+                                 wc_ctx->db, local_abspath,
+                                 FALSE, /* no tempfiles */
+                                 FALSE, /* only tree conflicts */
+                                 scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_wc__conflict_read_info(&operation, NULL, NULL, NULL,
+                                     &tree_conflicted, wc_ctx->db,
+                                     local_abspath, conflict_skel,
+                                     scratch_pool, scratch_pool));
+  if (!tree_conflicted)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(svn_wc__conflict_read_tree_conflict(&reason, &action,
+                                              &src_op_root_abspath,
+                                              wc_ctx->db, local_abspath,
+                                              conflict_skel,
+                                              scratch_pool, scratch_pool));
+
+  /* Make sure the expected conflict is recorded. */
+  if (operation != svn_wc_operation_update &&
+      operation != svn_wc_operation_switch)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict operation '%s' on '%s'"),
+                             svn_token__to_word(operation_map, operation),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (reason != svn_wc_conflict_reason_moved_away)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict reason '%s' on '%s'"),
+                             svn_token__to_word(reason_map, reason),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (action != svn_wc_conflict_action_edit)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict action '%s' on '%s'"),
+                             svn_token__to_word(action_map, action),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  /* Update the moved-away conflict victim. */
+  SVN_ERR(svn_wc__db_update_moved_away_conflict_victim(wc_ctx->db,
+                                                       local_abspath,
+                                                       src_op_root_abspath,
+                                                       operation,
+                                                       action,
+                                                       reason,
+                                                       cancel_func,
+                                                       cancel_baton,
+                                                       notify_func,
+                                                       notify_baton,
+                                                       scratch_pool));
+
+  SVN_ERR(svn_wc__db_op_mark_resolved(wc_ctx->db, local_abspath,
+                                      FALSE, FALSE, TRUE,
+                                      NULL, scratch_pool));
+  SVN_ERR(svn_wc__wq_run(wc_ctx->db, local_abspath, cancel_func, cancel_baton,
+                         scratch_pool));
+
+  if (notify_func)
+    notify_func(notify_baton,
+                svn_wc_create_notify(local_abspath,
+                                     svn_wc_notify_resolved_tree,
+                                     scratch_pool),
+                scratch_pool);
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__conflict_tree_merge_local_changes(svn_wc_context_t *wc_ctx,
+                                          const char *local_abspath,
+                                          const char *dest_abspath,
+                                          svn_cancel_func_t cancel_func,
+                                          void *cancel_baton,
+                                          svn_wc_notify_func2_t notify_func,
+                                          void *notify_baton,
+                                          apr_pool_t *scratch_pool)
+{
+  svn_wc_conflict_reason_t local_change;
+  svn_wc_conflict_action_t incoming_change;
+  svn_wc_operation_t operation;
+  svn_boolean_t tree_conflicted;
+  const apr_array_header_t *conflicts;
+  svn_skel_t *conflict_skel;
+
+  SVN_ERR(svn_wc__read_conflicts(&conflicts, &conflict_skel,
+                                 wc_ctx->db, local_abspath,
+                                 FALSE, /* no tempfiles */
+                                 FALSE, /* only tree conflicts */
+                                 scratch_pool, scratch_pool));
+
+  SVN_ERR(svn_wc__conflict_read_info(&operation, NULL, NULL, NULL,
+                                     &tree_conflicted, wc_ctx->db,
+                                     local_abspath, conflict_skel,
+                                     scratch_pool, scratch_pool));
+  if (!tree_conflicted)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(svn_wc__conflict_read_tree_conflict(&local_change, &incoming_change,
+                                              NULL, wc_ctx->db, local_abspath,
+                                              conflict_skel,
+                                              scratch_pool, scratch_pool));
+
+  /* Make sure the expected conflict is recorded. */
+  if (operation != svn_wc_operation_update &&
+      operation != svn_wc_operation_switch &&
+      operation != svn_wc_operation_merge)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict operation '%s' on '%s'"),
+                             svn_token__to_word(operation_map, operation),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (local_change != svn_wc_conflict_reason_edited)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict reason '%s' on '%s'"),
+                             svn_token__to_word(reason_map, local_change),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+  if (incoming_change != svn_wc_conflict_action_delete)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                             _("Unexpected conflict action '%s' on '%s'"),
+                             svn_token__to_word(action_map, incoming_change),
+                             svn_dirent_local_style(local_abspath,
+                                                    scratch_pool));
+
+  /* Merge local changes. */
+  SVN_ERR(svn_wc__db_merge_local_changes(wc_ctx->db, local_abspath,
+                                         dest_abspath, operation,
+                                         incoming_change, local_change,
+                                         cancel_func, cancel_baton,
+                                         notify_func, notify_baton,
+                                         scratch_pool));
+
+  SVN_ERR(svn_wc__wq_run(wc_ctx->db, local_abspath, cancel_func, cancel_baton,
+                         scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_wc__guess_incoming_move_target_nodes(apr_array_header_t **possible_targets,
+                                         svn_wc_context_t *wc_ctx,
+                                         const char *victim_abspath,
+                                         svn_node_kind_t victim_node_kind,
+                                         const char *moved_to_repos_relpath,
+                                         svn_revnum_t rev,
+                                         apr_pool_t *result_pool,
+                                         apr_pool_t *scratch_pool)
+{
+  apr_array_header_t *candidates;
+  apr_pool_t *iterpool;
+  int i;
+  apr_size_t longest_ancestor_len = 0;
+
+  *possible_targets = apr_array_make(result_pool, 1, sizeof(const char *));
+  SVN_ERR(svn_wc__find_repos_node_in_wc(&candidates, wc_ctx->db, victim_abspath,
+                                        moved_to_repos_relpath, rev,
+                                        scratch_pool, scratch_pool));
+
+  /* Find a "useful move target" node in our set of candidates.
+   * Since there is no way to be certain, filter out nodes which seem
+   * unlikely candidates, and return the first node which is "good enough".
+   * Nodes which are tree conflict victims don't count, and nodes which
+   * cannot be modified (e.g. replaced or deleted nodes) don't count.
+   * Nodes which are of a different node kind don't count either.
+   * Ignore switched nodes as well, since that is an unlikely case during
+   * update/swtich/merge conflict resolution. And externals shouldn't even
+   * be on our candidate list in the first place.
+   * If multiple candidates match these criteria, choose the one which
+   * shares the longest common ancestor with the victim. */
+  iterpool = svn_pool_create(scratch_pool);
+  for (i = 0; i < candidates->nelts; i++)
+    {
+      const char *local_abspath;
+      const char *ancestor_abspath;
+      apr_size_t ancestor_len;
+      svn_boolean_t tree_conflicted;
+      svn_wc__db_status_t status;
+      svn_boolean_t is_wcroot;
+      svn_boolean_t is_switched;
+      svn_node_kind_t node_kind;
+      const char *moved_to_abspath;
+      int insert_index;
+
+      svn_pool_clear(iterpool);
+
+      local_abspath = APR_ARRAY_IDX(candidates, i, const char *);
+
+      SVN_ERR(svn_wc__internal_conflicted_p(NULL, NULL, &tree_conflicted,
+                                            wc_ctx->db, local_abspath,
+                                            iterpool));
+      if (tree_conflicted)
+        continue;
+
+      SVN_ERR(svn_wc__db_read_info(&status, &node_kind,
+                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL,
+                                   wc_ctx->db, local_abspath, iterpool,
+                                   iterpool));
+      if (status != svn_wc__db_status_normal &&
+          status != svn_wc__db_status_added)
+        continue;
+
+      if (node_kind != victim_node_kind)
+        continue;
+
+      SVN_ERR(svn_wc__db_is_switched(&is_wcroot, &is_switched, NULL,
+                                     wc_ctx->db, local_abspath, iterpool));
+      if (is_wcroot || is_switched)
+        continue;
+
+      /* This might be a move target. Fingers crossed ;-) */
+      moved_to_abspath = apr_pstrdup(result_pool, local_abspath);
+
+      /* Insert the move target into the list. Targets which are closer
+       * (path-wise) to the conflict victim are more likely to be a good
+       * match, so put them at the front of the list. */
+      ancestor_abspath = svn_dirent_get_longest_ancestor(local_abspath,
+                                                         victim_abspath,
+                                                         iterpool);
+      ancestor_len = strlen(ancestor_abspath);
+      if (ancestor_len >= longest_ancestor_len)
+        {
+          longest_ancestor_len = ancestor_len;
+          insert_index = 0; /* prepend */
+        }
+      else
+        {
+          insert_index = (*possible_targets)->nelts; /* append */
+        }
+      svn_sort__array_insert(*possible_targets, &moved_to_abspath,
+                             insert_index);
+    }
+
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/ra-git/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/copy.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/copy.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/copy.c Tue Oct 11 09:11:50 2016
@@ -791,10 +791,11 @@ copy_or_move(svn_boolean_t *record_move_
             break; /* OK to add */
 
           default:
-            return svn_error_createf(SVN_ERR_ENTRY_EXISTS, NULL,
-                               _("There is already a versioned item '%s'"),
-                               svn_dirent_local_style(dst_abspath,
-                                                      scratch_pool));
+            if (!metadata_only)
+              return svn_error_createf(SVN_ERR_ENTRY_EXISTS, NULL,
+                                 _("There is already a versioned item '%s'"),
+                                 svn_dirent_local_style(dst_abspath,
+                                                        scratch_pool));
         }
   }
 

Modified: subversion/branches/ra-git/subversion/libsvn_wc/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/deprecated.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/deprecated.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/deprecated.c Tue Oct 11 09:11:50 2016
@@ -2051,7 +2051,7 @@ svn_wc_get_diff_editor6(const svn_delta_
                             wc_ctx,
                             anchor_abspath, target,
                             depth,
-                            use_git_diff_format, use_text_base,
+                            ignore_ancestry, use_text_base,
                             reverse_order, server_performs_filtering,
                             changelist_filter,
                             diff_processor,

Modified: subversion/branches/ra-git/subversion/libsvn_wc/questions.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/questions.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/questions.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/questions.c Tue Oct 11 09:11:50 2016
@@ -79,15 +79,15 @@
 
 
 /* Set *MODIFIED_P to TRUE if (after translation) VERSIONED_FILE_ABSPATH
- * (of VERSIONED_FILE_SIZE bytes) differs from PRISTINE_STREAM (of
- * PRISTINE_SIZE bytes), else to FALSE if not.
+ * (of VERSIONED_FILE_SIZE bytes) differs from pristine file with checksum
+ * PRISTINE_CHECKSUM, else to FALSE if not.
  *
  * If EXACT_COMPARISON is FALSE, translate VERSIONED_FILE_ABSPATH's EOL
  * style and keywords to repository-normal form according to its properties,
- * and compare the result with PRISTINE_STREAM.  If EXACT_COMPARISON is
- * TRUE, translate PRISTINE_STREAM's EOL style and keywords to working-copy
- * form according to VERSIONED_FILE_ABSPATH's properties, and compare the
- * result with VERSIONED_FILE_ABSPATH.
+ * calculate checksum and compare the result with PRISTINE_STREAM.  If
+ * EXACT_COMPARISON is TRUE, open pristine, translate it's EOL style and
+ * keywords to working-copy form according to VERSIONED_FILE_ABSPATH's
+ * properties, and compare the result with VERSIONED_FILE_ABSPATH.
  *
  * HAS_PROPS should be TRUE if the file had properties when it was not
  * modified, otherwise FALSE.
@@ -95,8 +95,6 @@
  * PROPS_MOD should be TRUE if the file's properties have been changed,
  * otherwise FALSE.
  *
- * PRISTINE_STREAM will be closed before a successful return.
- *
  * DB is a wc_db; use SCRATCH_POOL for temporary allocation.
  */
 static svn_error_t *
@@ -104,20 +102,20 @@ compare_and_verify(svn_boolean_t *modifi
                    svn_wc__db_t *db,
                    const char *versioned_file_abspath,
                    svn_filesize_t versioned_file_size,
-                   svn_stream_t *pristine_stream,
-                   svn_filesize_t pristine_size,
+                   const svn_checksum_t *pristine_checksum,
                    svn_boolean_t has_props,
                    svn_boolean_t props_mod,
                    svn_boolean_t exact_comparison,
                    apr_pool_t *scratch_pool)
 {
-  svn_boolean_t same;
   svn_subst_eol_style_t eol_style;
   const char *eol_str;
   apr_hash_t *keywords;
   svn_boolean_t special = FALSE;
   svn_boolean_t need_translation;
   svn_stream_t *v_stream; /* versioned_file */
+  svn_checksum_t *v_checksum;
+  svn_error_t *err;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_file_abspath));
 
@@ -140,13 +138,20 @@ compare_and_verify(svn_boolean_t *modifi
   else
     need_translation = FALSE;
 
-  if (! need_translation
-      && (versioned_file_size != pristine_size))
+  if (! need_translation)
     {
-      *modified_p = TRUE;
+      svn_filesize_t pristine_size;
+
+      SVN_ERR(svn_wc__db_pristine_read(NULL, &pristine_size, db,
+                                       versioned_file_abspath, pristine_checksum,
+                                       scratch_pool, scratch_pool));
+
+      if (versioned_file_size != pristine_size)
+        {
+          *modified_p = TRUE;
 
-      /* ### Why did we open the pristine? */
-      return svn_error_trace(svn_stream_close(pristine_stream));
+          return SVN_NO_ERROR;
+        }
     }
 
   /* ### Other checks possible? */
@@ -162,8 +167,13 @@ compare_and_verify(svn_boolean_t *modifi
       /* We don't use APR-level buffering because the comparison function
        * will do its own buffering. */
       apr_file_t *file;
-      SVN_ERR(svn_io_file_open(&file, versioned_file_abspath, APR_READ,
-                               APR_OS_DEFAULT, scratch_pool));
+      err = svn_io_file_open(&file, versioned_file_abspath, APR_READ,
+                             APR_OS_DEFAULT, scratch_pool);
+      /* Convert EACCESS on working copy path to WC specific error code. */
+      if (err && APR_STATUS_IS_EACCES(err->apr_err))
+        return svn_error_create(SVN_ERR_WC_PATH_ACCESS_DENIED, err, NULL);
+      else
+        SVN_ERR(err);
       v_stream = svn_stream_from_aprfile2(file, FALSE, scratch_pool);
 
       if (need_translation)
@@ -188,20 +198,38 @@ compare_and_verify(svn_boolean_t *modifi
             }
           else
             {
+              svn_boolean_t same;
+              svn_stream_t *pristine_stream;
+
+              SVN_ERR(svn_wc__db_pristine_read(&pristine_stream, NULL,
+                                               db, versioned_file_abspath,
+                                               pristine_checksum,
+                                               scratch_pool, scratch_pool));
               /* Wrap base stream to translate into working copy form, and
                * arrange to throw an error if its EOL style is inconsistent. */
               pristine_stream = svn_subst_stream_translated(pristine_stream,
                                                             eol_str, FALSE,
                                                             keywords, TRUE,
                                                             scratch_pool);
+              SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
+                                                scratch_pool));
+              *modified_p = (! same);
+              return SVN_NO_ERROR;
             }
         }
     }
 
-  SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
-                                    scratch_pool));
+  /* Get checksum of detranslated (normalized) content. */
+  err = svn_stream_contents_checksum(&v_checksum, v_stream,
+                                     pristine_checksum->kind,
+                                     scratch_pool, scratch_pool);
+  /* Convert EACCESS on working copy path to WC specific error code. */
+  if (err && APR_STATUS_IS_EACCES(err->apr_err))
+    return svn_error_create(SVN_ERR_WC_PATH_ACCESS_DENIED, err, NULL);
+  else
+    SVN_ERR(err);
 
-  *modified_p = (! same);
+  *modified_p = (! svn_checksum_match(v_checksum, pristine_checksum));
 
   return SVN_NO_ERROR;
 }
@@ -213,8 +241,6 @@ svn_wc__internal_file_modified_p(svn_boo
                                  svn_boolean_t exact_comparison,
                                  apr_pool_t *scratch_pool)
 {
-  svn_stream_t *pristine_stream;
-  svn_filesize_t pristine_size;
   svn_wc__db_status_t status;
   svn_node_kind_t kind;
   const svn_checksum_t *checksum;
@@ -302,27 +328,12 @@ svn_wc__internal_file_modified_p(svn_boo
     }
 
  compare_them:
-  SVN_ERR(svn_wc__db_pristine_read(&pristine_stream, &pristine_size,
-                                   db, local_abspath, checksum,
-                                   scratch_pool, scratch_pool));
-
   /* Check all bytes, and verify checksum if requested. */
-  {
-    svn_error_t *err;
-    err = compare_and_verify(modified_p, db,
+  SVN_ERR(compare_and_verify(modified_p, db,
                              local_abspath, dirent->filesize,
-                             pristine_stream, pristine_size,
-                             has_props, props_mod,
+                             checksum, has_props, props_mod,
                              exact_comparison,
-                             scratch_pool);
-
-    /* At this point we already opened the pristine file, so we know that
-       the access denied applies to the working copy path */
-    if (err && APR_STATUS_IS_EACCES(err->apr_err))
-      return svn_error_create(SVN_ERR_WC_PATH_ACCESS_DENIED, err, NULL);
-    else
-      SVN_ERR(err);
-  }
+                             scratch_pool));
 
   if (!*modified_p)
     {

Modified: subversion/branches/ra-git/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/update_editor.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/update_editor.c Tue Oct 11 09:11:50 2016
@@ -2883,10 +2883,7 @@ absent_node(const char *path,
   if (pb->skip_this)
     return SVN_NO_ERROR;
 
-  SVN_ERR(mark_directory_edited(pb, scratch_pool));
-
   local_abspath = svn_dirent_join(pb->local_abspath, name, scratch_pool);
-
   /* If an item by this name is scheduled for addition that's a
      genuine tree-conflict.  */
   err = svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
@@ -2906,6 +2903,10 @@ absent_node(const char *path,
       kind = svn_node_unknown;
     }
 
+  if (status != svn_wc__db_status_server_excluded)
+    SVN_ERR(mark_directory_edited(pb, scratch_pool));
+  /* Else fall through as we should update the revision anyway */
+
   if (status == svn_wc__db_status_normal)
     {
       svn_boolean_t wcroot;
@@ -2929,31 +2930,53 @@ absent_node(const char *path,
         }
       else
         {
-          /* The server asks us to replace a file external
-             (Existing BASE node; not reported by the working copy crawler or
-              there would have been a delete_entry() call.
-
-             There is no way we can store this state in the working copy as
-             the BASE layer is already filled.
-
-             We could error out, but that is not helping anybody; the user is not
-             even seeing with what the file external would be replaced, so let's
-             report a skip and continue the update.
-           */
+          svn_boolean_t file_external;
+          svn_revnum_t revnum;
 
-          if (eb->notify_func)
+          SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, &revnum, NULL, NULL,
+                                           NULL, NULL, NULL, NULL, NULL, NULL,
+                                           NULL, NULL, NULL, NULL,
+                                           &file_external,
+                                           eb->db, local_abspath,
+                                           scratch_pool, scratch_pool));
+
+          if (file_external)
             {
-              svn_wc_notify_t *notify;
-              notify = svn_wc_create_notify(
+              /* The server asks us to replace a file external
+                 (Existing BASE node; not reported by the working copy crawler
+                  or there would have been a delete_entry() call.
+
+                 There is no way we can store this state in the working copy as
+                 the BASE layer is already filled.
+                 We could error out, but that is not helping anybody; the user is not
+                 even seeing with what the file external would be replaced, so let's
+                 report a skip and continue the update.
+               */
+
+              if (eb->notify_func)
+                {
+                  svn_wc_notify_t *notify;
+                  notify = svn_wc_create_notify(
                                     local_abspath,
                                     svn_wc_notify_update_skip_obstruction,
                                     scratch_pool);
 
-              eb->notify_func(eb->notify_baton, notify, scratch_pool);
+                  eb->notify_func(eb->notify_baton, notify, scratch_pool);
+                }
+
+              svn_pool_destroy(scratch_pool);
+              return SVN_NO_ERROR;
             }
+          else
+            {
+              /* We have a normal local node that will now be hidden for the
+                 user. Let's try to delete what is there. This may introduce
+                 tree conflicts if there are local changes */
+              SVN_ERR(delete_entry(path, revnum, pb, scratch_pool));
 
-          svn_pool_destroy(scratch_pool);
-          return SVN_NO_ERROR;
+              /* delete_entry() promises that BASE is empty after the operation,
+                 so we can just fall through now */
+            }
         }
     }
   else if (status == svn_wc__db_status_not_present

Modified: subversion/branches/ra-git/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/wc-queries.sql?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/wc-queries.sql Tue Oct 11 09:11:50 2016
@@ -1291,6 +1291,10 @@ PRAGMA locking_mode = exclusive;
    exclusive-locking is mostly used on remote file systems. */
 PRAGMA journal_mode = DELETE
 
+-- STMT_FIND_REPOS_PATH_IN_WC
+SELECT local_relpath FROM nodes_current
+  WHERE wc_id = ?1 AND repos_path = ?2 AND revision = ?3
+
 /* ------------------------------------------------------------------------- */
 
 /* these are used in entries.c  */

Modified: subversion/branches/ra-git/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/wc_db.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/wc_db.c Tue Oct 11 09:11:50 2016
@@ -10168,7 +10168,7 @@ db_read_repos_info(svn_revnum_t *revisio
                                                              local_relpath),
                                     result_pool);
             }
-          else
+          else if (base_del_relpath)
             {
               SVN_ERR(svn_wc__db_base_get_info_internal(NULL, NULL, revision,
                                                         repos_relpath,
@@ -10188,6 +10188,8 @@ db_read_repos_info(svn_revnum_t *revisio
                                                              local_relpath),
                                     result_pool);
             }
+          else
+            SVN_ERR_MALFUNCTION();
         }
       else if (status == svn_wc__db_status_excluded)
         {
@@ -16577,3 +16579,48 @@ svn_wc__db_process_commit_queue(svn_wc__
 
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_wc__find_repos_node_in_wc(apr_array_header_t **local_abspath_list,
+                              svn_wc__db_t *db,
+                              const char *wri_abspath,
+                              const char *repos_relpath,
+                              svn_revnum_t rev,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool)
+{
+  svn_wc__db_wcroot_t *wcroot;
+  const char *wri_relpath;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
+
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &wri_relpath, db,
+                                                 wri_abspath, scratch_pool,
+                                                 scratch_pool));
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_FIND_REPOS_PATH_IN_WC));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isr", wcroot->wc_id, repos_relpath, rev));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+
+  *local_abspath_list = apr_array_make(result_pool, have_row ? 1 : 0,
+                                       sizeof(const char*));
+  while (have_row)
+    {
+      const char *local_relpath;
+      const char *local_abspath;
+
+      local_relpath = svn_sqlite__column_text(stmt, 0, NULL);
+      local_abspath = svn_dirent_join(wcroot->abspath, local_relpath,
+                                      result_pool);
+      APR_ARRAY_PUSH(*local_abspath_list, const char *) = local_abspath;
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+    
+  return svn_error_trace(svn_sqlite__reset(stmt));
+}
+

Modified: subversion/branches/ra-git/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/wc_db.h?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/wc_db.h Tue Oct 11 09:11:50 2016
@@ -3404,6 +3404,22 @@ svn_wc__db_update_moved_away_conflict_vi
                                              void *notify_baton,
                                              apr_pool_t *scratch_pool);
 
+/* Merge local changes from tree conflict victim at LOCAL_ABSPATH into the
+   directory at DEST_ABSPATH. This function requires that LOCAL_ABSPATH is
+   a directory and a tree-conflict victim. DST_ABSPATH must be a directory. */
+svn_error_t *
+svn_wc__db_merge_local_changes(svn_wc__db_t *db,
+                               const char *local_abspath,
+                               const char *dest_abspath,
+                               svn_wc_operation_t operation,
+                               svn_wc_conflict_action_t action,
+                               svn_wc_conflict_reason_t reason,
+                               svn_cancel_func_t cancel_func,
+                               void *cancel_baton,
+                               svn_wc_notify_func2_t notify_func,
+                               void *notify_baton,
+                               apr_pool_t *scratch_pool);
+
 /* LOCAL_ABSPATH is moved to MOVE_DST_ABSPATH.  MOVE_SRC_ROOT_ABSPATH
  * is the root of the move to MOVE_DST_OP_ROOT_ABSPATH.
  * DELETE_ABSPATH is the op-root of the move; it's the same
@@ -3438,7 +3454,7 @@ svn_wc__db_op_raise_moved_away(svn_wc__d
                                apr_pool_t *scratch_pool);
 
 /* Breaks all moves of nodes that exist at or below LOCAL_ABSPATH as
-   shadowed (read: deleted) by the opration rooted at
+   shadowed (read: deleted) by the operation rooted at
    delete_op_root_abspath.
  */
 svn_error_t *
@@ -3459,6 +3475,24 @@ svn_wc__required_lock_for_resolve(const
                                   const char *local_abspath,
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool);
+
+/* Return an array of const char * elements, which represent local absolute
+ * paths for nodes, within the working copy indicated by WRI_ABSPATH, which
+ * correspond to REPOS_RELPATH@REV.
+ * If no such nodes exist, return an empty array.
+ *
+ * Note that this function returns each and every such node that is known
+ * in the WC, including, for example, nodes that were children of a directory
+ * which has been replaced.
+ */
+svn_error_t *
+svn_wc__find_repos_node_in_wc(apr_array_header_t **local_abspath_list,
+                              svn_wc__db_t *db,
+                              const char *wri_abspath,
+                              const char *repos_relpath,
+                              svn_revnum_t rev,
+                              apr_pool_t *result_pool,
+                              apr_pool_t *scratch_pool);
 /* @} */
 
 typedef svn_error_t * (*svn_wc__db_verify_cb_t)(void *baton,

Modified: subversion/branches/ra-git/subversion/libsvn_wc/wc_db_pristine.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_wc/wc_db_pristine.c?rev=1764214&r1=1764213&r2=1764214&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_wc/wc_db_pristine.c Tue Oct 11 09:11:50 2016
@@ -227,7 +227,6 @@ svn_wc__db_pristine_read(svn_stream_t **
   const char *local_relpath;
   const char *pristine_abspath;
 
-  SVN_ERR_ASSERT(contents != NULL);
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
 
   /* Some 1.6-to-1.7 wc upgrades created rows without checksums and
@@ -317,9 +316,10 @@ pristine_install_txn(svn_sqlite__db_t *s
           {
             return svn_error_createf(
               SVN_ERR_WC_CORRUPT_TEXT_BASE, NULL,
-              _("New pristine text '%s' has different size: %ld versus %ld"),
+              _("New pristine text '%s' has different size: %s versus %s"),
               svn_checksum_to_cstring_display(sha1_checksum, scratch_pool),
-              (long int)finfo1.size, (long int)finfo2.size);
+              apr_off_t_toa(scratch_pool, finfo1.size),
+              apr_off_t_toa(scratch_pool, finfo2.size));
           }
       }
 #endif