hg 将补丁应用于工作目录是什么意思?

What does it mean that hg applies a patch to a working directory?

我这辈子第一次尝试使用补丁(恢复损坏的存储库)。所以我对这个概念不是很熟悉,虽然我读过一点。我正在使用 TortoiseHg。我已经创建了一个补丁(作为文件),切换到另一个存储库,并正在尝试导入它。我已经要求 THg 将它导入到存储库(其他选项是 Shelf 和 Working Directory)。当我单击“导入”时,THg 说补丁已导入到工作目录并且控制台显示:

% hg import --verbose --"PATH59.patch"
applying PATH59.patch
applied to working directory
[command completed successfully DATE]

而且我在历史记录中没有看到任何变化 window(无修订版 1059)。我想知道我现在应该做什么或者我做错了什么。

我在 Windows 10,TortoiseHg 4.9 和 Mercurial 4.9。

当您的工作目录中的某些内容以任何方式被修改时,它不会自动影响您存储库中的任何内容。您必须手动提交此类更改。

对于命令行hg patch我认为默认是自动提交。可能是 THG 使用了 --no-commit 选项。您可以在 THG 输出/日志 window.

中检查这一点

对于命令行,帮助里也有这个注释import ...

first applies changes to the working directory (unless --bypass is specified), import will abort if there are outstanding changes.

THG 导入 window 如下所示:

根据the docs

You have the choice of importing directly into the repository, the working folder, a shelf file, or your patch queue.

我想如果您检查 "patches will be imported to" 下拉菜单,它可能设置为 "working directory" 或类似的。如果您将其更改为 "Repository",我认为它会为您提交。

除非提供更好的答案,否则我必须假设此行为是由于存储库损坏造成的:在对未损坏的存储库执行完全相同的操作时不会观察到这种情况。