我正在使用Mercurial中的小型二進制文件作爲posted。在Mercurial中管理一對文件
這個二進制文件可以作爲文本轉儲以在版本之間進行區分,但問題是這些文件是成對出現的(例如:Form.scx/Form.sct),並且我找不到一種方法來告訴Mercurial當我做hg ediff
時,爲另一個對應文件「製作快照」(複製到臨時位置)。
我正在使用Mercurial中的小型二進制文件作爲posted。在Mercurial中管理一對文件
這個二進制文件可以作爲文本轉儲以在版本之間進行區分,但問題是這些文件是成對出現的(例如:Form.scx/Form.sct),並且我找不到一種方法來告訴Mercurial當我做hg ediff
時,爲另一個對應文件「製作快照」(複製到臨時位置)。
正如@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
只需製作一個快速腳本並將其設置爲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格式,而不是文本格式,因爲您不應該在回購庫中保留生成的項目 - 因爲如果更新一個而不是另一個,則會出現不一致的狀態。根據需要生成可比較的文本文件是更好的方法。