如何提取 Mercurial 中变更集的所有已更改文件?
直到最近,我们一直在网络工作室的所有项目中使用 SVN,并且 Subversive 和 TortoiseSVN 等多个客户端中存在一个非常方便的功能,可以提取在某个版本中更改的所有文件。
Mercurial 有没有办法做到这一点?我不在乎它是通过 GUI 还是命令行完成的,拥有一组在某个变更集中已更改的文件非常方便。
PS我第一次一定是写错了。我需要的不仅仅是文件列表,如果将所有文件导出到其他文件夹就太好了。
Until recently we have been using SVN for all projects of our web studio, and there is a very convenient feature present in several clients like Subversive and TortoiseSVN that can extract all files that have been changed in a certain revision.
Is there a way to do it in Mercurial? I don't care if it's done via a GUI or a command line, it's just very convenient to have a set of files that have been changed in a certain changeset.
P.S. I must have put it wrong the first time. I need more than just a list of files, it would be great to have all the files exported to some other folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
基于 Jerome 的答案,这将为您提供修订版 4 中更改的文件副本:
这会将修订版 4 中更改的所有文件放入您的主目录中新创建的名为changedfiles 的目录中。
如果将其更改为:
那么它们将显示在 zip 存档中。
值得注意的是,只有当文件名中没有空格时,这才有效。如果您犯了这个错误,那么我们需要使用 hg status --print0 -r revision -rparent-of-revision 来代替,但希望这不是必需的。
另请注意,版本号(在我们的示例中为“4”)出现了两次。整个事情可以很容易地包装在 shell 脚本中,并且可以参数化,这样您就不必记住在两个地方都更改它。
Building on Jerome's answer this will get you the copies of the files that changed in revision 4:
That puts all the files that changed into revision four into a newly created directory named changedfiles in your homedir.
If you change it to:
then they show up in a zip archive.
It's worth noting that that only works if you have no spaces in filenames. If you made that blunder then we'll need to use
hg status --print0 -r revision -r parent-of-revision
instead, but hopefully that's not necessary.Note also that the revision number, '4' in our example, shows up twice. The whole thing could very easily be wrapped in a shell script, and that would be parameterized so you don't have to remember to change it in both places.
这将为您提供修订版 4 中修改的文件列表:
更新: 如果您希望每行一个文件,您可以使用 Hg 书中描述的样式。
This gives you the list of modified files in revision 4:
Update: If you'd like to have one file per line, you may use the style described in Hg book.
根据您的 ned,有两个命令:
要获取与特定修订版相关的更改,您可以使用
hg export
:<前><代码>hg 导出 -r 23
这将生成所有更改的差异(实际上是一个格式化的补丁,准备应用)
要获取所有受影响的文件的名称,您可以使用
hg log
:<前><代码>hg log -r 23 -v
这将打印修订版本的元信息以及文件名称受到影响的。
Depending on your ned, there are two command:
To get the changes associated with a particular revision, you can use
hg export
:This will generate a diff of all the changes (actually a formatted patch, ready to be applied)
To get the name all the files that were affected, you can use
hg log
:This will print the meta-info for the revision, along with the names of the files that were affected.
此命令输出指定修订版中所有已更改文件的名称:
This command outputs names of all changed files in a specified revision: