简体   繁体   English

如何在Mercurial中提取变更集的所有已更改文件?

[英]How can I extract all changed files of a changeset in Mercurial?

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. 直到最近,我们一直在为我们的网络工作室的所有项目使用SVN,并且在Subversive和TortoiseSVN等几个客户端中存在一个非常方便的功能,可以提取在某个修订版中已更改的所有文件。

Is there a way to do it in Mercurial? 有没有办法在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. 我不关心它是通过GUI还是命令行完成的,拥有一组在某个变更集中已更改的文件非常方便。

PS I must have put it wrong the first time. PS我第一次肯定说错了。 I need more than just a list of files, it would be great to have all the files exported to some other folder. 我需要的不仅仅是文件列表,将所有文件导出到其他文件夹会很棒。

Building on Jerome's answer this will get you the copies of the files that changed in revision 4: 在Jerome的答案的基础上,这将获得修订版4中更改的文件副本

hg archive --type files --rev 4 -I $(hg log -r 4 --template {files} | sed 's/ / -I /g') ~/changedfiles

That puts all the files that changed into revision four into a newly created directory named changedfiles in your homedir. 这会将所有更改为修订版本4的文件放入homedir中名为changedfiles的新创建的目录中。

If you change it to: 如果您将其更改为:

hg archive --type zip --rev 4 -I $(hg log -r 4 --template {files} | sed 's/ / -I /g') ~/changedfiles.zip

then they show up in a zip archive. 然后他们出现在一个zip存档中。

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. 如果你犯了这个错误,那么我们将需要使用hg status --print0 -r revision -r parent-of-revision ,但希望这不是必需的。

Note also that the revision number, '4' in our example, shows up twice. 另请注意,我们示例中的修订号“4”显示两次。 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. 整个事情可以很容易地包装在一个shell脚本中,并且这将被参数化,因此您不必记住在两个地方都更改它。

This gives you the list of modified files in revision 4: 这将为您提供修订版4中已修改文件的列表:

hg log -r 4 --template {files}

Update: If you'd like to have one file per line, you may use the style described in Hg book . 更新:如果您希望每行有一个文件,可以使用Hg书中描述的样式

Depending on your ned, there are two command: 根据您的需要,有两个命令:

  1. To get the changes associated with a particular revision, you can use hg export : 要获取与特定修订关联的更改,可以使用hg export

     hg export -r 23 

This will generate a diff of all the changes (actually a formatted patch, ready to be applied) 这将生成所有更改的差异(实际上是格式化的补丁,准备应用)

  1. To get the name all the files that were affected, you can use hg log : 要获取受影响的所有文件的名称,可以使用hg log

     hg log -r 23 -v 

This will print the meta-info for the revision, along with the names of the files that were affected. 这将打印修订的元信息以及受影响的文件的名称。

此命令输出指定修订中所有已更改文件的名称:

hg export revision_num | grep ^diff | cut -f 6 -d ' '

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM