Set up differencing capabilities

From LabVIEW Wiki
Jump to: navigation, search

Easy Setup For Git

The easiest way to setup LVCompare and LVMerge for use with Git is to copy/paste the following into Git Bash

cd && git clone https://gitlab.com/sas-blog/LVCompare-Merge-Setup.git && cd LVCompare-Merge-Setup && ./setupLVTools.sh

This will clone a repo and run a shell script to set everything up. You can read more about it here: https://blog.sasworkshops.com/the-easiest-way-to-setup-lvcompare-and-lvmerge/

After that, you can use the difftool command in Git Bash to view diffs or use your favorite Git GUI.



There are several methods setting up differencing LabVIEW VIs with subversion. A new feature in LabVIEW 2009 in the program LVCompare.exe which allows graphical differencing from the command line. In older versions, TortoiseSVN can be coupled with the open source LVDiff to achieve the same goal.

LVCompare.exe National Instruments Documentation

This documentation describes the options you can pass to LVCompare.exe. For example, you can instruct LVCompare.exe to ignore changes in the position of front panel objects by pass in "-nofppos". For the full set of documentation please refer to the link below: LVCompare.exe from National Instruments

Using LVCompare.exe and svn CLI

From the command line, subversion cannot normally compare binary files such as vis. The svn diff command has a switch --diff-cmd to allow an external differencing engine to be used. This will be leveraged to used LVComare to operate on vis.

To use LVCompare.exe with subversion in the command line, first add "C:\Program Files\National Instruments\Shared\LabVIEW Compare" to your system PATH variable (this allows the command prompt to find LVcompare.exe).

The output of the diff command is quite complicated (from [1] subversion FAQ):

When using an external diff command, Subversion builds a fairly complicated command line. First is the specified --diff-cmd. Next comes the specified --extensions (although empty --extensions are ignored), or '-u' if --extensions is unspecified (or specified as ). Third and fourth, Subversion passes a '-L' and the first file's label (e.g. "project_issues.html (revision 11209)"). Fifth and sixth are another '-L' and the second label. Seventh and eighth are the first and second file names (e.g. ".svn/text-base/project_issues.html.svn-base" and ".svn/tmp/project_issues.html.tmp").



If your preferred diff command does not support these arguments, you may need to create a small wrapper script to discard arguments and just use the last couple file paths.

Warning: Beware that Subversion does not expect the external diff program to change the files it receives, and doing so may scramble the working copy.

On windows, this wrapper is easy to create. Save the following file as LVdiff.bat in the same directory as LVCompare.exe. This formulates the LVCompare command correctly.

@ECHO OFF
lvcompare "%cd%\%~7" "%cd%\%~6"

Then, to execute the diff, use the following command:

svn diff --diff-cmd LVdiff.bat --force CHANGED.vi

where CHANGED.vi is the one you want to diff.

IMPORTANT: As stated in the FAQ, subversion does not expect diff to make any changes, so make sure not to save the text-base vi.

Using LVCompare.exe and TortoiseSVN

For users of the TortoiseSVN client and LabVIEW 2009, it is also possible extend TortoiseSVN's built-in differencing functionality to allow VIs to be compared from a simple Windows Explorer right-click menu using LVCompare.exe. This can be achieved by adding an entry for .VI files to the "Advanced" list of TortoiseSVN's Diff settings with the following syntax[1]:

"C:\Program Files\National Instruments\Shared\LabVIEW Compare\LVCompare.exe" %base %mine

Note: If you're using 32-bit LabVIEW on a 64-bit Windows OS, the path would be:

"C:\Program Files (x86)\National Instruments\Shared\LabVIEW Compare\LVCompare.exe" %base %mine

(from [2] Command-Line Graphical Differencing of VIs)

Using TortoiseSVN and LVDiff for VIs

TortoiseSVN has its own program (TortoiseMerge) to show the differences between two different versions of a file. This works well with text files but since LabVIEW VIs are binary files it is advantageous to use LabVIEW's graphical differencing capabilities.

The professional version of LabVIEW has a "CMP Compare two VIs.vi" in the ...\LabVIEW x.x\project\procmphier.llb library.

The open-source "LVDiff" tool (see [3] for the main download but download the updated "lvdiff.vi" from the link here [4] since the version currently in the .zip file does not work with VIs in libraries) provides a wrapper to call this VI.

Be sure to update the paths in the .lvdiff file.

Open Windows Explorer.
Right-click on a directory and select "TortoiseSVN...Settings" from the pop-up menu.
Under "External Programs" select "Diff Viewer".
DiffViewerPageNew2.png

Click on the "Advanced..." button and add a ".vi" extension with the "External Program" pointing to "lvdiff.exe".
SettingUpLVDiff.png

To compare a file with the previous version in the repository right-click on the file in Windows explorer and select "TortoiseSVN...Diff with previous version".

Using SourceTree and LVDiff for VIs

You can invoke LVCompare.exe from Atlassian SourceTree by using the application found here: VI Compare. Set up SourceTree using the steps below.

Go To Tools>>Options

Tools,options.png

Select "Diff". Then Select "Custom" for External Diff Tool and Merge tool

2019-07-29 11h45 51.png

Navigate to the installed executables. Specify <"$LOCAL" "$REMOTE"> for Diff Command Arguments and <"$BASE" "$REMOTE" "$LOCAL" "$MERGED"> for Merge Command Arguments

2019-07-29 11h46 08.png