Automatic conversion of specific binary files to text to compare (diff) in Mercurial

白昼怎懂夜的黑 提交于 2020-01-04 13:49:31

问题


I have several -small- binary files added in my Mercurial repository. The files are the "source" files of one of my development tools (report / form / class definitions).

I made a program that dumps this binary files to a text file to allow easy diffs between them. Is there any way to tell Mercurial that certain file extensions need to run this conversion before running the diff program? Or I have to set my conversion program as the main diff tool and run the conversion -or not- and then run the real diff program?


回答1:


You can (TBT) use ExtDiff extension for pure Mercurial. In case of TortoiseHG

[diff-patterns]
**.ext = difftool

in hgrc plays the game




回答2:


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


来源:https://stackoverflow.com/questions/7707087/automatic-conversion-of-specific-binary-files-to-text-to-compare-diff-in-mercu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!