Mercurial - 如何创建两个版本之间更改的文件的 .zip?
我有一个个人 Mercurial 存储库,用于跟踪我正在进行的一些更改。我想与协作者共享这些更改,但是他们没有/无法获取 Mercurial,因此我需要发送整个文件集,协作者将在其端进行合并。我正在寻找一种方法来提取在两个修订号之间修改的文件子集的“提示”版本。在 Mercurial 中有没有办法轻松做到这一点?
添加赏金 - 这对我们来说仍然是一个痛苦。我们经常与内部“客户”合作,他们将我们的源代码版本作为 .zip 进行发布,并且测试一个小修复程序更容易以 .zip 覆盖形式分发,而不是作为补丁分发(因为我们通常不知道他们的文件的状态) )。
I have a personal Mercurial repository tracking some changes I am working on. I'd like to share these changes with a collaborator, however they don't have/can't get Mercurial, so I need to send the entire file set and the collaborator will merge on their end. I am looking for a way to extract the "tip" version of the subset of files that were modified between two revision numbers. Is there a way to easily do this in Mercurial?
Adding a bounty - This is still a pain for us. We often work with internal "customers" who take our source code releases as a .zip, and testing a small fix is easier to distribute as a .zip overlay than as a patch (since we often don't know the state of their files).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
最好的情况是对这些人施加适当的压力以获取 Mercurial,但除此之外,补丁可能比压缩文件集更好,因为补丁将跟踪删除和重命名。如果您仍然想要 zip 文件,我已经编写了一个简短的脚本来制作 zip 文件:
用法是 nameofscript.py fromrevision 到revisiondestination。例如,
nameofscript.py 45 51 c:\updates.zip
抱歉,命令行界面很差,但是嘿,脚本只花了 25 分钟就写好了。
注意:这应该从存储库内的工作目录运行。
The best case scenario is to put the proper pressure on these folks to get Mercurial, but barring that, a patch is probably better than a zipped set of files, since the patch will track deletes and renames. If you still want a zip file, I've written a short script that makes a zip file:
The usage would be nameofscript.py fromrevision torevision destination. E.g.,
nameofscript.py 45 51 c:\updates.zip
Sorry about the poor command line interface, but hey the script only took 25 minutes to write.
Note: this should be run from a working directory within a repository.
出色地。
hg 导出 $base:tip > patch.diff 将生成一个标准补丁文件,大多数工具都可以读取该文件。
特别是,GNU patch 命令可以对以前的文件应用整个补丁。还不够吗?我不明白为什么你需要这组文件:对我来说,应用补丁似乎比从 zip 中提取文件并将它们复制到正确的位置更容易。 另外,如果您的协作者进行了本地更改,您将覆盖它们。您没有使用版本控制工具直接强迫其他人手动合并更改,对吗?老实说,让
patch
来解决这个问题:)Well.
hg export $base:tip > patch.diff
will produce a standard patch file, readable by most tools around.In particular, the GNU
patch
command can apply the whole patch against the previous files. Isn't it enough? I dont see why you would need the set of files: to me, applying a patch seems easier than extracting files from a zip and copying them to the right place. Plus, if your collaborator has local changes, you will overwrite them. You're not using a Version Control tool to bluntly force the other person to merge manually the changes, right? Letpatch
deal with that, honestly :)在 UNIX 中,这可以通过以下方式完成:
In UNIX this can be done with:
我还贡献了一个扩展,请参阅 bitbucket 上的 hgexportfiles 扩展 了解更多信息。导出文件扩展适用于给定的修订版或修订版范围,并在指定的目录中创建一组更改的文件。将目录压缩为脚本的一部分很容易。
I also contributed an extension, see the hgexportfiles extension on bitbucket for more info. The export files extension works on a given revision or revision range and creates the set of changed files in a specified directory. It's easy to zip the directory as part of a script.
据我所知,没有一个方便的工具可以做到这一点(尽管 Mercurial 插件可能是可行的)。您可以使用
hg export from:to
导出文件集的补丁(来自哪里并识别修订版本。)如果您确实需要如提示中所示的整个文件,您可能可以根据 hg diff --stat -r from:to 的输出来破解某些内容,该输出会输出一个文件列表,其中包含有关更改了多少行的注释,例如:如果您的文件名称中包含空格或特殊字符,您可以使用类似的内容:
我会将处理特殊字符作为读者的练习;)
To my knowledge, there's not a handy tool for this (though a mercurial plugin might be doable). You can export a patch for the fileset, using
hg export from:to
(where from and to identify revisions.) If you really need the entire files as seen on tip, you could probably hack something together based on the output ofhg diff --stat -r from:to
, which outputs a list of files with annotations about how many lines were changed, like:If none of your files have spaces or special characters in their names, you could use something like:
I'll leave dealing with special characters as an exercise for the reader ;)
这是一个小而丑陋的 bash 脚本,可以完成这项工作,至少如果您在 Linux 环境中工作的话。这绝对没有任何检查,并且当您移动文件时很可能会中断,但这是一个开始。
命令:
代码:
Here is a small and ugly bash script that will do the job, at least if you work in an Linux environment. This has absolutely no checks what so ever and will most likely break when you have moved a file but it is a start.
Command:
Code:
我知道您已经对此有了一些答案,但我的一位朋友也遇到了类似的问题,我在 VB.Net 中创建了一个简单的程序来为他执行此操作,也许它对您也有帮助,该程序和该程序的副本来源位于下面链接的文章底部。
http://www.simianenterprises.co.uk/ blog/mercurial-export-changed-files-80.html
虽然这目前不允许您选择最终版本,但在使用源代码时添加它会很容易,但是您必须更新在提取文件之前手动更改为目标版本。
如果需要,您甚至可以对其进行修改以创建 zip 而不是文件文件夹(这也很好且易于手动压缩)
希望这对您或任何需要此功能的其他人有所帮助。
I know you already have a few answers to this one but a friend of mine had a similar issue and I created a simple program in VB.Net to do this for him perhaps it could help for you too, the prog and a copy of the source is at the bottom of the article linked below.
http://www.simianenterprises.co.uk/blog/mercurial-export-changed-files-80.html
Although this does not let you pick an end revision at the moment, it would be very easy to add that in using the source, however you would have to update to the target revision manually before extracting the files.
If needed you could even mod it to create the zip instead of a folder of files (which is also nice and easy to manually zip)
hope this helps either you or anyone else who wants this functionality.
我刚刚在这里贡献了一个扩展 https://sites.google.com/site/alessandronegrin /pack-mercurial-扩展
i just contributed an extension here https://sites.google.com/site/alessandronegrin/pack-mercurial-extension
我最近遇到了这个问题。我的解决方案:
这将删除所有在这两个修订之间未更改的跟踪文件。不过,您必须自己删除所有未跟踪的文件。这样做之后,本地分支就会处于不一致的状态;您可以通过运行 hg debugrebuildstate 来修复此问题(或者直接删除本地分支,如果您不再需要它)。
I ran into this problem recently. My solution:
This will have the effect of deleting all tracked files that were not changed between those two revisions. You will have to remove any untracked files yourself, though. After doing this, the local branch will be in an inconsistent state; you can fix this by running
hg debugrebuildstate
(or simply deleting the local branch, if you no longer need it).