Subversion: How to compare differences between incoming changes?

19

7

I would like to see the changes that my co-workers have made before I accept the incoming changes.

So I start by getting the status

svn st -u

...which tells me that I've got an incoming change

    *     9803   incomingChanges.html
M         9803   localChanges.html
M   *     9803   localAndIncoming.html

I can see what I've changed

svn diff localChanges.html

...but how can I diff localAndIncoming.html to show what has been changed, and how it's different than my working copy?

Andrew

Posted 2010-06-08T16:20:44.803

Reputation: 11 982

Not an answer to your command line question, but: in the end, once you know what is different from your working copy, you'll probably want to merge the repository changes with your own changes. When using some GUI to do so, why not use a GUI to help you do the initial diff as well? Tools like TortoiseSVN offer such compare. Also, IDEs like Eclipse can make reviewing incoming changes (even when there's nothing to merge -- nice to get an idea of what your coworkers have been up to) very easy, avoiding automatic merges.

– Arjan – 2010-06-12T12:08:25.963

1Is there a GUI way of seeing incoming changes using TortoiseSVN? – Christian – 2010-12-20T14:48:29.820

You'd also want to diff incomingChanges.html as well, no? – Raffi Khatchadourian – 2013-09-10T20:59:37.340

Answers

21

I believe what you need is:

svn diff -rBASE:HEAD

joelittlejohn

Posted 2010-06-08T16:20:44.803

Reputation: 310

2

FYI svn diff gives a diff based on the unmodified file stored in the .svn directory, not based on the live repo version.

You can run svn update to get subversion to attempt an update (and possibly merge) and then do an svn diff, but that's not as clean as I guess you want.

Finally svn diff does support diffing just on the repo. Example:

svn diff svn://svnserver/repo/localChanges.html -r REV_NO

Which defaults to comparing HEAD with the passed revision.

Andy

Posted 2010-06-08T16:20:44.803

Reputation: 2 959

2

With tortoisesvn (if you use windows)

  • Invoke the log screen

  • Select head revision

  • Right click on localAndIncoming.html

  • Choose Compare with working copy

Ghislain Hivon

Posted 2010-06-08T16:20:44.803

Reputation: 21

0

You really can't until you actually download the new version. Limitations like this were one of the big reasons why a new type of source control has become popular lately. It's called decentralized source control.
With this new form you have your own local repository, and you can then take changes from the main repository and run a diff on it, if you don't like the changes made you can revert your own repository and go from there.

http://mercurial.selenic.com/

And yeah, I know suggesting you switch products isn't an optimal solution, but it is a solution none the less.

Daisetsu

Posted 2010-06-08T16:20:44.803

Reputation: 5 195

0

Do another checkout in a fresh folder.

cd ..
svn checkout  /path/to/repo clean_working_copy

If you reuse clean_working_copy do not forget to update before

svn update clean_working_copy

Then compare your file with the one from clean_working_copy

diff your_working_copy/localAndIncoming.html clean_working_copy/localAndIncoming.html

Or with your prefered 3-way diff (mine is kdiff3)

kdiff3 --L1 Base --L2 theirs --L3 mine your_working_copy/.svn/text-base/localAndIncoming.html clean_working_copy/localAndIncoming.html your_working_copy/localAndIncoming.html

Ghislain Hivon

Posted 2010-06-08T16:20:44.803

Reputation: 21

This work, but a scm should provide a more integrated way. – rds – 2011-10-21T09:34:39.127

0

I think

svn diff -r HEAD

almost gives what you want. The only thing is that the + and - are reversed relative to what you expect.

Confusion

Posted 2010-06-08T16:20:44.803

Reputation: 101