1251881Speter/* 2251881Speter * patch-cmd.c -- Apply changes to a working copy. 3251881Speter * 4251881Speter * ==================================================================== 5251881Speter * Licensed to the Apache Software Foundation (ASF) under one 6251881Speter * or more contributor license agreements. See the NOTICE file 7251881Speter * distributed with this work for additional information 8251881Speter * regarding copyright ownership. The ASF licenses this file 9251881Speter * to you under the Apache License, Version 2.0 (the 10251881Speter * "License"); you may not use this file except in compliance 11251881Speter * with the License. You may obtain a copy of the License at 12251881Speter * 13251881Speter * http://www.apache.org/licenses/LICENSE-2.0 14251881Speter * 15251881Speter * Unless required by applicable law or agreed to in writing, 16251881Speter * software distributed under the License is distributed on an 17251881Speter * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18251881Speter * KIND, either express or implied. See the License for the 19251881Speter * specific language governing permissions and limitations 20251881Speter * under the License. 21251881Speter * ==================================================================== 22251881Speter */ 23251881Speter 24251881Speter/* ==================================================================== */ 25251881Speter 26251881Speter 27251881Speter 28251881Speter/*** Includes. ***/ 29251881Speter 30251881Speter#include "svn_client.h" 31251881Speter#include "svn_dirent_uri.h" 32251881Speter#include "svn_path.h" 33251881Speter#include "svn_error.h" 34251881Speter#include "svn_types.h" 35251881Speter#include "cl.h" 36251881Speter 37251881Speter#include "svn_private_config.h" 38251881Speter 39251881Speter 40251881Speter/*** Code. ***/ 41251881Speter 42251881Speter 43251881Speter/* This implements the `svn_opt_subcommand_t' interface. */ 44251881Spetersvn_error_t * 45251881Spetersvn_cl__patch(apr_getopt_t *os, 46251881Speter void *baton, 47251881Speter apr_pool_t *pool) 48251881Speter{ 49251881Speter svn_cl__opt_state_t *opt_state; 50251881Speter svn_client_ctx_t *ctx; 51251881Speter apr_array_header_t *targets; 52251881Speter const char *abs_patch_path; 53251881Speter const char *patch_path; 54251881Speter const char *abs_target_path; 55251881Speter const char *target_path; 56251881Speter 57251881Speter opt_state = ((svn_cl__cmd_baton_t *)baton)->opt_state; 58251881Speter ctx = ((svn_cl__cmd_baton_t *)baton)->ctx; 59251881Speter 60251881Speter SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os, 61251881Speter opt_state->targets, 62251881Speter ctx, FALSE, pool)); 63251881Speter SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool)); 64251881Speter 65251881Speter if (targets->nelts < 1) 66251881Speter return svn_error_create(SVN_ERR_CL_INSUFFICIENT_ARGS, 0, NULL); 67251881Speter 68251881Speter if (targets->nelts > 2) 69251881Speter return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL); 70251881Speter 71251881Speter patch_path = APR_ARRAY_IDX(targets, 0, const char *); 72251881Speter 73251881Speter SVN_ERR(svn_cl__check_target_is_local_path(patch_path)); 74251881Speter 75251881Speter SVN_ERR(svn_dirent_get_absolute(&abs_patch_path, patch_path, pool)); 76251881Speter 77251881Speter if (targets->nelts == 1) 78251881Speter target_path = ""; /* "" is the canonical form of "." */ 79251881Speter else 80251881Speter { 81251881Speter target_path = APR_ARRAY_IDX(targets, 1, const char *); 82251881Speter 83251881Speter SVN_ERR(svn_cl__check_target_is_local_path(target_path)); 84251881Speter } 85251881Speter SVN_ERR(svn_dirent_get_absolute(&abs_target_path, target_path, pool)); 86251881Speter 87251881Speter SVN_ERR(svn_client_patch(abs_patch_path, abs_target_path, 88251881Speter opt_state->dry_run, opt_state->strip, 89251881Speter opt_state->reverse_diff, 90251881Speter opt_state->ignore_whitespace, 91251881Speter TRUE, NULL, NULL, ctx, pool)); 92251881Speter 93251881Speter 94251881Speter if (! opt_state->quiet) 95251881Speter SVN_ERR(svn_cl__notifier_print_conflict_stats(ctx->notify_baton2, pool)); 96251881Speter 97251881Speter return SVN_NO_ERROR; 98251881Speter} 99