Jump to content

Mercurial: Difference between revisions

From LabVIEW Wiki
No edit summary
mNo edit summary
 
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Introduction<br> =
= Introduction  =


[[Image:Logo.Mercurial.png|left]]{{TOCright}}<br>
{{TOCright}}[[Image:Logo.Mercurial.png|right]]


Mercurial is a [[Source Code Control|Source Code Control]] system by Selenic, it's key feature is the distributed nature of the system.<br>
Mercurial is a [[Source Code Control|Source Code Control]] system by Selenic, it's key feature is the distributed nature of the system. This means that changes (commits) are stored in a local repository, which can be sent (pushed) to a central repository and which can be downloaded (pulled) by others.


This means that changes (commits) are stored in a local repository, which can be sent (pushed) to a central repository and which can be downloaded (pulled) by others.<br>
= Getting started =


= Getting started<br>  =
Joel Spolsky has written a How-To and Why-To page called [http://Www.hginit.com HG init] (hg is the chemical symbol for Mercury).


Joel Spolsky has written a How-To and Why-To page called [[Www.hginit.com|HG init]] (hg is the chemical symbol for Mercury).<br>
= Configuration =


= Configuration<br>  =
Mercurial stores it's setting in a file called 'hgrc' inside a hidden folder '.hg'


Mercurial stores it's setting in a file called 'hgrc' inside a hidden folder '.hg'<br>
== Setting up LVMerge  ==


== Setting up LVMerge<br>  ==
[http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/configmerge_thirdparty/ LVMerge] can be used by Mercurial as a Merge tool. Add the following text to the hgrc file:
 
[http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/configmerge_thirdparty/ LVMerge] can be used by Mercurial as a Merge tool. Add the following text to the hgrc file:<br>
<pre>[merge-tools]
<pre>[merge-tools]
LVMerge.args = $base $other $local $output
LVMerge.args = $base $other $local $output
Line 27: Line 25:
**.ctl = LVMerge
**.ctl = LVMerge
**.lvclass = LVMerge
**.lvclass = LVMerge
**.xctl == LVMerge
**.xctl = LVMerge
**.lvlib ==LVMerge
**.lvlib =LVMerge
</pre>  
</pre>
== Ignoring files<br> ==
 
You can now use TortoiseHG to perfrom a merge ([[Merge with TortoiseHG|How-To]])
 
 
 
== Setting up LVDiff ==
 
[http://meta-diff.sourceforge.net/ LVDiff] is a software package that uses the built in diff-functionality from LabVIEW to do command line based LVDiffs.
 
=== Download ===
 
First thing is to [http://meta-diff.sourceforge.net/ download] LVDiff, copy the contents of the zip-file to a location where you have writing priviliges (lvdiff uses a local ini file).<br />
Alternative: Installer from [http://decibel.ni.com/content/groups/mercurial NI Community Mercurial User Group]
 
=== Adjust ===
 
Then you need to open up the lvdiff.vi and implement these changes.
 
[[Image:Lvdiffcopy.png]]
 
This snippet (the actual code inside lvdiff copy is shown) tests if the filenames are the same and if that's the case it calls a VI called lvdiffcopy, which creates a copy of the file2.
For LabVIEW 2011 (and up) a patch file is available, use this to replace lvdiff.vi in the lvdiff installer folder[[File:Lvdiff_2011_patch.vi|lvdiff 2011 patch]].
 
=== Configure ===
 
To be able to select lvdiff as the diff tool you need to add the following settings to the [merge-tools] section of the hgrc configuration file:
<pre>lvdiff.diffargs = $child $parent
lvdiff.executable =C:\Program Files\lvdiff\lvdiff.exe
lvdiff.gui = True
lvdiff.binary = True
</pre>
 
If you are using TortoiseHg 1.0 or later, you can add a [diff-patterns] section to your hgrc file, analogous to the merge-patterns section mentioned above. This will enable automatic selection of the visual diff tool (see [http://tortoisehg.bitbucket.org/manual/1.0/common.html#word-diffs]):
<pre>
[diff-patterns]
**.vi = lvdiff
**.ctl = lvdiff
**.lvclass = lvdiff
**.xctl = lvdiff
**.lvlib = lvdiff
</pre>
 
=== Start LVDiff ===
 
You can start lvdiff in TorsoiseHg in the 'commit' dialog with right-click and 'Visual Diff':
 
[[Image:StartVisualDiff.png]]
 
In the following dialog, select 'LVDiff' and double click on the VI to diff:
 
[[Image:HG_LVDIffStart.png]]
 
After this LVdiff will launch LabVIEW and both VI (current and committed) will be compared.
 
== Ignoring files ==


Mercurial stores general ignore patterns in a file called '.hgignore' in the repository root, so you can add the patterns to the repository. I use the following patterns<br>
Mercurial stores general ignore patterns in a file called '.hgignore' in the repository root, so you can add the patterns to the repository. I use the following patterns
<pre>.ogp$
<pre>.ogp$
/built*$
/built*$
Line 38: Line 90:
.lvlps$
.lvlps$
.aliases$
.aliases$
</pre>  
</pre>
= Performing a merge<br> =
 
=== Globally ignoring files ===
If you're using TortoiseHG you can use a global ignore file, by adding the following in your %profile%\mercurial.ini file:
<pre>
[ui]
...
ignore = %userprofile%\.hgignore
...
</pre>
Next to the mercurial.ini file you create the reference .hgignore file with the contents of your choice ([http://programmer.brettveenstra.com/2010/02/27/mercurial-on-windows-tip-global-ignore-file/ source]).
 
= Performing a merge  =


The following conditions needs to be true to be able to perform a merge:<br>
The following conditions needs to be true to be able to perform a merge:


*All local changes needs to be commited (hg st should only show&nbsp;?)<br>
*All local changes needs to be commited (hg st should only show&nbsp;?)
*A changeset is pushed by another user to the central repository<br>
*A changeset is pushed by another user to the central repository
*The other changeset is not yet pulled<br>
*The other changeset is not yet pulled


The merge will try to detect the differences and call LVMerge if necesarry, LVmerge will show four VIs:<br>
The merge will try to detect the differences and call LVMerge if necesarry, LVmerge will show four VIs:


*Base, the base VI which was present in the changeset that is the same on both repositories<br>
*Base, the base VI which was present in the changeset that is the same on both repositories
*Mine, local commited VI<br>
*Mine, local commited VI
*Their, remote VI with edits from the other user<br>
*Their, remote VI with edits from the other user


These are not editable.<br>
These are not editable.


*Resulting, this is the VI that will be stored to disc after the merge finalizes. This file can be edited by the user<br>
*Resulting, this is the VI that will be stored to disc after the merge finalizes. This file can be edited by the user


For each diff LVMerge will give options to use either, 'base', 'mine' or 'their' code.<br>
For each diff LVMerge will give options to use either, 'base', 'mine' or 'their' code.


<br>


After the merge the code should be committed and pushed.<br>


Most Mercurial Clients will show a graph with the following layout:<br>
After the merge the code should be committed and pushed.


[[Image:MergeTrackHG.png|border]]<br>
Most Mercurial Clients will show a graph with the following layout:


= Mercurial clients  =
[[Image:MergeTrackHG.png|border]]
 
Here's the same graph from the 'other' user, which actually performed the merge:
 
[[Image:MergeTrackHG_Other.png|border]]


On Windows[[Image:Logo.Windows.png]], Mac[[Image:Logo.Mac.png]] and&nbsp; Linux [[Image:Logo.Linux.png]], there is a command line client called 'hg'. On windows there is a context menu tool called [http://tortoisehg.bitbucket.org TortoiseHG] based on the popular TortoiseSVN and TortoiseCVS tools
Here you see the opposite actions, two changesets in the local repo and one in the remote. Only difference is the moment of branching.


= Further reading =
= Mercurial clients =


*[http://mercurial.selenic.com Official website]<br>
On Windows[[Image:Logo.Windows.png]], Mac[[Image:Logo.Mac.png]] and&nbsp; Linux [[Image:Logo.Linux.png]], there is a command line client called 'hg'. On windows there is a context menu tool called [http://tortoisehg.bitbucket.io TortoiseHG] based on the popular TortoiseSVN and TortoiseCVS tools
*[http://www.hginit.com HG Init]<br>
*[http://hgbook.red-bean.com/ Mercurial: The Definitive Guide]<br>
*[http://redline6561.livejournal.com/362393.html Setting Up Mercurial with Apache]<br>
*[http://kiln.stackexchange.com Kiln / Mercurial Knowledge site]<br>


<br>
= External Links  =


<br>
*[http://mercurial.selenic.com Official website]
*[http://www.hginit.com HG Init]
*[http://hgbook.red-bean.com/ Mercurial: The Definitive Guide]
*[http://redline6561.livejournal.com/362393.html Setting Up Mercurial with Apache]
*[http://kiln.stackexchange.com Kiln / Mercurial Knowledge site]
*[http://decibel.ni.com/content/groups/mercurial NI Community Mercurial User Group]


[[Category:SCC]]
[[Category:SCC]]

Latest revision as of 20:40, 28 February 2019

Introduction

Mercurial is a Source Code Control system by Selenic, it's key feature is the distributed nature of the system. This means that changes (commits) are stored in a local repository, which can be sent (pushed) to a central repository and which can be downloaded (pulled) by others.

Getting started

Joel Spolsky has written a How-To and Why-To page called HG init (hg is the chemical symbol for Mercury).

Configuration

Mercurial stores it's setting in a file called 'hgrc' inside a hidden folder '.hg'

Setting up LVMerge

LVMerge can be used by Mercurial as a Merge tool. Add the following text to the hgrc file:

[merge-tools]
LVMerge.args = $base $other $local $output
LVMerge.executable = C:\Program Files\National Instruments\Shared\LabVIEW Merge\LVMerge.exe
LVMerge.gui = True
LVMerge.binary = True
[merge-patterns]
**.vi = LVMerge
**.ctl = LVMerge
**.lvclass = LVMerge
**.xctl = LVMerge
**.lvlib =LVMerge

You can now use TortoiseHG to perfrom a merge (How-To)


Setting up LVDiff

LVDiff is a software package that uses the built in diff-functionality from LabVIEW to do command line based LVDiffs.

Download

First thing is to download LVDiff, copy the contents of the zip-file to a location where you have writing priviliges (lvdiff uses a local ini file).
Alternative: Installer from NI Community Mercurial User Group

Adjust

Then you need to open up the lvdiff.vi and implement these changes.

This snippet (the actual code inside lvdiff copy is shown) tests if the filenames are the same and if that's the case it calls a VI called lvdiffcopy, which creates a copy of the file2. For LabVIEW 2011 (and up) a patch file is available, use this to replace lvdiff.vi in the lvdiff installer folderFile:Lvdiff 2011 patch.vi.

Configure

To be able to select lvdiff as the diff tool you need to add the following settings to the [merge-tools] section of the hgrc configuration file:

lvdiff.diffargs = $child $parent
lvdiff.executable =C:\Program Files\lvdiff\lvdiff.exe
lvdiff.gui = True
lvdiff.binary = True

If you are using TortoiseHg 1.0 or later, you can add a [diff-patterns] section to your hgrc file, analogous to the merge-patterns section mentioned above. This will enable automatic selection of the visual diff tool (see [1]):

[diff-patterns]
**.vi = lvdiff
**.ctl = lvdiff
**.lvclass = lvdiff
**.xctl = lvdiff
**.lvlib = lvdiff

Start LVDiff

You can start lvdiff in TorsoiseHg in the 'commit' dialog with right-click and 'Visual Diff':

In the following dialog, select 'LVDiff' and double click on the VI to diff:

After this LVdiff will launch LabVIEW and both VI (current and committed) will be compared.

Ignoring files

Mercurial stores general ignore patterns in a file called '.hgignore' in the repository root, so you can add the patterns to the repository. I use the following patterns

.ogp$
/built*$
/build*$
.lvlps$
.aliases$

Globally ignoring files

If you're using TortoiseHG you can use a global ignore file, by adding the following in your %profile%\mercurial.ini file:

[ui]
...
ignore = %userprofile%\.hgignore
...

Next to the mercurial.ini file you create the reference .hgignore file with the contents of your choice (source).

Performing a merge

The following conditions needs to be true to be able to perform a merge:

  • All local changes needs to be commited (hg st should only show ?)
  • A changeset is pushed by another user to the central repository
  • The other changeset is not yet pulled

The merge will try to detect the differences and call LVMerge if necesarry, LVmerge will show four VIs:

  • Base, the base VI which was present in the changeset that is the same on both repositories
  • Mine, local commited VI
  • Their, remote VI with edits from the other user

These are not editable.

  • Resulting, this is the VI that will be stored to disc after the merge finalizes. This file can be edited by the user

For each diff LVMerge will give options to use either, 'base', 'mine' or 'their' code.


After the merge the code should be committed and pushed.

Most Mercurial Clients will show a graph with the following layout:

Here's the same graph from the 'other' user, which actually performed the merge:

Here you see the opposite actions, two changesets in the local repo and one in the remote. Only difference is the moment of branching.

Mercurial clients

On Windows, Mac and  Linux , there is a command line client called 'hg'. On windows there is a context menu tool called TortoiseHG based on the popular TortoiseSVN and TortoiseCVS tools

External Links