Discussion:
command line syntax for svn diff
Bo Berglund
2018-04-28 05:23:35 UTC
Permalink
I want to examine the difference between two file revisions, one being
the file in the working copy and the other the same file as the
previous committed revision of that same file.
The diff should be sent to WinMerge for display.

In the WinMerge docs (http://manual.winmerge.org/Version_control.html)
they suggest to use this command line:
svn diff --diff-cmd "<path to WinMerge executable>" -x "-dl -dr" <file
to check>

But when I try this in a WC on a file that is part of the project
nothing at all happens:

svn diff --diff-cmd "C:\Programs\WinMerge\WinMergeU.exe" -x "-dl -dr"
espconfig.cpp

I suspect that the svn diff needs something more to work correctly,
the above command might only work with *local* uncommitted changes?

In SVNBook is shown the diff command as:
svn -diff -r 2:3 <filename>
where 2 and 3 are the revisions to compare.

But my problem is that the revisions where the file actually changed
last is not known, so how can I put the correct number into the
command?

There is also the --change parameter to svn diff, but the same problem
reappears: how to find out the revision where this particular file
changed in the past?

I am running Svn 1.9.7 command line client on Windows 7 X64.
I cannot install Tortoise because my Windows Explorer plug-in handler
is already filled to capacity...
--
Bo Berglund
Developer in Sweden
Arwin Arni Nandagopal
2018-04-28 06:39:24 UTC
Permalink
There are revision keywords like HEAD which references the latest revision and PREV which references the last changed revision of the target. E.g: SVN diff -rHEAD:PREV target.file will show the changes between the last changed revision for that file and the latest revision, which is effectively the change introduced by that last revision.

Arwin

________________________________
From: Bo Berglund <***@gmail.com>
Sent: Saturday, April 28, 2018 10:53:35 AM
To: ***@subversion.apache.org
Subject: command line syntax for svn diff

I want to examine the difference between two file revisions, one being
the file in the working copy and the other the same file as the
previous committed revision of that same file.
The diff should be sent to WinMerge for display.

In the WinMerge docs (http://manual.winmerge.org/Version_control.html)
they suggest to use this command line:
svn diff --diff-cmd "<path to WinMerge executable>" -x "-dl -dr" <file
to check>

But when I try this in a WC on a file that is part of the project
nothing at all happens:

svn diff --diff-cmd "C:\Programs\WinMerge\WinMergeU.exe" -x "-dl -dr"
espconfig.cpp

I suspect that the svn diff needs something more to work correctly,
the above command might only work with *local* uncommitted changes?

In SVNBook is shown the diff command as:
svn -diff -r 2:3 <filename>
where 2 and 3 are the revisions to compare.

But my problem is that the revisions where the file actually changed
last is not known, so how can I put the correct number into the
command?

There is also the --change parameter to svn diff, but the same problem
reappears: how to find out the revision where this particular file
changed in the past?

I am running Svn 1.9.7 command line client on Windows 7 X64.
I cannot install Tortoise because my Windows Explorer plug-in handler
is already filled to capacity...


--
Bo Berglund
Developer in Sweden
Bo Berglund
2018-04-28 07:39:35 UTC
Permalink
On Sat, 28 Apr 2018 06:39:24 +0000, Arwin Arni Nandagopal
Post by Arwin Arni Nandagopal
There are revision keywords like HEAD which references the latest revision
and PREV which references the last changed revision of the target.
E.g: SVN diff -rHEAD:PREV target.file will show the changes between the last
changed revision for that file and the latest revision, which is effectively
the change introduced by that last revision.
Thanks! That made a good way forward!

I did this on the command line:
svn diff -r HEAD:PREV espconfig.cpp

And now I get output which is a regular (humanly unreadable) diff:
Index: espconfig.cpp
===================================================================
--- espconfig.cpp (revision 2446)
+++ espconfig.cpp (revision 2434)
@@ -175,7 +175,6 @@
* A<ip address><ETX> sets IP address as X.Y.Z.W format
* B<baudrate><ETX> sets the serial port baud rate
* C<channelnumber><ETX> sets the wifi channel number in AP
mode (0-13 where 0 means no setting)
- * F<value><ETX> sets the STA mode IP address
fixed state
* H<hidden><ETX> sets if AP mode ssid shall be hidden (1)
or not (0)
* L<ETX> load config into CnfTmp
* M<value><ETX> sets the WiFi mode
@@ -187,7 +186,6 @@
* a<ETX> gets IP address
* b<ETX> gets the serial port baud rate
* c<ETX> gets the AP mode channel number (0..13)
- * f<ETX> gets the STA mode
fixed address setting (0..1)
* h<ETX> gets the AP mode ssid hidden state (0/1)
* i<ETX> gets the WiFi MAC address
* m<ETX> gets the WiFi mode
.... etc with + and - indicators....

But what I would like is to get this loaded into WinMerge so I can
examine side by side the code changes in context.

And of course the example from the WinMerge docs does not work yet...
I modified it thus:

svn diff -r HEAD:PREV --diff-cmd "C:\Programs\WinMerge\WinMergeU.exe"
-x "-dl -dr" espconfig.cpp

I have no idea what the parameters "-dl -dr" axtually do, though.

Question:
---------
Since I am new to SVN but it has been around for like 15 years I
expected this diff use to be pretty common but I find little info when
I google.
Do people not use diffs into sensible GUI display programs like
WinMerge when using SVN?
Or is GUI equivalent to saying TortoiseSVN?
(which I cannot install for reasons explained in my start post).
--
Bo Berglund
Developer in Sweden
Arwin Arni Nandagopal
2018-04-28 07:57:16 UTC
Permalink
The "-dl -dr" is the value for the -x option which are passed as arguments to the external diff command. These are parsed and used by your external diff tool. You'll have to see the documentation for that tool (WinMerge in your case). That said, I don't really know what people in GUI land do..

Arwin



From: Bo Berglund
Sent: Saturday, 28 April, 13:10
Subject: Re: command line syntax for svn diff
To: ***@subversion.apache.org


On Sat, 28 Apr 2018 06:39:24 +0000, Arwin Arni Nandagopal wrote: >There are revision keywords like HEAD which references the latest revision >and PREV which references the last changed revision of the target. >E.g: SVN diff -rHEAD:PREV target.file will show the changes between the last >changed revision for that file and the latest revision, which is effectively >the change introduced by that last revision. > Thanks! That made a good way forward! I did this on the command line: svn diff -r HEAD:PREV espconfig.cpp And now I get output which is a regular (humanly unreadable) diff: Index: espconfig.cpp =================================================================== --- espconfig.cpp (revision 2446) +++ espconfig.cpp (revision 2434) @@ -175,7 +175,6 @@ * A sets IP address as X.Y.Z.W format * B sets the serial port baud rate * C sets the wifi channel number in AP mode (0-13 where 0 means no setting) - * F sets the STA mode IP address fixed state * H sets if AP mode ssid shall be hidden (1) or not (0) * L load config into CnfTmp * M sets the WiFi mode @@ -187,7 +186,6 @@ * a gets IP address * b gets the serial port baud rate * c gets the AP mode channel number (0..13) - * f gets the STA mode fixed address setting (0..1) * h gets the AP mode ssid hidden state (0/1) * i gets the WiFi MAC address * m gets the WiFi mode .... etc with + and - indicators.... But what I would like is to get this loaded into WinMerge so I can examine side by side the code changes in context. And of course the example from the WinMerge docs does not work yet... I modified it thus: svn diff -r HEAD:PREV --diff-cmd "C:\Programs\WinMerge\WinMergeU.exe" -x "-dl -dr" espconfig.cpp I have no idea what the parameters "-dl -dr" axtually do, though. Question: --------- Since I am new to SVN but it has been around for like 15 years I expected this diff use to be pretty common but I find little info when I google. Do people not use diffs into sensible GUI display programs like WinMerge when using SVN? Or is GUI equivalent to saying TortoiseSVN? (which I cannot install for reasons explained in my start post). -- Bo Berglund Developer in Sweden
Bo Berglund
2018-04-28 09:09:17 UTC
Permalink
On Sat, 28 Apr 2018 07:57:16 +0000, Arwin Arni Nandagopal
Post by Arwin Arni Nandagopal
You'll have to see the documentation for that tool (WinMerge in your case).
THanks,
I ended up writing a batch file in a folder on path using svn cat to
get a temp copy of the previous revision to compare against:

@ECHO OFF
SET WINMERGE="C:\Programs\WinMerge\WinMergeU.exe"
SET INFILE=%1
IF EXIST %INFILE% GOTO proceed
GOTO exitnofile

:proceed
SET TMPFILE=%INFILE%.temp
svn cat -r PREV %INFILE% > %TMPFILE%
%WINMERGE% /e /x /u /dl "Current file" /dr "Previous revision"
%INFILE% %TMPFILE%
REM Cleanup
DEL %TMPFILE%

REM ----- Various exit modes ------
GOTO exitbat
:exitnofile
ECHO File not found so exiting
GOTO exitbat

:exitbat
REM Exit batch file

This seems to work as I want it to for now.
It will download the previous revision into a temp file in the current
dir, then invoke WinMerge with the original and the temp files as
arguments. Finally when closing it deletes the temp file.

Seems to work OK so far.

Thanks for your help, I did not know of the HEAD and PREV labels for
the revisions....
--
Bo Berglund
Developer in Sweden
Loading...