Free diff tool that is configurable? [closed]
Asked Answered
P

8

1

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 the line difference is exactly this ignore the difference.

How do I specifically do that?

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

Presbytery answered 22/12, 2009 at 18:10 Comment(5)
Instead of forcing a diff tool to do the exact opposite of what it's supposed to do (show you what is different), and relying on availability of such a tool, why not use a simple tool like sed or m4 to patch the file first?Cumshaw
patching file would change contents, and how would you patch a file partially, not all this or System are removed. I just want to ignore those that causing any diff.Presbytery
The other thing I would consider is that this is simply a bad practice. this.xxx does not mean the same thing as xxx. The first gets you the xxx property of the current object, the second gets the xxx in the nearest scope. There could be a bug that you miss as a result of ignoring the differences. It just seems like a bad habit to get into. In any case, good luck in finding a solution.Cumshaw
I suppose that it depends on why you are doing the diff in the first place. Presumably, it's part of your source control check-in process? If so, then just take the opportunity to resolve the differences between the 2 files (To whatever your organisations coding standard is) and check the file in - the problem should then no longer be an issue. My apologies if my assumptions are incorrectStem
@belugabob: Ok, let me explain, first of all I don't care whether I am removing correct 'this.' or not, I have lots of such differences and I want to focus on just the important one, and 'this.' is non important to me, as most of the refactoring is done by me only using CodeRush, so I know they are right, but before checking I need to double check what I am checking in. Why this feature is important may be the scootersoftware.com/videos/WN3Replacements.html video will explain more, but this is important to me. "resolve the differences between the 2 files" I don't get how's that diffPresbytery
P
0

I was not able to find the feature in any software, though Beyond Compare 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.

Presbytery answered 24/12, 2009 at 9:35 Comment(0)
C
3

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.

Customhouse answered 22/12, 2009 at 18:16 Comment(5)
Can you explain more, as I guess the preprocessor matches the whole line and you can't specify ignore when the difference is this.Presbytery
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.Customhouse
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.Presbytery
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.Customhouse
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.Presbytery
H
1

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.

Humbertohumble answered 22/12, 2009 at 18:18 Comment(2)
wrong answer (-1), where is the option. Please specify in detail how to ignore specific differences.Presbytery
Already tried that is does not work. Added the pattern this[.] and also the ^(\s)*this[.](.)*$ but nothing works.Presbytery
S
1

The best source comparing software that I ever used was Beyond Compare. With it, you could do exactly what you asked for: input a regular expression 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.

Scutch answered 22/12, 2009 at 18:44 Comment(5)
And how to do that in BeyondCompare, I can't find a option in that, the interface is pretty messy.Presbytery
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!Scutch
If you are using version 3, let me know, I will look for the configuration.Scutch
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.Presbytery
this\.(.*) <> $1 available under the Text Compare's Session menu -> Session Settings, Replacements tabPresbytery
M
0

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

Microbiology answered 22/12, 2009 at 18:17 Comment(6)
Can you tell me how to do that in Notepad++Presbytery
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.Microbiology
I don't think you get the question. There is no such option where I can set the Regex.Presbytery
The search & replace dialog already allows you to do regex.Microbiology
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.Presbytery
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.Microbiology
A
0

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 regular expression matches.

I had a quick re-read of the documentation, 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.

Anagram answered 22/12, 2009 at 20:42 Comment(0)
P
0

I was not able to find the feature in any software, though Beyond Compare 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.

Presbytery answered 24/12, 2009 at 9:35 Comment(0)
Z
0

If you know how to write JavaScript you can insert the regular expression 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.

Zarathustra answered 1/1, 2010 at 5:19 Comment(2)
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.Presbytery
You get what you pay for. A good tool is one that comes with well written documentation.Zarathustra
B
0

Try GNU diffutils. If you are on Windows, you can have GNU diff distributed with Cygwin from www.cygwin.com.

Bankbook answered 1/1, 2010 at 5:35 Comment(1)
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.Presbytery

© 2022 - 2024 — McMap. All rights reserved.