Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Labview merge tool for sourcetree 3.0

Peter Granum November 19, 2018

Hi

I am having issues with setting up labview merge and compare tools as external tools in sourcetree 3.0. The documentation I found was for pre 3.0 versions. It should be possible to set up an externel merge tool by clicking tools > options > diff ? I can then set the path to the relevant VI's, but I am not sure this is the right approach? At least it does not seem to work.

 

Peter

3 answers

1 accepted

0 votes
Answer accepted
UPWT December 12, 2018

I found that NI is providing a LabVIEW based solution to the LV Compare and LV Merge tool arguments issue.  They have provided the LabVIEW code in a GIT repository.  I just downloaded it and followed the instructions for building the EXEs, distributions and installer on my system and change the Sourcetree Diff and Merge callouts as specified.

I plan to try out the previous steps I implemented changing code in two local repos that point to the same remote repo, simulating two developers working on the same VI and committing/pushing in order to generate a conflict and then seeing if the tools will work as specified to leverage the Compare and Merge tools.

Here is the link to the GIT repository provided by NI: https://github.com/smithed/vicompare

Peter Granum December 13, 2018

Thank you very much, Ryan! I have tested both tools, and they seem to work perfectly!

The only problem I had was, when I tried to launch the external compare tool from sourcetree the first time. Labview complained that several files were not part of the project, so I clicked "add to project". This seemed to set the project in a weird state, so I closed the project without saving the changes. When I tried to launch the compare tool a second time, there was no problem. Unfortunately I did not grab a screenshot, but the problem seems to have went away. When I then tried to luanch the external merge tool, there was no problem.

I am surprised to see that this code apparently is 4-5 years old. Do you have some contact information of the guy who put up the code? Is he from NI?

UPWT December 13, 2018

Glad that it worked for you too.  I had a small issue the second time I stepped through - but that was due to me using a trial copy of LabVIEW on the PC I am using to evaluate Bitbucket and Sourcetree along with JIRA and Confluence, etc.

 

Daniel was the original poster of the page on NI.com that pointed me to the solution.  You can message him through that forum, as it doesn't look like Github allows contact of members.  He is from NI.  The page is kind of buried on the NI website which is probably why so many people are missing the solution when they do a web search or even a search on NI website for Sourcetree.  

https://forums.ni.com/t5/Reference-Design-Content/Getting-Started-Git-and-GitHub-setup/ta-p/3544824

This is his profile: 

https://forums.ni.com/t5/user/viewprofilepage/user-id/163300

About halfway down the left ribbon is a Contact Me panel with a button for sending a Private Message.  I just sent him one thanking him for the post.  Hopefully he responds.

 

Ryan

D Smith December 13, 2018

Hi all, I'm glad that tool is working well for you. I mentioned to ryan that I was making this a while back when I was trying to push for github use for my old group. Thats also how that doc on the reference design portal came about.

Another possibly useful script you may not be aware of is https://github.com/joerg/LabViewGitEnv/tree/windows

I tried using it at the time (and even branched it) but got frustrated, hence my version, but it looks like someone had spent some time contributing to it a few years ago -- so maybe my frustrations were resolved. I admit I had and still have 0 knowledge of the finer points of bash scripts, let alone bash scripts running in the git terminal on windows.

Some other things worth mentioning:

  • You can specify a version you want to use, I think with -lv, in other words add "-lv 2017" to the args
  • The code was written with the goal in mind of being relatively easy to edit. Check the docs folder (esp the image) for what goes where. The only part that is password protected is the core diff/merge function call.
  • If you are a mixed-use person, there should be a way to assign this to only be called for VIs, I believe...but honestly I find sourcetree good enough for the small bits of python or whatever that I edit.
  • If you use different labview versions simultaneously I think there are ways it can get confused...as I recall it looks to see if "LabVIEW.exe" is open and uses VI server if it is, but if the port is different it wont work. Or I could be making this up entirely, its been a while
    • I thought about maybe using this https://github.com/JamesMc86/LabVIEW-CLI to simplify things rather than trying to use VI server
    • Once 2018 is further behind us, it would be worth bumping the code to use the new command line interface

If you do see a specific issue in practice, feel free to put an issue on the repo. best case I fix it, worst case other people can know about it.

 

-Daniel

UPWT December 14, 2018

Daniel,

Thanks for the reply and passing on the knowledge.  I will also check out the joerg linked github .sh script solution to see if I like it as well. 

For everyone that might not be aware - you can modify the arguments for LV Compare on the Tools>Options>Diff set-up.

The valid arguments can be found here:

http://zone.ni.com/reference/en-XX/help/371361G-01/lvhowto/configlvcomp_thirdparty/

  • -noattr means do not compare VI attributes. (Things like VI documentation, LV Version I think)
  • -nofp means do not compare the front panels.
  • -nofppos means do not compare the size or position of front panel objects. (Sometimes you want to see the changes if they diff is cosmetic, sometimes you don't if it is a code bug on the BD you are chasing)
  • -nobd means do not compare the block diagrams.
  • -nobdcosm means do not compare the appearance of block diagram objects.
  • -nobdpos means do not compare the size or position of block diagram objects.
UPWT December 14, 2018

Maybe I wrote too soon, just tried adding to the arguments line and was told -nofp is a file that could not be found.

D Smith December 16, 2018

Yeah, at the time I didn't want to have the exe call the exe for some reason, but I can't remember exactly why. It should be easy to hack those pieces together if you want it to work that way. One possible reason I did this is that I used some private methods to make sure each VI gets its own application context to avoid issues where the two VIs being diff'd have the exact same namespaced name -- I don't think git does this, but maybe mercurial did? Anyway, point is I just called the labview diff and merge methods directly, rather than fixing the paths and calling into the exe.

So....while I exposed those flags as optional parameters on the 'black box' diff and merge methods, I never implemented them as part of the parsing, and the code (wrongly) treated every flag left over as a path it needed to fix.

I just spent a little while shoving together a few small fixes to the above. I gave it a quick test to make sure the basics still worked, but I probably won't get around to doing a more complete test for a while. Its now pushed to my github if you want to take a look and give it a try. Its a bit of a rush job but not too bad.

UPWT December 17, 2018

Thanks for even looking at it.

I branched my forked code and added a LV Dialog pop-up to allow me to change the settings each time I Diff, or I can turn it off in vidiff.ini and then run with the settings from vidiff.ini.  It seemed easier to me to do it that way than edit the Tools>Options>Git settings.

Mercurial might act differently, I am not sure.  I've used it in the past, but we rarely used Diff functionality and I didn't have to dig into it.

0 votes
UPWT December 11, 2018

I have been looking into this as well since I am evaluating Atlassian tools for Version Control with LabVIEW.  I am seeing the same issue.  I tried looking around for solutions as the ones I found were for Sourcetree prior to version 3.

Sourcetree is a very nice GUI for working with Git and I like that Sourcetree has embedded GIT so that makes adoption by my coworkers more likely.

It seems that others have solved the problem posted by writing scripts to provide LabVIEW Compare and LabVIEW Merge with the Absolute Paths to the argument file locations.  I tried the one posted by Endigit and it did not work.

Was hoping to see this was solved here...

0 votes
Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 19, 2018

Hello! There was a bug in custom diff tools recently that caused this to not work quite right (you can find the fixed version here)

 

After updating, you should be able to try the following:

"External Merge Tool" set to "Custom"

"Merge Command:" set to:

PATH TO 'LVMerge.exe' goes here

"Arguments" set to:

\"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
Peter Granum November 20, 2018

Hi Mike

Thanks for your reply! It seems to be more right now. However, it is not quite working yet. I have made a change to a file called "xxx.vi". In the "file status" tab I hightlight the file at hit ctrl+d to launch the external diff tool. Labview compare then launches with the error message seen below. Is there somewhere in sourcetree I can set the exact command that is executed, or how can I fix this problem?

When I try to resolve a merge conflict using the external merge tool, labview opens with the error seen in the attahced picture. Perhaps incorrect parameters are causing this problem as well.

 


LVCompare was called with incorrect parameters.


How to call LVCompare:

LVCompare <absolute path to vi1> <absolute path to vi2> [-lvpath <absolute path to LabVIEW>] [-noattr] [-nofp] [-nofppos] [-nobd] [-nobdcosm] [-nobdpos]

[-lvpath <absolute path to LabVIEW>] - Provide the path to the LabVIEW executable you want to compare the VIs
[-noattr] - Do not compare VI attributes
[-nofp] - Do not compare Front Panel
[-nofppos] - Do not compare Front Panel objects' position/size
[-nobd] - Do not compare Block Diagram
[-nobdcosm] - Do not compare Block Diagram objects' cosmetics
[-nobdpos] - Do not compare Block Diagram objects' position/size

Example:
LVCompare c:\test\apple.vi c:\test\orange.vi

Capture1.PNG

 

Peter Granum November 20, 2018

Hi Mike

Thanks for your reply! Something seems to work better now. However, it does not quite work yet. I tried to make a change to the file "xxx.vi". In the tab "file status" I highlighted the file and pressed ctrl+d to launch the external diff tool. Labview compare then opens and gives the error message seen below. Is there somewhere I can set the exact command executed by sourcetree, or how can I fix this problem?

When I try to resolve conflicts in a merge with the external merge tool, labview open and gives the error message seen in the attached picture. Perhaps It is due to incorrect parameters as well.


LVCompare was called with incorrect parameters.


How to call LVCompare:

LVCompare <absolute path to vi1> <absolute path to vi2> [-lvpath <absolute path to LabVIEW>] [-noattr] [-nofp] [-nofppos] [-nobd] [-nobdcosm] [-nobdpos]

[-lvpath <absolute path to LabVIEW>] - Provide the path to the LabVIEW executable you want to compare the VIs
[-noattr] - Do not compare VI attributes
[-nofp] - Do not compare Front Panel
[-nofppos] - Do not compare Front Panel objects' position/size
[-nobd] - Do not compare Block Diagram
[-nobdcosm] - Do not compare Block Diagram objects' cosmetics
[-nobdpos] - Do not compare Block Diagram objects' position/size

Example:
LVCompare c:\test\apple.vi c:\test\orange.vi

Capture1.PNG

Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 21, 2018

Hmmm... seems like you might need to add the absolute path to the LabVIEW exe in the parameters? Could you try the following?

\"C:\program files\PATHTOLABVIEW.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
Peter Granum November 22, 2018

I get the same error message, when I try to run the external diff tool. You can see my inputs to the diff options below:Capture.PNG

 

Diff command:

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

 

Arguments:

\"C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"

 

Merge command:

C:\Program Files (x86)\National Instruments\Shared\LabVIEW Merge\LVMerge.exe

 

Arguments:

\"C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events