Lines Matching refs:hunk

58   /* The patch this hunk belongs to. */
61 /* APR file handle to the patch file this hunk came from. */
64 /* Ranges used to keep track of this hunk's texts positions within
77 /* Number of lines of leading and trailing hunk context. */
83 svn_diff_hunk_reset_diff_text(svn_diff_hunk_t *hunk)
85 hunk->diff_text_range.current = hunk->diff_text_range.start;
89 svn_diff_hunk_reset_original_text(svn_diff_hunk_t *hunk)
91 if (hunk->patch->reverse)
92 hunk->modified_text_range.current = hunk->modified_text_range.start;
94 hunk->original_text_range.current = hunk->original_text_range.start;
98 svn_diff_hunk_reset_modified_text(svn_diff_hunk_t *hunk)
100 if (hunk->patch->reverse)
101 hunk->original_text_range.current = hunk->original_text_range.start;
103 hunk->modified_text_range.current = hunk->modified_text_range.start;
107 svn_diff_hunk_get_original_start(const svn_diff_hunk_t *hunk)
109 return hunk->patch->reverse ? hunk->modified_start : hunk->original_start;
113 svn_diff_hunk_get_original_length(const svn_diff_hunk_t *hunk)
115 return hunk->patch->reverse ? hunk->modified_length : hunk->original_length;
119 svn_diff_hunk_get_modified_start(const svn_diff_hunk_t *hunk)
121 return hunk->patch->reverse ? hunk->original_start : hunk->modified_start;
125 svn_diff_hunk_get_modified_length(const svn_diff_hunk_t *hunk)
127 return hunk->patch->reverse ? hunk->original_length : hunk->modified_length;
131 svn_diff_hunk_get_leading_context(const svn_diff_hunk_t *hunk)
133 return hunk->leading_context;
137 svn_diff_hunk_get_trailing_context(const svn_diff_hunk_t *hunk)
139 return hunk->trailing_context;
163 /* Try to parse a hunk range specification from the string RANGE.
186 * number the hunk starts at. */
198 /* Try to parse the line number the hunk starts at. */
202 /* Try to parse a hunk header in string HEADER, putting parsed information
204 * character string used to delimit the hunk header.
207 parse_hunk_header(const char *header, svn_diff_hunk_t *hunk,
237 if (! parse_range(&hunk->original_start, &hunk->original_length, range->data))
267 if (! parse_range(&hunk->modified_start, &hunk->modified_length, range->data))
274 /* Read a line of original or modified hunk text from the specified
278 * VERBOTEN should be '+' or '-', depending on which form of hunk text
345 svn_diff_hunk_readline_original_text(svn_diff_hunk_t *hunk,
353 hunk_readline_original_or_modified(hunk->apr_file,
354 hunk->patch->reverse ?
355 &hunk->modified_text_range :
356 &hunk->original_text_range,
358 hunk->patch->reverse ? '-' : '+',
363 svn_diff_hunk_readline_modified_text(svn_diff_hunk_t *hunk,
371 hunk_readline_original_or_modified(hunk->apr_file,
372 hunk->patch->reverse ?
373 &hunk->original_text_range :
374 &hunk->modified_text_range,
376 hunk->patch->reverse ? '+' : '-',
381 svn_diff_hunk_readline_diff_text(svn_diff_hunk_t *hunk,
393 if (hunk->diff_text_range.current >= hunk->diff_text_range.end)
404 SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_CUR, &pos, scratch_pool));
405 SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_SET,
406 &hunk->diff_text_range.current, scratch_pool));
407 max_len = hunk->diff_text_range.end - hunk->diff_text_range.current;
408 SVN_ERR(svn_io_file_readline(hunk->apr_file, &line, eol, eof, max_len,
411 hunk->diff_text_range.current = 0;
412 SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_CUR,
413 &hunk->diff_text_range.current, scratch_pool));
414 SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_SET, &pos, scratch_pool));
416 if (hunk->patch->reverse)
420 /* Line is a hunk header, reverse it. */
423 hunk->modified_start,
424 hunk->modified_length,
425 hunk->original_start,
426 hunk->original_length);
430 /* Line is a hunk header, reverse it. */
433 hunk->modified_start,
434 hunk->modified_length,
435 hunk->original_start,
436 hunk->original_length);
475 * If no hunk can be found, set *HUNK to NULL.
476 * Set IS_PROPERTY to TRUE if we have a property hunk. If the returned HUNK
478 * PROP_OPERATION will be set too. If we have a text hunk, PROP_NAME will be
483 parse_next_hunk(svn_diff_hunk_t **hunk,
517 /* We only set this if we have a property hunk header. */
524 *hunk = NULL;
535 *hunk = apr_pcalloc(result_pool, sizeof(**hunk));
570 /* Comment terminates the hunk text and says the hunk text
572 * of the patch file but not part of the hunk text. */
611 /* We're reading the first line of the hunk, so the start
612 * of the line just read is the hunk text's byte offset. */
624 /* It's a "context" line in the hunk. */
636 /* It's a "deleted" line in the hunk. */
640 /* A hunk may have context in the middle. We only want
650 /* It's an "added" line in the hunk. */
654 /* A hunk may have context in the middle. We only want
666 /* The hunk ends at EOF. */
672 * after the hunk text. */
687 /* Looks like we have a hunk header, try to rip it apart. */
688 in_hunk = parse_hunk_header(line->data, *hunk, text_atat,
692 original_lines = (*hunk)->original_length;
693 modified_lines = (*hunk)->modified_length;
699 /* Looks like we have a property hunk header, try to rip it
701 in_hunk = parse_hunk_header(line->data, *hunk, prop_atat,
705 original_lines = (*hunk)->original_length;
706 modified_lines = (*hunk)->modified_length;
745 * up skipping the line -- it may contain a patch or hunk header. */
750 (*hunk)->patch = patch;
751 (*hunk)->apr_file = apr_file;
752 (*hunk)->leading_context = leading_context;
753 (*hunk)->trailing_context = trailing_context;
754 (*hunk)->diff_text_range.start = start;
755 (*hunk)->diff_text_range.current = start;
756 (*hunk)->diff_text_range.end = end;
757 (*hunk)->original_text_range.start = start;
758 (*hunk)->original_text_range.current = start;
759 (*hunk)->original_text_range.end = original_end;
760 (*hunk)->modified_text_range.start = start;
761 (*hunk)->modified_text_range.current = start;
762 (*hunk)->modified_text_range.end = modified_end;
766 *hunk = NULL;
1109 svn_diff_hunk_t *hunk, svn_diff_operation_kind_t operation,
1127 APR_ARRAY_PUSH(prop_patch->hunks, svn_diff_hunk_t *) = hunk;
1159 * Parsing stops if no valid next hunk can be found.
1169 svn_diff_hunk_t *hunk;
1185 SVN_ERR(parse_next_hunk(&hunk, &is_property, &prop_name, &prop_operation,
1189 if (hunk && is_property)
1195 SVN_ERR(add_property_hunk(patch, prop_name, hunk, prop_operation,
1198 else if (hunk)
1200 APR_ARRAY_PUSH(patch->hunks, svn_diff_hunk_t *) = hunk;
1205 while (hunk);