Deleted Added
full compact
patch.c (256281) patch.c (289166)
1/*
2 * patch.c: patch application support
3 *
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file

--- 2043 unchanged lines hidden (view full) ---

2052 }
2053 }
2054 svn_pool_destroy(iterpool);
2055 }
2056
2057 return SVN_NO_ERROR;
2058}
2059
1/*
2 * patch.c: patch application support
3 *
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file

--- 2043 unchanged lines hidden (view full) ---

2052 }
2053 }
2054 svn_pool_destroy(iterpool);
2055 }
2056
2057 return SVN_NO_ERROR;
2058}
2059
2060static void
2061svn_sort__array(apr_array_header_t *array,
2062 int (*comparison_func)(const void *,
2063 const void *))
2064{
2065 qsort(array->elts, array->nelts, array->elt_size, comparison_func);
2066}
2067
2068/* Implements the callback for svn_sort__array. Puts hunks that match
2069 before hunks that do not match, puts hunks that match in order
2070 based on postion matched, puts hunks that do not match in order
2071 based on original position. */
2072static int
2073sort_matched_hunks(const void *a, const void *b)
2074{
2075 const hunk_info_t *item1 = *((const hunk_info_t * const *)a);
2076 const hunk_info_t *item2 = *((const hunk_info_t * const *)b);
2077 svn_boolean_t matched1 = !item1->rejected && !item1->already_applied;
2078 svn_boolean_t matched2 = !item2->rejected && !item2->already_applied;
2079 svn_linenum_t original1, original2;
2080
2081 if (matched1 && matched2)
2082 {
2083 /* Both match so use order matched in file. */
2084 if (item1->matched_line > item2->matched_line)
2085 return 1;
2086 else if (item1->matched_line == item2->matched_line)
2087 return 0;
2088 else
2089 return -1;
2090 }
2091 else if (matched2)
2092 /* Only second matches, put it before first. */
2093 return 1;
2094 else if (matched1)
2095 /* Only first matches, put it before second. */
2096 return -1;
2097
2098 /* Neither matches, sort by original_start. */
2099 original1 = svn_diff_hunk_get_original_start(item1->hunk);
2100 original2 = svn_diff_hunk_get_original_start(item2->hunk);
2101 if (original1 > original2)
2102 return 1;
2103 else if (original1 == original2)
2104 return 0;
2105 else
2106 return -1;
2107}
2108
2109
2060/* Apply a PATCH to a working copy at ABS_WC_PATH and put the result
2061 * into temporary files, to be installed in the working copy later.
2062 * Return information about the patch target in *PATCH_TARGET, allocated
2063 * in RESULT_POOL. Use WC_CTX as the working copy context.
2064 * STRIP_COUNT specifies the number of leading path components
2065 * which should be stripped from target paths in the patch.
2066 * REMOVE_TEMPFILES, PATCH_FUNC, and PATCH_BATON as in svn_client_patch().
2067 * IGNORE_WHITESPACE tells whether whitespace should be considered when

--- 65 unchanged lines hidden (view full) ---

2133 result_pool, iterpool));
2134 fuzz++;
2135 }
2136 while (hi->rejected && fuzz <= MAX_FUZZ && ! hi->already_applied);
2137
2138 APR_ARRAY_PUSH(target->content->hunks, hunk_info_t *) = hi;
2139 }
2140
2110/* Apply a PATCH to a working copy at ABS_WC_PATH and put the result
2111 * into temporary files, to be installed in the working copy later.
2112 * Return information about the patch target in *PATCH_TARGET, allocated
2113 * in RESULT_POOL. Use WC_CTX as the working copy context.
2114 * STRIP_COUNT specifies the number of leading path components
2115 * which should be stripped from target paths in the patch.
2116 * REMOVE_TEMPFILES, PATCH_FUNC, and PATCH_BATON as in svn_client_patch().
2117 * IGNORE_WHITESPACE tells whether whitespace should be considered when

--- 65 unchanged lines hidden (view full) ---

2183 result_pool, iterpool));
2184 fuzz++;
2185 }
2186 while (hi->rejected && fuzz <= MAX_FUZZ && ! hi->already_applied);
2187
2188 APR_ARRAY_PUSH(target->content->hunks, hunk_info_t *) = hi;
2189 }
2190
2191 /* Hunks are applied in the order determined by the matched line and
2192 this may be different from the order of the original lines. */
2193 svn_sort__array(target->content->hunks, sort_matched_hunks);
2194
2141 /* Apply or reject hunks. */
2142 for (i = 0; i < target->content->hunks->nelts; i++)
2143 {
2144 hunk_info_t *hi;
2145
2146 svn_pool_clear(iterpool);
2147
2148 if (cancel_func)

--- 895 unchanged lines hidden ---
2195 /* Apply or reject hunks. */
2196 for (i = 0; i < target->content->hunks->nelts; i++)
2197 {
2198 hunk_info_t *hi;
2199
2200 svn_pool_clear(iterpool);
2201
2202 if (cancel_func)

--- 895 unchanged lines hidden ---