2 * mergeinfo-cmd.c -- Query merge-relative info.
4 * ====================================================================
5 * Copyright (c) 2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 /* ==================================================================== */
25 #include "svn_pools.h"
26 #include "svn_client.h"
27 #include "svn_cmdline.h"
29 #include "svn_error.h"
30 #include "svn_error_codes.h"
31 #include "svn_types.h"
34 #include "svn_private_config.h"
39 /* Implements the svn_log_entry_receiver_t interface. BATON is a
40 pointer to a mergeinfo rangelist array. */
42 print_log_rev(void *baton
,
43 svn_log_entry_t
*log_entry
,
46 svn_cmdline_printf(pool
, "r%ld\n", log_entry
->revision
);
51 /* This implements the `svn_opt_subcommand_t' interface. */
53 svn_cl__mergeinfo(apr_getopt_t
*os
,
57 svn_cl__opt_state_t
*opt_state
= ((svn_cl__cmd_baton_t
*) baton
)->opt_state
;
58 svn_client_ctx_t
*ctx
= ((svn_cl__cmd_baton_t
*) baton
)->ctx
;
59 apr_array_header_t
*targets
;
60 const char *source_url
, *target
;
61 svn_opt_revision_t src_peg_revision
, tgt_peg_revision
;
63 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets
, os
,
67 /* We expect a single source URL followed by a single target --
68 nothing more, nothing less. */
69 if (targets
->nelts
< 1)
70 return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR
, NULL
,
71 _("Not enough arguments given"));
72 if (targets
->nelts
> 2)
73 return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR
, NULL
,
74 _("Too many arguments given"));
76 /* Parse the SOURCE-URL[@REV] argument. */
77 SVN_ERR(svn_opt_parse_path(&src_peg_revision
, &source_url
,
78 APR_ARRAY_IDX(targets
, 0, const char *), pool
));
79 if (! svn_path_is_url(source_url
))
80 return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR
, NULL
,
81 _("Path '%s' is not a URL"), source_url
);
83 /* Parse the TARGET[@REV] argument (if provided). */
84 if (targets
->nelts
== 2)
86 SVN_ERR(svn_opt_parse_path(&tgt_peg_revision
, &target
,
87 APR_ARRAY_IDX(targets
, 1, const char *),
93 tgt_peg_revision
.kind
= svn_opt_revision_unspecified
;
96 /* If no peg-rev was attached to the source URL, assume HEAD. */
97 if (src_peg_revision
.kind
== svn_opt_revision_unspecified
)
98 src_peg_revision
.kind
= svn_opt_revision_head
;
100 /* If no peg-rev was attached to a URL target, then assume HEAD; if
101 no peg-rev was attached to a non-URL target, then assume BASE. */
102 if (tgt_peg_revision
.kind
== svn_opt_revision_unspecified
)
104 if (svn_path_is_url(target
))
105 tgt_peg_revision
.kind
= svn_opt_revision_head
;
107 tgt_peg_revision
.kind
= svn_opt_revision_base
;
110 /* Do the real work, depending on the requested data flavor. */
111 if (opt_state
->show_revs
== svn_cl__show_revs_merged
)
113 SVN_ERR(svn_client_mergeinfo_log_merged(target
, &tgt_peg_revision
,
114 source_url
, &src_peg_revision
,
116 FALSE
, NULL
, ctx
, pool
));
118 else if (opt_state
->show_revs
== svn_cl__show_revs_eligible
)
120 SVN_ERR(svn_client_mergeinfo_log_eligible(target
, &tgt_peg_revision
,
121 source_url
, &src_peg_revision
,
123 FALSE
, NULL
, ctx
, pool
));