Hi! [[[ Add notifications for hunks applied with fuzz.
* subversion/tests/cmdline/patch_tests.py (patch_with_fuzz): Add a line to the target to cause one hunk to apply with offset and fuzz. With that we have all kinds of currently know patch notifications tested. * subversion/svn/notify.c (notify): Print a message for three different cases; fuzz, offset and both. * subversion/include/svn_wc.h (svn_wc_notify_t): Add a new field hunk_fuzz. * subversion/libsvn_client/patch.c (maybe_send_patch_notifications): Set the value of hunk_fuzz. Patch by: Daniel Näslund <daniel{_AT_}longitudo.com> ]]] There was one compiler warning about 'Format not a string literal' in notify.c. Now there are two. I could have concatenated the two svn_cmdline_printf() statements causing the warnings into one but not without severely hurting readability. Perhaps someone else has a solution. -Wno-literal perhaps? :-). Daniel
Index: subversion/tests/cmdline/patch_tests.py =================================================================== --- subversion/tests/cmdline/patch_tests.py (revision 905737) +++ subversion/tests/cmdline/patch_tests.py (arbetskopia) @@ -1059,6 +1059,7 @@ " SERIAL NUMBER: 45327\n", "and PROMOTION DATE: 13th June. 2009\n", "\n", + "This line is inserted to cause an offset of +1\n", "To claim your winning prize, you are to contact the appointed\n", "agent below as soon as possible for the immediate release of your\n", "winnings with the below details.\n", @@ -1131,6 +1132,7 @@ " SERIAL NUMBER: 45327\n", "and PROMOTION DATE: 13th June. 2009\n", "\n", + "This line is inserted to cause an offset of +1\n", "To claim your winning prize, you are to contact the appointed\n", "agent below as soon as possible for the immediate release of your\n", "winnings with the below details.\n", @@ -1142,6 +1144,9 @@ expected_output = [ 'U %s\n' % os.path.join(wc_dir, 'A', 'mu'), + '> applied hunk @@ -1,6 +1,7 @@ with fuzz 1\n', + '> applied hunk @@ -7,6 +8,7 @@ with fuzz 2\n', + '> applied hunk @@ -19,6 +20,7 @@ with offset 1 and fuzz 2\n', ] expected_disk = svntest.main.greek_state.copy() expected_disk.tweak('A/mu', contents=''.join(mu_contents)) Index: subversion/svn/notify.c =================================================================== --- subversion/svn/notify.c (revision 905737) +++ subversion/svn/notify.c (arbetskopia) @@ -327,18 +327,50 @@ } /* ### APR_INT64_T_FMT isn't translator-friendly */ - s = _("> applied hunk @@ -%lu,%lu +%lu,%lu @@ " - "with offset %s"); - if ((err = svn_cmdline_printf(pool, - apr_pstrcat(pool, s, - "%"APR_UINT64_T_FMT"\n", - NULL), + if (n->hunk_fuzz) + { + s = _("> applied hunk @@ -%lu,%lu +%lu,%lu @@ " + "with offset %s"); + if ((err = svn_cmdline_printf(pool, + apr_pstrcat(pool, s, + "%"APR_UINT64_T_FMT + " and fuzz %lu\n", + NULL), + n->hunk_original_start, + n->hunk_original_length, + n->hunk_modified_start, + n->hunk_modified_length, + minus, off, n->hunk_fuzz))) + goto print_error; + } + else + { + s = _("> applied hunk @@ -%lu,%lu +%lu,%lu @@ " + "with offset %s"); + if ((err = svn_cmdline_printf(pool, + apr_pstrcat(pool, s, + "%"APR_UINT64_T_FMT"\n", + NULL), + n->hunk_original_start, + n->hunk_original_length, + n->hunk_modified_start, + n->hunk_modified_length, + minus, off))) + goto print_error; + } + } + else if (n->hunk_fuzz) + { + if ((err = svn_cmdline_printf(pool, + _("> applied hunk @@ -%lu,%lu +%lu,%lu @@ " + "with fuzz %lu\n"), n->hunk_original_start, n->hunk_original_length, n->hunk_modified_start, n->hunk_modified_length, - minus, off))) + n->hunk_fuzz))) goto print_error; + } break; Index: subversion/include/svn_wc.h =================================================================== --- subversion/include/svn_wc.h (revision 905737) +++ subversion/include/svn_wc.h (arbetskopia) @@ -1248,6 +1248,10 @@ * @since New in 1.7. */ svn_linenum_t hunk_matched_line; + /* The fuzz factor the hunk is applied with. + * @since New in 1.7 */ + svn_linenum_t hunk_fuzz; + /* NOTE: Add new fields at the end to preserve binary compatibility. Also, if you add fields here, you have to update svn_wc_create_notify and svn_wc_dup_notify. */ Index: subversion/libsvn_client/patch.c =================================================================== --- subversion/libsvn_client/patch.c (revision 905737) +++ subversion/libsvn_client/patch.c (arbetskopia) @@ -1018,6 +1018,7 @@ notify->hunk_modified_start = hi->hunk->modified_start; notify->hunk_modified_length = hi->hunk->modified_length; notify->hunk_matched_line = hi->matched_line; + notify->hunk_fuzz = hi->fuzz; (*ctx->notify_func2)(ctx->notify_baton2, notify, pool); }