You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Brannon King <no...@gmail.com> on 2007/03/29 16:05:18 UTC

incorrect diff / merge

I was informed from the TortoiseSVN mailing list that I need to post this
problem here. The following two examples don't diff correctly (in my
opinion). The "if" statement on the bottom should take priority over the
indentation of the braces. Is there some setting I could tweak to improve
the performance of the diff tool for code like this?

File 1:
if(a){
	b
	c
	d
	e
	while(f){
		if(g)
			break;
	}
	if(g && h && i)
		return
}

File 2:
lock(sr){
	if(a){
		b
		c
		d
		e
		while(f){
			if(g && h && i)
				break;
		}
		if(g && h && i)
			return
	}
}



Thanks for your time,
Brannon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: incorrect diff / merge

Posted by Jan Hendrik <li...@gmail.com>.
Concerning Re: incorrect diff / merge
Duncan Murdoch wrote on 29 Mar 2007, 19:11, at least in part:

> On 3/29/2007 3:31 PM, Brannon King wrote:
> > Thanks for responding. I don't know exactly what diff parameters the
> > TortoiseSVN uses. But you are describing the exact issue I was
> > having; the entire block is chucked when it should have aligned the
> > "while" and "if" statements because white space is less valuable in
> > programming than other characters. I guess what I want is some
> > parameter that allows me to favor source-code type diffs.
> 
> TortoiseSVN (and svn) can be told to use an external diff.  On
> Windows, I recommend the (shareware) Beyond Compare.  It does a very
> nice job of displaying diffs.

Or try WinDiff.  I think ver. 2.6 (current) has a setting for character-
based diff display, otherwise one can hit F4 and the actual 
(multiple) diffs in a line are selected one by by one.

http://sourceforge.net/projects/winmerge

Here are the commandlines I use with TortoiseSVN for external Diff 
Viewer and Merge Tool resp.:

E:\PRG\Tools\WinMerge\WinMergeU.exe -e -x -ub -dl %yname -dr %bname %mine -wr %base

E:\PRG\Tools\WinMerge\WinMergeU.exe -e -x -ub -dl %yname -dr %tname %mine -wr %theirs %merged

Check WinMerge help to find out if character-based diffs are a 
setting within Winmerge or could be set by commandline switches 
(and what the above mean; part of them are TSVN switches BTW.
> 
> Duncan Murdoch
> 
> >  
> > 
> > -----Original Message-----
> > You'll have to be a little more detailed about your problem.  What
> > command are you running to get the diff?  What are you getting back?
> > What are you *expecting* back?
> > 
> > The difference between those two fragments would usually (AKA as
> > shown by diff -u) show up as a complete removal of the first block,
> > followed by an addition of the whole second block.  If that's not
> > what you're diffing, you'll need to tell us.
> > 
> > -kgd
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> > For additional commands, e-mail: users-help@subversion.tigris.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org For
> additional commands, e-mail: users-help@subversion.tigris.org
> 


---------------------------------------
Freedom quote:

     We do not move forward by curtailing people's liberty
     because we are afraid of what they may do or say.
               -- Eleanor Roosevelt, The Nation, 1940

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: incorrect diff / merge

Posted by Brannon King <no...@gmail.com>.
Setting to ignore whitespace does make a great difference in this case,
though I usually like catching whitespace changes. What I would like is a
setting to make a whitespace mismatch some percentage as valuable as a
character mismatch.

------------

--- merge1.txt
+++ merge2.txt
-if(a){
-	b
-	c
-	d
-	e
-	while(f){
-		if(g)
-			break;
+lock(sr){
+	if(a){
+		b
+		c
+		d
+		e
+		while(f){
+			if(g)
+				break;
	}
-	if(g && h && i)
-		return;
  }

-kgd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: incorrect diff / merge

Posted by Brannon King <no...@gmail.com>.
Setting to ignore whitespace does make a great difference in this case,
though I usually like catching whitespace changes. What I would like is a
setting to make a whitespace mismatch some percentage as valuable as a
character mismatch.

------------

--- merge1.txt
+++ merge2.txt
-if(a){
-	b
-	c
-	d
-	e
-	while(f){
-		if(g)
-			break;
+lock(sr){
+	if(a){
+		b
+		c
+		d
+		e
+		while(f){
+			if(g)
+				break;
	}
-	if(g && h && i)
-		return;
  }

-kgd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: incorrect diff / merge

Posted by Kris Deugau <kd...@vianet.ca>.
Brannon King wrote:
> Thanks for responding. I don't know exactly what diff parameters the
> TortoiseSVN uses. But you are describing the exact issue I was having; the
> entire block is chucked when it should have aligned the "while" and "if"
> statements because white space is less valuable in programming than other
> characters. I guess what I want is some parameter that allows me to favor
> source-code type diffs.

Basically, this is normal.  I know there are probably diff utilities 
that work on a character basis - I also know that most of the ones most 
people are likely to use in practice are *line*-based.  (The standard 
*nix diff and patch programs, for instance...)  I *think* the *nix diff 
has an option to ignore whitespace;  I don't recall offhand if Tortoise 
does or not, and if you can set it persistently.

Whitespace changes are still changes - whether they have meaning to 
other tools working with the files or not.

And yes, it gets obnoxious trying to track "real" changes through this 
mess.  <g>

Tortoise IIRC has a nice display at the bottom of its diff window;  it 
*will* actually show you the per-character changes for whichever line 
you click on.  However, that's not all that useful in your case...

[Brannon sent me a screenshot offlist;  here's a rough text 
representation of what it would look like in a shell - a fairly normal 
diff.]

--- merge1.txt
+++ merge2.txt
-if(a){
-	b
-	c
-	d
-	e
-	while(f){
-		if(g)
-			break;
+lock(sr){
+	if(a){
+		b
+		c
+		d
+		e
+		while(f){
+			if(g)
+				break;
	}
-	if(g && h && i)
-		return;
  }

-kgd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: incorrect diff / merge

Posted by Duncan Murdoch <mu...@stats.uwo.ca>.
On 3/29/2007 3:31 PM, Brannon King wrote:
> Thanks for responding. I don't know exactly what diff parameters the
> TortoiseSVN uses. But you are describing the exact issue I was having; the
> entire block is chucked when it should have aligned the "while" and "if"
> statements because white space is less valuable in programming than other
> characters. I guess what I want is some parameter that allows me to favor
> source-code type diffs.

TortoiseSVN (and svn) can be told to use an external diff.  On Windows, 
I recommend the (shareware) Beyond Compare.  It does a very nice job of 
displaying diffs.

Duncan Murdoch

>  
> 
> -----Original Message-----
> You'll have to be a little more detailed about your problem.  What command
> are you running to get the diff?  What are you getting back? 
> What are you *expecting* back?
> 
> The difference between those two fragments would usually (AKA as shown by
> diff -u) show up as a complete removal of the first block, followed by an
> addition of the whole second block.  If that's not what you're diffing,
> you'll need to tell us.
> 
> -kgd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: incorrect diff / merge

Posted by Brannon King <no...@gmail.com>.
Thanks for responding. I don't know exactly what diff parameters the
TortoiseSVN uses. But you are describing the exact issue I was having; the
entire block is chucked when it should have aligned the "while" and "if"
statements because white space is less valuable in programming than other
characters. I guess what I want is some parameter that allows me to favor
source-code type diffs.
 

-----Original Message-----
You'll have to be a little more detailed about your problem.  What command
are you running to get the diff?  What are you getting back? 
What are you *expecting* back?

The difference between those two fragments would usually (AKA as shown by
diff -u) show up as a complete removal of the first block, followed by an
addition of the whole second block.  If that's not what you're diffing,
you'll need to tell us.

-kgd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: incorrect diff / merge

Posted by Kris Deugau <kd...@vianet.ca>.
Brannon King wrote:
> I was informed from the TortoiseSVN mailing list that I need to post this
> problem here. The following two examples don't diff correctly (in my
> opinion). The "if" statement on the bottom should take priority over the
> indentation of the braces. Is there some setting I could tweak to improve
> the performance of the diff tool for code like this?

[snip code fragments]

You'll have to be a little more detailed about your problem.  What 
command are you running to get the diff?  What are you getting back? 
What are you *expecting* back?

The difference between those two fragments would usually (AKA as shown 
by diff -u) show up as a complete removal of the first block, followed 
by an addition of the whole second block.  If that's not what you're 
diffing, you'll need to tell us.

-kgd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org