CorneliuTusnea
28-Mar-2006, 10:17 PM
Hi,
I've been spending a bit of time trying to integrate BC with VS to allow me to easly select files to be compared in and out of VS. (We use lots of branches so I wanted to be efficient about comparing code.) Here are two bat scripts can can easly be installed in Tools->External tools in VS that integrate VS with BC.
1. BC-Left.bat
Set left file for BC.
This will set the key in the
HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx\Linked to the selected file, thus you can then use VS to select the right file or use the explorer shell extension to select the right file.
@echo off
rem del bc-left.reg
SET Line=%1
:: Remove quotes from the line
SET Line=%Line:"=%
:: Make path double escaped (c:\temp->c:\\temp")
SET Line=%Line:\=\\%
echo Windows Registry Editor Version 5.00 >> bc-left.reg
echo [HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx] >> bc-left.reg
echo "Linked"="F%Line%" >> bc-left.reg
regedit /s bc-left.reg
echo Set: %1 as left compare file.
2. Bc-right-and-compare.bat
Start BC with the left file and the newly selected right file. This will read the value from:
HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx\Linked and use that for the left file.
@echo off
set leftFile=
START /W REGEDIT /E "%Temp%.\bc.reg" "HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx"
FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%.\bc.reg ^¦ FIND "Linked"') DO SET leftFile=%%B
SET leftFile=%leftFile:"F=%
SET leftFile=%leftFile:"=%
SET leftFile=%leftFile:\\=\%
start "C:\Program Files\Beyond Compare 2\bc2.exe" "%leftFile%" %1
To use this: Save the two bat files to some folder. Goto VS->Tools->External Tools->Add.
Set Command to point to the bat file, set Arguments to: $(ItemPath), set Initial Directory to the folder where the bat file resides.
These bat files allow you to compare files by selecting files either from VS or Explorer: VS->VS, VS->Explorer, Explorer->VS.
I hope someone will find this usefull :)
Corneliu.
I've been spending a bit of time trying to integrate BC with VS to allow me to easly select files to be compared in and out of VS. (We use lots of branches so I wanted to be efficient about comparing code.) Here are two bat scripts can can easly be installed in Tools->External tools in VS that integrate VS with BC.
1. BC-Left.bat
Set left file for BC.
This will set the key in the
HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx\Linked to the selected file, thus you can then use VS to select the right file or use the explorer shell extension to select the right file.
@echo off
rem del bc-left.reg
SET Line=%1
:: Remove quotes from the line
SET Line=%Line:"=%
:: Make path double escaped (c:\temp->c:\\temp")
SET Line=%Line:\=\\%
echo Windows Registry Editor Version 5.00 >> bc-left.reg
echo [HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx] >> bc-left.reg
echo "Linked"="F%Line%" >> bc-left.reg
regedit /s bc-left.reg
echo Set: %1 as left compare file.
2. Bc-right-and-compare.bat
Start BC with the left file and the newly selected right file. This will read the value from:
HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx\Linked and use that for the left file.
@echo off
set leftFile=
START /W REGEDIT /E "%Temp%.\bc.reg" "HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\BCShellEx"
FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%.\bc.reg ^¦ FIND "Linked"') DO SET leftFile=%%B
SET leftFile=%leftFile:"F=%
SET leftFile=%leftFile:"=%
SET leftFile=%leftFile:\\=\%
start "C:\Program Files\Beyond Compare 2\bc2.exe" "%leftFile%" %1
To use this: Save the two bat files to some folder. Goto VS->Tools->External Tools->Add.
Set Command to point to the bat file, set Arguments to: $(ItemPath), set Initial Directory to the folder where the bat file resides.
These bat files allow you to compare files by selecting files either from VS or Explorer: VS->VS, VS->Explorer, Explorer->VS.
I hope someone will find this usefull :)
Corneliu.