aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/mozilla/mercurial/installing_mercurial/index.html
blob: 1ea2cc22e313fbadfab4fb70e0838ef317e2b9f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: Installing Mercurial
slug: Mozilla/Mercurial/Installing_Mercurial
translation_of: Mozilla/Mercurial/Installing_Mercurial
---
<p>{{ Note('If you have not yet read the <a href="/en-US/docs/Mercurial_basics">Mercurial basics</a> do so now, or see <a href="/en-US/docs/Mercurial">Mercurial</a> for other resources.') }}</p>

<div class="note">
<p>Please refer to <a href="https://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/index.html"> Mercurial For Mozillians at ReadTheDocs</a> for current best-practices around Mercurial, including many helpful extra tools and guidelines that make using Mercurial fast and easy.</p>
</div>

<h2 id="Installing" name="Installing">安装</h2>

<p>See <a href="http://mozilla-version-control-tools.readthedocs.org/en/latest/hgmozilla/installing.html">Installing Mercurial</a> from the Mozilla Version Control Guide.</p>

<h2 id="基本设置">基本设置</h2>

<p>You should configure Mercurial before submitting patches to Mozilla.</p>

<p>If you will be pulling the Firefox source code or one of the derived repositories, the easiest way to configure Mercurial is to run the <em>mercurial-setup</em> mach command:</p>

<pre>./mach mercurial-setup</pre>

<p>This command starts an interactive wizard that will help ensure your Mercurial is configured with the latest recommended settings. This command will not change any files on your machine without your consent.</p>

<p>If you don't have the Firefox source code available, you should edit your Mercurial configuration file to look like the following:</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>[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>

<h2 id="其他设置">其他设置</h2>

<h3 id="Merge_program" name="Merge_program">Merge 合并程序</h3>

<p>After installing, <strong>choose a <a class="external" href="https://www.mercurial-scm.org/wiki/MergeToolConfiguration">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 id="配置_kdiff3_作为合并工具">配置 kdiff3 作为合并工具</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 <code>contrib/mergetools.hgrc</code> 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 id="Extensions">Extensions</h3>

<p>There's a number of extensions you can enable. See <a href="http://mercurial.selenic.com/wiki/UsingExtensions" title="http://mercurial.selenic.com/wiki/UsingExtensions">http://mercurial.selenic.com/wiki/UsingExtensions</a>. Almost everyone should probably enable the following:</p>

<ul>
 <li>color - Colorize terminal output</li>
 <li>histedit - Provides <em>git rebase --interactive</em> behavior.</li>
 <li>pager - Feed command output into a pager (like <em>less</em>)</li>
 <li>progress - Draw progress bars on long-running operations.</li>
 <li>rebase - Ability to easily rebase patches on top of other heads.</li>
 <li>transplant - Easily move patches between repositories, branches, etc.</li>
</ul>

<p>These can all be turned on by just adding this to your .hgrc file:</p>

<pre>[extensions]
color =
rebase =
histedit =
progress =
transplant =
pager =
</pre>

<p>In addition, there are some 3rd party extensions that are incredibly useful for basic development:</p>

<dl>
 <dt><a href="https://hg.mozilla.org/hgcustom/version-control-tools/file/default/hgext/mozext" title="https://hg.mozilla.org/users/gszorc_mozilla.com/hgext-gecko-dev">mozext</a></dt>
 <dd>Mozilla-specific functionality to aid in developing Firefox/Gecko.</dd>
 <dt><a href="https://github.com/pbiggar/trychooser">trychooser</a></dt>
 <dd>Automatically creates a try commit message and then pushes changes to Mozilla's Try infrastructure. Just run:
 <pre>hg trychooser</pre>
 </dd>
 <dt><a href="https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz">qimportbz</a></dt>
 <dd>Import patches from Bugzilla. Creates a filename and commit message for you based on the bug's metadata.
 <pre>hg qimport bz://1234567
  </pre>
 </dd>
 <dt><a href="https://hg.mozilla.org/users/tmielczarek_mozilla.com/bzexport">bzexport</a></dt>
 <dd>Export patches to Bugzilla. There are quite a few optional arguments here to create new or update existing bugs with the attment, as well as auto matically request reviews. Type hg help bzexport for a full list but the basic syntax is:
 <pre>hg bzexport -i 1234567</pre>
 </dd>
</dl>

<p>Installing these is fairly easy. You'll just need to find a place on your system to store the extensions, and clone the extension repos into it:</p>

<pre>hg clone https://bitbucket.org/edgimar/crecord
hg clone https://bitbucket.org/sfink/mqext
hg clone https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz
git clone https://github.com/pbiggar/trychooser
</pre>

<p>And then add then to your .hgrc file</p>

<pre>[extensions]
qcrecord =  /path/to/crecord/crecord
mqext =  path/to/mqext
qimportbz =  path/to/qimportbz
trychooser = path/to/trychooser/trychooser
</pre>

<h3 id="Configuring_the_try_repository">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>

<p> </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>Alternatively, you can install the <a class="link-https" href="https://bitbucket.org/sfink/trychooser" title="https://bitbucket.org/sfink/trychooser">trychooser extension</a> (<a class="link-https" href="https://github.com/pbiggar/trychooser" title="https://github.com/pbiggar/trychooser">older version</a>).</p>