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

发布于 2024-08-15 12:24:50 字数 231 浏览 6 评论 0原文

直到最近,我们一直在网络工作室的所有项目中使用 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 技术交流群。

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

发布评论

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

评论(4

友欢 2024-08-22 12:24:50

基于 Jerome 的答案,这将为您提供修订版 4 中更改的文件副本

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

这会将修订版 4 中更改的所有文件放入您的主目录中新创建的名为changedfiles 的目录中。

如果将其更改为:

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

那么它们将显示在 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:

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.

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.

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.

你对谁都笑 2024-08-22 12:24:50

这将为您提供修订版 4 中修改的文件列表:

hg log -r 4 --template {files}

更新: 如果您希望每行一个文件,您可以使用 Hg 书中描述的样式

This gives you the list of modified files in revision 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.

吾家有女初长成 2024-08-22 12:24:50

根据您的 ned,有两个命令:

  1. 要获取与特定修订版相关的更改,您可以使用 hg export

    <前><代码>hg 导出 -r 23

这将生成所有更改的差异(实际上是一个格式化的补丁,准备应用)

  1. 要获取所有受影响的文件的名称,您可以使用 hg log

    <前><代码>hg log -r 23 -v

这将打印修订版本的元信息以及文件名称受到影响的。

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 -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 -r 23 -v
    

This will print the meta-info for the revision, along with the names of the files that were affected.

作业与我同在 2024-08-22 12:24:50

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

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

This command outputs names of all changed files in a specified revision:

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