I've drilled a changelist into 'svn patch'. [[[ 0:% $svn st subversion 0:% $svn patch ../diffs/svn-patch-add_to_cl.diff --add-to-cl cl A [cl] subversion/tests/libsvn_client/client-test.c U subversion/tests/libsvn_client/client-test.c A [cl] subversion/svn/patch-cmd.c U subversion/svn/patch-cmd.c A [cl] subversion/svn/cl.h U subversion/svn/cl.h A [cl] subversion/svn/main.c U subversion/svn/main.c A [cl] subversion/include/svn_client.h U subversion/include/svn_client.h A [cl] subversion/libsvn_client/patch.c U subversion/libsvn_client/patch.c 0:% $svn st --cl cl
--- Changelist 'cl': M subversion/include/svn_client.h M subversion/tests/libsvn_client/client-test.c M subversion/svn/patch-cmd.c M subversion/svn/cl.h M subversion/svn/main.c M subversion/libsvn_client/patch.c ]]] Comments? Thoughts? I haven't tested how it integrates with tree changes (files being added/removed/moved/copied by 'svn patch') yet. In fact, I'm not sure what's the current status of that: does 'svn patch' currently support tree operations other than adding/removing files?
Index: subversion/tests/libsvn_client/client-test.c =================================================================== --- subversion/tests/libsvn_client/client-test.c (revision 978886) +++ subversion/tests/libsvn_client/client-test.c (working copy) @@ -380,7 +380,7 @@ test_patch(const svn_test_opts_t *opts, pcb.reject_tempfiles = apr_hash_make(pool); pcb.state_pool = pool; SVN_ERR(svn_client_patch(patch_file_path, wc_path, FALSE, 0, FALSE, - FALSE, FALSE, patch_collection_func, &pcb, + FALSE, FALSE, NULL, patch_collection_func, &pcb, ctx, pool, pool)); SVN_ERR(svn_io_file_close(patch_file, pool)); Index: subversion/svn/patch-cmd.c =================================================================== --- subversion/svn/patch-cmd.c (revision 978886) +++ subversion/svn/patch-cmd.c (working copy) @@ -76,7 +76,8 @@ svn_cl__patch(apr_getopt_t *os, opt_state->dry_run, opt_state->strip_count, opt_state->reverse_diff, opt_state->ignore_whitespace, - TRUE, NULL, NULL, ctx, pool, pool)); + TRUE, opt_state->add_to_changelist, + NULL, NULL, ctx, pool, pool)); if (! opt_state->quiet) Index: subversion/svn/cl.h =================================================================== --- subversion/svn/cl.h (revision 978886) +++ subversion/svn/cl.h (working copy) @@ -208,6 +208,7 @@ typedef struct svn_cl__opt_state_t apr_array_header_t *changelists; /* changelist filters */ const char *changelist; /* operate on this changelist THIS IS TEMPORARY (LAST OF CHANGELISTS) */ + const char *add_to_changelist; /* add to this changelist */ svn_boolean_t keep_changelists;/* don't remove changelists after commit */ svn_boolean_t keep_local; /* delete path only from repository */ svn_boolean_t all_revprops; /* retrieve all revprops */ Index: subversion/svn/main.c =================================================================== --- subversion/svn/main.c (revision 978886) +++ subversion/svn/main.c (working copy) @@ -122,6 +122,7 @@ typedef enum { opt_show_diff, opt_internal_diff, opt_use_git_diff_format, + opt_add_to_changelist, } svn_cl__longopt_t; /* Option codes and descriptions for the command line client. @@ -290,6 +291,10 @@ const apr_getopt_option_t svn_cl__options[] = N_("operate only on members of changelist ARG\n" " " "[alias: --cl]")}, + {"add-to-changelist", opt_add_to_changelist, 1, + N_("add files to changelist ARG\n" + " " + "[alias: --add-to-cl]")}, {"keep-changelists", opt_keep_changelists, 0, N_("don't delete changelists after commit")}, {"keep-local", opt_keep_local, 0, N_("keep path in working copy\n" @@ -390,6 +395,7 @@ const apr_getopt_option_t svn_cl__options[] = {"ro", opt_record_only, 0, NULL}, {"cd", opt_config_dir, 1, NULL}, {"cl", opt_changelist, 1, NULL}, + {"add-to-cl", opt_add_to_changelist, 1, NULL}, {"kl", opt_keep_local, 0, NULL}, {"sr", opt_show_revs, 1, NULL}, {"ri", opt_reintegrate, 0, NULL}, @@ -848,7 +854,10 @@ const svn_opt_subcommand_desc2_t svn_cl__cmd_table " do not agree with.\n" ), {'q', opt_dry_run, opt_strip_count, opt_reverse_diff, - opt_ignore_whitespace} }, + opt_ignore_whitespace, opt_add_to_changelist}, + {{opt_add_to_changelist, N_("add patched files to changelist ARG\n" + " " + "[alias: --add-to-cl]")}} }, { "propdel", svn_cl__propdel, {"pdel", "pd"}, N_ ("Remove a property from files, dirs, or revisions.\n" @@ -1699,6 +1708,9 @@ main(int argc, const char *argv[]) apr_hash_set(changelists, opt_state.changelist, APR_HASH_KEY_STRING, (void *)1); break; + case opt_add_to_changelist: + opt_state.add_to_changelist = apr_pstrdup(pool, opt_arg); + break; case opt_keep_changelists: opt_state.keep_changelists = TRUE; break; Index: subversion/include/svn_client.h =================================================================== --- subversion/include/svn_client.h (revision 978886) +++ subversion/include/svn_client.h (working copy) @@ -5235,6 +5235,9 @@ typedef svn_error_t *(*svn_client_patch_func_t)( * If @a patch_func is non-NULL, invoke @a patch_func with @a patch_baton * for each patch target processed. * + * If @a changelist is non-NULL, add each patch target processed to that + * changelist. + * * If @a ctx->notify_func2 is non-NULL, invoke @a ctx->notify_func2 with * @a ctx->notify_baton2 as patching progresses. * @@ -5253,6 +5256,7 @@ svn_client_patch(const char *patch_abspath, svn_boolean_t reverse, svn_boolean_t ignore_whitespace, svn_boolean_t remove_tempfiles, + const char *changelist, svn_client_patch_func_t patch_func, void *patch_baton, svn_client_ctx_t *ctx, Index: subversion/libsvn_client/patch.c =================================================================== --- subversion/libsvn_client/patch.c (revision 978886) +++ subversion/libsvn_client/patch.c (working copy) @@ -1463,8 +1463,11 @@ apply_one_patch(patch_target_t **patch_target, svn int strip_count, svn_boolean_t ignore_whitespace, svn_boolean_t remove_tempfiles, + const char *changelist, svn_client_patch_func_t patch_func, void *patch_baton, + svn_wc_notify_func2_t notify_func2, + void *notify_baton2, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool) @@ -1496,6 +1499,14 @@ apply_one_patch(patch_target_t **patch_target, svn } } + if (changelist && target->kind_on_disk == svn_node_file) + { + SVN_ERR(svn_wc_set_changelist2(wc_ctx, target->local_abspath, changelist, + cancel_func, cancel_baton, + notify_func2, notify_baton2, + scratch_pool)); + } + iterpool = svn_pool_create(scratch_pool); /* Match hunks. */ for (i = 0; i < patch->hunks->nelts; i++) @@ -2261,6 +2272,9 @@ typedef struct { /* The client context. */ svn_client_ctx_t *ctx; + + /* The changelist (if any) to associate the files with. */ + const char *changelist; } apply_patches_baton_t; /* Callback for use with svn_wc__call_with_write_lock(). @@ -2312,7 +2326,10 @@ apply_patches(void *baton, btn->ctx->wc_ctx, btn->strip_count, btn->ignore_whitespace, btn->remove_tempfiles, + btn->changelist, btn->patch_func, btn->patch_baton, + btn->ctx->notify_func2, + btn->ctx->notify_baton2, btn->ctx->cancel_func, btn->ctx->cancel_baton, iterpool, iterpool)); @@ -2357,6 +2374,7 @@ svn_client_patch(const char *patch_abspath, svn_boolean_t reverse, svn_boolean_t ignore_whitespace, svn_boolean_t remove_tempfiles, + const char *changelist, svn_client_patch_func_t patch_func, void *patch_baton, svn_client_ctx_t *ctx, @@ -2379,6 +2397,7 @@ svn_client_patch(const char *patch_abspath, baton.remove_tempfiles = remove_tempfiles; baton.patch_func = patch_func; baton.patch_baton = patch_baton; + baton.changelist = changelist; return svn_error_return( svn_wc__call_with_write_lock(apply_patches, &baton,