在 Mercurial 中将一对文件作为一个文件进行管理

发布于 2024-12-08 23:39:23 字数 320 浏览 1 评论 0原文

我正在 Mercurial 中使用小型二进制文件 发布

这个二进制文件可以转储为文本以在版本之间进行比较,但问题是这些文件成对出现(例如:Form.scx / Form.sct),并且我找不到一种方法来告诉 Mercurial“制作一个当我执行 hg ediff 时,其他相应文件的快照”(复制到临时位置)。

I'm working with small binary files in Mercurial as posted.

This binary files can be dumped as text to make a diff between versions, but the problem is that the files comes in pairs (eg: Form.scx / Form.sct), and I cannot found a way to tell Mercurial to "make a snapshot" (copy to a temporary location) of the other corresponding file when I do an hg ediff.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

弄潮 2024-12-15 23:39:23

只需制作一个快速脚本并将其设置为 extdiff 的工具即可。我猜您使用的是 Windows,但无论与此等效的 powershell 是什么:

#!/bin/sh
binary-to-text $1 /tmp/$1.sct
binary-to-text $2 /tmp/$2.sct
diff /tmp/$1.sct /tmp/$2.sct
rm /tmp/$1.sct /tmp/$2.sct

它都会创建、比较然后删除文本版本。您需要小心不要覆盖,处理多个并发调用等。

然后配置一个新命令来运行您的脚本:

[extdiff]
cmd.mydiff = that_script_above.sh

然后您可以执行以下操作:

hg mydiff

理想情况下,您的存储库中只有“源”bonary 格式,不是文本格式,因为您不应该将生成的项目保留在存储库中 - 因为如果您更新其中一个而不是另一个,则会出现不一致的状态。根据需要生成可比较的文本文件是更好的方法。

Just make a quick script and set that as the tool for extdiff. I'm guessing you're on Windows, but whatever the powershell equivalent to this is:

#!/bin/sh
binary-to-text $1 /tmp/$1.sct
binary-to-text $2 /tmp/$2.sct
diff /tmp/$1.sct /tmp/$2.sct
rm /tmp/$1.sct /tmp/$2.sct

That creates, compares, and then deletes the text versions. You'd want to be careful to not overwrite, deal with multiple concurrent invocations, etc.

Then configure a new command to run your script:

[extdiff]
cmd.mydiff = that_script_above.sh

Then you can do things like:

hg mydiff

Ideally you have only the "source" bonary format in your respository, not the text format, as you shouldn't keep generated items in the repo -- because if you update one but not the other you have an inconsistent state. Generating the comparable text files on demand is a better way to go.

过潦 2024-12-15 23:39:23

正如 @Ryan 所建议的,我最终在 diff 程序之前得到了一个批次:

@echo off
set f1=%1
set f2=%2
::Temporary dir created by hg to copy the snapshot file
set tdir=%~dp1
::Original repository dir
set repo=%~dp2
::Filename extension
set ext=%~x1
::The binary files comes in pairs: scx/sct \ vcx/vct ...
set ex2=%ext:~0,-1%t

::Check if "dumpable" extension
echo %ext% | grep -iE "(vcx|vct|scx|sct|pjx|pjt|frx|frt)" > nul && goto DumpFile
goto diff

:DumpFile
set f1="%tdir%\_Dump1.prg"
set f2="%tdir%\_Dump2.prg"
::Get the pair file from the repository
hg cat %repo%\%~n1%ex2% -o "%~dpn1%ex2%" -R %repo%

::Do the dump, then the diff
MyDumpProgram.exe %1 %f1%
MyDumpProgram.exe %2 %f2%
goto diff

:diff
ExamDiff.exe %f1% %f2%
pause

然后在 %UserProfile%\.hgrc 中配置该批次

[extdiff]
cmd.ediff = d:\Utiles\diff2.bat

As suggested by @Ryan, I ended up with a small batch previous to the diff program:

@echo off
set f1=%1
set f2=%2
::Temporary dir created by hg to copy the snapshot file
set tdir=%~dp1
::Original repository dir
set repo=%~dp2
::Filename extension
set ext=%~x1
::The binary files comes in pairs: scx/sct \ vcx/vct ...
set ex2=%ext:~0,-1%t

::Check if "dumpable" extension
echo %ext% | grep -iE "(vcx|vct|scx|sct|pjx|pjt|frx|frt)" > nul && goto DumpFile
goto diff

:DumpFile
set f1="%tdir%\_Dump1.prg"
set f2="%tdir%\_Dump2.prg"
::Get the pair file from the repository
hg cat %repo%\%~n1%ex2% -o "%~dpn1%ex2%" -R %repo%

::Do the dump, then the diff
MyDumpProgram.exe %1 %f1%
MyDumpProgram.exe %2 %f2%
goto diff

:diff
ExamDiff.exe %f1% %f2%
pause

and then config the batch in %UserProfile%\.hgrc

[extdiff]
cmd.ediff = d:\Utiles\diff2.bat
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文