如何配置 BeyondCompare 以忽略注释中 SCM 替换的文本?

发布于 2024-09-17 20:58:43 字数 331 浏览 2 评论 0原文

我确实有一些被 SCM 替换的文本序列(在我的例子中是 Perforce)。

我确实想配置 BeyondCompare 将这些序列视为不重要的差异,以便在比较文件时能够忽略它们。

在我的例子中,它是关于Python源文件的,序列看起来像

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

有时这些序列可以在注释之外,但即使在这种情况下,我也希望能够忽略这些行,因为它们并没有真正改变。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

被翻牌 2024-09-24 20:58:43

您需要定义一个新的语法元素(我们称之为“SCM”)并将其标记为不重要(请参阅此处的教程;选择“基本”并确保选中“正则表达式”)。

语法元素应该是(如果我正确解释你的例子):

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

这将忽略任何包含 $Id:, $DateTime: 等的行。

如果你只想忽略以 # $... 开头的行,使用

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

如果您只想忽略 $ 之间的内容(并将其他所有内容视为重要),请使用

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

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

取决于您是否关心这些关键词与否。

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.

情感失落者 2024-09-24 20:58:43

Beyond Compare 的解析器当前 (v3/v4) 不支持嵌套元素,因此如果文本已被分类为注释、字符串等,则文件格式语法不能用于将 SCM 序列标记为对特定文件类型不重要 Beyond Compare 4.0 添加了对在整个比较中将任意文本

标记为不重要的支持,与语法分开。

  1. 加载您感兴趣的文件
  2. 单击会话设置按钮(又名带有裁判员图标的规则)或使用会话->会话设置 菜单项。
  3. 切换到重要性选项卡
  4. 单击不重要文本列表底部的+ 按钮。
  5. 将纯文本或正则表达式添加到要查找的文本编辑中,并在必要时选中正则表达式复选框。在这种情况下,正则表达式为:
    \$(Id|DateTime|作者|更改):.*\$
  6. 单击确定
  7. 默认情况下,这些更改只会影响当前比较。您可以将“会话设置”对话框底部的组合框从仅用于此视图更改为同时更新会话默认值,以使其影响所有文件类型的所有未来比较。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文