Return-Path: Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: (qmail 33351 invoked from network); 6 Jul 2010 09:58:31 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Jul 2010 09:58:31 -0000 Received: (qmail 74423 invoked by uid 500); 6 Jul 2010 09:58:31 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 74330 invoked by uid 500); 6 Jul 2010 09:58:29 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 74323 invoked by uid 99); 6 Jul 2010 09:58:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 09:58:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jul 2010 09:58:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8937D2388906; Tue, 6 Jul 2010 09:57:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r960858 - /subversion/trunk/subversion/libsvn_client/patch.c Date: Tue, 06 Jul 2010 09:57:02 -0000 To: commits@subversion.apache.org From: rhuijben@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100706095702.8937D2388906@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rhuijben Date: Tue Jul 6 09:57:02 2010 New Revision: 960858 URL: http://svn.apache.org/viewvc?rev=960858&view=rev Log: Following up on r960851, move code in a function by itself and resolve an error on checking files not in a wc. * subversion/libsvn_client/patch.c (resolve_target_wc_file_info): New function. (resolve_target_path): Extract eol and keywords check code and use only if the file is in the wc. Suggested by: stsp Modified: subversion/trunk/subversion/libsvn_client/patch.c Modified: subversion/trunk/subversion/libsvn_client/patch.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=960858&r1=960857&r2=960858&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_client/patch.c (original) +++ subversion/trunk/subversion/libsvn_client/patch.c Tue Jul 6 09:57:02 2010 @@ -216,6 +216,59 @@ strip_path(const char **result, const ch return SVN_NO_ERROR; } +/* Obtain eol and keywords information for LOCAL_ABSPATH, from WC_CTX and + store the obtained information in *TARGET. */ +static svn_error_t * +resolve_target_wc_file_info(svn_wc_context_t *wc_ctx, + const char *local_abspath, + patch_target_t *target, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) +{ + apr_hash_t *props; + svn_string_t *keywords_val, *eol_style_val; + + /* Handle svn:keyword and svn:eol-style properties. */ + SVN_ERR(svn_wc_prop_list2(&props, wc_ctx, local_abspath, + scratch_pool, scratch_pool)); + keywords_val = apr_hash_get(props, SVN_PROP_KEYWORDS, + APR_HASH_KEY_STRING); + if (keywords_val) + { + svn_revnum_t changed_rev; + apr_time_t changed_date; + const char *rev_str; + const char *author; + const char *url; + + SVN_ERR(svn_wc__node_get_changed_info(&changed_rev, + &changed_date, + &author, wc_ctx, + local_abspath, + scratch_pool, + scratch_pool)); + rev_str = apr_psprintf(scratch_pool, "%"SVN_REVNUM_T_FMT, + changed_rev); + SVN_ERR(svn_wc__node_get_url(&url, wc_ctx, + target->local_abspath, + scratch_pool, scratch_pool)); + SVN_ERR(svn_subst_build_keywords2(&target->keywords, + keywords_val->data, + rev_str, url, changed_date, + author, result_pool)); + } + + eol_style_val = apr_hash_get(props, SVN_PROP_EOL_STYLE, + APR_HASH_KEY_STRING); + if (eol_style_val) + { + svn_subst_eol_style_from_value(&target->eol_style, + &target->eol_str, + eol_style_val->data); + } + return SVN_NO_ERROR; +} + /* Resolve the exact path for a patch TARGET at path PATH_FROM_PATCHFILE, * which is the path of the target as it appeared in the patch file. * Put a canonicalized version of PATH_FROM_PATCHFILE into @@ -227,7 +280,7 @@ strip_path(const char **result, const ch * STRIP_COUNT specifies the number of leading path components * which should be stripped from target paths in the patch. * If the path is not skipped also obtain eol-style and keywords - * information and store this in *TARGET. + * information by calling resolve_target_wc_info() on TARGET. * Use RESULT_POOL for allocations of fields in TARGET. */ static svn_error_t * resolve_target_path(patch_target_t *target, @@ -334,49 +387,9 @@ resolve_target_path(patch_target_t *targ if (target->locally_deleted && target->kind_on_disk != svn_node_none) target->skipped = TRUE; - { - apr_hash_t *props; - svn_string_t *keywords_val, *eol_style_val; - - /* Handle svn:keyword and svn:eol-style properties. */ - SVN_ERR(svn_wc_prop_list2(&props, wc_ctx, target->local_abspath, - scratch_pool, scratch_pool)); - keywords_val = apr_hash_get(props, SVN_PROP_KEYWORDS, - APR_HASH_KEY_STRING); - if (keywords_val) - { - svn_revnum_t changed_rev; - apr_time_t changed_date; - const char *rev_str; - const char *author; - const char *url; - - SVN_ERR(svn_wc__node_get_changed_info(&changed_rev, - &changed_date, - &author, wc_ctx, - target->local_abspath, - scratch_pool, - scratch_pool)); - rev_str = apr_psprintf(scratch_pool, "%"SVN_REVNUM_T_FMT, - changed_rev); - SVN_ERR(svn_wc__node_get_url(&url, wc_ctx, - target->local_abspath, - scratch_pool, scratch_pool)); - SVN_ERR(svn_subst_build_keywords2(&target->keywords, - keywords_val->data, - rev_str, url, changed_date, - author, result_pool)); - } - - eol_style_val = apr_hash_get(props, SVN_PROP_EOL_STYLE, - APR_HASH_KEY_STRING); - if (eol_style_val) - { - svn_subst_eol_style_from_value(&target->eol_style, - &target->eol_str, - eol_style_val->data); - } - } + if (target->kind_on_disk == svn_node_file) + SVN_ERR(resolve_target_wc_file_info(wc_ctx, target->local_abspath, + target, result_pool, scratch_pool)); return SVN_NO_ERROR; }