[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: diff_repos_wc question

From: Karl Fogel <kfogel_at_red-bean.com>
Date: Fri, 03 Oct 2008 22:50:11 -0400

"Neels J. Hofmeyr" <neels_at_elego.de> writes:
> Let me rephrase that:
>
> Is it currently possible to do a diff between
> URL_at_REV
> and
> an unrelated[1] working copy with local mods
> , and if yes, how?
> [1] unrelated, as in not of the same URL.

   $ cd svn_trunk_working_copy
   $ echo "This is a local mod." >> README
   $ svn diff --old=http://svn.collab.net/repos/svn/trunk/INSTALL@33019 --new=README

-Karl

> I'm curious both for commandline and sourcecode solutions. I need a
> reference to implement diff_summarize_repos_wc(), if there is one.
>
> Thanks a lot,
> ~Neels
>
>
>
> Neels J. Hofmeyr wrote:
>> I am confused... when I look in the code, I find
>>
>> subversion/libsvn_client/diff.c:1226
>> [[[
>> /* Perform a diff between a repository path and a working-copy path.
>>
>> PATH1 may be either a URL or a working copy path. PATH2 is a
>> working copy path. REVISION1 and REVISION2 are their respective
>> revisions. If REVERSE is TRUE, the diff will be done in reverse.
>> If PEG_REVISION is specified, then PATH1 is the path in the peg
>> revision, and the actual repository path to be compared is
>> determined by following copy history.
>>
>> All other options are the same as those passed to svn_client_diff4(). */
>> static svn_error_t *
>> diff_repos_wc(const char *path1,
>> const svn_opt_revision_t *revision1,
>> const svn_opt_revision_t *peg_revision,
>> const char *path2,
>> const svn_opt_revision_t *revision2,
>> svn_boolean_t reverse,
>> svn_depth_t depth,
>> svn_boolean_t ignore_ancestry,
>> const apr_array_header_t *changelists,
>> const svn_wc_diff_callbacks3_t *callbacks,
>> struct diff_cmd_baton *callback_baton,
>> svn_client_ctx_t *ctx,
>> apr_pool_t *pool)
>> ]]]
>>
>> and
>>
>> :1363
>> [[[
>> /* This is basically just the guts of svn_client_diff[_peg]3(). */
>> static svn_error_t *
>> do_diff(const struct diff_parameters *diff_param,
>> const svn_wc_diff_callbacks3_t *callbacks,
>> struct diff_cmd_baton *callback_baton,
>> svn_client_ctx_t *ctx,
>> apr_pool_t *pool)
>> {
>> struct diff_paths diff_paths;
>>
>> /* Check if paths/revisions are urls/local. */
>> SVN_ERR(check_paths(diff_param, &diff_paths));
>>
>> if (diff_paths.is_repos1)
>> {
>> if (diff_paths.is_repos2)
>> {
>> return diff_repos_repos(diff_param, callbacks, callback_baton,
>> ctx, pool);
>> }
>> else /* path2 is a working copy path */
>> {
>> return diff_repos_wc(diff_param->path1, diff_param->revision1,
>> diff_param->peg_revision,
>> diff_param->path2, diff_param->revision2,
>> FALSE, diff_param->depth,
>> diff_param->ignore_ancestry,
>> diff_param->changelists,
>> callbacks, callback_baton, ctx, pool);
>> ]]]
>>
>> So there is code that decides to do a diff between a repos path and a
>> working copy. But I can't seem to diff a repository revision against a
>> working copy with local modifications from the commandline.
>>
>> I am trying to diff path A/B/E at rev 2 against the locally modified working
>> copy of A/B3/E (A/B3 being a modified copy of A/B):
>>
>> [[[
>> $ pwd
>> [...]/A/B3
>> $ svn diff file:///[...]/A/B/E_at_2 E
>> subversion/svn/diff-cmd.c:282: (apr_err=200007)
>> svn: Target lists to diff may not contain both working copy paths and URLs
>>
>> $ cd E
>> $ pwd
>> [...]/A/B3/E
>> $ svn diff file:///[...]/A/B/E_at_2
>> subversion/libsvn_client/diff.c:900: (apr_err=195002)
>> svn: Not all required revisions are specified
>>
>> $ pwd
>> [...]/A/B3/E
>> $ svn diff -r 2 ../../B/E
>> subversion/libsvn_client/diff.c:836: (apr_err=150000)
>> svn: '../../B/E' is not under version control
>> # oh, ok, it is removed on HEAD. Restore...
>> $ svn up -r 2 ../../B
>> A ../../B/E
>> A ../../B/E/alpha
>> A ../../B/E/newfile
>> A ../../B/E/beta
>> Updated to revision 2.
>> $ svn diff --revision 2 ../../B/E
>> $ # No output at all, but there are differences
>> $ ls
>> alpha beta bumm newfile
>> $ ls ../../B/E/
>> alpha beta newfile
>> $ cat newfile
>> This is the file 'newfile'.
>> Last changed in '$Revision: 6 $'.
>> karl
>> $ cat ../../B/E/newfile
>> This is the file 'newfile'.
>> Last changed in '$Revision: 2 $'.
>> $ svn ci -m m
>> $ svn diff --revision 2 ../../B/E
>> $
>> ]]]
>>
>> The subversion book says on the diff command: "OLD-TGT and NEW-TGT may be
>> working copy paths or URL[@REV]." I assumed it also means that OLD-TGT may
>> be a repository URL while NEW-TGT may be a working copy path.
>>
>> It furthermore says:
>> [[[
>> --revision N
>> The client compares TARGET_at_N against the working copy.
>> ]]]
>>
>> in this context:
>>
>> [[[
>> If TARGET is a working copy path, the default behavior (when no --revision
>> option is provided) is to display the differences between the base and
>> working copies of TARGET. If a --revision option is specified in this
>> scenario, though, it means:
>>
>> --revision N:M
>> The server compares TARGET_at_N and TARGET_at_M.
>>
>> --revision N
>> The client compares TARGET_at_N against the working copy.
>>
>> If the alternate syntax is used, the server compares URL1 and URL2 at
>> revisions N and M, respectively. If either N or M is omitted, a value of
>> HEAD is assumed.
>>
>> By default, svn diff ignores the ancestry of files and merely compares the
>> contents of the two files being compared. If you use --notice-ancestry, the
>> ancestry of the paths in question will be taken into consideration when
>> comparing revisions (i.e., if you run svn diff on two files with identical
>> contents but different ancestry, you will see the entire contents of the
>> file as having been removed and added again).
>> ]]]
>>
>> Which is my third diff command shown above. Well, it probably means to say
>> that it compares TARGET_at_N against the working copy at TARGET. To me it reads
>> though that it compares TARGET_at_N to the working copy at `pwd`.
>>
>> The general sound of the diff help is that any diff combination is possible.
>> There is code that looks like that's the case. The subversion book is at
>> least ambiguous on the question.
>>
>> Help anyone?
>>
>> Thanks,
>> ~Neels
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-10-04 05:14:37 CEST

This is an archived mail posted to the Subversion Dev mailing list.