[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

multiple merge notifications

From: Ben Collins-Sussman <sussman_at_red-bean.com>
Date: 2007-05-11 05:34:47 CEST

Here's a patch in progress, not yet committed, which displays multiple
merge-range notifications during a merge.

There's a big problem, though. Our test suite has devolved over the
years. In the early days, both expected and actual output was always
described in some sort of structure; the test would build the
expected structure, and the test-suite would parse actual output into
a structure as well. Then the structures would be compared.

This approach was great, because if we changed svn's output, we just
tweaked the structure, or tweaked the parser of the output.

But over time, our tests have become more and more dependent on the
evil svntest.action.run_and_verify_svn() function. This routine was
meant for really trivial stuff, but now we have all these tests
passing in *exact* expected output into it, and there's no parsing
going on anywhere.

As a result, because my change adds some lines to 'svn merge' output
like this:

   --- Merging revision 4-9 into '/blah'

... about a million tests break. And I can't tell any parser to just
ignore such lines, like in the old days. I have to go and add these
newly expected lines to an endless number of tests!

So, as a stopgap, I've hacked a function in svntest to just filter out
such lines... and now most tests are passing again. In a separate
change, I guess I'll fix all the tests.

--------------------------

Have 'svn merge' notify client when it merges each range.

* subversion/include/svn_wc.h
  (svn_wc_notify_action_t): new 'svn_wc_notify_merge_begin' action.
  (svn_wc_notify_t): new 'merge_range' field to describe range being merged.

* subversion/libsvn_wc/util.c
  (svn_wc_create_notify): have constructor explicitly NULL new field.
  (svn_wc_dup_notify): duplicate the new merge_range_t field.

* subversion/libsvn_client/merge.c
  (do_merge, do_single_file_merge): send new merge_begin notification.

* subversion/svn/notify.c
  (notify): print the merge_begin notification, describe range being merged.

* subversion/tests/cmdline/svntest/actions.py
  (compare_and_display_lines): ### HACK: filter lines that start with '---'

Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 24986)
+++ subversion/include/svn_wc.h (working copy)
@@ -733,8 +733,12 @@
   svn_wc_notify_changelist_clear,

   /** Failed to update a path's changelist association. @since New in 1.5. */
- svn_wc_notify_changelist_failed
+ svn_wc_notify_changelist_failed,

+ /** A merge operation (to path) has begun. See @c merge_range in
+ @c svn_wc_notify_t. @since New in 1.5 */
+ svn_wc_notify_merge_begin,
+
 } svn_wc_notify_action_t;

@@ -840,6 +844,9 @@
   /** When @c action is @c svn_wc_notify_changelist_add or name. In all other
    * cases, it is @c NULL. */
   const char *changelist_name;
+ /** When @c action is @c svn_wc_notify_merge_begin. In all other
+ cases, it is @c NULL. */
+ svn_merge_range_t *merge_range;
   /* 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_wc/util.c
===================================================================
--- subversion/libsvn_wc/util.c (revision 24986)
+++ subversion/libsvn_wc/util.c (working copy)
@@ -127,6 +127,7 @@
   ret->lock_state = svn_wc_notify_lock_state_unknown;
   ret->revision = SVN_INVALID_REVNUM;
   ret->changelist_name = NULL;
+ ret->merge_range = NULL;

   return ret;
 }
@@ -161,6 +162,8 @@
     }
   if (ret->changelist_name)
     ret->changelist_name = apr_pstrdup(pool, ret->changelist_name);
+ if (ret->merge_range)
+ ret->merge_range = svn_merge_range_dup(ret->merge_range, pool);

   return ret;
 }
Index: subversion/libsvn_client/merge.c
===================================================================
--- subversion/libsvn_client/merge.c (revision 24986)
+++ subversion/libsvn_client/merge.c (working copy)
@@ -1865,8 +1865,6 @@
      may create holes in range to merge. Loop over the revision
      ranges we have left to merge, getting an editor for each range,
      and applying its delta. */
- /* ### FIXME: Handle notification callbacks for multiple merges into
- ### a single versioned resource. */
   for (i = 0; i < remaining_ranges->nelts; i++)
     {
       /* When using this merge range, account for the exclusivity of
@@ -1875,6 +1873,14 @@
       svn_merge_range_t *r = APR_ARRAY_IDX(remaining_ranges, i,
                                            svn_merge_range_t *);

+ /* ### TODO(sussman): should this whole for loop be using a
+ cleared subpool?? */
+ svn_wc_notify_t *notify = svn_wc_create_notify(target_wcpath,
+ svn_wc_notify_merge_begin,
+ pool);
+ notify->merge_range = r;
+ notification_receiver(&notify_b, notify, pool);
+
       /* We must avoid subsequent merges to files which are already in
          conflict, as subsequent merges might overlap with the
          conflict markers in the file (or worse, be completely inside
@@ -2201,8 +2207,6 @@
         APR_ARRAY_PUSH(remaining_ranges, svn_merge_range_t *) = &range;
     }

- /* ### FIXME: Handle notification callbacks for multiple merges into
- ### a single versioned resource. */
   for (i = 0; i < remaining_ranges->nelts; i++)
     {
       /* When using this merge range, account for the exclusivity of
@@ -2211,6 +2215,14 @@
       svn_merge_range_t *r = APR_ARRAY_IDX(remaining_ranges, i,
                                            svn_merge_range_t *);

+ /* ### TODO(sussman): should this whole for loop be using a
+ cleared subpool?? */
+ svn_wc_notify_t *n = svn_wc_create_notify(target_wcpath,
+ svn_wc_notify_merge_begin,
+ pool);
+ n->merge_range = r;
+ notification_receiver(&notify_b, n, pool);
+
       /* While we currently don't allow it, in theory we could be
          fetching two fulltexts from two different repositories here. */
       SVN_ERR(single_file_merge_get_file(&tmpfile1, ra_session1, &props1,
Index: subversion/tests/cmdline/svntest/actions.py
===================================================================
--- subversion/tests/cmdline/svntest/actions.py (revision 24986)
+++ subversion/tests/cmdline/svntest/actions.py (working copy)
@@ -922,8 +922,13 @@
   if actual is None: act = []
   else: act = actual

- if exp != act:
- display_lines(message, label, expected, actual)
+ filtered_actual = []
+ for line in actual:
+ if not line.startswith("---"):
+ filtered_actual.append(line)
+
+ if exp != filtered_actual:
+ display_lines(message, label, expected, filtered_actual)
     raise main.SVNLineUnequal

 def compare_unordered_and_display_lines(message, label, expected, actual):
Index: subversion/svn/notify.c
===================================================================
--- subversion/svn/notify.c (revision 24986)
+++ subversion/svn/notify.c (working copy)
@@ -410,6 +410,18 @@
       svn_error_clear(n->err);
       break;

+ case svn_wc_notify_merge_begin:
+ if (n->merge_range->start == n->merge_range->end)
+ err = svn_cmdline_printf(pool, _("--- Merging revision %ld to
'%s':\n"),
+ n->merge_range->start, path_local);
+ else
+ err = svn_cmdline_printf(pool, _("--- Merging revisions
%ld-%ld to '%s':\n"),
+ n->merge_range->start, n->merge_range->end,
+ path_local);
+ if (err)
+ goto print_error;
+ break;
+
     default:
       break;
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 11 05:35:13 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.