Installing Mercurial

  • Revision slug: Installing_Mercurial
  • Revision title: Installing Mercurial
  • Revision id: 52515
  • Created:
  • Creator: DBaron
  • Is current revision? No
  • Comment more on try repo and [paths]; 90 words added, 2 words removed

Revision Content

{{ Note("If you have not yet read the Mercurial basics do so now, or see Mercurial for other resources.") }}

Installing

 

On Windows:
Mercurial comes with MozillaBuild, in the folder 'hg'.  See also wikimo:Mercurial on Windows.

 

Other systems:
If you use apt-get, emerge, port, yast, or yum to install software, just do the usual. If this gives you an old version (pre-1.5 -- check with hg version), you can update it using easy_install as follows (using apt-get in this example):
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install -U mercurial

Otherwise, the Mercurial binary packages are for you.

Configuration

You should configure Mercurial before pulling the code. Your mercurial configuration file should have at least the following settings:

[ui]
username = Your Real Name <user@example.com>
merge = your-merge-program (or internal:merge)
 
[diff]
git = 1
showfunc = 1
unified = 8

[defaults]
commit = -v

On Windows, these settings can be added to $HOME\.hgrc or $HOME\Mercurial.ini, or, if you'd like global settings, C:\mozilla-build\hg\Mercurial.ini or C:\Program Files\Mercurial\Mercurial.ini. On UNIX-like systems, they should be in your $HOME/.hgrc file.

You can configure the editor to use for commit messages using the editor option in the {{ mediawiki.external('ui') }} section or by setting the EDITOR environment variable.

If you are trying to access the repository through a proxy server, see these instructions.

Merge program

After installing, choose a merge program. Seriously. Do it now. If you don't, Mercurial will choose one for you and spring it on you when you least expect it.

A reasonable thing to do is to set ui.merge=internal:merge in the Mercurial configuration file (see below), which makes Mercurial try to merge changes and add the conflict markers (a la CVS) to the files that couldn't be merged.

Under Ubuntu, you can install meld package, then in in the Mercurial configuration file (see below) set ui.merge=meld

You can see the list of merge conflicts by looking for "merging ... failed!" in the update output.

Configuring kdiff3 as a merge tool

If you're on Linux and you have kdiff3 installed, you probably want to configure kdiff3 as a merge tool.  (It's better than meld because it will actually resolve a bunch of the conflicts without prompting you, generally quite accurately.)  You can do this by adding the following lines (which come from contrib/mergetools.hgrc in the Mercurial distribution):

[merge-tools]
kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output
kdiff3.regkey=Software\KDiff3
kdiff3.regappend=\kdiff3.exe
kdiff3.fixeol=True
kdiff3.gui=True

Configuring mq

Many Mozilla developers use the mq extension.  If you want to enable it, you probably want the following in your .hgrc:

[extensions]
mq =

[defaults]
qnew = -U

[mq]
plain = True

Configuring the try repository

If you have access to the try server you may want to configure Mercurial so you can refer to it simply as "try", since it can be useful from all your trees.  This can be done by adding this to your ~/.hgrc (or Mercurial.ini):

[paths]
try = ssh://hg.mozilla.org/try/

You can also configure short names like this that are specific to a particular repository by adding a [paths] section to the .hg/hgrc file within a repository.  There are two magic names, "default" and "default-push", which are used as the default push/pull targets.  (If "default" is specified and "default-push" is not, "default" is used for both.)

{{ languages( { "fr": "fr/Installation_de_Mercurial" } ) }}

Revision Source

<p>{{ Note("If you have not yet read the <a href='\"en/Mercurial_basics\"'>Mercurial basics</a> do so now, or see <a href='\"en/Mercurial\"'>Mercurial</a> for other resources.") }}</p>
<h2 name="Installing">Installing</h2>
<p> </p>
<dl> <dt>On Windows:</dt> <dd>Mercurial comes with <a href="/En/Developer_Guide/Build_Instructions/Windows_Prerequisites#MozillaBuild" title="en/Windows_Build_Prerequisites#MozillaBuild">MozillaBuild</a>, in the folder 'hg'.  See also <a class="link-https" href="https://wiki.mozilla.org/Mercurial_on_Windows" title="https://wiki.mozilla.org/Mercurial_on_Windows">wikimo:Mercurial on Windows</a>. <p> </p> </dd> <dt>Other systems:</dt> <dd>If you use <code>apt-get</code>, <code>emerge</code>, <code>port</code>, <code>yast</code>, or <code>yum</code> to install software, just do the usual. If this gives you an old version (pre-1.5 -- check with <code>hg version</code>), you can update it using <code>easy_install</code> as follows (using <code>apt-get</code> in this example): <pre class="eval">sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install -U mercurial
</pre> <p>Otherwise, the <a class="external" href="http://www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages">Mercurial binary packages</a> are for you.</p> </dd>
</dl>
<h2>Configuration</h2>
<p>You should configure Mercurial before pulling the code. Your mercurial configuration file should have at least the following settings:</p>
<pre class="eval">[ui]
username = Your Real Name &lt;<a class=" link-mailto" href="mailto:user@example.com" rel="freelink">user@example.com</a>&gt;
merge = <em>your-merge-program</em> (or internal:merge)
 
[diff]
git = 1
showfunc = 1
unified = 8

[defaults]
commit = -v
</pre>
<p>On Windows, these settings can be added to <code>$HOME\.hgrc</code> or <code>$HOME\Mercurial.ini</code>, or, if you'd like global settings, <code>C:\mozilla-build\hg\Mercurial.ini</code> or <code>C:\Program Files\Mercurial\Mercurial.ini</code>. On UNIX-like systems, they should be in your <code>$HOME/.hgrc</code> file.</p>
<p>You can configure the editor to use for commit messages using the <code>editor</code> option in the <code>{{ mediawiki.external('ui') }}</code> section or by setting the <code>EDITOR</code> environment variable.</p>
<p>If you are trying to access the repository through a proxy server, see <a class=" external" href="http://www.selenic.com/mercurial/hgrc.5.html#http-proxy" title="http://www.selenic.com/mercurial/hgrc.5.html#http-proxy">these instructions</a>.</p>
<h3 name="Merge_program">Merge program</h3>
<p>After installing, <strong>choose a <a class="external" href="http://www.selenic.com/mercurial/wiki/index.cgi/MergeProgram">merge program</a></strong>. Seriously. Do it now. If you don't, Mercurial will choose one for you and spring it on you when you least expect it.</p>
<p>A reasonable thing to do is to set <code>ui.merge=internal:merge</code> in the Mercurial configuration file (see below), which makes Mercurial try to merge changes and add the conflict markers (a la CVS) to the files that couldn't be merged.</p>
<p>Under Ubuntu, you can install meld package, then in in the Mercurial configuration file (see below) set <code>ui.merge=meld</code></p>
<p>You can see the list of merge conflicts by looking for "merging ... failed!" in the update output.</p>
<h4>Configuring kdiff3 as a merge tool</h4>
<p>If you're on Linux and you have kdiff3 installed, you probably want to configure kdiff3 as a merge tool.  (It's better than meld because it will actually resolve a bunch of the conflicts without prompting you, generally quite accurately.)  You can do this by adding the following lines (which come from contrib/mergetools.hgrc in the Mercurial distribution):</p>
<pre>[merge-tools]
kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output
kdiff3.regkey=Software\KDiff3
kdiff3.regappend=\kdiff3.exe
kdiff3.fixeol=True
kdiff3.gui=True

</pre>
<h3>Configuring mq</h3>
<p>Many Mozilla developers use the mq extension.  If you want to enable it, you probably want the following in your .hgrc:</p>
<pre>[extensions]
mq =

[defaults]
qnew = -U

[mq]
plain = True
</pre>
<h3>Configuring the try repository</h3>
<p>If you have access to the <a class=" link-https" href="https://wiki.mozilla.org/Build:TryServer" title="https://wiki.mozilla.org/Build:TryServer">try server</a> you may want to configure Mercurial so you can refer to it simply as "try", since it can be useful from all your trees.  This can be done by adding this to your ~/.hgrc (or Mercurial.ini):</p>
<pre>[paths]
try = ssh://hg.mozilla.org/try/
</pre>
<p>You can also configure short names like this that are specific to a particular repository by adding a [paths] section to the .hg/hgrc file within a repository.  There are two magic names, "default" and "default-push", which are used as the default push/pull targets.  (If "default" is specified and "default-push" is not, "default" is used for both.)</p>
<p>{{ languages( { "fr": "fr/Installation_de_Mercurial" } ) }}</p>
Revert to this revision