自动将特定的二进制文件转换为文本,以便在Mercurial中进行比较(比较) [英] Automatic conversion of specific binary files to text to compare (diff) in Mercurial
问题描述
我在Mercurial存储库中添加了几个-small-二进制文件.这些文件是我的一种开发工具(报告/表单/类定义)的源"文件.
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).
我制作了一个程序,将该二进制文件转储为文本文件,以便于它们之间的轻松区分.有没有办法告诉Mercurial,某些文件扩展名需要在运行diff程序之前运行此转换?还是我必须将转换程序设置为主要的diff工具并运行转换-否则-然后然后运行真正的diff程序?
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?
推荐答案
我在diff程序之前得到了一个 small 批处理:
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
,然后在%UserProfile%\.hgrc中配置批处理
and then config the batch in %UserProfile%\.hgrc
[extdiff]
cmd.ediff = d:\Utiles\diff2.bat
这篇关于自动将特定的二进制文件转换为文本,以便在Mercurial中进行比较(比较)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!