I'm using C# and VB.NET.
我正在使用C#和VB.NET。
I often (every days...) add comments to existing source files. When I check-in these files, I would like to have my merge tool to ignore any changes made to comments - I just want to be sure that I did not change the code.
我经常(每天......)为现有的源文件添加注释。当我签入这些文件时,我想让我的合并工具忽略对注释所做的任何更改 - 我只是想确保我没有更改代码。
I use WinMerge and Team Foundation Control Server (yes, no chance : Subversion was not an option when I accepted this job :o). Both of them can ignore white spaces but cannot ignore comments. Result : I have to carefully look at all the changes that I have made to each file before checking them in. And this is pretty cumbersome.
我使用WinMerge和Team Foundation Control Server(是的,没有机会:当我接受这个工作时,Subversion不是一个选项:o)。它们都可以忽略空格但不能忽略注释。结果:在检查之前,我必须仔细查看我对每个文件所做的所有更改。这非常麻烦。
(Well, since most of my co-workers do not comment at all -- hey, they use pretty long namespace/class/methods/property/type/constant names that tell it all, guys ! -- it's a lot of work.)
(好吧,因为我的大多数同事都没有评论 - 嘿,他们使用相当长的名称空间/类/方法/属性/类型/常量名称来告诉所有人,伙计们! - 这是很多工作。 )
Any suggestions ?
有什么建议 ?
All the best, Sylvain.
一切顺利,西尔万。
6 个解决方案
#1
BeyondCompare has a filter for ignoring "unimportant" changes and comments belong to that category by default.
BeyondCompare有一个过滤器,用于忽略“不重要”的更改,默认情况下注释属于该类别。
#2
Compare++ has an option "Ignore comment changes" and "Ignore pure formatted changes" which should honor your request.
比较++有一个选项“忽略注释更改”和“忽略纯格式更改”,这应该符合您的请求。
#3
You said you used WinMerge - well it has the ability to filter out comments.
你说你使用过WinMerge - 它有能力过滤掉评论。
However it only works for comments that are on a separate line, so for example:
但是它仅适用于单独行上的注释,例如:
int i; // comment
will be detected as different from
将被检测为与...不同
int i;
#4
It sounds like you're using commenting as a tool to understand the code as you work with it. That's an interesting idea, the equivalent of highlighting a book or taking notes. But you need to make sure you strip out all these transient comments before working with others.
听起来你正在使用注释作为工具来理解代码。这是一个有趣的想法,相当于突出一本书或做笔记。但是,在与其他人合作之前,您需要确保删除所有这些短暂的评论。
Before comparing or promoting, run your source files through a filter program that strips the comment. This could be a one-liner perl script.
在比较或推广之前,通过删除注释的过滤器程序运行源文件。这可能是一个单行的perl脚本。
To make it easier, use a distinctive pattern for your non-permanent comments, to make them easier to filter out (and to distinguish between these transient comments, and comments you really want to leave in the source). E.g. if you were writing in C++, always comment using
为了方便起见,请为您的非永久性注释使用独特的模式,以便更容易过滤掉(以及区分这些瞬时注释以及您真正希望留在源中的注释)。例如。如果您使用C ++编写,请始终使用注释
//Sylvain: this is my comment here.
or some other pattern that is even easier to grep for.
或其他一些更容易grep的模式。
#5
If the content of the comments are not something you care about, and do not matter, why not delete them?
如果评论的内容不是您关心的内容,并不重要,为什么不删除它们呢?
If well documented code that is readable and understandable is part of what you create, why not review changes to that meta-data?
如果记录良好且可读且易懂的代码是您创建的代码的一部分,为什么不查看对该元数据的更改?
#6
Adding comment to your code is smell that your code is hard to read, code should be self describing, like someone has said that , good code is like good joke, it does not need to be explained. It is better to change your variable name, put section of your code into a subroutine. Re factoring is better than commenting. Even you find a tool to solve you commenting problem, it does not solve the real problem that is make you code easy to understand.
在你的代码中添加注释会发现你的代码难以阅读,代码应该是自我描述的,就像有人说的那样,好的代码就像是一个好笑话,不需要解释。最好更改变量名,将代码段放入子程序中。重新分解比评论更好。即使你找到一个工具来解决你的评论问题,它也无法解决使代码易于理解的真正问题。
#1
BeyondCompare has a filter for ignoring "unimportant" changes and comments belong to that category by default.
BeyondCompare有一个过滤器,用于忽略“不重要”的更改,默认情况下注释属于该类别。
#2
Compare++ has an option "Ignore comment changes" and "Ignore pure formatted changes" which should honor your request.
比较++有一个选项“忽略注释更改”和“忽略纯格式更改”,这应该符合您的请求。
#3
You said you used WinMerge - well it has the ability to filter out comments.
你说你使用过WinMerge - 它有能力过滤掉评论。
However it only works for comments that are on a separate line, so for example:
但是它仅适用于单独行上的注释,例如:
int i; // comment
will be detected as different from
将被检测为与...不同
int i;
#4
It sounds like you're using commenting as a tool to understand the code as you work with it. That's an interesting idea, the equivalent of highlighting a book or taking notes. But you need to make sure you strip out all these transient comments before working with others.
听起来你正在使用注释作为工具来理解代码。这是一个有趣的想法,相当于突出一本书或做笔记。但是,在与其他人合作之前,您需要确保删除所有这些短暂的评论。
Before comparing or promoting, run your source files through a filter program that strips the comment. This could be a one-liner perl script.
在比较或推广之前,通过删除注释的过滤器程序运行源文件。这可能是一个单行的perl脚本。
To make it easier, use a distinctive pattern for your non-permanent comments, to make them easier to filter out (and to distinguish between these transient comments, and comments you really want to leave in the source). E.g. if you were writing in C++, always comment using
为了方便起见,请为您的非永久性注释使用独特的模式,以便更容易过滤掉(以及区分这些瞬时注释以及您真正希望留在源中的注释)。例如。如果您使用C ++编写,请始终使用注释
//Sylvain: this is my comment here.
or some other pattern that is even easier to grep for.
或其他一些更容易grep的模式。
#5
If the content of the comments are not something you care about, and do not matter, why not delete them?
如果评论的内容不是您关心的内容,并不重要,为什么不删除它们呢?
If well documented code that is readable and understandable is part of what you create, why not review changes to that meta-data?
如果记录良好且可读且易懂的代码是您创建的代码的一部分,为什么不查看对该元数据的更改?
#6
Adding comment to your code is smell that your code is hard to read, code should be self describing, like someone has said that , good code is like good joke, it does not need to be explained. It is better to change your variable name, put section of your code into a subroutine. Re factoring is better than commenting. Even you find a tool to solve you commenting problem, it does not solve the real problem that is make you code easy to understand.
在你的代码中添加注释会发现你的代码难以阅读,代码应该是自我描述的,就像有人说的那样,好的代码就像是一个好笑话,不需要解释。最好更改变量名,将代码段放入子程序中。重新分解比评论更好。即使你找到一个工具来解决你的评论问题,它也无法解决使代码易于理解的真正问题。