You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/02/05 17:03:50 UTC
svn commit: r1442640 - in /subversion/trunk/subversion/svn: diff-cmd.c svn.c
Author: stsp
Date: Tue Feb 5 16:03:49 2013
New Revision: 1442640
URL: http://svn.apache.org/viewvc?rev=1442640&view=rev
Log:
Make 'svn diff PATH URL' and 'svn diff URL PATH', where exactly two targets
are given and one target is a URL, a new shorthand invocation syntax for
'svn diff --old PATH --new URL' and 'svn diff --old URL --new PATH',
respectively.
These invocations used to error out with a "cannot mix repository and working
copy targets" before. User may intuitively try to diff a working copy to a URL
in the manner allowed by these new shorthands, so this is a usability
enhancement (principle of least surprise).
Suggested by: Alexey Neyman
* subversion/svn/diff-cmd.c
(svn_cl__diff): Map a 2-target diff invocation where one target is a URL and
the other target is a path to 'svn diff --old TARGET1 --new TARGET2'.
* subversion/svn/svn.c
(svn_cl__cmd_table): Update 'svn help diff' output accordingly.
Modified:
subversion/trunk/subversion/svn/diff-cmd.c
subversion/trunk/subversion/svn/svn.c
Modified: subversion/trunk/subversion/svn/diff-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/diff-cmd.c?rev=1442640&r1=1442639&r2=1442640&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/diff-cmd.c (original)
+++ subversion/trunk/subversion/svn/diff-cmd.c Tue Feb 5 16:03:49 2013
@@ -221,12 +221,13 @@ svn_cl__diff(apr_getopt_t *os,
if (! opt_state->old_target && ! opt_state->new_target
&& (targets->nelts == 2)
- && svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *))
- && svn_path_is_url(APR_ARRAY_IDX(targets, 1, const char *))
+ && (svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *))
+ || svn_path_is_url(APR_ARRAY_IDX(targets, 1, const char *)))
&& opt_state->start_revision.kind == svn_opt_revision_unspecified
&& opt_state->end_revision.kind == svn_opt_revision_unspecified)
{
- /* The 'svn diff OLD_URL[@OLDREV] NEW_URL[@NEWREV]' case matches. */
+ /* A 2-target diff where one or both targets are URLs. These are
+ * shorthands for some 'svn diff --old X --new Y' invocations. */
SVN_ERR(svn_opt_parse_path(&opt_state->start_revision, &old_target,
APR_ARRAY_IDX(targets, 0, const char *),
@@ -236,10 +237,33 @@ svn_cl__diff(apr_getopt_t *os,
pool));
targets->nelts = 0;
- if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
- opt_state->start_revision.kind = svn_opt_revision_head;
- if (opt_state->end_revision.kind == svn_opt_revision_unspecified)
- opt_state->end_revision.kind = svn_opt_revision_head;
+ /* Set default start/end revisions based on target types, in the same
+ * manner as done for the corresponding '--old X --new Y' cases. */
+ if (svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *))
+ && svn_path_is_url(APR_ARRAY_IDX(targets, 1, const char *)))
+ {
+ /* The 'svn diff OLD_URL[@OLDREV] NEW_URL[@NEWREV]' case matches. */
+ if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
+ opt_state->start_revision.kind = svn_opt_revision_head;
+ if (opt_state->end_revision.kind == svn_opt_revision_unspecified)
+ opt_state->end_revision.kind = svn_opt_revision_head;
+ }
+ else if (svn_path_is_url(APR_ARRAY_IDX(targets, 0, const char *)))
+ {
+ /* The 'svn diff OLD_URL[@OLDREV] NEW_PATH[@NEWREV]' case matches. */
+ if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
+ opt_state->start_revision.kind = svn_opt_revision_head;
+ if (opt_state->end_revision.kind == svn_opt_revision_unspecified)
+ opt_state->end_revision.kind = svn_opt_revision_working;
+ }
+ else
+ {
+ /* The 'svn diff OLD_PATH[@OLDREV] NEW_URL[@NEWREV]' case matches. */
+ if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
+ opt_state->start_revision.kind = svn_opt_revision_working;
+ if (opt_state->end_revision.kind == svn_opt_revision_unspecified)
+ opt_state->end_revision.kind = svn_opt_revision_head;
+ }
}
else if (opt_state->old_target)
{
Modified: subversion/trunk/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/svn.c?rev=1442640&r1=1442639&r2=1442640&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/svn.c (original)
+++ subversion/trunk/subversion/svn/svn.c Tue Feb 5 16:03:49 2013
@@ -541,6 +541,8 @@ const svn_opt_subcommand_desc2_t svn_cl_
" 2. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \\\n"
" [PATH...]\n"
" 3. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]\n"
+ " 4. diff OLD-URL[@OLDREV] NEW-PATH[@NEWREV]\n"
+ " 5. diff OLD-PATH[@OLDREV] NEW-URL[@NEWREV]\n"
"\n"
" 1. Display the changes made to TARGETs as they are seen in REV between\n"
" two revisions. TARGETs may be all working copy paths or all URLs.\n"
@@ -557,6 +559,8 @@ const svn_opt_subcommand_desc2_t svn_cl_
" to N, -r N:M makes OLDREV default to N and NEWREV default to M.\n"
"\n"
" 3. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV]'\n"
+ " 4. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-PATH[@NEWREV]'\n"
+ " 5. Shorthand for 'svn diff --old=OLD-PATH[@OLDREV] --new=NEW-URL[@NEWREV]'\n"
"\n"
" Use just 'svn diff' to display local modifications in a working copy.\n"),
{'r', 'c', opt_old_cmd, opt_new_cmd, 'N', opt_depth, opt_diff_cmd,