Lines to Omit regex case insensitivity?

Support for our DiffMerge utility.

Moderator: SourceGear

Post Reply
mksql
Posts: 2
Joined: Tue May 20, 2008 2:18 pm

Lines to Omit regex case insensitivity?

Post by mksql » Tue May 20, 2008 2:27 pm

I am trying to compare two trees of SQL object scripts that use different syntax for the IF EXISTS...DROP header. I wish to ignore these differences, and only look into the CREATE body. For example, the following are equivalent:

Code: Select all

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[view1]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[view1]
GO

CREATE VIEW dbo.view1
AS

SELECT * FROM dbo.table1

go

Code: Select all

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[view1]'))
DROP VIEW [dbo].[view1]
GO

CREATE VIEW dbo.view1
AS

SELECT * FROM dbo.table1

GO
However, DiffMerge 3.1.0 appears to hit on the text case differences. If I upper case all text in these scripts, then they show as equivalent.

My current approach is to create a Lines to Omit pattern in the ruleset, with pattern ^IF\s*(NOT)*\s*EXISTS, and skipping 3 lines (these headers are auto-generated, so I can assume simple patterns).

A screenshot with the results is attached. What is wrong with my approach?
Attachments
diffmerge310_test.jpg
diffmerge310_test.jpg (57.88 KiB) Viewed 12428 times
diffmerge310_test2.jpg
diffmerge310_test2.jpg (38.75 KiB) Viewed 12429 times

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Try this.

Post by jeffhostetler » Wed May 21, 2008 7:37 am

I'll dig into the regex case question.

For now, try adding a second "Lines to Omit" pattern with
lower case SQL syntax. This should cause the IF statement
on both sides to be ignored.

Hope this helps,
jeff

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Another suggestion.

Post by jeffhostetler » Wed May 21, 2008 8:09 am

You can also use the advanced regex syntax indicator ***:
and then use (?i) to turn on ignore-case at the beginning of
the regex.

So, your pattern should look like:

***:(?i)^IF\s*(NOT)*\s*EXISTS

I defaulted to advanced regex's everywhere in the program
except for dialog validation code, so that is why you need
the ***: first.

Hope this helps,
jeff

mksql
Posts: 2
Joined: Tue May 20, 2008 2:18 pm

Post by mksql » Wed May 21, 2008 9:07 am

The *** syntax works, for the file comparison, now showing the files as equivalent, skipping the omit lines.

However, when comparing two folders, the files still show up as different in the list of files, but opening the pair reports "Files are equivalent under the current RuleSet."

Is there an option that will allow the ruleset to filter in the folder view as well?

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Not currently.

Post by jeffhostetler » Wed May 21, 2008 9:39 am

Currently, the folder diff does raw byte comparisons on the pairs of
files; it doesn't use the Ruleset mechanism. This was done for speed;
folder diff can be doggy as it is.

The ability to let the folder diff code use the Ruleset mechanism is
a popular request. I'll add your vote.

jeff

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: Lines to Omit regex case insensitivity?

Post by jeffhostetler » Thu Apr 09, 2009 10:09 am

SourceGear DiffMerge 3.3.0 is now available and fixes these problems.

[1] I added the advanced regex flags to the code so that you won't need the prefix.
[2] I updated the folder window to (optionally) use some parts of the Ruleset to
try to minimize the chances of you getting the "Files are identical or equivalent..."
message box.

Full details can be found at http://www.sourcegear.com/diffmerge/index.html.

jeff hostetler

Post Reply