Mercurial 中各种文件的特定提交消息

发布于 2024-11-27 06:06:25 字数 108 浏览 0 评论 0原文

在我的 Mercurial 存储库中,我修改了 4 个文件,

当我进行提交时,提交消息应用于我修改的所有文件,但是,有任何形式可以为我在提交屏幕中修改的每个文件编写特定的提交消息吗? ?

In My Mercurial Repository, I have 4 files I modified,

When I make a Commit, The commit message applied to all Files I modified, but, there are any form to write a specific commit message for every file I modified in the commit screen??

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

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

发布评论

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

评论(3

星光不落少年眉 2024-12-04 06:06:25

理想情况下,每个变更集都应该包含一些特定的更改,无论是小到通过更正文件中的一行来修复小错误,还是大到更改整个代码库中函数的签名。

这允许您稍后执行诸如将变更集移植到不同分支之类的操作,只有当您的变更集没有被不相关的内容污染时,这才容易。

,这是现代 DVCS(例如 Mercurial 或 Git)与旧系统(例如跟踪修订版本的 SVN)之间的主要区别。现代 DVCS 跟踪更改。)

(顺便说一句 就像您需要为每个文件编写单独的注释一样,这可能意味着您实际上一次提交了几个不相关的更改,这不是一个好的做法。

另一方面,如果不是这种情况,你当然可以编写多行消息:

User can no longer add the same product twice (issue123)

add_product.py: added server-side validation
scripts.js: added client-side validation

Ideally, every changeset should contain some specific change, be it something as small as fixing a small bug by correcting a single line in a file, or something as big as changing the signature of a function all over the codebase.

This allows you to do things like transplanting a changeset to a different branch later, which is only easy when your changesets are not polluted by unrelated stuff.

(By the way, this is the main difference between modern DVCS like Mercurial or Git, which track changes, and older systems like SVN, which track revisions.)

If you feel like you need to write separate comments for every file, this might mean you're actually committing several unrelated changes at once, which isn't good practice.

On the other hand, if it's not the case, you can of course write a multi-line message:

User can no longer add the same product twice (issue123)

add_product.py: added server-side validation
scripts.js: added client-side validation
滿滿的愛 2024-12-04 06:06:25

如果您使用命令行,您可以通过在 hg commit 命令行上传递单个文件来提交对它们的更改:

> hg st
M file1.cpp
M file1.h
M file2.cpp
M file2.h
> hg commit -m "Some changes" file1.cpp file1.h
> hg st
M file2.cpp
M file2.h

您可以使用 TortoiseHg 执行相同的操作,只需“检查”您想要检查的文件在 thg commit 窗口中 - 或者更准确地说,通过取消选中那些您不想提交的内容。

但请注意,这将创建多个变更集,每个变更集对应一个提交。如果这不是你想要的,那么我会同意 Helgi 的观点。

在 TortoiseHg 的早期版本中(当它是使用 tk 编写时,所以不是很久以前),实际上可以选择文件更改的单个“块”并单独提交它们。然而,当前版本中尚不提供此功能,而且据我所知,暂时还没有计划。

If you are using the command line, you can commit changes to individual files by passing them on the hg commit command line:

> hg st
M file1.cpp
M file1.h
M file2.cpp
M file2.h
> hg commit -m "Some changes" file1.cpp file1.h
> hg st
M file2.cpp
M file2.h

You can do the same thing using TortoiseHg by only "checking" the files you want checked in in the thg commit window - or more precisely, by unchecking those you don't want committed.

Note however that this will create several changesets, one for each commit. If this is not what you want, then I would agree with Helgi.

In a previous version of TortoiseHg (back when it was written using tk, so not that long ago), it was actually possible to select individual "chunks" of changes to a file and commit them separately. However this is not available in the current version, and as far as I am aware is not planned for a while.

得不到的就毁灭 2024-12-04 06:06:25

实际上,提交消息适用于变更集,其中包含对您修改的文件的更改。

如果您想解决对每个文件的更改,您可以创建多行消息:

new features, fixed bugs, etc.
file1.txt: fixed bug 1234
file2.txt: refactored body of Foobar()
file3.txt: did Rot13 on the entire file, twice
file4.txt: added overload of Bar() to except a second Foo object

但是,我不建议为每个文件执行更改集,尽管这是可能的。

Actually, the commit message applies to the changeset, which contains changes to the files you modified.

You could make multi-line messages if you want to address the changes to each file:

new features, fixed bugs, etc.
file1.txt: fixed bug 1234
file2.txt: refactored body of Foobar()
file3.txt: did Rot13 on the entire file, twice
file4.txt: added overload of Bar() to except a second Foo object

I don't recommend doing a changeset for each file, however, even though that is possible.

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