Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure BeyondCompare to ignore SCM replaced text in comments?

I do have some text sequences that are replaced by the SCM (Perforce in my case).

I do want to configure BeyondCompare to consider these sequences as unimportant differences in order to be able to ignore them when I compare files.

In my case it's about Python source files and the sequences are looking like

# $Id: //depot/.../filename#7 $
# $DateTime: 2010/09/01 10:45:29 $
# $Author: username $
# $Change: 1234 $

Sometimes these sequences can be outside comments, but even in this cases I would like to be able ignore these lines because they are not really changed.

like image 999
sorin Avatar asked Sep 06 '10 14:09

sorin


People also ask

How do I ignore comments on beyond compare?

To ignore text differences, define a new Grammar element (what the text is), then mark it as unimportant.

How do I ignore case sensitive beyond compare?

If you are doing "Text compare", then you should make sure that "Character case" is not selected in the "Imporantance" tab, then choose "Ignore Unimportant Differences" -- that will do a case-insensitive compare. Save this answer.

How do you comment on beyond compare?

Select the format that matches your files. Go to the Grammar tab. Select the Comment grammar element, which might be defined as # to end of line.


2 Answers

You need to define a new grammar element (let's call it "SCM") and mark it as unimportant (see the tutorial here; choose "Basic" and make sure to check "Regular Expression").

The grammar element should be (if I interpret your examples correctly):

^.*\$(Id|DateTime|Author|Change):.*$

This will ignore any line that contains $Id:, $DateTime: etc.

If you only want to ignore lines that start with # $..., use

^\s*#s*\$(Id|DateTime|Author|Change):.*$

And if you only want to ignore stuff between $ (and treat everything else as important), use

\$[^$\r\n]*\$

or

\$(Id|DateTime|Author|Change)[^$\r\n]*\$

depending on whether you care about those keywords or not.

like image 87
Tim Pietzcker Avatar answered Sep 29 '22 15:09

Tim Pietzcker


Beyond Compare's parser doesn't currently (v3/v4) support nested elements, so file formats grammars can't be used to mark an SCM sequence as unimportant for a specific file type if the text is already classified as a comment, string, etc.

Beyond Compare 4.0 added support for marking arbitrary text as unimportant across an entire comparison, separate from the grammar.

  1. Load the files you're interested in
  2. Click the Session Settings button (aka Rules w/ umpire icon) or use the Session->Session Settings menu item.
  3. Switch to the Importance tab
  4. Click the + button at the bottom of the Unimportant text list.
  5. Add the plain text or regular expression to Text to find edit and check the Regular Expression checkbox if necessary. In this case the regular expression would be:
    \$(Id|DateTime|Author|Change):.*\$
  6. Click Ok.
  7. By default these changes will only affect the current comparison. You can change the combobox at the bottom of the Session Settings dialog from Use for this view only to Also update session defaults to make it affect all future comparisons for all file types.
like image 28
Zoë Peterson Avatar answered Sep 29 '22 14:09

Zoë Peterson