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

[PATCH] Partial fix for Issue #443: post-commit hook script (error) output lost.

From: Madan U Sreenivasan <madan_at_collab.net>
Date: 2005-06-28 14:01:41 CEST

- Have extracted only the ra_dav part of the patch (for ease of
  review ) and fixed the factorizations.
- Also attached are design files that help understand the patch.
- I have tested this with a test case on all three protocols ( the
  test currently passes only over ra_dav )

[[[
   Partial fix for Issue #443: post-commit hook script (error) output
   lost.
   Includes post-commit hook stderr propagation for ra_dav
   Does not include post-commit hook stderr propagation for ra_local
   and ra_svn.
   Does not include the pre-revprop-change fix.

   * subversion/libsvn_ra/ra_loader.c
     (svn_ra_find_protocol): New API to find out which
     schema/protocol
     would be used, given a URL.
     (svn_ra_get_commit_editor2): New version of the API to use
     the new commit_editor function and hence use the new callback.
   * subversion/libsvn_ra/ra_loader.h
     (svn_ra__vtable_t): Added comments for get_commit_editor and
     intoduced a new member get_commit_editor2 which now uses the
     svn_commit_callback2_t.
   * subversion/include/svn_repos.h
     (svn_repos_get_commit_editor3): New API to accomodate the
     svn_commit_callback2_t callback type.
   * subversion/include/svn_types.h
     (svn_commit_callback2_t): Ah, the core change. A callback that
     takes the post_commit_err parameter.
   * subversion/include/svn_client.h
     (svn_client_commit_info2_t): The structure that carries the
     commit success parameters now has to carry the post_commit_err
     too.
     (svn_client_mkdir): mkdir should now use the new structure -
     svn_client_commit_info2_t.
     (svn_client_delete): delete should now use the new structure -
     svn_client_commit_info2_t.
     (svn_client_commit3): New API that uses
     svn_client_commit_info2_t.
     (svn_client_copy2): New API that uses svn_client_commit_info2_t.
   * subversion/include/svn_ra.h
     (svn_ra_find_protocol): New API declaration added.
     (svn_ra_get_commit_editor2): New API that uses the new callback.
   * subversion/libsvn_ra_local/ra_plugin.c
     (ra_local_vtable): ra_local's vtable does NOT have callback2.
   * subversion/libsvn_client/delete.c
     (delete_urls): delete_urls now uses the
     svn_client_commit_info2_t structure.
     Call svn_ra_get_commit_editor2() if ra_dav.
     Call svn_ra_get_commit_editor() otherwise.
     (svn_client_delete): svn_client_delete should now use
     svn_client_commit_info2_t.
   * subversion/libsvn_client/client.h
     (svn_client__commit_get_baton): Should now use the new commit
     info structrure - svn_client_commit_info2_t.
     (svn_client__commit_callback2): New callback that now takes
     post_commit_err as one of its parameters.
   * subversion/libsvn_client/copy.c
     (repos_to_repos_copy): Now uses the svn_client_commit_info2_t
     structure.
     Call svn_ra_get_commit_editor2() if ra_dav.
     Call svn_ra_get_commit_editor() otherwise.
     (wc_to_repos_copy): Now uses the svn_client_commit_info2_t
     structure.
     Call svn_ra_get_commit_editor2() if ra_dav.
     Call svn_ra_get_commit_editor() otherwise.
     (setup_copy): Now uses svn_client_commit_info2_t.
     (svn_client_copy2): New version of API that takes a
     svn_client_commit_info2_t for commit_info.
     (svn_client_move3): New version of API that takes a
     svn_client_commit_info2_t for commit_info.
   * subversion/libsvn_client/commit_util.c
     (commit_baton): Now uses svn_client_commit_info2_t.
     (svn_client__commit_get_baton): Now uses
     svn_client_commit_info2_t.
     (svn_client__commit_callback2): This callback function
     fills the svn_client_commit_info2_t structure with the
     post_commit_err, if any.
   * subversion/libsvn_client/add.c
     (mkdir_urls): Now uses svn_client_commit_info2_t.
     Calls svn_ra_get_commit_editor2() if ra_dav.
     Calls svn_ra_get_commit_editor() otherwise.
     (svn_client_mkdir): Now uses svn_client_commit_info2_t.
   * subversion/libsvn_client/commit.c
     (get_ra_editor): Now uses svn_client_commit_info2_t.
     Calls svn_ra_get_commit_editor2() if ra_dav.
     Calls svn_ra_get_commit_editor() otherwise.
     (svn_client_import2): get_ra_editor now passed typecasted
     commit_info.
     (svn_client_commit3): New version of API that uses
     svn_client_commit_info2_t.
     (svn_client_commit2): A svn_client_commit_info2_t is allocated
     and passed back as svn_client_commit_info_t. This doesn't matter
     as svn_client_commit_info2_t is one member more than
     svn_client_commit_info_t.
   * subversion/mod_dav_svn/merge.c
     (#include): Included svn_xml.h
     (dav_svn__merge_response): Now takes an extra post_commit_err
     parameter. If the post_commit_err is available,
     - Adds the SVN namespace
     - post-commit-err element to hold the post_commit_err
        to the merge response.
   * subversion/mod_dav_svn/dav_svn.h
     (dav_svn__merge_response): Now takes a new post_commit_err
     parameter.
   * subversion/mod_dav_svn/version.c
     (dav_svn_merge): If post-commit hook returns an error,
     pass it along to dav_svn__merge_response.
   * subversion/clients/cmdline/cl.h
     (svn_cl__print_commit_info2): Declaration for the new function
     that ultimately prints out the post-commit hook's stderr to
     the user.
   * subversion/clients/cmdline/mkdir-cmd.c
     (svn_cl__mkdir): Now uses svn_client_commit_info2_t and
     svn_cl__print_commit_info2.
   * subversion/clients/cmdline/move-cmd.c
     (svn_cl__move): Now uses svn_client_commit_info2_t and
     svn_cl__print_commit_info2.
   * subversion/clients/cmdline/copy-cmd.c
     (svn_cl__copy): Now uses svn_client_commit_info2_t and
     svn_cl__print_commit_info2.
   * subversion/clients/cmdline/util.c
     (svn_cl__print_commit_info2): Home at last!!! New version of
     API.
     svn_cl__print_commit_info2 is the function that ultimately
     prints out the post_commit_error to the user.
   * subversion/clients/cmdline/commit-cmd.c
     (svn_cl__commit): Now uses svn_client_commit_info2_t and
     svn_cl__print_commit_info2 for callback.
   * subversion/clients/cmdline/delete-cmd.c
     (svn_cl__delete): Now uses svn_client_commit_info2_t and
     svn_cl__print_commit_info2 for callback.
   * subversion/tests/clients/cmdline/commit_tests.py
     (post_commit_hook_test): New function to test the post-commit
     hook's propogation of stderr to the client.
     (test_list): Added post_commit_hook_test to list of tests.
   * subversion/libsvn_repos/hooks.c
     (svn_repos__hooks_post_commit): Now runs the post-commit hook
     with the read_errstream parameter as TRUE.
   * subversion/libsvn_repos/commit.c
     (edit_baton): Added new member - callback2, to hold a callback
     of type svn_commit_callback2_t. Also added comments that
     callback
     should be removed once all code uses callback2.
     (close_edit): Handles the post-commit stderr. Decides whether
     to use the callback or the callback2 member of the edit baton.
     (svn_repos_get_commit_editor3): Uses svn_commit_callback2_t for
     callback type, and fills callback2 of the edit baton.
     (svn_repos_get_commit_editor2): Still uses svn_commit_callback_t
     and fills the callback member of the edit baton.
   * subversion/libsvn_ra_svn/client.c
     (ra_svn_vtable): ra_svn's vtable doesnt have a
     get_commit_editor2 member.
   * subversion/libsvn_ra_dav/merge.c
     (merge_elements): Added the post-commit-err element.
     (merge_ctx_t): Added the post_commit_err member.
     (validate_element): Make ELEM_post_commit_err a valid element.
     (end_element): Add case, and handle ELEM_post_commit_err.
     (svn_ra_dav__merge_activity2): New merge function to handle
     post-commit hook's stderr.
   * subversion/libsvn_ra_dav/ra_dav.h
     (svn_ra_dav__get_commit_editor2): New version of API, using
     svn_commit_callback2_t.
     (enum): Added ELEM_post_commit_err member.
     (svn_ra_dav__merge_activity2): Declaration for new version of
     API.
   * subversion/libsvn_ra_dav/session.c
     (dav_vtable): Now contains a get_commit_editor2 function, but no
     get_commit_editor function.
   * subversion/libsvn_ra_dav/commit.c
     (commit_ctx_t): Added the callback2 member.
     (commit_close_edit): Now uses te svn_ra_dav__merge_activity2
     function.
     (svn_ra_dav__get_commit_editor2): Now fills the callback2 member
     (svn_ra_dav__get_commit_editor): Still fills the callback member
]]]

                                                                                                            
READING GUIDE :
- Please follow the sequence numbers to examine control flow
- The server side sequence is preceeded with a 'S'
- Detailed explanation is present in the accompanying doc 443.flow.txt

                            +------------------------------------------------+
                            | Code flow for following patch for issue #443 |
                            +------------------------------------------------+

                                               Client Side
                                               -----------
                                                                                                            
     0.svn_client_commit3()
     6. | +---> svn_cl__print_commit_info2
            | |(use svn_client_commit_info2_t (X) )
            | |
            V ^ libsvn_client
    +---------------------------------------------------+
    | 1.svn_ra_open.......................... |
    | 2.svn_ra_get_commit_editor2 \ |
    | +-------------------------+ . |
    | | +---------------------+ | . |
    | | | X--->callback_baton | | . |
    | | +---------------------+ | . |
    | | | | . |
    | | V | . |
    | | edit_baton | . |
    | +-------------------------+ . |
    | - . |
    | - . |
    | 3.vtable->close_edit . |
    | . . |
    | . . |
    | . 5.callback() . |
    | . ^ . |
    | . . . |
    | . . . |
    +-----------.--------------.-------------.----------+
                . . .
----------------.--------------.-------------.--------------------------
                . libsvn_ra . . client accesses ra_dav, ra_local
----------------.--------------.-------------.-------------------------- and ra_svn via libsvn_ra.
                .libsvn_ra_dav . .
  -----+ +-----.--------------.-------------.----------------+ +----- dav_vtable is of type
       | | . . . | | svn_ra__vtable_t which
       | | . ^ V | | now contains get_commit_editor2
   r | | . . [dav_vtable] | | r which can handle the new
   a | | V . | | a commit_info type callback.
   - | | 4.close_edit \.......<........ | | -
   l | | 4.1.svn_ra_dav__merge_activity2 . | | s
   o | | 4.1.1.ne_xml_push_handler ^ | | v
   c | | ..4.1.2.send the request and handle. | | n
   a | | . the merge-response. . | |
   l | | . 4.2execute the callback.....>..... | |
       | | . | |
       | | . | |
       | | .<........................................ . | |
       | | . . | |
       | | . . | |
       | | . . | |
       | | . . | |
       | | . . | |
       | | . . | |
       | | . . | |
  -----+ +-.------------------------------------------.------+ +-----
            . .
            . Over the network... .
            . .
            . | | .
            . | | .
          --.--+-----------------+----------------+----.-------------+----
            . | . |
            . | . |
            . Server Side .
            . ------------- .
      +-----.------------------------------------------.--------------------+
      | . . |
      | . apache server . |
      | . . |
      +-----.------------------------------------------.--------------------+
            . .
            V merge-request (deltav) ^ merge-response (deltav)
            . .
            . .
            . mod_dav_svn .
   +--------.------------------------------------------.---------+
   | V . |
   | S1.dav_svn_merge . |
   | S1.1svn_repos_fs_commit_txn . |
   | S1.2extract the post-commit hook's stderr . |
   | S1.3dav_svn__merge_response...................... |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   | |
   +-------------------------------------------------------------+
                                                                                                             
                                                                                                             
                                                                                                             
                                                                                                             
                                                                                                             
                                                                                                             
                                                                                                            

Client Server
------ ------
0 svn_client_commit3()
(for svn mkdir, cp, mv, rm, start directly at step 2-
 that is, svn_ra_open() is not part of the commit
 flow for these commands )

1 svn_ra_open()
- Get appropriate vtable.

2 svn_ra_get_commit_editor2()
- Fill callback baton with callback
  structure. Also fill edit baton member
  with callback baton.

3 vtable->close_edit
- close the editor (edit_baton is a
  parameter).

4 close_edit
- close_edit calls appropriate callback
  in libsvn_client. Also returns various
  commit info (from 4.1.3) and callback
  baton.

4.1 svn_ra_dav__merge_activity2

4.1.1 ne_xml_push_handler
- Push validate handler etc., The validate
  handler uses the merge_elements structure
  to validate the merge-response elements.
  Merge_elements now has an entry for
  post-commit-err.

4.1.2 send request

                                                1 dav_svn_merge

                                                1.1 svn_repos_fs_commit_txn [*]
                                                1.2 extract post-commit hook's stderr
                                                1.3 dav_svn__merge_response()

4.1.3 handle merge-response

4.2 execute the callback

5 The commit callback fills in X, the values
  that are returned back from the server
  after commit. These include revision, date,
  author... now also post_commit_err.

6 svn_cl__print_commit_info2()
  Can now handle an extra parameter that contains the
  post-commit hook's stderr by using
  svn_client_commit_info2_t (X) which
  has an additional post-commit-err param
  for post-commit hook's stderr.

[*]
1.1 [4.1.2.1] svn_repos_fs_commit_txn
executes the pre-commit hook, the commit txn and the post-commit hook.
The post-commit hook's stderr is kept in serr->child.

1.2 [4.1.2.2] extract post-commit hook's stderr
The post commit hook's stderr will be determined by checking for
SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED in serr->apr_err. The value of
serr->child->message which is the post-commit hook's stderr is stored.

1.3 [4.1.2.3] dav_svn__merge_response
The post-commit hook's stderr is now an extra parameter to this func.
The merge response now created by dav_svn__merge_response would contain
a <post-commit-err> element if the stderr is not NULL.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Tue Jun 28 13:56:04 2005

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.