tags:

views:

321

answers:

8

Is there a diff tool, that allows me to write regular expression to remove a line from difference. Like see the two lines:

this.Visible = true;
Visible = true;

And can I write an expression such that if line difference is exactly this ignore the difference.

Can you please be specific on how to do that?

I give you one more example like System.Exception and Exception both are same for me, so I don't want to show them in the Diff.

+2  A: 

You can do this with KDiff3. See the documentation section on Preprocessor Commands.

Update: I see you have a further request that appears to need a semantic diff program. See Semantic Diff Utilities for some suggestions.

Greg Hewgill
Can you explain more, as I guess the preprocessor matches the whole line and you can't specify ignore when the difference is this.
Priyank Bolia
Right, you can't directly say "ignore this kind of difference". However, you can normalise the inputs so that the differences no longer appear. For example, to ignore the case of letters in the inputs, you might convert all uppercase characters to lowercase using the "line-matching preprocessor command". For your example, you could remove all instances of `this.` from your input lines using the same filter.
Greg Hewgill
that would give completely wrong results and that is not my question. I guess WinMerge also have line filtering. I am interested in Diff filtering.
Priyank Bolia
It sounds like you're more interested in a semantic diff, rather than a textual diff. I've updated my answer with a link to more info.
Greg Hewgill
that has accepted answer as Eclipse, which is no use to C# people. Also I still looking for something configurable rather than semantic diff, though I am doing semantic diff only, but hide only the diff that I am interested in.
Priyank Bolia
A: 

Notepad++ has a compare plugin, which is pretty configurable.

Jay Zeng
Can you tell me how to do that in Notepad++
Priyank Bolia
After you install notepad++, go to "Plugin" ->"Compare" , you will see a bunch of options there for you to configure, or you can choose the first option "Compare" (bonus: Alt+D) to perform diff.
Jay Zeng
I don't think you get the question. There is no such option where I can set the Regex.
Priyank Bolia
Jay Zeng
I know how to search and replace in notepad++, I am using it for years now, the question is about ignoring differences in diff tools.
Priyank Bolia
It is all about your regex in this case, if you have used it for years, then I guess you haven't spend enough time on digging it.
Jay Zeng
+1  A: 

DiffMerge from SourceGear supports this. You'll need to create a Ruleset that matches the files you are merging or edit the default Rule set. In the ruleset add patterns to the Lines to Omit property. See the Ommitted Lines property in the online help for more info.

David Norman
wrong answer (-1), where is the option. Please specify in detail how to ignore specific differences.
Priyank Bolia
Is this better?
David Norman
Already tried that is does not work. Added the pattern this[.] and also the ^(\s)*this[.](.)*$ but nothing works.
Priyank Bolia
+1  A: 

Best source comparing software that I ever used was BeyondCompare. With it, you could do exactly what you asked for: input a REGEX that told the software to ignore certain differences. However, it's not free.

If you really need a free applicative, you can try WinMerge. I'm not very fond of the interface, though.

Bruno Brant
And how to do that in BeyondCompare, I can't find a option in that, the interface is pretty messy.
Priyank Bolia
On version 2, on "File Compare", go to "Tools"->"Pick Rules"->"New rules". Then go to Importance tab, and on Unimportant Text click on "New", choose "Regular Expression", and ta-da!
Bruno Brant
If you are using version 3, let me know, I will look for the configuration.
Bruno Brant
Thanks I asked the support, and it looks like it working. Its in the Rules replacement tab. There is no Unimportant Text in ver 3. I guess they have modified it.
Priyank Bolia
this\.(.*) <> $1 available under the Text Compare's Session menu -> Session Settings, Replacements tab
Priyank Bolia
A: 

If you can't find an existing diff tool that will do what you want you could write your own.

Python has a diff module for writing diff-like tools, which will handle all the complexities of the diffing algorithm for you. They have an example script that will do a file diff in standard unix diff/patch format or side-by-side HTML in 60 lines of code.

The differs in the module let you define 'junk' filters to pre-process lines to remove parts that you do not want included in the diff. these are python functions so you are not limited to regex matches.

edit

I had a quick re-read of the docs and the filters only work for ignoring whole lines or individual chars, which is not what you want. However you can easily pre-process the data you feed into the differ to remove the text you want to ignore.

Dave Kirby
A: 

Not able to find in any few software the feature, though BC and Araxis have this feature, from the Winmerge Wiki it looks like they won't support plugins or any such feature in new future. Too Bad.

Priyank Bolia
A: 

If you know how to write JavaScript you can insert the regex in question into the minification portion of the Pretty Diff tool. The tool is entirely free and the code is completely open with inline documentation. If there is a specific feature you would like added to the tool, aside from a personal customization, please let me know and I will add it.

http://mailmarkup.org/prettydiff/prettydiff.html

To be honest, it doesn't look like a diff tool, in any sense. A good tool is one that doesn't need any time to learn and a good UI is that: Don't make me think.
Priyank Bolia
You get what you pay for. A good tool is one that comes with well written documentation.
A: 

Try GNU diffutils.

http://www.gnu.org/software/diffutils/manual/html_mono/diff.html#Specified%20Folding

If you are on windows, you can have GNU diff distributed with cygwin from www.cygwin.com.

Ken
don't think it is any different, it suppress the whole line as others and not just the difference. Correct me please, if I am wrong.
Priyank Bolia