hgbook

view po/zh.po @ 711:364d2ce9e055

Update Chinese translation

* po/zh.po:
408 translated messages, 1620 untranslated messages.
author Dongsheng Song <songdongsheng@live.cn>
date Sat Apr 18 11:52:33 2009 +0800 (2009-04-18)
parents 8613844dd2cf
children a13404f69f8d
line source
1 #
2 # Simplified Chinese translation for hgbook
3 # This file is distributed under the same license as the hgbook.
4 #
5 # Authors:
6 # Dongsheng Song <dongsheng.song@gmail.com>, 2009
7 #
8 # Check translation:
9 # msgfmt --statistics -c -o zh.mo zh.po
10 #
11 # Please format your translation before commit:
12 # msgcat --sort-by-file --width=80 -o zh_new.po zh.po
13 # mv -f zh_new.po zh.po
14 #
15 # Dictionary:
16 # blame 追溯
17 # branch 分支
18 # changes 修改
19 # changeset 修改集
20 # checkout 检出
21 # remove 移除(从版本库删除)
22 # delete 删除(只从文件系统删除)
23 # filelog 文件日志
24 # patchset 补丁集
25 # pushing to 推到
26 # pulling from 拉自,抓取
27 # rename 改名
28 # repository 版本库
29 # revert 恢复
30 # revision 版本
31 # revlog 版本日志
32 # tag 标签
33 # tip 顶点
34 # undo 撤销
35 # unversioned 未版本控制
36 # updated 更新到,同步到(适用于旧版本)
37 # versioned 受版本控制
38 # working copy 工作副本
39 # ...
40 #
41 msgid ""
42 msgstr ""
43 "Project-Id-Version: hgbook 1.2\n"
44 "POT-Creation-Date: 2009-04-18 10:05+0800\n"
45 "PO-Revision-Date: 2009-04-18 11:50+0800\n"
46 "Last-Translator: 宋冬生 <songdonogsheng@live.cn>\n"
47 "Language-Team: Simplified Chinese <i18n-zh@googlegroups.com >\n"
48 "MIME-Version: 1.0\n"
49 "Content-Type: text/plain; charset=UTF-8\n"
50 "Content-Transfer-Encoding: 8bit\n"
51 "X-Poedit-Language: Chinese\n"
52 "X-Poedit-Country: CHINA\n"
53 "X-Poedit-SourceCharset: utf-8\n"
55 #. type: Content of: <book><title>
56 #: ../en/00book.xml:41
57 msgid "Mercurial: The Definitive Guide"
58 msgstr "Mercurial 权威指南"
60 #. type: Content of: <book><subtitle>
61 #: ../en/00book.xml:46
62 msgid "Compiled from $rev_id$"
63 msgstr "编译自 $rev_id$"
65 #. type: Content of: <book><bookinfo>
66 #: ../en/00book.xml:48
67 msgid "<edition>1</edition> <isbn>9780596800673</isbn>"
68 msgstr "<edition>1</edition> <isbn>9780596800673</isbn>"
70 #. type: Content of: <book><bookinfo><authorgroup><author><firstname>
71 #: ../en/00book.xml:52
72 msgid "Bryan"
73 msgstr "Bryan"
75 #. type: Content of: <book><bookinfo><authorgroup><author><surname>
76 #: ../en/00book.xml:53
77 msgid "O'Sullivan"
78 msgstr "O'Sullivan"
80 #. type: Content of: <book><bookinfo>
81 #: ../en/00book.xml:57
82 msgid ""
83 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
84 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
85 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
86 msgstr ""
87 "<editor> <firstname>Mike</firstname> <surname>Loukides</surname> </editor> "
88 "<copyright> <year>2006</year> <year>2007</year> <year>2008</year> <year>2009</"
89 "year> <holder>Bryan O'Sullivan</holder> </copyright>"
91 #. type: Content of: <book><appendix><title>
92 #: ../en/appB-mq-ref.xml:5
93 msgid "Mercurial Queues reference"
94 msgstr "Mercurial 队列参考"
96 #. type: Content of: <book><appendix><sect1><title>
97 #: ../en/appB-mq-ref.xml:8
98 msgid "MQ command reference"
99 msgstr "MQ 命令参考"
101 #. type: Content of: <book><appendix><sect1><para>
102 #: ../en/appB-mq-ref.xml:10
103 msgid ""
104 "For an overview of the commands provided by MQ, use the command <command role="
105 "\"hg-cmd\">hg help mq</command>."
106 msgstr ""
108 #. type: Content of: <book><appendix><sect1><sect2><title>
109 #: ../en/appB-mq-ref.xml:14
110 msgid ""
111 "<command role=\"hg-ext-mq\">qapplied</command>&emdash;print applied patches"
112 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
114 #. type: Content of: <book><appendix><sect1><sect2><para>
115 #: ../en/appB-mq-ref.xml:17
116 msgid ""
117 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
118 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
119 "the last patch in the list is the <quote>top</quote> patch."
120 msgstr ""
122 #. type: Content of: <book><appendix><sect1><sect2><title>
123 #: ../en/appB-mq-ref.xml:24
124 msgid ""
125 "<command role=\"hg-ext-mq\">qcommit</command>&emdash;commit changes in the "
126 "queue repository"
127 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
129 #. type: Content of: <book><appendix><sect1><sect2><para>
130 #: ../en/appB-mq-ref.xml:27
131 msgid ""
132 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
133 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
134 "patches</filename> repository. This command only works if the <filename role="
135 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
136 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
137 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
138 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
139 "<command role=\"hg-ext-mq\">qinit</command>."
140 msgstr ""
142 #. type: Content of: <book><appendix><sect1><sect2><para>
143 #: ../en/appB-mq-ref.xml:39
144 msgid ""
145 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
146 "patches</command>."
147 msgstr ""
149 #. type: Content of: <book><appendix><sect1><sect2><title>
150 #: ../en/appB-mq-ref.xml:43
151 msgid ""
152 "<command role=\"hg-ext-mq\">qdelete</command>&emdash;delete a patch from the "
153 "<filename role=\"special\">series</filename> file"
154 msgstr ""
155 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
156 "\">series</filename> 中删除补丁"
158 #. type: Content of: <book><appendix><sect1><sect2><para>
159 #: ../en/appB-mq-ref.xml:48
160 msgid ""
161 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
162 "for a patch from the <filename role=\"special\">series</filename> file in the "
163 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
164 "directory. It does not pop the patch if the patch is already applied. By "
165 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
166 "cmd-qdel-opt\">-f</option> option to do that."
167 msgstr ""
169 #. type: Content of: <book><appendix><sect1><sect2><para>
170 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:99 ../en/appB-mq-ref.xml:157
171 #: ../en/appB-mq-ref.xml:197 ../en/appB-mq-ref.xml:264
172 #: ../en/appB-mq-ref.xml:335 ../en/appB-mq-ref.xml:404
173 #: ../en/appB-mq-ref.xml:497
174 msgid "Options:"
175 msgstr "选项:"
177 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
178 #: ../en/appB-mq-ref.xml:59
179 msgid ""
180 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
181 msgstr ""
183 #. type: Content of: <book><appendix><sect1><sect2><title>
184 #: ../en/appB-mq-ref.xml:66
185 msgid ""
186 "<command role=\"hg-ext-mq\">qdiff</command>&emdash;print a diff of the "
187 "topmost applied patch"
188 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
190 #. type: Content of: <book><appendix><sect1><sect2><para>
191 #: ../en/appB-mq-ref.xml:69
192 msgid ""
193 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
194 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
195 "r-2:-1</command>."
196 msgstr ""
198 #. type: Content of: <book><appendix><sect1><sect2><title>
199 #: ../en/appB-mq-ref.xml:75
200 msgid ""
201 "<command role=\"hg-ext-mq\">qfold</command>&emdash;merge (<quote>fold</"
202 "quote>) several patches into one"
203 msgstr ""
204 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
205 "quote>)成一个"
207 #. type: Content of: <book><appendix><sect1><sect2><para>
208 #: ../en/appB-mq-ref.xml:78
209 msgid ""
210 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
211 "patches into the topmost applied patch, so that the topmost applied patch "
212 "makes the union of all of the changes in the patches in question."
213 msgstr ""
215 #. type: Content of: <book><appendix><sect1><sect2><para>
216 #: ../en/appB-mq-ref.xml:83
217 msgid ""
218 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
219 "command> will exit with an error if any is. The order in which patches are "
220 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
221 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
222 "followed by <literal>b</literal></quote>."
223 msgstr ""
225 #. type: Content of: <book><appendix><sect1><sect2><para>
226 #: ../en/appB-mq-ref.xml:91
227 msgid ""
228 "The comments from the folded patches are appended to the comments of the "
229 "destination patch, with each block of comments separated by three asterisk "
230 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
231 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
232 "combined patch/changeset after the folding has completed."
233 msgstr ""
235 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
236 #: ../en/appB-mq-ref.xml:101
237 msgid ""
238 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
239 "and patch description for the newly folded patch."
240 msgstr ""
242 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
243 #: ../en/appB-mq-ref.xml:106
244 msgid ""
245 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
246 "given file as the new commit message and patch description for the folded "
247 "patch."
248 msgstr ""
250 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
251 #: ../en/appB-mq-ref.xml:111
252 msgid ""
253 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
254 "the new commit message and patch description for the folded patch."
255 msgstr ""
257 #. type: Content of: <book><appendix><sect1><sect2><title>
258 #: ../en/appB-mq-ref.xml:119
259 msgid ""
260 "<command role=\"hg-ext-mq\">qheader</command>&emdash;display the header/"
261 "description of a patch"
262 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
264 #. type: Content of: <book><appendix><sect1><sect2><para>
265 #: ../en/appB-mq-ref.xml:123
266 msgid ""
267 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
268 "or description, of a patch. By default, it prints the header of the topmost "
269 "applied patch. Given an argument, it prints the header of the named patch."
270 msgstr ""
272 #. type: Content of: <book><appendix><sect1><sect2><title>
273 #: ../en/appB-mq-ref.xml:130
274 msgid ""
275 "<command role=\"hg-ext-mq\">qimport</command>&emdash;import a third-party "
276 "patch into the queue"
277 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
279 #. type: Content of: <book><appendix><sect1><sect2><para>
280 #: ../en/appB-mq-ref.xml:133
281 msgid ""
282 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
283 "an external patch to the <filename role=\"special\">series</filename> file, "
284 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
285 "hg/patches</filename> directory. It adds the entry immediately after the "
286 "topmost applied patch, but does not push the patch."
287 msgstr ""
289 #. type: Content of: <book><appendix><sect1><sect2><para>
290 #: ../en/appB-mq-ref.xml:141
291 msgid ""
292 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
293 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
294 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
295 "imported patch."
296 msgstr ""
298 #. type: Content of: <book><appendix><sect1><sect2><title>
299 #: ../en/appB-mq-ref.xml:149
300 msgid ""
301 "<command role=\"hg-ext-mq\">qinit</command>&emdash;prepare a repository to "
302 "work with MQ"
303 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
305 #. type: Content of: <book><appendix><sect1><sect2><para>
306 #: ../en/appB-mq-ref.xml:152
307 msgid ""
308 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
309 "to work with MQ. It creates a directory called <filename role=\"special\" "
310 "class=\"directory\">.hg/patches</filename>."
311 msgstr ""
313 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
314 #: ../en/appB-mq-ref.xml:159
315 msgid ""
316 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
317 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
318 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
319 "file that will ignore the <filename role=\"special\">status</filename> file."
320 msgstr ""
322 #. type: Content of: <book><appendix><sect1><sect2><para>
323 #: ../en/appB-mq-ref.xml:169
324 msgid ""
325 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
326 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
327 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
328 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
329 msgstr ""
331 #. type: Content of: <book><appendix><sect1><sect2><title>
332 #: ../en/appB-mq-ref.xml:178
333 msgid "<command role=\"hg-ext-mq\">qnew</command>&emdash;create a new patch"
334 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
336 #. type: Content of: <book><appendix><sect1><sect2><para>
337 #: ../en/appB-mq-ref.xml:181
338 msgid ""
339 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
340 "It takes one mandatory argument, the name to use for the patch file. The "
341 "newly created patch is created empty by default. It is added to the "
342 "<filename role=\"special\">series</filename> file after the current topmost "
343 "applied patch, and is immediately pushed on top of that patch."
344 msgstr ""
346 #. type: Content of: <book><appendix><sect1><sect2><para>
347 #: ../en/appB-mq-ref.xml:189
348 msgid ""
349 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
350 "working directory, it will refuse to create a new patch unless the <option "
351 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
352 "behavior allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
353 "topmost applied patch before you apply a new patch on top of it."
354 msgstr ""
356 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
357 #: ../en/appB-mq-ref.xml:199
358 msgid ""
359 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
360 "the contents of the working directory are modified. Any outstanding "
361 "modifications are added to the newly created patch, so after this command "
362 "completes, the working directory will no longer be modified."
363 msgstr ""
365 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
366 #: ../en/appB-mq-ref.xml:206
367 msgid ""
368 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
369 "the commit message. This text will be stored at the beginning of the patch "
370 "file, before the patch data."
371 msgstr ""
373 #. type: Content of: <book><appendix><sect1><sect2><title>
374 #: ../en/appB-mq-ref.xml:215
375 msgid ""
376 "<command role=\"hg-ext-mq\">qnext</command>&emdash;print the name of the next "
377 "patch"
378 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
380 #. type: Content of: <book><appendix><sect1><sect2><para>
381 #: ../en/appB-mq-ref.xml:218
382 msgid ""
383 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
384 "of the next patch in the <filename role=\"special\">series</filename> file "
385 "after the topmost applied patch. This patch will become the topmost applied "
386 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
387 msgstr ""
389 #. type: Content of: <book><appendix><sect1><sect2><title>
390 #: ../en/appB-mq-ref.xml:227
391 msgid ""
392 "<command role=\"hg-ext-mq\">qpop</command>&emdash;pop patches off the stack"
393 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
395 #. type: Content of: <book><appendix><sect1><sect2><para>
396 #: ../en/appB-mq-ref.xml:230
397 msgid ""
398 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
399 "patches from the top of the stack of applied patches. By default, it removes "
400 "only one patch."
401 msgstr ""
403 #. type: Content of: <book><appendix><sect1><sect2><para>
404 #: ../en/appB-mq-ref.xml:234
405 msgid ""
406 "This command removes the changesets that represent the popped patches from "
407 "the repository, and updates the working directory to undo the effects of the "
408 "patches."
409 msgstr ""
411 #. type: Content of: <book><appendix><sect1><sect2><para>
412 #: ../en/appB-mq-ref.xml:238
413 msgid ""
414 "This command takes an optional argument, which it uses as the name or index "
415 "of the patch to pop to. If given a name, it will pop patches until the named "
416 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
417 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
418 "series file, counting from zero (empty lines and lines containing only "
419 "comments do not count). It pops patches until the patch identified by the "
420 "given index is the topmost applied patch."
421 msgstr ""
423 #. type: Content of: <book><appendix><sect1><sect2><para>
424 #: ../en/appB-mq-ref.xml:248
425 msgid ""
426 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
427 "patches or the <filename role=\"special\">series</filename> file. It is thus "
428 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
429 "removed from the <filename role=\"special\">series</filename> file, or a "
430 "patch that you have renamed or deleted entirely. In the latter two cases, "
431 "use the name of the patch as it was when you applied it."
432 msgstr ""
434 #. type: Content of: <book><appendix><sect1><sect2><para>
435 #: ../en/appB-mq-ref.xml:257
436 msgid ""
437 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
438 "pop any patches if the working directory has been modified. You can override "
439 "this behavior using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
440 "option, which reverts all modifications in the working directory."
441 msgstr ""
443 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
444 #: ../en/appB-mq-ref.xml:266
445 msgid ""
446 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
447 "patches. This returns the repository to its state before you applied any "
448 "patches."
449 msgstr ""
451 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
452 #: ../en/appB-mq-ref.xml:271
453 msgid ""
454 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
455 "modifications to the working directory when popping."
456 msgstr ""
458 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
459 #: ../en/appB-mq-ref.xml:276
460 msgid ""
461 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
462 "named queue."
463 msgstr ""
465 #. type: Content of: <book><appendix><sect1><sect2><para>
466 #: ../en/appB-mq-ref.xml:281
467 msgid ""
468 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
469 "the end of the <filename role=\"special\">status</filename> file for each "
470 "patch that it pops."
471 msgstr ""
473 #. type: Content of: <book><appendix><sect1><sect2><title>
474 #: ../en/appB-mq-ref.xml:288
475 msgid ""
476 "<command role=\"hg-ext-mq\">qprev</command>&emdash;print the name of the "
477 "previous patch"
478 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
480 #. type: Content of: <book><appendix><sect1><sect2><para>
481 #: ../en/appB-mq-ref.xml:291
482 msgid ""
483 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
484 "the patch in the <filename role=\"special\">series</filename> file that comes "
485 "before the topmost applied patch. This will become the topmost applied patch "
486 "if you run <command role=\"hg-ext-mq\">qpop</command>."
487 msgstr ""
489 #. type: Content of: <book><appendix><sect1><sect2><title>
490 #: ../en/appB-mq-ref.xml:300
491 msgid ""
492 "<command role=\"hg-ext-mq\">qpush</command>&emdash;push patches onto the stack"
493 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
495 #. type: Content of: <book><appendix><sect1><sect2><para>
496 #: ../en/appB-mq-ref.xml:303
497 msgid ""
498 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
499 "applied stack. By default, it adds only one patch."
500 msgstr ""
502 #. type: Content of: <book><appendix><sect1><sect2><para>
503 #: ../en/appB-mq-ref.xml:307
504 msgid ""
505 "This command creates a new changeset to represent each applied patch, and "
506 "updates the working directory to apply the effects of the patches."
507 msgstr ""
509 #. type: Content of: <book><appendix><sect1><sect2><para>
510 #: ../en/appB-mq-ref.xml:311
511 msgid "The default data used when creating a changeset are as follows:"
512 msgstr ""
514 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
515 #: ../en/appB-mq-ref.xml:314
516 msgid ""
517 "The commit date and time zone are the current date and time zone. Because "
518 "these data are used to compute the identity of a changeset, this means that "
519 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
520 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
521 "a different identity than the changeset you popped."
522 msgstr ""
524 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
525 #: ../en/appB-mq-ref.xml:322
526 msgid ""
527 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
528 "commit</command> command."
529 msgstr ""
531 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
532 #: ../en/appB-mq-ref.xml:326
533 msgid ""
534 "The commit message is any text from the patch file that comes before the "
535 "first diff header. If there is no such text, a default commit message is "
536 "used that identifies the name of the patch."
537 msgstr ""
539 #. type: Content of: <book><appendix><sect1><sect2><para>
540 #: ../en/appB-mq-ref.xml:331
541 msgid ""
542 "If a patch contains a Mercurial patch header (XXX add link), the information "
543 "in the patch header overrides these defaults."
544 msgstr ""
546 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
547 #: ../en/appB-mq-ref.xml:337
548 msgid ""
549 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
550 "patches from the <filename role=\"special\">series</filename> file until "
551 "there are none left to push."
552 msgstr ""
554 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
555 #: ../en/appB-mq-ref.xml:343
556 msgid ""
557 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
558 "patch to the end of the commit message."
559 msgstr ""
561 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
562 #: ../en/appB-mq-ref.xml:347
563 msgid ""
564 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
565 "apply cleanly, use the entry for the patch in another saved queue to compute "
566 "the parameters for a three-way merge, and perform a three-way merge using the "
567 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
568 "patch content."
569 msgstr ""
571 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
572 #: ../en/appB-mq-ref.xml:355
573 msgid ""
574 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
575 "merging while pushing."
576 msgstr ""
578 #. type: Content of: <book><appendix><sect1><sect2><para>
579 #: ../en/appB-mq-ref.xml:360
580 msgid ""
581 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
582 "modify, the <filename role=\"special\">series</filename> file. It appends "
583 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
584 "patch that it pushes."
585 msgstr ""
587 #. type: Content of: <book><appendix><sect1><sect2><title>
588 #: ../en/appB-mq-ref.xml:368
589 msgid ""
590 "<command role=\"hg-ext-mq\">qrefresh</command>&emdash;update the topmost "
591 "applied patch"
592 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
594 #. type: Content of: <book><appendix><sect1><sect2><para>
595 #: ../en/appB-mq-ref.xml:372
596 msgid ""
597 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
598 "topmost applied patch. It modifies the patch, removes the old changeset that "
599 "represented the patch, and creates a new changeset to represent the modified "
600 "patch."
601 msgstr ""
603 #. type: Content of: <book><appendix><sect1><sect2><para>
604 #: ../en/appB-mq-ref.xml:378
605 msgid ""
606 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
607 "following modifications:"
608 msgstr ""
610 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
611 #: ../en/appB-mq-ref.xml:381
612 msgid ""
613 "Changes to the commit message, i.e. the text before the first diff header in "
614 "the patch file, are reflected in the new changeset that represents the patch."
615 msgstr ""
617 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
618 #: ../en/appB-mq-ref.xml:386
619 msgid ""
620 "Modifications to tracked files in the working directory are added to the "
621 "patch."
622 msgstr ""
624 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
625 #: ../en/appB-mq-ref.xml:389
626 msgid ""
627 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
628 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
629 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
630 "files and copy and rename destinations are added to the patch, while removed "
631 "files and rename sources are removed."
632 msgstr ""
634 #. type: Content of: <book><appendix><sect1><sect2><para>
635 #: ../en/appB-mq-ref.xml:398
636 msgid ""
637 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
638 "still recreates the changeset that represents the patch. This causes the "
639 "identity of the changeset to differ from the previous changeset that "
640 "identified the patch."
641 msgstr ""
643 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
644 #: ../en/appB-mq-ref.xml:406
645 msgid ""
646 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
647 "and patch description, using the preferred text editor."
648 msgstr ""
650 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
651 #: ../en/appB-mq-ref.xml:411
652 msgid ""
653 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
654 "message and patch description, using the given text."
655 msgstr ""
657 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
658 #: ../en/appB-mq-ref.xml:416
659 msgid ""
660 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
661 "message and patch description, using text from the given file."
662 msgstr ""
664 #. type: Content of: <book><appendix><sect1><sect2><title>
665 #: ../en/appB-mq-ref.xml:424
666 msgid "<command role=\"hg-ext-mq\">qrename</command>&emdash;rename a patch"
667 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
669 #. type: Content of: <book><appendix><sect1><sect2><para>
670 #: ../en/appB-mq-ref.xml:427
671 msgid ""
672 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
673 "and changes the entry for the patch in the <filename role=\"special\">series</"
674 "filename> file."
675 msgstr ""
677 #. type: Content of: <book><appendix><sect1><sect2><para>
678 #: ../en/appB-mq-ref.xml:431
679 msgid ""
680 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
681 "the topmost applied patch. With two arguments, it renames its first argument "
682 "to its second."
683 msgstr ""
685 #. type: Content of: <book><appendix><sect1><sect2><title>
686 #: ../en/appB-mq-ref.xml:438
687 msgid ""
688 "<command role=\"hg-ext-mq\">qrestore</command>&emdash;restore saved queue "
689 "state"
690 msgstr "<command role=\"hg-ext-mq\">qrestore</command>—恢复保存的队列"
692 #. type: Content of: <book><appendix><sect1><sect2><para>
693 #: ../en/appB-mq-ref.xml:442
694 msgid "XXX No idea what this does."
695 msgstr ""
697 #. type: Content of: <book><appendix><sect1><sect2><title>
698 #: ../en/appB-mq-ref.xml:446
699 msgid ""
700 "<command role=\"hg-ext-mq\">qsave</command>&emdash;save current queue state"
701 msgstr "<command role=\"hg-ext-mq\">qsave</command>—保存当前的队列状态"
703 #. type: Content of: <book><appendix><sect1><sect2><para>
704 #: ../en/appB-mq-ref.xml:449
705 msgid "XXX Likewise."
706 msgstr ""
708 #. type: Content of: <book><appendix><sect1><sect2><title>
709 #: ../en/appB-mq-ref.xml:453
710 msgid ""
711 "<command role=\"hg-ext-mq\">qseries</command>&emdash;print the entire patch "
712 "series"
713 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
715 #. type: Content of: <book><appendix><sect1><sect2><para>
716 #: ../en/appB-mq-ref.xml:456
717 msgid ""
718 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
719 "patch series from the <filename role=\"special\">series</filename> file. It "
720 "prints only patch names, not empty lines or comments. It prints in order "
721 "from first to be applied to last."
722 msgstr ""
724 #. type: Content of: <book><appendix><sect1><sect2><title>
725 #: ../en/appB-mq-ref.xml:464
726 msgid ""
727 "<command role=\"hg-ext-mq\">qtop</command>&emdash;print the name of the "
728 "current patch"
729 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
731 #. type: Content of: <book><appendix><sect1><sect2><para>
732 #: ../en/appB-mq-ref.xml:467
733 msgid ""
734 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
735 "currently applied patch."
736 msgstr ""
738 #. type: Content of: <book><appendix><sect1><sect2><title>
739 #: ../en/appB-mq-ref.xml:472
740 msgid ""
741 "<command role=\"hg-ext-mq\">qunapplied</command>&emdash;print patches not yet "
742 "applied"
743 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
745 #. type: Content of: <book><appendix><sect1><sect2><para>
746 #: ../en/appB-mq-ref.xml:476
747 msgid ""
748 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
749 "of patches from the <filename role=\"special\">series</filename> file that "
750 "are not yet applied. It prints them in order from the next patch that will "
751 "be pushed to the last."
752 msgstr ""
754 #. type: Content of: <book><appendix><sect1><sect2><title>
755 #: ../en/appB-mq-ref.xml:484
756 msgid ""
757 "<command role=\"hg-cmd\">hg strip</command>&emdash;remove a revision and "
758 "descendants"
759 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
761 #. type: Content of: <book><appendix><sect1><sect2><para>
762 #: ../en/appB-mq-ref.xml:487
763 msgid ""
764 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
765 "and all of its descendants, from the repository. It undoes the effects of "
766 "the removed revisions from the repository, and updates the working directory "
767 "to the first parent of the removed revision."
768 msgstr ""
770 #. type: Content of: <book><appendix><sect1><sect2><para>
771 #: ../en/appB-mq-ref.xml:493
772 msgid ""
773 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
774 "removed changesets in a bundle, so that they can be reapplied if removed in "
775 "error."
776 msgstr ""
778 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
779 #: ../en/appB-mq-ref.xml:499
780 msgid ""
781 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
782 "intermixed with the stripped changesets in the backup bundle."
783 msgstr ""
785 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
786 #: ../en/appB-mq-ref.xml:503
787 msgid ""
788 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
789 "remove all heads. XXX This should be renamed, and use <literal>-f</literal> "
790 "to strip revs when there are pending changes."
791 msgstr ""
793 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
794 #: ../en/appB-mq-ref.xml:508
795 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
796 msgstr ""
798 #. type: Content of: <book><appendix><sect1><title>
799 #: ../en/appB-mq-ref.xml:515
800 msgid "MQ file reference"
801 msgstr "MQ 文件参考"
803 #. type: Content of: <book><appendix><sect1><sect2><title>
804 #: ../en/appB-mq-ref.xml:518
805 msgid "The <filename role=\"special\">series</filename> file"
806 msgstr "<filename role=\"special\">序列</filename>文件"
808 #. type: Content of: <book><appendix><sect1><sect2><para>
809 #: ../en/appB-mq-ref.xml:521
810 msgid ""
811 "The <filename role=\"special\">series</filename> file contains a list of the "
812 "names of all patches that MQ can apply. It is represented as a list of "
813 "names, with one name saved per line. Leading and trailing white space in "
814 "each line are ignored."
815 msgstr ""
817 #. type: Content of: <book><appendix><sect1><sect2><para>
818 #: ../en/appB-mq-ref.xml:527
819 msgid ""
820 "Lines may contain comments. A comment begins with the <quote><literal>#</"
821 "literal></quote> character, and extends to the end of the line. Empty lines, "
822 "and lines that contain only comments, are ignored."
823 msgstr ""
825 #. type: Content of: <book><appendix><sect1><sect2><para>
826 #: ../en/appB-mq-ref.xml:532
827 msgid ""
828 "You will often need to edit the <filename role=\"special\">series</filename> "
829 "file by hand, hence the support for comments and empty lines noted above. "
830 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
831 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
832 "You can also change the order in which patches are applied by reordering "
833 "their entries in the <filename role=\"special\">series</filename> file."
834 msgstr ""
836 #. type: Content of: <book><appendix><sect1><sect2><para>
837 #: ../en/appB-mq-ref.xml:541
838 msgid ""
839 "Placing the <filename role=\"special\">series</filename> file under revision "
840 "control is also supported; it is a good idea to place all of the patches that "
841 "it refers to under revision control, as well. If you create a patch "
842 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
843 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
844 "you automatically."
845 msgstr ""
847 #. type: Content of: <book><appendix><sect1><sect2><title>
848 #: ../en/appB-mq-ref.xml:551
849 msgid "The <filename role=\"special\">status</filename> file"
850 msgstr "<filename role=\"special\">状态</filename>文件"
852 #. type: Content of: <book><appendix><sect1><sect2><para>
853 #: ../en/appB-mq-ref.xml:554
854 msgid ""
855 "The <filename role=\"special\">status</filename> file contains the names and "
856 "changeset hashes of all patches that MQ currently has applied. Unlike the "
857 "<filename role=\"special\">series</filename> file, this file is not intended "
858 "for editing. You should not place this file under revision control, or "
859 "modify it in any way. It is used by MQ strictly for internal book-keeping."
860 msgstr ""
862 #. type: Content of: <book><appendix><title>
863 #: ../en/appC-srcinstall.xml:5
864 msgid "Installing Mercurial from source"
865 msgstr "从源代码安装 Mercurial"
867 #. type: Content of: <book><appendix><sect1><title>
868 #: ../en/appC-srcinstall.xml:8
869 msgid "On a Unix-like system"
870 msgstr "类 Unix 系统"
872 #. type: Content of: <book><appendix><sect1><para>
873 #: ../en/appC-srcinstall.xml:10
874 msgid ""
875 "If you are using a Unix-like system that has a sufficiently recent version of "
876 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
877 msgstr ""
878 "如果你使用类 Unix 系统,并且有足够新的 Python (2.3 更新),从源代码安装 "
879 "Mercurial 就很容易了。"
881 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
882 #: ../en/appC-srcinstall.xml:14
883 msgid ""
884 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
885 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
886 msgstr ""
887 "从 <ulink url=\"http://www.selenic.com/mercurial/download\">http://www."
888 "selenic.com/mercurial/download</ulink> 下载最新的源代码。"
890 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
891 #: ../en/appC-srcinstall.xml:17
892 msgid "Unpack the tarball:"
893 msgstr "解压:"
895 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
896 #: ../en/appC-srcinstall.xml:20
897 msgid ""
898 "Go into the source directory and run the installer script. This will build "
899 "Mercurial and install it in your home directory."
900 msgstr "进入源代码目录,执行安装教本。这会构建 Mercurial,安装到你的家目录。"
902 #. type: Content of: <book><appendix><sect1><para>
903 #: ../en/appC-srcinstall.xml:27
904 msgid ""
905 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
906 "subdirectory of your home directory. Don't forget to make sure that this "
907 "directory is present in your shell's search path."
908 msgstr ""
909 "安装完成后,Mercurial 就位于家目录的 <literal>bin</literal> 子目录。不要忘记将"
910 "这个目录加入到你的可执行文件搜索路径中。"
912 #. type: Content of: <book><appendix><sect1><para>
913 #: ../en/appC-srcinstall.xml:32
914 msgid ""
915 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
916 "variable so that the Mercurial executable can find the rest of the Mercurial "
917 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
918 "python</literal>. The exact path that you will need to use depends on how "
919 "Python was built for your system, but should be easy to figure out. If "
920 "you're uncertain, look through the output of the installer script above, and "
921 "see where the contents of the <literal>mercurial</literal> directory were "
922 "installed to."
923 msgstr ""
924 "你可能需要设置环境变量 <envar>PYTHONPATH</envar>,以便 Mercurial 可执行文件能"
925 "找到 Mercurial 包。例如,在我的笔记本电脑中,必须设置为 <literal>/home/bos/"
926 "lib/python</literal>。你需要使用的路径依赖于 Python 的构建方式,这很容易找出"
927 "来。如果你不确定,仔细察看上面的安装脚本输出,检查包含 <literal>mercurial</"
928 "literal> 目录的内容的安装位置。"
930 #. type: Content of: <book><appendix><sect1><title>
931 #: ../en/appC-srcinstall.xml:44
932 msgid "On Windows"
933 msgstr "Windows 系统"
935 #. type: Content of: <book><appendix><sect1><para>
936 #: ../en/appC-srcinstall.xml:46
937 msgid ""
938 "Building and installing Mercurial on Windows requires a variety of tools, a "
939 "fair amount of technical knowledge, and considerable patience. I very much "
940 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
941 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
942 "that you use a binary package instead."
943 msgstr ""
944 "在 Windows 中构建和安装 Mercurial 需要各种工具,相当多的技术背景,以及足够的耐"
945 "心。如果你是一个<quote>初级用户</quote>,我<emphasis>很不赞成</emphasis>这个方"
946 "法。我强烈建议你使用二进制安装包,除非你想深入研究 Mercurial 本身。"
948 #. type: Content of: <book><appendix><sect1><para>
949 #: ../en/appC-srcinstall.xml:53
950 msgid ""
951 "If you are intent on building Mercurial from source on Windows, follow the "
952 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
953 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
954 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
955 "process to involve a lot of fiddly work."
956 msgstr ""
957 "If you are intent on building Mercurial from source on Windows, follow the "
958 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
959 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
960 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
961 "process to involve a lot of fiddly work."
963 #. type: Content of: <book><appendix><title>
964 #: ../en/appD-license.xml:5
965 msgid "Open Publication License"
966 msgstr "开放出版协议"
968 #. type: Content of: <book><appendix><para>
969 #: ../en/appD-license.xml:7
970 msgid "Version 1.0, 8 June 1999"
971 msgstr "版本 1.0,1999 年 6 月 8 日。"
973 #. type: Content of: <book><appendix><sect1><title>
974 #: ../en/appD-license.xml:10
975 msgid "Requirements on both unmodified and modified versions"
976 msgstr ""
978 #. type: Content of: <book><appendix><sect1><para>
979 #: ../en/appD-license.xml:13
980 msgid ""
981 "The Open Publication works may be reproduced and distributed in whole or in "
982 "part, in any medium physical or electronic, provided that the terms of this "
983 "license are adhered to, and that this license or an incorporation of it by "
984 "reference (with any options elected by the author(s) and/or publisher) is "
985 "displayed in the reproduction."
986 msgstr ""
988 #. type: Content of: <book><appendix><sect1><para>
989 #: ../en/appD-license.xml:20
990 msgid "Proper form for an incorporation by reference is as follows:"
991 msgstr ""
993 #. type: Content of: <book><appendix><sect1><blockquote><para>
994 #: ../en/appD-license.xml:24
995 msgid ""
996 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
997 "designee</emphasis>. This material may be distributed only subject to the "
998 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
999 "y</emphasis> or later (the latest version is presently available at <ulink "
1000 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
1001 "openpub/</ulink>)."
1002 msgstr ""
1004 #. type: Content of: <book><appendix><sect1><para>
1005 #: ../en/appD-license.xml:33
1006 msgid ""
1007 "The reference must be immediately followed with any options elected by the "
1008 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
1009 "options\"/>)."
1010 msgstr ""
1012 #. type: Content of: <book><appendix><sect1><para>
1013 #: ../en/appD-license.xml:37
1014 msgid ""
1015 "Commercial redistribution of Open Publication-licensed material is permitted."
1016 msgstr ""
1018 #. type: Content of: <book><appendix><sect1><para>
1019 #: ../en/appD-license.xml:40
1020 msgid ""
1021 "Any publication in standard (paper) book form shall require the citation of "
1022 "the original publisher and author. The publisher and author's names shall "
1023 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1024 "the original publisher's name shall be as large as the title of the work and "
1025 "cited as possessive with respect to the title."
1026 msgstr ""
1028 #. type: Content of: <book><appendix><sect1><title>
1029 #: ../en/appD-license.xml:49
1030 msgid "Copyright"
1031 msgstr ""
1033 #. type: Content of: <book><appendix><sect1><para>
1034 #: ../en/appD-license.xml:51
1035 msgid ""
1036 "The copyright to each Open Publication is owned by its author(s) or designee."
1037 msgstr ""
1039 #. type: Content of: <book><appendix><sect1><title>
1040 #: ../en/appD-license.xml:56
1041 msgid "Scope of license"
1042 msgstr ""
1044 #. type: Content of: <book><appendix><sect1><para>
1045 #: ../en/appD-license.xml:58
1046 msgid ""
1047 "The following license terms apply to all Open Publication works, unless "
1048 "otherwise explicitly stated in the document."
1049 msgstr ""
1051 #. type: Content of: <book><appendix><sect1><para>
1052 #: ../en/appD-license.xml:62
1053 msgid ""
1054 "Mere aggregation of Open Publication works or a portion of an Open "
1055 "Publication work with other works or programs on the same media shall not "
1056 "cause this license to apply to those other works. The aggregate work shall "
1057 "contain a notice specifying the inclusion of the Open Publication material "
1058 "and appropriate copyright notice."
1059 msgstr ""
1061 #. type: Content of: <book><appendix><sect1><para>
1062 #: ../en/appD-license.xml:69
1063 msgid ""
1064 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1065 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1066 "the license remain in force."
1067 msgstr ""
1069 #. type: Content of: <book><appendix><sect1><para>
1070 #: ../en/appD-license.xml:74
1071 msgid ""
1072 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1073 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1074 "express or implied, including, but not limited to, the implied warranties of "
1075 "merchantability and fitness for a particular purpose or a warranty of non-"
1076 "infringement."
1077 msgstr ""
1079 #. type: Content of: <book><appendix><sect1><title>
1080 #: ../en/appD-license.xml:83
1081 msgid "Requirements on modified works"
1082 msgstr ""
1084 #. type: Content of: <book><appendix><sect1><para>
1085 #: ../en/appD-license.xml:85
1086 msgid ""
1087 "All modified versions of documents covered by this license, including "
1088 "translations, anthologies, compilations and partial documents, must meet the "
1089 "following requirements:"
1090 msgstr ""
1092 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1093 #: ../en/appD-license.xml:90
1094 msgid "The modified version must be labeled as such."
1095 msgstr ""
1097 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1098 #: ../en/appD-license.xml:93
1099 msgid ""
1100 "The person making the modifications must be identified and the modifications "
1101 "dated."
1102 msgstr ""
1104 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1105 #: ../en/appD-license.xml:96
1106 msgid ""
1107 "Acknowledgement of the original author and publisher if applicable must be "
1108 "retained according to normal academic citation practices."
1109 msgstr ""
1111 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1112 #: ../en/appD-license.xml:100
1113 msgid "The location of the original unmodified document must be identified."
1114 msgstr ""
1116 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1117 #: ../en/appD-license.xml:103
1118 msgid ""
1119 "The original author's (or authors') name(s) may not be used to assert or "
1120 "imply endorsement of the resulting document without the original author's (or "
1121 "authors') permission."
1122 msgstr ""
1124 #. type: Content of: <book><appendix><sect1><title>
1125 #: ../en/appD-license.xml:111
1126 msgid "Good-practice recommendations"
1127 msgstr ""
1129 #. type: Content of: <book><appendix><sect1><para>
1130 #: ../en/appD-license.xml:113
1131 msgid ""
1132 "In addition to the requirements of this license, it is requested from and "
1133 "strongly recommended of redistributors that:"
1134 msgstr ""
1136 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1137 #: ../en/appD-license.xml:118
1138 msgid ""
1139 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1140 "provide email notification to the authors of your intent to redistribute at "
1141 "least thirty days before your manuscript or media freeze, to give the authors "
1142 "time to provide updated documents. This notification should describe "
1143 "modifications, if any, made to the document."
1144 msgstr ""
1146 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1147 #: ../en/appD-license.xml:125
1148 msgid ""
1149 "All substantive modifications (including deletions) be either clearly marked "
1150 "up in the document or else described in an attachment to the document."
1151 msgstr ""
1153 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1154 #: ../en/appD-license.xml:129
1155 msgid ""
1156 "Finally, while it is not mandatory under this license, it is considered good "
1157 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1158 "Publication-licensed work to its author(s)."
1159 msgstr ""
1161 #. type: Content of: <book><appendix><sect1><title>
1162 #: ../en/appD-license.xml:137
1163 msgid "License options"
1164 msgstr ""
1166 #. type: Content of: <book><appendix><sect1><para>
1167 #: ../en/appD-license.xml:139
1168 msgid ""
1169 "The author(s) and/or publisher of an Open Publication-licensed document may "
1170 "elect certain options by appending language to the reference to or copy of "
1171 "the license. These options are considered part of the license instance and "
1172 "must be included with the license (or its incorporation by reference) in "
1173 "derived works."
1174 msgstr ""
1176 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1177 #: ../en/appD-license.xml:147
1178 msgid ""
1179 "To prohibit distribution of substantively modified versions without the "
1180 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1181 "is defined as a change to the semantic content of the document, and excludes "
1182 "mere changes in format or typographical corrections."
1183 msgstr ""
1185 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1186 #: ../en/appD-license.xml:154
1187 msgid ""
1188 "To accomplish this, add the phrase <quote>Distribution of substantively "
1189 "modified versions of this document is prohibited without the explicit "
1190 "permission of the copyright holder.</quote> to the license reference or copy."
1191 msgstr ""
1193 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1194 #: ../en/appD-license.xml:160
1195 msgid ""
1196 "To prohibit any publication of this work or derivative works in whole or in "
1197 "part in standard (paper) book form for commercial purposes is prohibited "
1198 "unless prior permission is obtained from the copyright holder."
1199 msgstr ""
1201 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1202 #: ../en/appD-license.xml:165
1203 msgid ""
1204 "To accomplish this, add the phrase <quote>Distribution of the work or "
1205 "derivative of the work in any standard (paper) book form is prohibited unless "
1206 "prior permission is obtained from the copyright holder.</quote> to the "
1207 "license reference or copy."
1208 msgstr ""
1210 #. type: Content of: <book><preface><title>
1211 #: ../en/ch00-preface.xml:5
1212 msgid "Preface"
1213 msgstr "序言"
1215 #. type: Content of: <book><preface><sect1><title>
1216 #: ../en/ch00-preface.xml:8
1217 msgid "Why revision control? Why Mercurial?"
1218 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
1220 #. type: Content of: <book><preface><sect1><para>
1221 #: ../en/ch00-preface.xml:10
1222 msgid ""
1223 "Revision control is the process of managing multiple versions of a piece of "
1224 "information. In its simplest form, this is something that many people do by "
1225 "hand: every time you modify a file, save it under a new name that contains a "
1226 "number, each one higher than the number of the preceding version."
1227 msgstr ""
1229 #. type: Content of: <book><preface><sect1><para>
1230 #: ../en/ch00-preface.xml:16
1231 msgid ""
1232 "Manually managing multiple versions of even a single file is an error-prone "
1233 "task, though, so software tools to help automate this process have long been "
1234 "available. The earliest automated revision control tools were intended to "
1235 "help a single user to manage revisions of a single file. Over the past few "
1236 "decades, the scope of revision control tools has expanded greatly; they now "
1237 "manage multiple files, and help multiple people to work together. The best "
1238 "modern revision control tools have no problem coping with thousands of people "
1239 "working together on projects that consist of hundreds of thousands of files."
1240 msgstr ""
1242 #. type: Content of: <book><preface><sect1><para>
1243 #: ../en/ch00-preface.xml:27
1244 msgid ""
1245 "The arrival of distributed revision control is relatively recent, and so far "
1246 "this new field has grown due to people's willingness to explore ill-charted "
1247 "territory."
1248 msgstr ""
1250 #. type: Content of: <book><preface><sect1><para>
1251 #: ../en/ch00-preface.xml:31
1252 msgid ""
1253 "I am writing a book about distributed revision control because I believe that "
1254 "it is an important subject that deserves a field guide. I chose to write "
1255 "about Mercurial because it is the easiest tool to learn the terrain with, and "
1256 "yet it scales to the demands of real, challenging environments where many "
1257 "other revision control tools buckle."
1258 msgstr ""
1260 #. type: Content of: <book><preface><sect1><sect2><title>
1261 #: ../en/ch00-preface.xml:39
1262 msgid "Why use revision control?"
1263 msgstr "为什么使用版本控制?"
1265 #. type: Content of: <book><preface><sect1><sect2><para>
1266 #: ../en/ch00-preface.xml:41
1267 msgid ""
1268 "There are a number of reasons why you or your team might want to use an "
1269 "automated revision control tool for a project."
1270 msgstr ""
1272 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1273 #: ../en/ch00-preface.xml:46
1274 msgid ""
1275 "It will track the history and evolution of your project, so you don't have "
1276 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
1277 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
1278 "it; and <emphasis>what</emphasis> the change was."
1279 msgstr ""
1281 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1282 #: ../en/ch00-preface.xml:53
1283 msgid ""
1284 "When you're working with other people, revision control software makes it "
1285 "easier for you to collaborate. For example, when people more or less "
1286 "simultaneously make potentially incompatible changes, the software will help "
1287 "you to identify and resolve those conflicts."
1288 msgstr ""
1290 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1291 #: ../en/ch00-preface.xml:59
1292 msgid ""
1293 "It can help you to recover from mistakes. If you make a change that later "
1294 "turns out to be in error, you can revert to an earlier version of one or more "
1295 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
1296 "will even help you to efficiently figure out exactly when a problem was "
1297 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
1298 msgstr ""
1300 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1301 #: ../en/ch00-preface.xml:66
1302 msgid ""
1303 "It will help you to work simultaneously on, and manage the drift between, "
1304 "multiple versions of your project."
1305 msgstr ""
1307 #. type: Content of: <book><preface><sect1><sect2><para>
1308 #: ../en/ch00-preface.xml:71
1309 msgid ""
1310 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
1311 "whether you're working on a project by yourself, or with a hundred other "
1312 "people."
1313 msgstr ""
1315 #. type: Content of: <book><preface><sect1><sect2><para>
1316 #: ../en/ch00-preface.xml:76
1317 msgid ""
1318 "A key question about the practicality of revision control at these two "
1319 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
1320 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
1321 "emphasis>. A revision control tool that's difficult to understand or use is "
1322 "going to impose a high cost."
1323 msgstr ""
1325 #. type: Content of: <book><preface><sect1><sect2><para>
1326 #: ../en/ch00-preface.xml:84
1327 msgid ""
1328 "A five-hundred-person project is likely to collapse under its own weight "
1329 "almost immediately without a revision control tool and process. In this case, "
1330 "the cost of using revision control might hardly seem worth considering, since "
1331 "<emphasis>without</emphasis> it, failure is almost guaranteed."
1332 msgstr ""
1334 #. type: Content of: <book><preface><sect1><sect2><para>
1335 #: ../en/ch00-preface.xml:91
1336 msgid ""
1337 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
1338 "poor place to use a revision control tool, because surely the cost of using "
1339 "one must be close to the overall cost of the project. Right?"
1340 msgstr ""
1342 #. type: Content of: <book><preface><sect1><sect2><para>
1343 #: ../en/ch00-preface.xml:96
1344 msgid ""
1345 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
1346 "development. You can learn the basics in just a few minutes, and due to its "
1347 "low overhead, you can apply revision control to the smallest of projects with "
1348 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
1349 "command sequences competing for mental space with whatever you're "
1350 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
1351 "performance and peer-to-peer nature let you scale painlessly to handle large "
1352 "projects."
1353 msgstr ""
1355 #. type: Content of: <book><preface><sect1><sect2><para>
1356 #: ../en/ch00-preface.xml:106
1357 msgid ""
1358 "No revision control tool can rescue a poorly run project, but a good choice "
1359 "of tools can make a huge difference to the fluidity with which you can work "
1360 "on a project."
1361 msgstr ""
1363 #. type: Content of: <book><preface><sect1><sect2><title>
1364 #: ../en/ch00-preface.xml:113
1365 msgid "The many names of revision control"
1366 msgstr "版本控制的别名"
1368 #. type: Content of: <book><preface><sect1><sect2><para>
1369 #: ../en/ch00-preface.xml:115
1370 msgid ""
1371 "Revision control is a diverse field, so much so that it is referred to by "
1372 "many names and acronyms. Here are a few of the more common variations you'll "
1373 "encounter:"
1374 msgstr ""
1376 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1377 #: ../en/ch00-preface.xml:119
1378 msgid "Revision control (RCS)"
1379 msgstr "版本控制(RCS)"
1381 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1382 #: ../en/ch00-preface.xml:120
1383 msgid "Software configuration management (SCM), or configuration management"
1384 msgstr "软件配置管理(SCM),或配置管理"
1386 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1387 #: ../en/ch00-preface.xml:122
1388 msgid "Source code management"
1389 msgstr "源代码管理"
1391 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1392 #: ../en/ch00-preface.xml:123
1393 msgid "Source code control, or source control"
1394 msgstr "源代码控制,或源控制"
1396 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1397 #: ../en/ch00-preface.xml:125
1398 msgid "Version control (VCS)"
1399 msgstr "版本控制(VCS)"
1401 #. type: Content of: <book><preface><sect1><sect2><para>
1402 #: ../en/ch00-preface.xml:127
1403 msgid ""
1404 "Some people claim that these terms actually have different meanings, but in "
1405 "practice they overlap so much that there's no agreed or even useful way to "
1406 "tease them apart."
1407 msgstr ""
1409 #. type: Content of: <book><preface><sect1><title>
1410 #: ../en/ch00-preface.xml:135
1411 msgid "This book is a work in progress"
1412 msgstr "本书正在编写中"
1414 #. type: Content of: <book><preface><sect1><para>
1415 #: ../en/ch00-preface.xml:137
1416 msgid ""
1417 "I am releasing this book while I am still writing it, in the hope that it "
1418 "will prove useful to others. I am writing under an open license in the hope "
1419 "that you, my readers, will contribute feedback and perhaps content of your "
1420 "own."
1421 msgstr ""
1423 #. type: Content of: <book><preface><sect1><title>
1424 #: ../en/ch00-preface.xml:144
1425 msgid "About the examples in this book"
1426 msgstr "本书的例子"
1428 #. type: Content of: <book><preface><sect1><para>
1429 #: ../en/ch00-preface.xml:146
1430 msgid ""
1431 "This book takes an unusual approach to code samples. Every example is "
1432 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
1433 "that executes the Mercurial commands you see. Every time an image of the "
1434 "book is built from its sources, all the example scripts are automatically "
1435 "run, and their current results compared against their expected results."
1436 msgstr ""
1438 #. type: Content of: <book><preface><sect1><para>
1439 #: ../en/ch00-preface.xml:153
1440 msgid ""
1441 "The advantage of this approach is that the examples are always accurate; they "
1442 "describe <emphasis>exactly</emphasis> the behavior of the version of "
1443 "Mercurial that's mentioned at the front of the book. If I update the version "
1444 "of Mercurial that I'm documenting, and the output of some command changes, "
1445 "the build fails."
1446 msgstr ""
1448 #. type: Content of: <book><preface><sect1><para>
1449 #: ../en/ch00-preface.xml:160
1450 msgid ""
1451 "There is a small disadvantage to this approach, which is that the dates and "
1452 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
1453 "way that they wouldn't be if the same commands were being typed by a human. "
1454 "Where a human can issue no more than one command every few seconds, with any "
1455 "resulting timestamps correspondingly spread out, my automated example scripts "
1456 "run many commands in one second."
1457 msgstr ""
1459 #. type: Content of: <book><preface><sect1><para>
1460 #: ../en/ch00-preface.xml:168
1461 msgid ""
1462 "As an instance of this, several consecutive commits in an example can show up "
1463 "as having occurred during the same second. You can see this occur in the "
1464 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
1465 "bisect\"/>, for instance."
1466 msgstr ""
1468 #. type: Content of: <book><preface><sect1><para>
1469 #: ../en/ch00-preface.xml:174
1470 msgid ""
1471 "So when you're reading examples, don't place too much weight on the dates or "
1472 "times you see in the output of commands. But <emphasis>do</emphasis> be "
1473 "confident that the behavior you're seeing is consistent and reproducible."
1474 msgstr ""
1476 #. type: Content of: <book><preface><sect1><title>
1477 #: ../en/ch00-preface.xml:182
1478 msgid "Trends in the field"
1479 msgstr "版本控制的发展趋势"
1481 #. type: Content of: <book><preface><sect1><para>
1482 #: ../en/ch00-preface.xml:184
1483 msgid ""
1484 "There has been an unmistakable trend in the development and use of revision "
1485 "control tools over the past four decades, as people have become familiar with "
1486 "the capabilities of their tools and constrained by their limitations."
1487 msgstr ""
1489 #. type: Content of: <book><preface><sect1><para>
1490 #: ../en/ch00-preface.xml:189
1491 msgid ""
1492 "The first generation began by managing single files on individual computers. "
1493 "Although these tools represented a huge advance over ad-hoc manual revision "
1494 "control, their locking model and reliance on a single computer limited them "
1495 "to small, tightly-knit teams."
1496 msgstr ""
1498 #. type: Content of: <book><preface><sect1><para>
1499 #: ../en/ch00-preface.xml:195
1500 msgid ""
1501 "The second generation loosened these constraints by moving to network-"
1502 "centered architectures, and managing entire projects at a time. As projects "
1503 "grew larger, they ran into new problems. With clients needing to talk to "
1504 "servers very frequently, server scaling became an issue for large projects. "
1505 "An unreliable network connection could prevent remote users from being able "
1506 "to talk to the server at all. As open source projects started making read-"
1507 "only access available anonymously to anyone, people without commit privileges "
1508 "found that they could not use the tools to interact with a project in a "
1509 "natural way, as they could not record their changes."
1510 msgstr ""
1512 #. type: Content of: <book><preface><sect1><para>
1513 #: ../en/ch00-preface.xml:207
1514 msgid ""
1515 "The current generation of revision control tools is peer-to-peer in nature. "
1516 "All of these systems have dropped the dependency on a single central server, "
1517 "and allow people to distribute their revision control data to where it's "
1518 "actually needed. Collaboration over the Internet has moved from constrained "
1519 "by technology to a matter of choice and consensus. Modern tools can operate "
1520 "offline indefinitely and autonomously, with a network connection only needed "
1521 "when syncing changes with another repository."
1522 msgstr ""
1524 #. type: Content of: <book><preface><sect1><title>
1525 #: ../en/ch00-preface.xml:219
1526 msgid "A few of the advantages of distributed revision control"
1527 msgstr "分布版本控制的优点"
1529 #. type: Content of: <book><preface><sect1><para>
1530 #: ../en/ch00-preface.xml:222
1531 msgid ""
1532 "Even though distributed revision control tools have for several years been as "
1533 "robust and usable as their previous-generation counterparts, people using "
1534 "older tools have not yet necessarily woken up to their advantages. There are "
1535 "a number of ways in which distributed tools shine relative to centralised "
1536 "ones."
1537 msgstr ""
1539 #. type: Content of: <book><preface><sect1><para>
1540 #: ../en/ch00-preface.xml:229
1541 msgid ""
1542 "For an individual developer, distributed tools are almost always much faster "
1543 "than centralised tools. This is for a simple reason: a centralised tool "
1544 "needs to talk over the network for many common operations, because most "
1545 "metadata is stored in a single copy on the central server. A distributed "
1546 "tool stores all of its metadata locally. All else being equal, talking over "
1547 "the network adds overhead to a centralised tool. Don't underestimate the "
1548 "value of a snappy, responsive tool: you're going to spend a lot of time "
1549 "interacting with your revision control software."
1550 msgstr ""
1552 #. type: Content of: <book><preface><sect1><para>
1553 #: ../en/ch00-preface.xml:240
1554 msgid ""
1555 "Distributed tools are indifferent to the vagaries of your server "
1556 "infrastructure, again because they replicate metadata to so many locations. "
1557 "If you use a centralised system and your server catches fire, you'd better "
1558 "hope that your backup media are reliable, and that your last backup was "
1559 "recent and actually worked. With a distributed tool, you have many backups "
1560 "available on every contributor's computer."
1561 msgstr ""
1563 #. type: Content of: <book><preface><sect1><para>
1564 #: ../en/ch00-preface.xml:248
1565 msgid ""
1566 "The reliability of your network will affect distributed tools far less than "
1567 "it will centralised tools. You can't even use a centralised tool without a "
1568 "network connection, except for a few highly constrained commands. With a "
1569 "distributed tool, if your network connection goes down while you're working, "
1570 "you may not even notice. The only thing you won't be able to do is talk to "
1571 "repositories on other computers, something that is relatively rare compared "
1572 "with local operations. If you have a far-flung team of collaborators, this "
1573 "may be significant."
1574 msgstr ""
1576 #. type: Content of: <book><preface><sect1><sect2><title>
1577 #: ../en/ch00-preface.xml:259
1578 msgid "Advantages for open source projects"
1579 msgstr "开源项目的优点"
1581 #. type: Content of: <book><preface><sect1><sect2><para>
1582 #: ../en/ch00-preface.xml:261
1583 msgid ""
1584 "If you take a shine to an open source project and decide that you would like "
1585 "to start hacking on it, and that project uses a distributed revision control "
1586 "tool, you are at once a peer with the people who consider themselves the "
1587 "<quote>core</quote> of that project. If they publish their repositories, you "
1588 "can immediately copy their project history, start making changes, and record "
1589 "your work, using the same tools in the same ways as insiders. By contrast, "
1590 "with a centralised tool, you must use the software in a <quote>read only</"
1591 "quote> mode unless someone grants you permission to commit changes to their "
1592 "central server. Until then, you won't be able to record changes, and your "
1593 "local modifications will be at risk of corruption any time you try to update "
1594 "your client's view of the repository."
1595 msgstr ""
1597 #. type: Content of: <book><preface><sect1><sect2><sect3><title>
1598 #: ../en/ch00-preface.xml:277
1599 msgid "The forking non-problem"
1600 msgstr "分叉不是问题"
1602 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1603 #: ../en/ch00-preface.xml:279
1604 msgid ""
1605 "It has been suggested that distributed revision control tools pose some sort "
1606 "of risk to open source projects because they make it easy to <quote>fork</"
1607 "quote> the development of a project. A fork happens when there are "
1608 "differences in opinion or attitude between groups of developers that cause "
1609 "them to decide that they can't work together any longer. Each side takes a "
1610 "more or less complete copy of the project's source code, and goes off in its "
1611 "own direction."
1612 msgstr ""
1614 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1615 #: ../en/ch00-preface.xml:289
1616 msgid ""
1617 "Sometimes the camps in a fork decide to reconcile their differences. With a "
1618 "centralised revision control system, the <emphasis>technical</emphasis> "
1619 "process of reconciliation is painful, and has to be performed largely by "
1620 "hand. You have to decide whose revision history is going to <quote>win</"
1621 "quote>, and graft the other team's changes into the tree somehow. This "
1622 "usually loses some or all of one side's revision history."
1623 msgstr ""
1625 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1626 #: ../en/ch00-preface.xml:298
1627 msgid ""
1628 "What distributed tools do with respect to forking is they make forking the "
1629 "<emphasis>only</emphasis> way to develop a project. Every single change that "
1630 "you make is potentially a fork point. The great strength of this approach is "
1631 "that a distributed revision control tool has to be really good at "
1632 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
1633 "they happen all the time."
1634 msgstr ""
1636 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1637 #: ../en/ch00-preface.xml:307
1638 msgid ""
1639 "If every piece of work that everybody does, all the time, is framed in terms "
1640 "of forking and merging, then what the open source world refers to as a "
1641 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
1642 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
1643 "fork:"
1644 msgstr ""
1646 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1647 #: ../en/ch00-preface.xml:314
1648 msgid ""
1649 "They eliminate the social distinction that centralised tools impose: that "
1650 "between insiders (people with commit access) and outsiders (people without)."
1651 msgstr ""
1653 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1654 #: ../en/ch00-preface.xml:318
1655 msgid ""
1656 "They make it easier to reconcile after a social fork, because all that's "
1657 "involved from the perspective of the revision control software is just "
1658 "another merge."
1659 msgstr ""
1661 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1662 #: ../en/ch00-preface.xml:323
1663 msgid ""
1664 "Some people resist distributed tools because they want to retain tight "
1665 "control over their projects, and they believe that centralised tools give "
1666 "them this control. However, if you're of this belief, and you publish your "
1667 "CVS or Subversion repositories publicly, there are plenty of tools available "
1668 "that can pull out your entire project's history (albeit slowly) and recreate "
1669 "it somewhere that you don't control. So while your control in this case is "
1670 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
1671 "people feel compelled to mirror and fork your history."
1672 msgstr ""
1674 #. type: Content of: <book><preface><sect1><sect2><title>
1675 #: ../en/ch00-preface.xml:338
1676 msgid "Advantages for commercial projects"
1677 msgstr "商业项目的优点"
1679 #. type: Content of: <book><preface><sect1><sect2><para>
1680 #: ../en/ch00-preface.xml:340
1681 msgid ""
1682 "Many commercial projects are undertaken by teams that are scattered across "
1683 "the globe. Contributors who are far from a central server will see slower "
1684 "command execution and perhaps less reliability. Commercial revision control "
1685 "systems attempt to ameliorate these problems with remote-site replication add-"
1686 "ons that are typically expensive to buy and cantankerous to administer. A "
1687 "distributed system doesn't suffer from these problems in the first place. "
1688 "Better yet, you can easily set up multiple authoritative servers, say one per "
1689 "site, so that there's no redundant communication between repositories over "
1690 "expensive long-haul network links."
1691 msgstr ""
1693 #. type: Content of: <book><preface><sect1><sect2><para>
1694 #: ../en/ch00-preface.xml:352
1695 msgid ""
1696 "Centralised revision control systems tend to have relatively low "
1697 "scalability. It's not unusual for an expensive centralised system to fall "
1698 "over under the combined load of just a few dozen concurrent users. Once "
1699 "again, the typical response tends to be an expensive and clunky replication "
1700 "facility. Since the load on a central server&emdash;if you have one at "
1701 "all&emdash;is many times lower with a distributed tool (because all of the "
1702 "data is replicated everywhere), a single cheap server can handle the needs of "
1703 "a much larger team, and replication to balance load becomes a simple matter "
1704 "of scripting."
1705 msgstr ""
1707 #. type: Content of: <book><preface><sect1><sect2><para>
1708 #: ../en/ch00-preface.xml:364
1709 msgid ""
1710 "If you have an employee in the field, troubleshooting a problem at a "
1711 "customer's site, they'll benefit from distributed revision control. The tool "
1712 "will let them generate custom builds, try different fixes in isolation from "
1713 "each other, and search efficiently through history for the sources of bugs "
1714 "and regressions in the customer's environment, all without needing to connect "
1715 "to your company's network."
1716 msgstr ""
1718 #. type: Content of: <book><preface><sect1><title>
1719 #: ../en/ch00-preface.xml:375
1720 msgid "Why choose Mercurial?"
1721 msgstr "为什么选择 Mercurial?"
1723 #. type: Content of: <book><preface><sect1><para>
1724 #: ../en/ch00-preface.xml:377
1725 msgid ""
1726 "Mercurial has a unique set of properties that make it a particularly good "
1727 "choice as a revision control system."
1728 msgstr ""
1730 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1731 #: ../en/ch00-preface.xml:380
1732 msgid "It is easy to learn and use."
1733 msgstr ""
1735 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1736 #: ../en/ch00-preface.xml:381
1737 msgid "It is lightweight."
1738 msgstr ""
1740 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1741 #: ../en/ch00-preface.xml:382
1742 msgid "It scales excellently."
1743 msgstr ""
1745 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1746 #: ../en/ch00-preface.xml:383
1747 msgid "It is easy to customise."
1748 msgstr ""
1750 #. type: Content of: <book><preface><sect1><para>
1751 #: ../en/ch00-preface.xml:386
1752 msgid ""
1753 "If you are at all familiar with revision control systems, you should be able "
1754 "to get up and running with Mercurial in less than five minutes. Even if not, "
1755 "it will take no more than a few minutes longer. Mercurial's command and "
1756 "feature sets are generally uniform and consistent, so you can keep track of a "
1757 "few general rules instead of a host of exceptions."
1758 msgstr ""
1760 #. type: Content of: <book><preface><sect1><para>
1761 #: ../en/ch00-preface.xml:393
1762 msgid ""
1763 "On a small project, you can start working with Mercurial in moments. Creating "
1764 "new changes and branches; transferring changes around (whether locally or "
1765 "over a network); and history and status operations are all fast. Mercurial "
1766 "attempts to stay nimble and largely out of your way by combining low "
1767 "cognitive overhead with blazingly fast operations."
1768 msgstr ""
1770 #. type: Content of: <book><preface><sect1><para>
1771 #: ../en/ch00-preface.xml:400
1772 msgid ""
1773 "The usefulness of Mercurial is not limited to small projects: it is used by "
1774 "projects with hundreds to thousands of contributors, each containing tens of "
1775 "thousands of files and hundreds of megabytes of source code."
1776 msgstr ""
1778 #. type: Content of: <book><preface><sect1><para>
1779 #: ../en/ch00-preface.xml:405
1780 msgid ""
1781 "If the core functionality of Mercurial is not enough for you, it's easy to "
1782 "build on. Mercurial is well suited to scripting tasks, and its clean "
1783 "internals and implementation in Python make it easy to add features in the "
1784 "form of extensions. There are a number of popular and useful extensions "
1785 "already available, ranging from helping to identify bugs to improving "
1786 "performance."
1787 msgstr ""
1789 #. type: Content of: <book><preface><sect1><title>
1790 #: ../en/ch00-preface.xml:415
1791 msgid "Mercurial compared with other tools"
1792 msgstr "Mercurial 与其它工具的比较"
1794 #. type: Content of: <book><preface><sect1><para>
1795 #: ../en/ch00-preface.xml:417
1796 msgid ""
1797 "Before you read on, please understand that this section necessarily reflects "
1798 "my own experiences, interests, and (dare I say it) biases. I have used every "
1799 "one of the revision control tools listed below, in most cases for several "
1800 "years at a time."
1801 msgstr ""
1803 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1804 #: ../en/ch00-preface.xml:425 ../en/ch00-preface.xml:636
1805 msgid "Subversion"
1806 msgstr ""
1808 #. type: Content of: <book><preface><sect1><sect2><para>
1809 #: ../en/ch00-preface.xml:427
1810 msgid ""
1811 "Subversion is a popular revision control tool, developed to replace CVS. It "
1812 "has a centralised client/server architecture."
1813 msgstr ""
1815 #. type: Content of: <book><preface><sect1><sect2><para>
1816 #: ../en/ch00-preface.xml:431
1817 msgid ""
1818 "Subversion and Mercurial have similarly named commands for performing the "
1819 "same operations, so if you're familiar with one, it is easy to learn to use "
1820 "the other. Both tools are portable to all popular operating systems."
1821 msgstr ""
1823 #. type: Content of: <book><preface><sect1><sect2><para>
1824 #: ../en/ch00-preface.xml:436
1825 msgid ""
1826 "Prior to version 1.5, Subversion had no useful support for merges. At the "
1827 "time of writing, its merge tracking capability is new, and known to be <ulink "
1828 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
1829 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
1830 msgstr ""
1832 #. type: Content of: <book><preface><sect1><sect2><para>
1833 #: ../en/ch00-preface.xml:442
1834 msgid ""
1835 "Mercurial has a substantial performance advantage over Subversion on every "
1836 "revision control operation I have benchmarked. I have measured its advantage "
1837 "as ranging from a factor of two to a factor of six when compared with "
1838 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
1839 "fastest access method available. In more realistic deployments involving a "
1840 "network-based store, Subversion will be at a substantially larger "
1841 "disadvantage. Because many Subversion commands must talk to the server and "
1842 "Subversion does not have useful replication facilities, server capacity and "
1843 "network bandwidth become bottlenecks for modestly large projects."
1844 msgstr ""
1846 #. type: Content of: <book><preface><sect1><sect2><para>
1847 #: ../en/ch00-preface.xml:455
1848 msgid ""
1849 "Additionally, Subversion incurs substantial storage overhead to avoid network "
1850 "transactions for a few common operations, such as finding modified files "
1851 "(<literal>status</literal>) and displaying modifications against the current "
1852 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
1853 "is often the same size as, or larger than, a Mercurial repository and working "
1854 "directory, even though the Mercurial repository contains a complete history "
1855 "of the project."
1856 msgstr ""
1858 #. type: Content of: <book><preface><sect1><sect2><para>
1859 #: ../en/ch00-preface.xml:465
1860 msgid ""
1861 "Subversion is widely supported by third party tools. Mercurial currently "
1862 "lags considerably in this area. This gap is closing, however, and indeed "
1863 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
1864 "Like Mercurial, Subversion has an excellent user manual."
1865 msgstr ""
1867 #. type: Content of: <book><preface><sect1><sect2><para>
1868 #: ../en/ch00-preface.xml:471
1869 msgid ""
1870 "Because Subversion doesn't store revision history on the client, it is well "
1871 "suited to managing projects that deal with lots of large, opaque binary "
1872 "files. If you check in fifty revisions to an incompressible 10MB file, "
1873 "Subversion's client-side space usage stays constant The space used by any "
1874 "distributed SCM will grow rapidly in proportion to the number of revisions, "
1875 "because the differences between each revision are large."
1876 msgstr ""
1878 #. type: Content of: <book><preface><sect1><sect2><para>
1879 #: ../en/ch00-preface.xml:480
1880 msgid ""
1881 "In addition, it's often difficult or, more usually, impossible to merge "
1882 "different versions of a binary file. Subversion's ability to let a user lock "
1883 "a file, so that they temporarily have the exclusive right to commit changes "
1884 "to it, can be a significant advantage to a project where binary files are "
1885 "widely used."
1886 msgstr ""
1888 #. type: Content of: <book><preface><sect1><sect2><para>
1889 #: ../en/ch00-preface.xml:487
1890 msgid ""
1891 "Mercurial can import revision history from a Subversion repository. It can "
1892 "also export revision history to a Subversion repository. This makes it easy "
1893 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
1894 "parallel before deciding to switch. History conversion is incremental, so "
1895 "you can perform an initial conversion, then small additional conversions "
1896 "afterwards to bring in new changes."
1897 msgstr ""
1899 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1900 #: ../en/ch00-preface.xml:499 ../en/ch00-preface.xml:638
1901 msgid "Git"
1902 msgstr "Git"
1904 #. type: Content of: <book><preface><sect1><sect2><para>
1905 #: ../en/ch00-preface.xml:501
1906 msgid ""
1907 "Git is a distributed revision control tool that was developed for managing "
1908 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
1909 "influenced by Monotone."
1910 msgstr ""
1912 #. type: Content of: <book><preface><sect1><sect2><para>
1913 #: ../en/ch00-preface.xml:506
1914 msgid ""
1915 "Git has a very large command set, with version 1.5.0 providing 139 individual "
1916 "commands. It has something of a reputation for being difficult to learn. "
1917 "Compared to Git, Mercurial has a strong focus on simplicity."
1918 msgstr ""
1920 #. type: Content of: <book><preface><sect1><sect2><para>
1921 #: ../en/ch00-preface.xml:511
1922 msgid ""
1923 "In terms of performance, Git is extremely fast. In several cases, it is "
1924 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
1925 "other operations. However, on Windows, the performance and general level of "
1926 "support that Git provides is, at the time of writing, far behind that of "
1927 "Mercurial."
1928 msgstr ""
1930 #. type: Content of: <book><preface><sect1><sect2><para>
1931 #: ../en/ch00-preface.xml:518
1932 msgid ""
1933 "While a Mercurial repository needs no maintenance, a Git repository requires "
1934 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
1935 "performance degrades, while space usage grows rapidly. A server that "
1936 "contains many Git repositories that are not rigorously and frequently "
1937 "repacked will become heavily disk-bound during backups, and there have been "
1938 "instances of daily backups taking far longer than 24 hours as a result. A "
1939 "freshly packed Git repository is slightly smaller than a Mercurial "
1940 "repository, but an unpacked repository is several orders of magnitude larger."
1941 msgstr ""
1943 #. type: Content of: <book><preface><sect1><sect2><para>
1944 #: ../en/ch00-preface.xml:529
1945 msgid ""
1946 "The core of Git is written in C. Many Git commands are implemented as shell "
1947 "or Perl scripts, and the quality of these scripts varies widely. I have "
1948 "encountered several instances where scripts charged along blindly in the "
1949 "presence of errors that should have been fatal."
1950 msgstr ""
1952 #. type: Content of: <book><preface><sect1><sect2><para>
1953 #: ../en/ch00-preface.xml:535
1954 msgid "Mercurial can import revision history from a Git repository."
1955 msgstr ""
1957 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1958 #: ../en/ch00-preface.xml:541 ../en/ch00-preface.xml:637
1959 msgid "CVS"
1960 msgstr "CVS"
1962 #. type: Content of: <book><preface><sect1><sect2><para>
1963 #: ../en/ch00-preface.xml:543
1964 msgid ""
1965 "CVS is probably the most widely used revision control tool in the world. Due "
1966 "to its age and internal untidiness, it has been only lightly maintained for "
1967 "many years."
1968 msgstr ""
1970 #. type: Content of: <book><preface><sect1><sect2><para>
1971 #: ../en/ch00-preface.xml:547
1972 msgid ""
1973 "It has a centralised client/server architecture. It does not group related "
1974 "file changes into atomic commits, making it easy for people to <quote>break "
1975 "the build</quote>: one person can successfully commit part of a change and "
1976 "then be blocked by the need for a merge, causing other people to see only a "
1977 "portion of the work they intended to do. This also affects how you work with "
1978 "project history. If you want to see all of the modifications someone made as "
1979 "part of a task, you will need to manually inspect the descriptions and "
1980 "timestamps of the changes made to each file involved (if you even know what "
1981 "those files were)."
1982 msgstr ""
1984 #. type: Content of: <book><preface><sect1><sect2><para>
1985 #: ../en/ch00-preface.xml:559
1986 msgid ""
1987 "CVS has a muddled notion of tags and branches that I will not attempt to even "
1988 "describe. It does not support renaming of files or directories well, making "
1989 "it easy to corrupt a repository. It has almost no internal consistency "
1990 "checking capabilities, so it is usually not even possible to tell whether or "
1991 "how a repository is corrupt. I would not recommend CVS for any project, "
1992 "existing or new."
1993 msgstr ""
1995 #. type: Content of: <book><preface><sect1><sect2><para>
1996 #: ../en/ch00-preface.xml:567
1997 msgid ""
1998 "Mercurial can import CVS revision history. However, there are a few caveats "
1999 "that apply; these are true of every other revision control tool's CVS "
2000 "importer, too. Due to CVS's lack of atomic changes and unversioned "
2001 "filesystem hierarchy, it is not possible to reconstruct CVS history "
2002 "completely accurately; some guesswork is involved, and renames will usually "
2003 "not show up. Because a lot of advanced CVS administration has to be done by "
2004 "hand and is hence error-prone, it's common for CVS importers to run into "
2005 "multiple problems with corrupted repositories (completely bogus revision "
2006 "timestamps and files that have remained locked for over a decade are just two "
2007 "of the less interesting problems I can recall from personal experience)."
2008 msgstr ""
2010 #. type: Content of: <book><preface><sect1><sect2><para>
2011 #: ../en/ch00-preface.xml:581
2012 msgid "Mercurial can import revision history from a CVS repository."
2013 msgstr ""
2015 #. type: Content of: <book><preface><sect1><sect2><title>
2016 #: ../en/ch00-preface.xml:587
2017 msgid "Commercial tools"
2018 msgstr "商业工具"
2020 #. type: Content of: <book><preface><sect1><sect2><para>
2021 #: ../en/ch00-preface.xml:589
2022 msgid ""
2023 "Perforce has a centralised client/server architecture, with no client-side "
2024 "caching of any data. Unlike modern revision control tools, Perforce requires "
2025 "that a user run a command to inform the server about every file they intend "
2026 "to edit."
2027 msgstr ""
2029 #. type: Content of: <book><preface><sect1><sect2><para>
2030 #: ../en/ch00-preface.xml:595
2031 msgid ""
2032 "The performance of Perforce is quite good for small teams, but it falls off "
2033 "rapidly as the number of users grows beyond a few dozen. Modestly large "
2034 "Perforce installations require the deployment of proxies to cope with the "
2035 "load their users generate."
2036 msgstr ""
2038 #. type: Content of: <book><preface><sect1><sect2><title>
2039 #: ../en/ch00-preface.xml:604
2040 msgid "Choosing a revision control tool"
2041 msgstr "选择版本控制工具"
2043 #. type: Content of: <book><preface><sect1><sect2><para>
2044 #: ../en/ch00-preface.xml:606
2045 msgid ""
2046 "With the exception of CVS, all of the tools listed above have unique "
2047 "strengths that suit them to particular styles of work. There is no single "
2048 "revision control tool that is best in all situations."
2049 msgstr ""
2051 #. type: Content of: <book><preface><sect1><sect2><para>
2052 #: ../en/ch00-preface.xml:611
2053 msgid ""
2054 "As an example, Subversion is a good choice for working with frequently edited "
2055 "binary files, due to its centralised nature and support for file locking."
2056 msgstr ""
2058 #. type: Content of: <book><preface><sect1><sect2><para>
2059 #: ../en/ch00-preface.xml:615
2060 msgid ""
2061 "I personally find Mercurial's properties of simplicity, performance, and good "
2062 "merge support to be a compelling combination that has served me well for "
2063 "several years."
2064 msgstr ""
2066 #. type: Content of: <book><preface><sect1><title>
2067 #: ../en/ch00-preface.xml:623
2068 msgid "Switching from another tool to Mercurial"
2069 msgstr "从其它工具切换到 Mercurial"
2071 #. type: Content of: <book><preface><sect1><para>
2072 #: ../en/ch00-preface.xml:625
2073 msgid ""
2074 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
2075 "\">convert</literal>, which can incrementally import revision history from "
2076 "several other revision control tools. By <quote>incremental</quote>, I mean "
2077 "that you can convert all of a project's history to date in one go, then rerun "
2078 "the conversion later to obtain new changes that happened after the initial "
2079 "conversion."
2080 msgstr ""
2082 #. type: Content of: <book><preface><sect1><para>
2083 #: ../en/ch00-preface.xml:633
2084 msgid ""
2085 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
2086 "literal> are as follows:"
2087 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
2089 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2090 #: ../en/ch00-preface.xml:639
2091 msgid "Darcs"
2092 msgstr "Darcs"
2094 #. type: Content of: <book><preface><sect1><para>
2095 #: ../en/ch00-preface.xml:641
2096 msgid ""
2097 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
2098 "from Mercurial to Subversion. This makes it possible to try Subversion and "
2099 "Mercurial in parallel before committing to a switchover, without risking the "
2100 "loss of any work."
2101 msgstr ""
2103 #. type: Content of: <book><preface><sect1><para>
2104 #: ../en/ch00-preface.xml:647
2105 msgid ""
2106 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
2107 "use. Simply point it at the path or URL of the source repository, optionally "
2108 "give it the name of the destination repository, and it will start working. "
2109 "After the initial conversion, just run the same command again to import new "
2110 "changes."
2111 msgstr ""
2113 #. type: Content of: <book><preface><sect1><title>
2114 #: ../en/ch00-preface.xml:656
2115 msgid "A short history of revision control"
2116 msgstr "版本控制简史"
2118 #. type: Content of: <book><preface><sect1><para>
2119 #: ../en/ch00-preface.xml:658
2120 msgid ""
2121 "The best known of the old-time revision control tools is SCCS (Source Code "
2122 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
2123 "SCCS operated on individual files, and required every person working on a "
2124 "project to have access to a shared workspace on a single system. Only one "
2125 "person could modify a file at any time; arbitration for access to files was "
2126 "via locks. It was common for people to lock files, and later forget to "
2127 "unlock them, preventing anyone else from modifying those files without the "
2128 "help of an administrator."
2129 msgstr ""
2131 #. type: Content of: <book><preface><sect1><para>
2132 #: ../en/ch00-preface.xml:669
2133 msgid ""
2134 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
2135 "called his program RCS (Revision Control System). Like SCCS, RCS required "
2136 "developers to work in a single shared workspace, and to lock files to prevent "
2137 "multiple people from modifying them simultaneously."
2138 msgstr ""
2140 #. type: Content of: <book><preface><sect1><para>
2141 #: ../en/ch00-preface.xml:675
2142 msgid ""
2143 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
2144 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
2145 "Versions System). The big innovation of CVS was that it let developers work "
2146 "simultaneously and somewhat independently in their own personal workspaces. "
2147 "The personal workspaces prevented developers from stepping on each other's "
2148 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
2149 "of every project file, and could modify their copies independently. They had "
2150 "to merge their edits prior to committing changes to the central repository."
2151 msgstr ""
2153 #. type: Content of: <book><preface><sect1><para>
2154 #: ../en/ch00-preface.xml:686
2155 msgid ""
2156 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
2157 "in 1989 the code that has since developed into the modern version of CVS. "
2158 "CVS subsequently acquired the ability to operate over a network connection, "
2159 "giving it a client/server architecture. CVS's architecture is centralised; "
2160 "only the server has a copy of the history of the project. Client workspaces "
2161 "just contain copies of recent versions of the project's files, and a little "
2162 "metadata to tell them where the server is. CVS has been enormously "
2163 "successful; it is probably the world's most widely used revision control "
2164 "system."
2165 msgstr ""
2167 #. type: Content of: <book><preface><sect1><para>
2168 #: ../en/ch00-preface.xml:697
2169 msgid ""
2170 "In the early 1990s, Sun Microsystems developed an early distributed revision "
2171 "control system, called TeamWare. A TeamWare workspace contains a complete "
2172 "copy of the project's history. TeamWare has no notion of a central "
2173 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
2174 "SCCS.)"
2175 msgstr ""
2177 #. type: Content of: <book><preface><sect1><para>
2178 #: ../en/ch00-preface.xml:704
2179 msgid ""
2180 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
2181 "records simultaneous changes to multiple files individually, instead of "
2182 "grouping them together as a single logically atomic operation. It does not "
2183 "manage its file hierarchy well; it is easy to make a mess of a repository by "
2184 "renaming files and directories. Worse, its source code is difficult to read "
2185 "and maintain, which made the <quote>pain level</quote> of fixing these "
2186 "architectural problems prohibitive."
2187 msgstr ""
2189 #. type: Content of: <book><preface><sect1><para>
2190 #: ../en/ch00-preface.xml:714
2191 msgid ""
2192 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
2193 "started a project to replace it with a tool that would have a better "
2194 "architecture and cleaner code. The result, Subversion, does not stray from "
2195 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
2196 "better namespace management, and a number of other features that make it a "
2197 "generally better tool than CVS. Since its initial release, it has rapidly "
2198 "grown in popularity."
2199 msgstr ""
2201 #. type: Content of: <book><preface><sect1><para>
2202 #: ../en/ch00-preface.xml:723
2203 msgid ""
2204 "More or less simultaneously, Graydon Hoare began working on an ambitious "
2205 "distributed revision control system that he named Monotone. While Monotone "
2206 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
2207 "goes beyond earlier (and subsequent) revision control tools in a number of "
2208 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
2209 "integral notion of <quote>trust</quote> for code from different sources."
2210 msgstr ""
2212 #. type: Content of: <book><preface><sect1><para>
2213 #: ../en/ch00-preface.xml:732
2214 msgid ""
2215 "Mercurial began life in 2005. While a few aspects of its design are "
2216 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
2217 "and scalability to very large projects."
2218 msgstr ""
2220 #. type: Content of: <book><preface><sect1><title>
2221 #: ../en/ch00-preface.xml:740
2222 msgid "Colophon&emdash;this book is Free"
2223 msgstr "后记—本书是自由的!"
2225 #. type: Content of: <book><preface><sect1><para>
2226 #: ../en/ch00-preface.xml:742
2227 msgid ""
2228 "This book is licensed under the Open Publication License, and is produced "
2229 "entirely using Free Software tools. It is typeset with DocBook XML. "
2230 "Illustrations are drawn and rendered with <ulink url=\"http://www.inkscape."
2231 "org/\">Inkscape</ulink>."
2232 msgstr ""
2234 #. type: Content of: <book><preface><sect1><para>
2235 #: ../en/ch00-preface.xml:747
2236 msgid ""
2237 "The complete source code for this book is published as a Mercurial "
2238 "repository, at <ulink url=\"http://hg.serpentine.com/mercurial/book\">http://"
2239 "hg.serpentine.com/mercurial/book</ulink>."
2240 msgstr ""
2242 #. type: Content of: <book><chapter><title>
2243 #: ../en/ch01-tour-basic.xml:5
2244 msgid "A tour of Mercurial: the basics"
2245 msgstr "Mercurial 教程: 基础知识"
2247 #. type: Content of: <book><chapter><sect1><title>
2248 #: ../en/ch01-tour-basic.xml:8
2249 msgid "Installing Mercurial on your system"
2250 msgstr "安装 Mercurial"
2252 #. type: Content of: <book><chapter><sect1><para>
2253 #: ../en/ch01-tour-basic.xml:10
2254 msgid ""
2255 "Prebuilt binary packages of Mercurial are available for every popular "
2256 "operating system. These make it easy to start using Mercurial on your "
2257 "computer immediately."
2258 msgstr ""
2259 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
2260 "用 Mercurial 变得很容易。"
2262 #. type: Content of: <book><chapter><sect1><sect2><title>
2263 #: ../en/ch01-tour-basic.xml:15
2264 msgid "Windows"
2265 msgstr "Windows"
2267 #. type: Content of: <book><chapter><sect1><sect2><para>
2268 #: ../en/ch01-tour-basic.xml:17
2269 msgid ""
2270 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
2271 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
2272 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
2273 "external dependencies; it <quote>just works</quote>. It provides both "
2274 "command line and graphical user interfaces."
2275 msgstr ""
2276 "Windows 中最好的 Mercurial 版本是TortoiseHg,它的主页地址是 <ulink url="
2277 "\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://bitbucket.org/"
2278 "tortoisehg/stable/wiki/Home</ulink>。这个软件没有外部依赖,它可以<quote>独立工"
2279 "作</quote>,同时提供了命令行和图形用户界面。"
2281 #. type: Content of: <book><chapter><sect1><sect2><title>
2282 #: ../en/ch01-tour-basic.xml:27
2283 msgid "Mac OS X"
2284 msgstr "Mac OS X"
2286 #. type: Content of: <book><chapter><sect1><sect2><para>
2287 #: ../en/ch01-tour-basic.xml:29
2288 msgid ""
2289 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
2290 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
2291 msgstr ""
2292 "Lee Cantey 为 Mac OS X 在 <ulink url=\"http://mercurial.berkwood.com"
2293 "\">http://mercurial.berkwood.com</ulink> 发布了 Mercurial 安装程序。"
2295 #. type: Content of: <book><chapter><sect1><sect2><title>
2296 #: ../en/ch01-tour-basic.xml:35
2297 msgid "Linux"
2298 msgstr "Linux"
2300 #. type: Content of: <book><chapter><sect1><sect2><para>
2301 #: ../en/ch01-tour-basic.xml:37
2302 msgid ""
2303 "Because each Linux distribution has its own packaging tools, policies, and "
2304 "rate of development, it's difficult to give a comprehensive set of "
2305 "instructions on how to install Mercurial binaries. The version of Mercurial "
2306 "that you will end up with can vary depending on how active the person is who "
2307 "maintains the package for your distribution."
2308 msgstr ""
2309 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
2310 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
2311 "使用的发行版的 Mercurial 维护者的活跃程度。"
2313 #. type: Content of: <book><chapter><sect1><sect2><para>
2314 #: ../en/ch01-tour-basic.xml:44
2315 msgid ""
2316 "To keep things simple, I will focus on installing Mercurial from the command "
2317 "line under the most popular Linux distributions. Most of these distributions "
2318 "provide graphical package managers that will let you install Mercurial with a "
2319 "single click; the package name to look for is <literal>mercurial</literal>."
2320 msgstr ""
2321 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
2322 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
2323 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
2325 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2326 #: ../en/ch01-tour-basic.xml:52
2327 msgid "Ubuntu and Debian:"
2328 msgstr "Ubuntu 与 Debian:"
2330 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2331 #: ../en/ch01-tour-basic.xml:54
2332 msgid "Fedora and OpenSUSE:"
2333 msgstr "Fedora and OpenSUSE:"
2335 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2336 #: ../en/ch01-tour-basic.xml:56
2337 msgid "Gentoo:"
2338 msgstr "Gentoo:"
2340 #. type: Content of: <book><chapter><sect1><sect2><title>
2341 #: ../en/ch01-tour-basic.xml:62
2342 msgid "Solaris"
2343 msgstr "Solaris"
2345 #. type: Content of: <book><chapter><sect1><sect2><para>
2346 #: ../en/ch01-tour-basic.xml:64
2347 msgid ""
2348 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
2349 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
2350 msgstr ""
2351 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
2352 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
2354 #. type: Content of: <book><chapter><sect1><title>
2355 #: ../en/ch01-tour-basic.xml:73
2356 msgid "Getting started"
2357 msgstr "开始"
2359 #. type: Content of: <book><chapter><sect1><para>
2360 #: ../en/ch01-tour-basic.xml:75
2361 msgid ""
2362 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
2363 "to find out whether Mercurial is actually installed properly. The actual "
2364 "version information that it prints isn't so important; it's whether it prints "
2365 "anything at all that we care about."
2366 msgstr ""
2367 "首先,我们使用 <command role=\"hg-cmd\">hg version</command> 命令检查 "
2368 "Mercurial 是否正确安装。它打印出来的实际版本信息并不重要;我们只关心它是否能打"
2369 "印出我们需要的信息。"
2371 #. type: Content of: <book><chapter><sect1><sect2><title>
2372 #: ../en/ch01-tour-basic.xml:84
2373 msgid "Built-in help"
2374 msgstr "内置帮助"
2376 #. type: Content of: <book><chapter><sect1><sect2><para>
2377 #: ../en/ch01-tour-basic.xml:86
2378 msgid ""
2379 "Mercurial provides a built-in help system. This is invaluable for those "
2380 "times when you find yourself stuck trying to remember how to run a command. "
2381 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
2382 "command>; it will print a brief list of commands, along with a description of "
2383 "what each does. If you ask for help on a specific command (as below), it "
2384 "prints more detailed information."
2385 msgstr ""
2386 "Mercurial 内置了帮助系统。当你不记得如何执行一个命令时,它会给你重要的帮助。如"
2387 "果你完全没有头绪,那就直接运行 <command role=\"hg-cmd\">hg help</command>;它"
2388 "会给出命令的简短列表,还描述了每个命令的作用。如果你需要具体命令的帮助(下述),"
2389 "它会给出更详细的信息。"
2391 #. type: Content of: <book><chapter><sect1><sect2><para>
2392 #: ../en/ch01-tour-basic.xml:97
2393 msgid ""
2394 "For a more impressive level of detail (which you won't usually need) run "
2395 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
2396 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
2397 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
2398 "print more information than it usually would."
2399 msgstr ""
2400 "要获得更多的详细信息(通常不需要),可以执行 <command role=\"hg-cmd\">hg help "
2401 "<option role=\"hg-opt-global\">-v</option></command>。选项 <option role=\"hg-"
2402 "opt-global\">-v</option> 是 <option role=\"hg-opt-global\">--verbose</option> "
2403 "的短格式,告诉 Mercurial 要打印通常不需要的更多信息。"
2405 #. type: Content of: <book><chapter><sect1><title>
2406 #: ../en/ch01-tour-basic.xml:108
2407 msgid "Working with a repository"
2408 msgstr "使用版本库"
2410 #. type: Content of: <book><chapter><sect1><para>
2411 #: ../en/ch01-tour-basic.xml:110
2412 msgid ""
2413 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
2414 "The repository for a project contains all of the files that <quote>belong to</"
2415 "quote> that project, along with a historical record of the project's files."
2416 msgstr ""
2418 #. type: Content of: <book><chapter><sect1><para>
2419 #: ../en/ch01-tour-basic.xml:116
2420 msgid ""
2421 "There's nothing particularly magical about a repository; it is simply a "
2422 "directory tree in your filesystem that Mercurial treats as special. You can "
2423 "rename or delete a repository any time you like, using either the command "
2424 "line or your file browser."
2425 msgstr ""
2427 #. type: Content of: <book><chapter><sect1><sect2><title>
2428 #: ../en/ch01-tour-basic.xml:123
2429 msgid "Making a local copy of a repository"
2430 msgstr "创建版本库的工作副本"
2432 #. type: Content of: <book><chapter><sect1><sect2><para>
2433 #: ../en/ch01-tour-basic.xml:125
2434 msgid ""
2435 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
2436 "While you could use a normal file copying command to make a copy of a "
2437 "repository, it's best to use a built-in command that Mercurial provides. "
2438 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
2439 "it makes an identical copy of an existing repository."
2440 msgstr ""
2442 #. type: Content of: <book><chapter><sect1><sect2><para>
2443 #: ../en/ch01-tour-basic.xml:134
2444 msgid ""
2445 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
2446 "as we can see above, it lets us clone repositories over the network. Another "
2447 "is that it remembers where we cloned from, which we'll find useful soon when "
2448 "we want to fetch new changes from another repository."
2449 msgstr ""
2451 #. type: Content of: <book><chapter><sect1><sect2><para>
2452 #: ../en/ch01-tour-basic.xml:140
2453 msgid ""
2454 "If our clone succeeded, we should now have a local directory called <filename "
2455 "class=\"directory\">hello</filename>. This directory will contain some files."
2456 msgstr ""
2458 #. type: Content of: <book><chapter><sect1><sect2><para>
2459 #: ../en/ch01-tour-basic.xml:146
2460 msgid ""
2461 "These files have the same contents and history in our repository as they do "
2462 "in the repository we cloned."
2463 msgstr ""
2465 #. type: Content of: <book><chapter><sect1><sect2><para>
2466 #: ../en/ch01-tour-basic.xml:149
2467 msgid ""
2468 "Every Mercurial repository is complete, self-contained, and independent. It "
2469 "contains its own private copy of a project's files and history. As we just "
2470 "mentioned, a cloned repository remembers the location of the repository it "
2471 "was cloned from, but Mercurial will not communicate with that repository, or "
2472 "any other, unless you tell it to."
2473 msgstr ""
2475 #. type: Content of: <book><chapter><sect1><sect2><para>
2476 #: ../en/ch01-tour-basic.xml:156
2477 msgid ""
2478 "What this means for now is that we're free to experiment with our repository, "
2479 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
2480 "affect anyone else."
2481 msgstr ""
2483 #. type: Content of: <book><chapter><sect1><sect2><title>
2484 #: ../en/ch01-tour-basic.xml:162
2485 msgid "What's in a repository?"
2486 msgstr "什么是版本库?"
2488 #. type: Content of: <book><chapter><sect1><sect2><para>
2489 #: ../en/ch01-tour-basic.xml:164
2490 msgid ""
2491 "When we take a more detailed look inside a repository, we can see that it "
2492 "contains a directory named <filename class=\"directory\">.hg</filename>. "
2493 "This is where Mercurial keeps all of its metadata for the repository."
2494 msgstr ""
2496 #. type: Content of: <book><chapter><sect1><sect2><para>
2497 #: ../en/ch01-tour-basic.xml:171
2498 msgid ""
2499 "The contents of the <filename class=\"directory\">.hg</filename> directory "
2500 "and its subdirectories are private to Mercurial. Every other file and "
2501 "directory in the repository is yours to do with as you please."
2502 msgstr ""
2504 #. type: Content of: <book><chapter><sect1><sect2><para>
2505 #: ../en/ch01-tour-basic.xml:177
2506 msgid ""
2507 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
2508 "filename> directory is the <quote>real</quote> repository, and all of the "
2509 "files and directories that coexist with it are said to live in the "
2510 "<emphasis>working directory</emphasis>. An easy way to remember the "
2511 "distinction is that the <emphasis>repository</emphasis> contains the "
2512 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
2513 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
2514 "at a particular point in history."
2515 msgstr ""
2517 #. type: Content of: <book><chapter><sect1><title>
2518 #: ../en/ch01-tour-basic.xml:192
2519 msgid "A tour through history"
2520 msgstr "回溯历史"
2522 #. type: Content of: <book><chapter><sect1><para>
2523 #: ../en/ch01-tour-basic.xml:194
2524 msgid ""
2525 "One of the first things we might want to do with a new, unfamiliar repository "
2526 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
2527 "command gives us a view of the history of changes in the repository."
2528 msgstr ""
2530 #. type: Content of: <book><chapter><sect1><para>
2531 #: ../en/ch01-tour-basic.xml:201
2532 msgid ""
2533 "By default, this command prints a brief paragraph of output for each change "
2534 "to the project that was recorded. In Mercurial terminology, we call each of "
2535 "these recorded events a <emphasis>changeset</emphasis>, because it can "
2536 "contain a record of changes to several files."
2537 msgstr ""
2539 #. type: Content of: <book><chapter><sect1><para>
2540 #: ../en/ch01-tour-basic.xml:207
2541 msgid ""
2542 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
2543 "command> are as follows."
2544 msgstr ""
2546 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2547 #: ../en/ch01-tour-basic.xml:211
2548 msgid ""
2549 "<literal>changeset</literal>: This field has the format of a number, followed "
2550 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
2551 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
2552 "is a unique identifier: the same hex string will always refer to the same "
2553 "changeset. The number is shorter and easier to type than the hex string, but "
2554 "it isn't unique: the same number in two different clones of a repository may "
2555 "identify different changesets. Why provide the number at all, then? For "
2556 "local convenience."
2557 msgstr ""
2559 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2560 #: ../en/ch01-tour-basic.xml:223
2561 msgid ""
2562 "<literal>user</literal>: The identity of the person who created the "
2563 "changeset. This is a free-form field, but it most often contains a person's "
2564 "name and email address."
2565 msgstr ""
2567 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2568 #: ../en/ch01-tour-basic.xml:227
2569 msgid ""
2570 "<literal>date</literal>: The date and time on which the changeset was "
2571 "created, and the timezone in which it was created. (The date and time are "
2572 "local to that timezone; they display what time and date it was for the person "
2573 "who created the changeset.)"
2574 msgstr ""
2576 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2577 #: ../en/ch01-tour-basic.xml:232
2578 msgid ""
2579 "<literal>summary</literal>: The first line of the text message that the "
2580 "creator of the changeset entered to describe the changeset."
2581 msgstr ""
2583 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2584 #: ../en/ch01-tour-basic.xml:236
2585 msgid ""
2586 "Some changesets, such as the first in the list above, have a <literal>tag</"
2587 "literal> field. A tag is another way to identify a changeset, by giving it "
2588 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
2589 "it always refers to the newest change in a repository.)"
2590 msgstr ""
2592 #. type: Content of: <book><chapter><sect1><para>
2593 #: ../en/ch01-tour-basic.xml:244
2594 msgid ""
2595 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
2596 "purely a summary; it is missing a lot of detail."
2597 msgstr ""
2599 #. type: Content of: <book><chapter><sect1><para>
2600 #: ../en/ch01-tour-basic.xml:248
2601 msgid ""
2602 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
2603 "representation of the history of the <filename class=\"directory\">hello</"
2604 "filename> repository, to make it a little easier to see which direction "
2605 "history is <quote>flowing</quote> in. We'll be returning to this figure "
2606 "several times in this chapter and the chapter that follows."
2607 msgstr ""
2609 #. type: Content of: <book><chapter><sect1><figure><title>
2610 #: ../en/ch01-tour-basic.xml:257
2611 msgid ""
2612 "Graphical history of the <filename class=\"directory\">hello</filename> "
2613 "repository"
2614 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
2616 #. type: Content of: <book><chapter><sect1><figure>
2617 #: ../en/ch01-tour-basic.xml:259 ../en/ch02-tour-merge.xml:50
2618 #: ../en/ch02-tour-merge.xml:188 ../en/ch03-concepts.xml:295
2619 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
2620 msgstr ""
2622 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
2623 #: ../en/ch01-tour-basic.xml:260
2624 msgid ""
2625 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
2626 msgstr ""
2628 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
2629 #: ../en/ch01-tour-basic.xml:261 ../en/ch02-tour-merge.xml:52
2630 #: ../en/ch02-tour-merge.xml:82 ../en/ch02-tour-merge.xml:163
2631 #: ../en/ch02-tour-merge.xml:190 ../en/ch02-tour-merge.xml:260
2632 #: ../en/ch03-concepts.xml:59 ../en/ch03-concepts.xml:108
2633 #: ../en/ch03-concepts.xml:193 ../en/ch03-concepts.xml:297
2634 #: ../en/ch03-concepts.xml:348 ../en/ch03-concepts.xml:363
2635 #: ../en/ch03-concepts.xml:404 ../en/ch03-concepts.xml:424
2636 #: ../en/ch03-concepts.xml:467 ../en/ch05-collab.xml:322
2637 #: ../en/ch08-undo.xml:365 ../en/ch08-undo.xml:412 ../en/ch08-undo.xml:477
2638 #: ../en/ch08-undo.xml:515 ../en/ch11-mq.xml:412
2639 msgid "XXX add text"
2640 msgstr ""
2642 #. type: Content of: <book><chapter><sect1><sect2><title>
2643 #: ../en/ch01-tour-basic.xml:266
2644 msgid "Changesets, revisions, and talking to other people"
2645 msgstr "修改集,版本,与其它用户交互"
2647 #. type: Content of: <book><chapter><sect1><sect2><para>
2648 #: ../en/ch01-tour-basic.xml:269
2649 msgid ""
2650 "As English is a notoriously sloppy language, and computer science has a "
2651 "hallowed history of terminological confusion (why use one term when four will "
2652 "do?), revision control has a variety of words and phrases that mean the same "
2653 "thing. If you are talking about Mercurial history with other people, you "
2654 "will find that the word <quote>changeset</quote> is often compressed to "
2655 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
2656 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
2657 msgstr ""
2659 #. type: Content of: <book><chapter><sect1><sect2><para>
2660 #: ../en/ch01-tour-basic.xml:279
2661 msgid ""
2662 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
2663 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
2664 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
2665 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
2666 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
2667 "identifies a changeset using both a number and a hexadecimal string."
2668 msgstr ""
2670 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2671 #: ../en/ch01-tour-basic.xml:288
2672 msgid ""
2673 "The revision number is a handy notation that is <emphasis>only valid in that "
2674 "repository</emphasis>."
2675 msgstr ""
2677 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2678 #: ../en/ch01-tour-basic.xml:291
2679 msgid ""
2680 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
2681 "emphasis> that will always identify that exact changeset in <emphasis>every</"
2682 "emphasis> copy of the repository."
2683 msgstr ""
2685 #. type: Content of: <book><chapter><sect1><sect2><para>
2686 #: ../en/ch01-tour-basic.xml:297
2687 msgid ""
2688 "This distinction is important. If you send someone an email talking about "
2689 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
2690 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
2691 "that a revision number depends on the order in which changes arrived in a "
2692 "repository, and there is no guarantee that the same changes will happen in "
2693 "the same order in different repositories. Three changes <literal>a,b,c</"
2694 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
2695 "while in another as <literal>0,2,1</literal>."
2696 msgstr ""
2698 #. type: Content of: <book><chapter><sect1><sect2><para>
2699 #: ../en/ch01-tour-basic.xml:309
2700 msgid ""
2701 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
2702 "need to discuss a changeset with someone, or make a record of a changeset for "
2703 "some other reason (for example, in a bug report), use the hexadecimal "
2704 "identifier."
2705 msgstr ""
2707 #. type: Content of: <book><chapter><sect1><sect2><title>
2708 #: ../en/ch01-tour-basic.xml:317
2709 msgid "Viewing specific revisions"
2710 msgstr "察看指定版本"
2712 #. type: Content of: <book><chapter><sect1><sect2><para>
2713 #: ../en/ch01-tour-basic.xml:319
2714 msgid ""
2715 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
2716 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
2717 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
2718 "number or a hexadecimal identifier, and you can provide as many revisions as "
2719 "you want."
2720 msgstr ""
2722 #. type: Content of: <book><chapter><sect1><sect2><para>
2723 #: ../en/ch01-tour-basic.xml:328
2724 msgid ""
2725 "If you want to see the history of several revisions without having to list "
2726 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
2727 "express the idea <quote>I want all revisions between <literal>abc</literal> "
2728 "and <literal>def</literal>, inclusive</quote>."
2729 msgstr ""
2731 #. type: Content of: <book><chapter><sect1><sect2><para>
2732 #: ../en/ch01-tour-basic.xml:336
2733 msgid ""
2734 "Mercurial also honours the order in which you specify revisions, so <command "
2735 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
2736 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
2737 msgstr ""
2739 #. type: Content of: <book><chapter><sect1><sect2><title>
2740 #: ../en/ch01-tour-basic.xml:343
2741 msgid "More detailed information"
2742 msgstr "更详细的信息"
2744 #. type: Content of: <book><chapter><sect1><sect2><para>
2745 #: ../en/ch01-tour-basic.xml:345
2746 msgid ""
2747 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
2748 "command> is useful if you already know what you're looking for, you may need "
2749 "to see a complete description of the change, or a list of the files changed, "
2750 "if you're trying to decide whether a changeset is the one you're looking for. "
2751 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
2752 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
2753 "option gives you this extra detail."
2754 msgstr ""
2756 #. type: Content of: <book><chapter><sect1><sect2><para>
2757 #: ../en/ch01-tour-basic.xml:357
2758 msgid ""
2759 "If you want to see both the description and content of a change, add the "
2760 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
2761 "patch</option>) option. This displays the content of a change as a "
2762 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
2763 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
2764 msgstr ""
2766 #. type: Content of: <book><chapter><sect1><sect2><para>
2767 #: ../en/ch01-tour-basic.xml:367
2768 msgid ""
2769 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
2770 "it's well worth remembering."
2771 msgstr ""
2773 #. type: Content of: <book><chapter><sect1><title>
2774 #: ../en/ch01-tour-basic.xml:374
2775 msgid "All about command options"
2776 msgstr "命令选项"
2778 #. type: Content of: <book><chapter><sect1><para>
2779 #: ../en/ch01-tour-basic.xml:376
2780 msgid ""
2781 "Let's take a brief break from exploring Mercurial commands to discuss a "
2782 "pattern in the way that they work; you may find this useful to keep in mind "
2783 "as we continue our tour."
2784 msgstr ""
2786 #. type: Content of: <book><chapter><sect1><para>
2787 #: ../en/ch01-tour-basic.xml:380
2788 msgid ""
2789 "Mercurial has a consistent and straightforward approach to dealing with the "
2790 "options that you can pass to commands. It follows the conventions for "
2791 "options that are common to modern Linux and Unix systems."
2792 msgstr ""
2794 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2795 #: ../en/ch01-tour-basic.xml:387
2796 msgid ""
2797 "Every option has a long name. For example, as we've already seen, the "
2798 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
2799 "opt-log\">--rev</option> option."
2800 msgstr ""
2802 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2803 #: ../en/ch01-tour-basic.xml:393
2804 msgid ""
2805 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
2806 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
2807 "reason that some options don't have short names is that the options in "
2808 "question are rarely used.)"
2809 msgstr ""
2811 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2812 #: ../en/ch01-tour-basic.xml:400
2813 msgid ""
2814 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
2815 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
2816 "\">-r</option>)."
2817 msgstr ""
2819 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2820 #: ../en/ch01-tour-basic.xml:406
2821 msgid ""
2822 "Option naming and usage is consistent across commands. For example, every "
2823 "command that lets you specify a changeset ID or revision number accepts both "
2824 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
2825 "rev</option> arguments."
2826 msgstr ""
2828 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2829 #: ../en/ch01-tour-basic.xml:413
2830 msgid ""
2831 "If you are using short options, you can save typing by running them together. "
2832 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
2833 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
2834 msgstr ""
2836 #. type: Content of: <book><chapter><sect1><para>
2837 #: ../en/ch01-tour-basic.xml:420
2838 msgid ""
2839 "In the examples throughout this book, I use short options instead of long. "
2840 "This just reflects my own preference, so don't read anything significant into "
2841 "it."
2842 msgstr ""
2844 #. type: Content of: <book><chapter><sect1><para>
2845 #: ../en/ch01-tour-basic.xml:424
2846 msgid ""
2847 "Most commands that print output of some kind will print more output when "
2848 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
2849 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
2850 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
2851 msgstr ""
2853 #. type: Content of: <book><chapter><sect1><note><title>
2854 #: ../en/ch01-tour-basic.xml:431
2855 msgid "Option naming consistency"
2856 msgstr ""
2858 #. type: Content of: <book><chapter><sect1><note><para>
2859 #: ../en/ch01-tour-basic.xml:433
2860 msgid ""
2861 "Almost always, Mercurial commands use consistent option names to refer to the "
2862 "same concepts. For instance, if a command deals with changesets, you'll "
2863 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
2864 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
2865 "makes it easier to remember what options a particular command takes."
2866 msgstr ""
2868 #. type: Content of: <book><chapter><sect1><title>
2869 #: ../en/ch01-tour-basic.xml:444
2870 msgid "Making and reviewing changes"
2871 msgstr "创建和复审修改"
2873 #. type: Content of: <book><chapter><sect1><para>
2874 #: ../en/ch01-tour-basic.xml:446
2875 msgid ""
2876 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
2877 "at making some changes and examining them."
2878 msgstr ""
2880 #. type: Content of: <book><chapter><sect1><para>
2881 #: ../en/ch01-tour-basic.xml:450
2882 msgid ""
2883 "The first thing we'll do is isolate our experiment in a repository of its "
2884 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
2885 "don't need to clone a copy of the remote repository. Since we already have a "
2886 "copy of it locally, we can just clone that instead. This is much faster than "
2887 "cloning over the network, and cloning a local repository uses less disk space "
2888 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
2889 msgstr ""
2891 #. type: Content of: <book><chapter><sect1><para><footnote><para>
2892 #: ../en/ch01-tour-basic.xml:457
2893 msgid ""
2894 "The saving of space arises when source and destination repositories are on "
2895 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
2896 "write sharing of its internal metadata. If that explanation meant nothing to "
2897 "you, don't worry: everything happens transparently and automatically, and you "
2898 "don't need to understand it."
2899 msgstr ""
2901 #. type: Content of: <book><chapter><sect1><para>
2902 #: ../en/ch01-tour-basic.xml:467
2903 msgid ""
2904 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
2905 "of a remote repository around, which you can then make temporary clones of to "
2906 "create sandboxes for each task you want to work on. This lets you work on "
2907 "multiple tasks in parallel, each isolated from the others until it's complete "
2908 "and you're ready to integrate it back. Because local clones are so cheap, "
2909 "there's almost no overhead to cloning and destroying repositories whenever "
2910 "you want."
2911 msgstr ""
2913 #. type: Content of: <book><chapter><sect1><para>
2914 #: ../en/ch01-tour-basic.xml:476
2915 msgid ""
2916 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
2917 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
2918 "world</quote> program."
2919 msgstr ""
2921 #. type: Content of: <book><chapter><sect1><para>
2922 #: ../en/ch01-tour-basic.xml:482
2923 msgid "Let's edit this file so that it prints a second line of output."
2924 msgstr ""
2926 #. type: Content of: <book><chapter><sect1><para>
2927 #: ../en/ch01-tour-basic.xml:487
2928 msgid ""
2929 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
2930 "what Mercurial knows about the files in the repository."
2931 msgstr ""
2933 #. type: Content of: <book><chapter><sect1><para>
2934 #: ../en/ch01-tour-basic.xml:493
2935 msgid ""
2936 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
2937 "some files, but a line starting with <quote><literal>M</literal></quote> for "
2938 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
2939 "\">hg status</command> will not print any output for files that have not been "
2940 "modified."
2941 msgstr ""
2943 #. type: Content of: <book><chapter><sect1><para>
2944 #: ../en/ch01-tour-basic.xml:500
2945 msgid ""
2946 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
2947 "that we modified <filename>hello.c</filename>. We didn't need to "
2948 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
2949 "before we started, or that we had modified the file after we were done; it "
2950 "was able to figure this out itself."
2951 msgstr ""
2953 #. type: Content of: <book><chapter><sect1><para>
2954 #: ../en/ch01-tour-basic.xml:508
2955 msgid ""
2956 "It's somewhat helpful to know that we've modified <filename>hello.c</"
2957 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
2958 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
2959 "diff</command> command."
2960 msgstr ""
2962 #. type: Content of: <book><chapter><sect1><title>
2963 #: ../en/ch01-tour-basic.xml:517 ../en/ch11-mq.xml:187
2964 msgid "Understanding patches"
2965 msgstr "理解补丁"
2967 #. type: Content of: <book><chapter><sect1><tip><para>
2968 #: ../en/ch01-tour-basic.xml:519
2969 msgid ""
2970 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
2971 "how to read output above."
2972 msgstr ""
2974 #. type: Content of: <book><chapter><sect1><title>
2975 #: ../en/ch01-tour-basic.xml:525
2976 msgid "Recording changes in a new changeset"
2977 msgstr "在新修改集中记录修改"
2979 #. type: Content of: <book><chapter><sect1><para>
2980 #: ../en/ch01-tour-basic.xml:527
2981 msgid ""
2982 "We can modify files, build and test our changes, and use <command role=\"hg-"
2983 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
2984 "review our changes, until we're satisfied with what we've done and arrive at "
2985 "a natural stopping point where we want to record our work in a new changeset."
2986 msgstr ""
2988 #. type: Content of: <book><chapter><sect1><para>
2989 #: ../en/ch01-tour-basic.xml:534
2990 msgid ""
2991 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
2992 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
2993 "<quote>committing</quote>."
2994 msgstr ""
2996 #. type: Content of: <book><chapter><sect1><sect2><title>
2997 #: ../en/ch01-tour-basic.xml:540
2998 msgid "Setting up a username"
2999 msgstr "配置用户名称"
3001 #. type: Content of: <book><chapter><sect1><sect2><para>
3002 #: ../en/ch01-tour-basic.xml:542
3003 msgid ""
3004 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
3005 "first time, it is not guaranteed to succeed. Mercurial records your name and "
3006 "address with each change that you commit, so that you and others will later "
3007 "be able to tell who made each change. Mercurial tries to automatically "
3008 "figure out a sensible username to commit the change with. It will attempt "
3009 "each of the following methods, in order:"
3010 msgstr ""
3012 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3013 #: ../en/ch01-tour-basic.xml:551
3014 msgid ""
3015 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
3016 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
3017 "followed by a username, this is always given the highest precedence."
3018 msgstr ""
3020 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3021 #: ../en/ch01-tour-basic.xml:556
3022 msgid ""
3023 "If you have set the <envar>HGUSER</envar> environment variable, this is "
3024 "checked next."
3025 msgstr ""
3027 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3028 #: ../en/ch01-tour-basic.xml:559
3029 msgid ""
3030 "If you create a file in your home directory called <filename role=\"special"
3031 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
3032 "entry, that will be used next. To see what the contents of this file should "
3033 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
3034 msgstr ""
3036 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3037 #: ../en/ch01-tour-basic.xml:567
3038 msgid ""
3039 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
3040 "used next."
3041 msgstr ""
3043 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3044 #: ../en/ch01-tour-basic.xml:570
3045 msgid ""
3046 "Mercurial will query your system to find out your local user name and host "
3047 "name, and construct a username from these components. Since this often "
3048 "results in a username that is not very useful, it will print a warning if it "
3049 "has to do this."
3050 msgstr ""
3052 #. type: Content of: <book><chapter><sect1><sect2><para>
3053 #: ../en/ch01-tour-basic.xml:577
3054 msgid ""
3055 "If all of these mechanisms fail, Mercurial will fail, printing an error "
3056 "message. In this case, it will not let you commit until you set up a "
3057 "username."
3058 msgstr ""
3060 #. type: Content of: <book><chapter><sect1><sect2><para>
3061 #: ../en/ch01-tour-basic.xml:581
3062 msgid ""
3063 "You should think of the <envar>HGUSER</envar> environment variable and the "
3064 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
3065 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
3066 "Mercurial's default selection of username. For normal use, the simplest and "
3067 "most robust way to set a username for yourself is by creating a <filename "
3068 "role=\"special\">.hgrc</filename> file; see below for details."
3069 msgstr ""
3071 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3072 #: ../en/ch01-tour-basic.xml:590
3073 msgid "Creating a Mercurial configuration file"
3074 msgstr "创建 Mercurial 的配置文件"
3076 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3077 #: ../en/ch01-tour-basic.xml:592
3078 msgid ""
3079 "To set a user name, use your favorite editor to create a file called "
3080 "<filename role=\"special\">.hgrc</filename> in your home directory. "
3081 "Mercurial will use this file to look up your personalised configuration "
3082 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
3083 "filename> should look like this."
3084 msgstr ""
3086 #. type: Content of: <book><chapter><sect1><sect2><sect3><remark>
3087 #: ../en/ch01-tour-basic.xml:600
3088 msgid "Figure out what the appropriate directory is on Windows."
3089 msgstr ""
3091 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3092 #: ../en/ch01-tour-basic.xml:607
3093 msgid ""
3094 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
3095 "emphasis> of the config file, so you can read the <quote><literal>username "
3096 "= ...</literal></quote> line as meaning <quote>set the value of the "
3097 "<literal>username</literal> item in the <literal>ui</literal> section</"
3098 "quote>. A section continues until a new section begins, or the end of the "
3099 "file. Mercurial ignores empty lines and treats any text from "
3100 "<quote><literal>#</literal></quote> to the end of a line as a comment."
3101 msgstr ""
3103 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3104 #: ../en/ch01-tour-basic.xml:620
3105 msgid "Choosing a user name"
3106 msgstr "选择用户名称"
3108 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3109 #: ../en/ch01-tour-basic.xml:622
3110 msgid ""
3111 "You can use any text you like as the value of the <literal>username</literal> "
3112 "config item, since this information is for reading by other people, but will "
3113 "not be interpreted by Mercurial. The convention that most people follow is "
3114 "to use their name and email address, as in the example above."
3115 msgstr ""
3117 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
3118 #: ../en/ch01-tour-basic.xml:629
3119 msgid ""
3120 "Mercurial's built-in web server obfuscates email addresses, to make it more "
3121 "difficult for the email harvesting tools that spammers use. This reduces the "
3122 "likelihood that you'll start receiving more junk email if you publish a "
3123 "Mercurial repository on the web."
3124 msgstr ""
3126 #. type: Content of: <book><chapter><sect1><sect2><title>
3127 #: ../en/ch01-tour-basic.xml:639
3128 msgid "Writing a commit message"
3129 msgstr "写提交日志"
3131 #. type: Content of: <book><chapter><sect1><sect2><para>
3132 #: ../en/ch01-tour-basic.xml:641
3133 msgid ""
3134 "When we commit a change, Mercurial drops us into a text editor, to enter a "
3135 "message that will describe the modifications we've made in this changeset. "
3136 "This is called the <emphasis>commit message</emphasis>. It will be a record "
3137 "for readers of what we did and why, and it will be printed by <command role="
3138 "\"hg-cmd\">hg log</command> after we've finished committing."
3139 msgstr ""
3141 #. type: Content of: <book><chapter><sect1><sect2><para>
3142 #: ../en/ch01-tour-basic.xml:651
3143 msgid ""
3144 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
3145 "drops us into will contain an empty line or two, followed by a number of "
3146 "lines starting with <quote><literal>HG:</literal></quote>."
3147 msgstr ""
3149 #. type: Content of: <book><chapter><sect1><sect2><para>
3150 #: ../en/ch01-tour-basic.xml:665
3151 msgid ""
3152 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
3153 "quote>; it uses them only to tell us which files it's recording changes to. "
3154 "Modifying or deleting these lines has no effect."
3155 msgstr ""
3157 #. type: Content of: <book><chapter><sect1><sect2><title>
3158 #: ../en/ch01-tour-basic.xml:671
3159 msgid "Writing a good commit message"
3160 msgstr "写好提交日志"
3162 #. type: Content of: <book><chapter><sect1><sect2><para>
3163 #: ../en/ch01-tour-basic.xml:673
3164 msgid ""
3165 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
3166 "a commit message by default, it's best to write a commit message whose first "
3167 "line stands alone. Here's a real example of a commit message that "
3168 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
3169 "that is not readable."
3170 msgstr ""
3172 #. type: Content of: <book><chapter><sect1><sect2><para>
3173 #: ../en/ch01-tour-basic.xml:687
3174 msgid ""
3175 "As far as the remainder of the contents of the commit message are concerned, "
3176 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
3177 "about the contents of the commit message, though your project may have "
3178 "policies that dictate a certain kind of formatting."
3179 msgstr ""
3181 #. type: Content of: <book><chapter><sect1><sect2><para>
3182 #: ../en/ch01-tour-basic.xml:693
3183 msgid ""
3184 "My personal preference is for short, but informative, commit messages that "
3185 "tell me something that I can't figure out with a quick glance at the output "
3186 "of <command role=\"hg-cmd\">hg log --patch</command>."
3187 msgstr ""
3189 #. type: Content of: <book><chapter><sect1><sect2><title>
3190 #: ../en/ch01-tour-basic.xml:700
3191 msgid "Aborting a commit"
3192 msgstr "终止提交"
3194 #. type: Content of: <book><chapter><sect1><sect2><para>
3195 #: ../en/ch01-tour-basic.xml:702
3196 msgid ""
3197 "If you decide that you don't want to commit while in the middle of editing a "
3198 "commit message, simply exit from your editor without saving the file that "
3199 "it's editing. This will cause nothing to happen to either the repository or "
3200 "the working directory."
3201 msgstr ""
3203 #. type: Content of: <book><chapter><sect1><sect2><para>
3204 #: ../en/ch01-tour-basic.xml:707
3205 msgid ""
3206 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
3207 "any arguments, it records all of the changes we've made, as reported by "
3208 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
3209 "diff</command>."
3210 msgstr ""
3212 #. type: Content of: <book><chapter><sect1><sect2><title>
3213 #: ../en/ch01-tour-basic.xml:714
3214 msgid "Admiring our new handiwork"
3215 msgstr "欣赏我们的成果"
3217 #. type: Content of: <book><chapter><sect1><sect2><para>
3218 #: ../en/ch01-tour-basic.xml:716
3219 msgid ""
3220 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
3221 "tip</command> command to display the changeset we just created. This command "
3222 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
3223 "command>, but it only displays the newest revision in the repository."
3224 msgstr ""
3226 #. type: Content of: <book><chapter><sect1><sect2><para>
3227 #: ../en/ch01-tour-basic.xml:725
3228 msgid ""
3229 "We refer to the newest revision in the repository as the <emphasis>tip "
3230 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
3231 msgstr ""
3233 #. type: Content of: <book><chapter><sect1><sect2><para>
3234 #: ../en/ch01-tour-basic.xml:729
3235 msgid ""
3236 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
3237 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
3238 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
3239 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
3240 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
3241 "patches is another example of the consistent naming we mentioned earlier."
3242 msgstr ""
3244 #. type: Content of: <book><chapter><sect1><title>
3245 #: ../en/ch01-tour-basic.xml:741
3246 msgid "Sharing changes"
3247 msgstr "共享修改"
3249 #. type: Content of: <book><chapter><sect1><para>
3250 #: ../en/ch01-tour-basic.xml:743
3251 msgid ""
3252 "We mentioned earlier that repositories in Mercurial are self-contained. This "
3253 "means that the changeset we just created exists only in our <filename class="
3254 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
3255 "we can propagate this change into other repositories."
3256 msgstr ""
3258 #. type: Content of: <book><chapter><sect1><sect2><title>
3259 #: ../en/ch01-tour-basic.xml:751
3260 msgid "Pulling changes from another repository"
3261 msgstr "从其它版本库取得修改"
3263 #. type: Content of: <book><chapter><sect1><sect2><para>
3264 #: ../en/ch01-tour-basic.xml:752
3265 msgid ""
3266 "To get started, let's clone our original <filename class=\"directory\">hello</"
3267 "filename> repository, which does not contain the change we just committed. "
3268 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
3269 "filename>."
3270 msgstr ""
3272 #. type: Content of: <book><chapter><sect1><sect2><para>
3273 #: ../en/ch01-tour-basic.xml:760
3274 msgid ""
3275 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
3276 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
3277 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
3278 "changes into a repository is a somewhat scary prospect. Mercurial provides "
3279 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
3280 "changes the <command role=\"hg-cmd\">hg pull</command> command "
3281 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
3282 "the changes in."
3283 msgstr ""
3285 #. type: Content of: <book><chapter><sect1><sect2><para>
3286 #: ../en/ch01-tour-basic.xml:773
3287 msgid ""
3288 "Suppose you're pulling changes from a repository on the network somewhere. "
3289 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
3290 "output, and before you pull those changes, someone might have committed "
3291 "something in the remote repository. This means that it's possible to pull "
3292 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
3293 "command>."
3294 msgstr ""
3296 #. type: Content of: <book><chapter><sect1><sect2><para>
3297 #: ../en/ch01-tour-basic.xml:781
3298 msgid ""
3299 "Bringing changes into a repository is a simple matter of running the <command "
3300 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
3301 "pull from."
3302 msgstr ""
3304 #. type: Content of: <book><chapter><sect1><sect2><para>
3305 #: ../en/ch01-tour-basic.xml:788
3306 msgid ""
3307 "As you can see from the before-and-after output of <command role=\"hg-cmd"
3308 "\">hg tip</command>, we have successfully pulled changes into our "
3309 "repository. There remains one step before we can see these changes in the "
3310 "working directory."
3311 msgstr ""
3313 #. type: Content of: <book><chapter><sect1><sect2><title>
3314 #: ../en/ch01-tour-basic.xml:796
3315 msgid "Updating the working directory"
3316 msgstr "更新工作目录"
3318 #. type: Content of: <book><chapter><sect1><sect2><para>
3319 #: ../en/ch01-tour-basic.xml:798
3320 msgid ""
3321 "We have so far glossed over the relationship between a repository and its "
3322 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
3323 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
3324 "repository, but if we check, there's no sign of those changes in the working "
3325 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
3326 "not (by default) touch the working directory. Instead, we use the <command "
3327 "role=\"hg-cmd\">hg update</command> command to do this."
3328 msgstr ""
3330 #. type: Content of: <book><chapter><sect1><sect2><para>
3331 #: ../en/ch01-tour-basic.xml:810
3332 msgid ""
3333 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
3334 "doesn't update the working directory automatically. There's actually a good "
3335 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
3336 "update the working directory to the state it was in at <emphasis>any "
3337 "revision</emphasis> in the history of the repository. If you had the working "
3338 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
3339 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
3340 "automatically updated the working directory to a new revision, you might not "
3341 "be terribly happy."
3342 msgstr ""
3344 #. type: Content of: <book><chapter><sect1><sect2><para>
3345 #: ../en/ch01-tour-basic.xml:821
3346 msgid ""
3347 "However, since pull-then-update is such a common thing to do, Mercurial lets "
3348 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
3349 "option to <command role=\"hg-cmd\">hg pull</command>."
3350 msgstr ""
3352 #. type: Content of: <book><chapter><sect1><sect2><para>
3353 #: ../en/ch01-tour-basic.xml:826
3354 msgid ""
3355 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
3356 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
3357 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
3358 "we'd have to take an explicit step to update the working directory:"
3359 msgstr ""
3361 #. type: Content of: <book><chapter><sect1><sect2><para>
3362 #: ../en/ch01-tour-basic.xml:835
3363 msgid ""
3364 "To find out what revision the working directory is at, use the <command role="
3365 "\"hg-cmd\">hg parents</command> command."
3366 msgstr ""
3368 #. type: Content of: <book><chapter><sect1><sect2><para>
3369 #: ../en/ch01-tour-basic.xml:841
3370 msgid ""
3371 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
3372 "arrows connecting each changeset. The node that the arrow leads "
3373 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
3374 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
3375 "a parent in just the same way; this is the changeset that the working "
3376 "directory currently contains."
3377 msgstr ""
3379 #. type: Content of: <book><chapter><sect1><sect2><para>
3380 #: ../en/ch01-tour-basic.xml:850
3381 msgid ""
3382 "To update the working directory to a particular revision, give a revision "
3383 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
3384 "command."
3385 msgstr ""
3387 #. type: Content of: <book><chapter><sect1><sect2><para>
3388 #: ../en/ch01-tour-basic.xml:857
3389 msgid ""
3390 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
3391 "command> will update to the tip revision, as shown by the second call to "
3392 "<command role=\"hg-cmd\">hg update</command> in the example above."
3393 msgstr ""
3395 #. type: Content of: <book><chapter><sect1><sect2><title>
3396 #: ../en/ch01-tour-basic.xml:865
3397 msgid "Pushing changes to another repository"
3398 msgstr "发布修改到其它版本库"
3400 #. type: Content of: <book><chapter><sect1><sect2><para>
3401 #: ../en/ch01-tour-basic.xml:867
3402 msgid ""
3403 "Mercurial lets us push changes to another repository, from the repository "
3404 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
3405 "pull</command> above, we'll create a temporary repository to push our changes "
3406 "into."
3407 msgstr ""
3409 #. type: Content of: <book><chapter><sect1><sect2><para>
3410 #: ../en/ch01-tour-basic.xml:875
3411 msgid ""
3412 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
3413 "changes would be pushed into another repository."
3414 msgstr ""
3416 #. type: Content of: <book><chapter><sect1><sect2><para>
3417 #: ../en/ch01-tour-basic.xml:881
3418 msgid ""
3419 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
3420 "push."
3421 msgstr ""
3423 #. type: Content of: <book><chapter><sect1><sect2><para>
3424 #: ../en/ch01-tour-basic.xml:887
3425 msgid ""
3426 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
3427 "\">hg push</command> command does not update the working directory in the "
3428 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
3429 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
3430 "<literal>-u</literal> option that updates the other repository's working "
3431 "directory. This asymmetry is deliberate: the repository we're pushing to "
3432 "might be on a remote server and shared between several people. If we were to "
3433 "update its working directory while someone was working in it, their work "
3434 "would be disrupted."
3435 msgstr ""
3437 #. type: Content of: <book><chapter><sect1><sect2><para>
3438 #: ../en/ch01-tour-basic.xml:899
3439 msgid ""
3440 "What happens if we try to pull or push changes and the receiving repository "
3441 "already has those changes? Nothing too exciting."
3442 msgstr ""
3444 #. type: Content of: <book><chapter><sect1><sect2><title>
3445 #: ../en/ch01-tour-basic.xml:906
3446 msgid "Sharing changes over a network"
3447 msgstr "通过网络共享修改"
3449 #. type: Content of: <book><chapter><sect1><sect2><para>
3450 #: ../en/ch01-tour-basic.xml:908
3451 msgid ""
3452 "The commands we have covered in the previous few sections are not limited to "
3453 "working with local repositories. Each works in exactly the same fashion over "
3454 "a network connection; simply pass in a URL instead of a local path."
3455 msgstr ""
3457 #. type: Content of: <book><chapter><sect1><sect2><para>
3458 #: ../en/ch01-tour-basic.xml:916
3459 msgid ""
3460 "In this example, we can see what changes we could push to the remote "
3461 "repository, but the repository is understandably not set up to let anonymous "
3462 "users push to it."
3463 msgstr ""
3465 #. type: Content of: <book><chapter><title>
3466 #: ../en/ch02-tour-merge.xml:5
3467 msgid "A tour of Mercurial: merging work"
3468 msgstr "Mercurial 教程: 合并工作"
3470 #. type: Content of: <book><chapter><para>
3471 #: ../en/ch02-tour-merge.xml:7
3472 msgid ""
3473 "We've now covered cloning a repository, making changes in a repository, and "
3474 "pulling or pushing changes from one repository into another. Our next step "
3475 "is <emphasis>merging</emphasis> changes from separate repositories."
3476 msgstr ""
3478 #. type: Content of: <book><chapter><sect1><title>
3479 #: ../en/ch02-tour-merge.xml:13
3480 msgid "Merging streams of work"
3481 msgstr "合并的流程"
3483 #. type: Content of: <book><chapter><sect1><para>
3484 #: ../en/ch02-tour-merge.xml:15
3485 msgid ""
3486 "Merging is a fundamental part of working with a distributed revision control "
3487 "tool."
3488 msgstr ""
3490 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3491 #: ../en/ch02-tour-merge.xml:18
3492 msgid ""
3493 "Alice and Bob each have a personal copy of a repository for a project they're "
3494 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
3495 "feature in his. They want the shared repository to contain both the bug fix "
3496 "and the new feature."
3497 msgstr ""
3499 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3500 #: ../en/ch02-tour-merge.xml:24
3501 msgid ""
3502 "I frequently work on several different tasks for a single project at once, "
3503 "each safely isolated in its own repository. Working this way means that I "
3504 "often need to merge one piece of my own work with another."
3505 msgstr ""
3507 #. type: Content of: <book><chapter><sect1><para>
3508 #: ../en/ch02-tour-merge.xml:30
3509 msgid ""
3510 "Because merging is such a common thing to need to do, Mercurial makes it "
3511 "easy. Let's walk through the process. We'll begin by cloning yet another "
3512 "repository (see how often they spring up?) and making a change in it."
3513 msgstr ""
3515 #. type: Content of: <book><chapter><sect1><para>
3516 #: ../en/ch02-tour-merge.xml:37
3517 msgid ""
3518 "We should now have two copies of <filename>hello.c</filename> with different "
3519 "contents. The histories of the two repositories have also diverged, as "
3520 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>."
3521 msgstr ""
3523 #. type: Content of: <book><chapter><sect1><figure><title>
3524 #: ../en/ch02-tour-merge.xml:46
3525 msgid ""
3526 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
3527 "filename> and <filename class=\"directory\">my-new-hello</filename> "
3528 "repositories"
3529 msgstr ""
3530 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
3531 "\"directory\">my-new-hello</filename> 最新的历史分叉"
3533 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3534 #: ../en/ch02-tour-merge.xml:51
3535 msgid ""
3536 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
3537 "imageobject>"
3538 msgstr ""
3540 #. type: Content of: <book><chapter><sect1><para>
3541 #: ../en/ch02-tour-merge.xml:56
3542 msgid ""
3543 "We already know that pulling changes from our <filename class=\"directory"
3544 "\">my-hello</filename> repository will have no effect on the working "
3545 "directory."
3546 msgstr ""
3548 #. type: Content of: <book><chapter><sect1><para>
3549 #: ../en/ch02-tour-merge.xml:62
3550 msgid ""
3551 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
3552 "something about <quote>heads</quote>."
3553 msgstr ""
3555 #. type: Content of: <book><chapter><sect1><sect2><title>
3556 #: ../en/ch02-tour-merge.xml:66
3557 msgid "Head changesets"
3558 msgstr "顶点修改集"
3560 #. type: Content of: <book><chapter><sect1><sect2><para>
3561 #: ../en/ch02-tour-merge.xml:68
3562 msgid ""
3563 "A head is a change that has no descendants, or children, as they're also "
3564 "known. The tip revision is thus a head, because the newest revision in a "
3565 "repository doesn't have any children, but a repository can contain more than "
3566 "one head."
3567 msgstr ""
3569 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3570 #: ../en/ch02-tour-merge.xml:75
3571 msgid ""
3572 "Repository contents after pulling from <filename class=\"directory\">my-"
3573 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
3574 msgstr ""
3575 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
3576 "\"directory\">my-new-hello</filename> 之后版本库的内容"
3578 #. type: Content of: <book><chapter><sect1><sect2><figure>
3579 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:159
3580 #: ../en/ch02-tour-merge.xml:256 ../en/ch03-concepts.xml:57
3581 #: ../en/ch03-concepts.xml:106 ../en/ch03-concepts.xml:191
3582 #: ../en/ch03-concepts.xml:346 ../en/ch03-concepts.xml:361
3583 #: ../en/ch03-concepts.xml:402 ../en/ch03-concepts.xml:422
3584 #: ../en/ch03-concepts.xml:463 ../en/ch05-collab.xml:320
3585 #: ../en/ch08-undo.xml:363 ../en/ch08-undo.xml:410 ../en/ch08-undo.xml:475
3586 #: ../en/ch08-undo.xml:513 ../en/ch11-mq.xml:410
3587 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
3588 msgstr ""
3590 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3591 #: ../en/ch02-tour-merge.xml:79
3592 msgid ""
3593 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
3594 msgstr ""
3596 #. type: Content of: <book><chapter><sect1><sect2><para>
3597 #: ../en/ch02-tour-merge.xml:86
3598 msgid ""
3599 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
3600 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
3601 "class=\"directory\">my-new-hello</filename>. The history that was already "
3602 "present in <filename class=\"directory\">my-new-hello</filename> is "
3603 "untouched, but a new revision has been added. By referring to <xref linkend="
3604 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
3605 "emphasis> remains the same in the new repository, but the <emphasis>revision "
3606 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
3607 "it's not safe to use revision numbers when discussing changesets.) We can "
3608 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
3609 "command> command."
3610 msgstr ""
3612 #. type: Content of: <book><chapter><sect1><sect2><title>
3613 #: ../en/ch02-tour-merge.xml:105
3614 msgid "Performing the merge"
3615 msgstr "执行合并"
3617 #. type: Content of: <book><chapter><sect1><sect2><para>
3618 #: ../en/ch02-tour-merge.xml:107
3619 msgid ""
3620 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
3621 "command> command to update to the new tip?"
3622 msgstr ""
3624 #. type: Content of: <book><chapter><sect1><sect2><para>
3625 #: ../en/ch02-tour-merge.xml:113
3626 msgid ""
3627 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
3628 "command won't do a merge; it won't update the working directory when it "
3629 "thinks we might want to do a merge, unless we force it to do so. Instead, we "
3630 "use the <command role=\"hg-cmd\">hg merge</command> command to merge the two "
3631 "heads."
3632 msgstr ""
3634 #. type: Content of: <book><chapter><sect1><sect2><para>
3635 #: ../en/ch02-tour-merge.xml:122
3636 msgid ""
3637 "This updates the working directory so that it contains changes from "
3638 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
3639 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
3640 "<filename>hello.c</filename>."
3641 msgstr ""
3643 #. type: Content of: <book><chapter><sect1><sect2><title>
3644 #: ../en/ch02-tour-merge.xml:132
3645 msgid "Committing the results of the merge"
3646 msgstr "提交合并结果"
3648 #. type: Content of: <book><chapter><sect1><sect2><para>
3649 #: ../en/ch02-tour-merge.xml:134
3650 msgid ""
3651 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
3652 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
3653 "command> the results of the merge."
3654 msgstr ""
3656 #. type: Content of: <book><chapter><sect1><sect2><para>
3657 #: ../en/ch02-tour-merge.xml:141
3658 msgid ""
3659 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
3660 "of our former heads as its parents. These are the same revisions that were "
3661 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
3662 msgstr ""
3664 #. type: Content of: <book><chapter><sect1><sect2><para>
3665 #: ../en/ch02-tour-merge.xml:148
3666 msgid ""
3667 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
3668 "what happens to the working directory during the merge, and how this affects "
3669 "the repository when the commit happens. During the merge, the working "
3670 "directory has two parent changesets, and these become the parents of the new "
3671 "changeset."
3672 msgstr ""
3674 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3675 #: ../en/ch02-tour-merge.xml:157
3676 msgid "Working directory and repository during merge, and following commit"
3677 msgstr "在合并期间,以及提交之后的工作目录与版本库"
3679 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3680 #: ../en/ch02-tour-merge.xml:160
3681 msgid ""
3682 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
3683 "imageobject>"
3684 msgstr ""
3686 #. type: Content of: <book><chapter><sect1><sect2><para>
3687 #: ../en/ch02-tour-merge.xml:167
3688 msgid ""
3689 "We sometimes talk about a merge having <emphasis>sides</emphasis>: the left "
3690 "side is the first parent in the output of <command role=\"hg-cmd\">hg "
3691 "parents</command>, and the right side is the second. If the working "
3692 "directory was at e.g. revision 5 before we began a merge, that revision will "
3693 "become the left side of the merge."
3694 msgstr ""
3696 #. type: Content of: <book><chapter><sect1><title>
3697 #: ../en/ch02-tour-merge.xml:177
3698 msgid "Merging conflicting changes"
3699 msgstr "合并有冲突的改变"
3701 #. type: Content of: <book><chapter><sect1><para>
3702 #: ../en/ch02-tour-merge.xml:179
3703 msgid ""
3704 "Most merges are simple affairs, but sometimes you'll find yourself merging "
3705 "changes where each side modifies the same portions of the same files. Unless "
3706 "both modifications are identical, this results in a <emphasis>conflict</"
3707 "emphasis>, where you have to decide how to reconcile the different changes "
3708 "into something coherent."
3709 msgstr ""
3711 #. type: Content of: <book><chapter><sect1><figure><title>
3712 #: ../en/ch02-tour-merge.xml:187
3713 msgid "Conflicting changes to a document"
3714 msgstr "冲突的修改"
3716 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3717 #: ../en/ch02-tour-merge.xml:189
3718 msgid ""
3719 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
3720 "imageobject>"
3721 msgstr ""
3723 #. type: Content of: <book><chapter><sect1><para>
3724 #: ../en/ch02-tour-merge.xml:194
3725 msgid ""
3726 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
3727 "conflicting changes to a document. We started with a single version of the "
3728 "file; then we made some changes; while someone else made different changes to "
3729 "the same text. Our task in resolving the conflicting changes is to decide "
3730 "what the file should look like."
3731 msgstr ""
3733 #. type: Content of: <book><chapter><sect1><para>
3734 #: ../en/ch02-tour-merge.xml:201
3735 msgid ""
3736 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
3737 "it runs an external program, usually one that displays some kind of graphical "
3738 "conflict resolution interface. By default, Mercurial tries to find one of "
3739 "several different merging tools that are likely to be installed on your "
3740 "system. It first tries a few fully automatic merging tools; if these don't "
3741 "succeed (because the resolution process requires human guidance) or aren't "
3742 "present, it tries a few different graphical merging tools."
3743 msgstr ""
3745 #. type: Content of: <book><chapter><sect1><para>
3746 #: ../en/ch02-tour-merge.xml:211
3747 msgid ""
3748 "It's also possible to get Mercurial to run another program or script instead "
3749 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
3750 "environment variable to the name of your preferred program."
3751 msgstr ""
3753 #. type: Content of: <book><chapter><sect1><sect2><title>
3754 #: ../en/ch02-tour-merge.xml:217
3755 msgid "Using a graphical merge tool"
3756 msgstr "使用图形合并工具"
3758 #. type: Content of: <book><chapter><sect1><sect2><para>
3759 #: ../en/ch02-tour-merge.xml:219
3760 msgid ""
3761 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
3762 "use to describe the features that are common to graphical file merging "
3763 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
3764 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
3765 "performing is called a <emphasis>three-way merge</emphasis>, because there "
3766 "are three different versions of the file of interest to us. The tool thus "
3767 "splits the upper portion of the window into three panes:"
3768 msgstr ""
3770 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3771 #: ../en/ch02-tour-merge.xml:229
3772 msgid ""
3773 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
3774 "most recent version from which the two versions we're trying to merge are "
3775 "descended."
3776 msgstr ""
3778 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3779 #: ../en/ch02-tour-merge.xml:234
3780 msgid ""
3781 "In the middle is <quote>our</quote> version of the file, with the contents "
3782 "that we modified."
3783 msgstr ""
3785 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3786 #: ../en/ch02-tour-merge.xml:237
3787 msgid ""
3788 "On the right is <quote>their</quote> version of the file, the one that from "
3789 "the changeset that we're trying to merge with."
3790 msgstr ""
3792 #. type: Content of: <book><chapter><sect1><sect2><para>
3793 #: ../en/ch02-tour-merge.xml:241
3794 msgid ""
3795 "In the pane below these is the current <emphasis>result</emphasis> of the "
3796 "merge. Our task is to replace all of the red text, which indicates unresolved "
3797 "conflicts, with some sensible merger of the <quote>ours</quote> and "
3798 "<quote>theirs</quote> versions of the file."
3799 msgstr ""
3801 #. type: Content of: <book><chapter><sect1><sect2><para>
3802 #: ../en/ch02-tour-merge.xml:248
3803 msgid ""
3804 "All four of these panes are <emphasis>locked together</emphasis>; if we "
3805 "scroll vertically or horizontally in any of them, the others are updated to "
3806 "display the corresponding sections of their respective files."
3807 msgstr ""
3809 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3810 #: ../en/ch02-tour-merge.xml:254
3811 msgid "Using <command>kdiff3</command> to merge versions of a file"
3812 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
3814 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3815 #: ../en/ch02-tour-merge.xml:257
3816 msgid ""
3817 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
3818 "imageobject>"
3819 msgstr ""
3821 #. type: Content of: <book><chapter><sect1><sect2><para>
3822 #: ../en/ch02-tour-merge.xml:265
3823 msgid ""
3824 "For each conflicting portion of the file, we can choose to resolve the "
3825 "conflict using some combination of text from the base version, ours, or "
3826 "theirs. We can also manually edit the merged file at any time, in case we "
3827 "need to make further modifications."
3828 msgstr ""
3830 #. type: Content of: <book><chapter><sect1><sect2><para>
3831 #: ../en/ch02-tour-merge.xml:271
3832 msgid ""
3833 "There are <emphasis>many</emphasis> file merging tools available, too many to "
3834 "cover here. They vary in which platforms they are available for, and in "
3835 "their particular strengths and weaknesses. Most are tuned for merging files "
3836 "containing plain text, while a few are aimed at specialised file formats "
3837 "(generally XML)."
3838 msgstr ""
3840 #. type: Content of: <book><chapter><sect1><sect2><title>
3841 #: ../en/ch02-tour-merge.xml:280
3842 msgid "A worked example"
3843 msgstr "合并实例"
3845 #. type: Content of: <book><chapter><sect1><sect2><para>
3846 #: ../en/ch02-tour-merge.xml:282
3847 msgid ""
3848 "In this example, we will reproduce the file modification history of <xref "
3849 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
3850 "repository with a base version of our document."
3851 msgstr ""
3853 #. type: Content of: <book><chapter><sect1><sect2><para>
3854 #: ../en/ch02-tour-merge.xml:289
3855 msgid "We'll clone the repository and make a change to the file."
3856 msgstr ""
3858 #. type: Content of: <book><chapter><sect1><sect2><para>
3859 #: ../en/ch02-tour-merge.xml:294
3860 msgid ""
3861 "And another clone, to simulate someone else making a change to the file. "
3862 "(This hints at the idea that it's not all that unusual to merge with yourself "
3863 "when you isolate tasks in separate repositories, and indeed to find and "
3864 "resolve conflicts while doing so.)"
3865 msgstr ""
3867 #. type: Content of: <book><chapter><sect1><sect2><para>
3868 #: ../en/ch02-tour-merge.xml:302
3869 msgid ""
3870 "Having created two different versions of the file, we'll set up an "
3871 "environment suitable for running our merge."
3872 msgstr ""
3874 #. type: Content of: <book><chapter><sect1><sect2><para>
3875 #: ../en/ch02-tour-merge.xml:308
3876 msgid ""
3877 "In this example, I'll set <envar>HGMERGE</envar> to tell Mercurial to use the "
3878 "non-interactive <command>merge</command> command. This is bundled with many "
3879 "Unix-like systems. (If you're following this example on your computer, don't "
3880 "bother setting <envar>HGMERGE</envar>.)"
3881 msgstr ""
3883 #. type: Content of: <book><chapter><sect1><sect2><para>
3884 #: ../en/ch02-tour-merge.xml:317
3885 msgid ""
3886 "Because <command>merge</command> can't resolve the conflicting changes, it "
3887 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
3888 "indicating which lines have conflicts, and whether they came from our version "
3889 "of the file or theirs."
3890 msgstr ""
3892 #. type: Content of: <book><chapter><sect1><sect2><para>
3893 #: ../en/ch02-tour-merge.xml:323
3894 msgid ""
3895 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
3896 "able to merge successfully, so it tells us what commands we'll need to run if "
3897 "we want to redo the merging operation. This could be useful if, for example, "
3898 "we were running a graphical merge tool and quit because we were confused or "
3899 "realised we had made a mistake."
3900 msgstr ""
3902 #. type: Content of: <book><chapter><sect1><sect2><para>
3903 #: ../en/ch02-tour-merge.xml:330
3904 msgid ""
3905 "If automatic or manual merges fail, there's nothing to prevent us from "
3906 "<quote>fixing up</quote> the affected files ourselves, and committing the "
3907 "results of our merge:"
3908 msgstr ""
3910 #. type: Content of: <book><chapter><sect1><title>
3911 #: ../en/ch02-tour-merge.xml:339
3912 msgid "Simplifying the pull-merge-commit sequence"
3913 msgstr "简化拉-合并-提交程序"
3915 #. type: Content of: <book><chapter><sect1><para>
3916 #: ../en/ch02-tour-merge.xml:341
3917 msgid ""
3918 "The process of merging changes as outlined above is straightforward, but "
3919 "requires running three commands in sequence."
3920 msgstr ""
3922 #. type: Content of: <book><chapter><sect1><para>
3923 #: ../en/ch02-tour-merge.xml:347
3924 msgid ""
3925 "In the case of the final commit, you also need to enter a commit message, "
3926 "which is almost always going to be a piece of uninteresting "
3927 "<quote>boilerplate</quote> text."
3928 msgstr ""
3930 #. type: Content of: <book><chapter><sect1><para>
3931 #: ../en/ch02-tour-merge.xml:351
3932 msgid ""
3933 "It would be nice to reduce the number of steps needed, if this were "
3934 "possible. Indeed, Mercurial is distributed with an extension called <literal "
3935 "role=\"hg-ext\">fetch</literal> that does just this."
3936 msgstr ""
3938 #. type: Content of: <book><chapter><sect1><para>
3939 #: ../en/ch02-tour-merge.xml:356
3940 msgid ""
3941 "Mercurial provides a flexible extension mechanism that lets people extend its "
3942 "functionality, while keeping the core of Mercurial small and easy to deal "
3943 "with. Some extensions add new commands that you can use from the command "
3944 "line, while others work <quote>behind the scenes,</quote> for example adding "
3945 "capabilities to the server."
3946 msgstr ""
3948 #. type: Content of: <book><chapter><sect1><para>
3949 #: ../en/ch02-tour-merge.xml:363
3950 msgid ""
3951 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
3952 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
3953 "extension acts as a combination of <command role=\"hg-cmd\">hg pull -u</"
3954 "command>, <command role=\"hg-cmd\">hg merge</command> and <command role=\"hg-"
3955 "cmd\">hg commit</command>. It begins by pulling changes from another "
3956 "repository into the current repository. If it finds that the changes added a "
3957 "new head to the repository, it begins a merge, then (if the merge succeeded) "
3958 "commits the result of the merge with an automatically-generated commit "
3959 "message. If no new heads were added, it updates the working directory to the "
3960 "new tip changeset."
3961 msgstr ""
3963 #. type: Content of: <book><chapter><sect1><para>
3964 #: ../en/ch02-tour-merge.xml:376
3965 msgid ""
3966 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
3967 "Edit the <filename role=\"special\">.hgrc</filename> file in your home "
3968 "directory, and either go to the <literal role=\"rc-extensions\">extensions</"
3969 "literal> section or create an <literal role=\"rc-extensions\">extensions</"
3970 "literal> section. Then add a line that simply reads <quote><literal>fetch=</"
3971 "literal></quote>."
3972 msgstr ""
3974 #. type: Content of: <book><chapter><sect1><para>
3975 #: ../en/ch02-tour-merge.xml:388
3976 msgid ""
3977 "(Normally, the right-hand side of the <quote><literal>=</literal></quote> "
3978 "would indicate where to find the extension, but since the <literal role=\"hg-"
3979 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
3980 "knows where to search for it.)"
3981 msgstr ""
3983 #. type: Content of: <book><chapter><title>
3984 #: ../en/ch03-concepts.xml:5
3985 msgid "Behind the scenes"
3986 msgstr "Mercurial 内幕"
3988 #. type: Content of: <book><chapter><para>
3989 #: ../en/ch03-concepts.xml:7
3990 msgid ""
3991 "Unlike many revision control systems, the concepts upon which Mercurial is "
3992 "built are simple enough that it's easy to understand how the software really "
3993 "works. Knowing these details certainly isn't necessary, so it is certainly "
3994 "safe to skip this chapter. However, I think you will get more out of the "
3995 "software with a <quote>mental model</quote> of what's going on."
3996 msgstr ""
3998 #. type: Content of: <book><chapter><para>
3999 #: ../en/ch03-concepts.xml:14
4000 msgid ""
4001 "Being able to understand what's going on behind the scenes gives me "
4002 "confidence that Mercurial has been carefully designed to be both "
4003 "<emphasis>safe</emphasis> and <emphasis>efficient</emphasis>. And just as "
4004 "importantly, if it's easy for me to retain a good idea of what the software "
4005 "is doing when I perform a revision control task, I'm less likely to be "
4006 "surprised by its behavior."
4007 msgstr ""
4009 #. type: Content of: <book><chapter><para>
4010 #: ../en/ch03-concepts.xml:22
4011 msgid ""
4012 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
4013 "design, then continue to discuss some of the interesting details of its "
4014 "implementation."
4015 msgstr ""
4017 #. type: Content of: <book><chapter><sect1><title>
4018 #: ../en/ch03-concepts.xml:27
4019 msgid "Mercurial's historical record"
4020 msgstr "Mercurial 的历史记录"
4022 #. type: Content of: <book><chapter><sect1><sect2><title>
4023 #: ../en/ch03-concepts.xml:30
4024 msgid "Tracking the history of a single file"
4025 msgstr "跟踪单一文件的历史"
4027 #. type: Content of: <book><chapter><sect1><sect2><para>
4028 #: ../en/ch03-concepts.xml:32
4029 msgid ""
4030 "When Mercurial tracks modifications to a file, it stores the history of that "
4031 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
4032 "in the filelog contains enough information to reconstruct one revision of the "
4033 "file that is being tracked. Filelogs are stored as files in the <filename "
4034 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
4035 "filelog contains two kinds of information: revision data, and an index to "
4036 "help Mercurial to find a revision efficiently."
4037 msgstr ""
4039 #. type: Content of: <book><chapter><sect1><sect2><para>
4040 #: ../en/ch03-concepts.xml:43
4041 msgid ""
4042 "A file that is large, or has a lot of history, has its filelog stored in "
4043 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
4044 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
4045 "much history, the revision data and index are combined in a single "
4046 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
4047 "in the working directory and the filelog that tracks its history in the "
4048 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
4049 msgstr ""
4051 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4052 #: ../en/ch03-concepts.xml:55
4053 msgid ""
4054 "Relationships between files in working directory and filelogs in repository"
4055 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
4057 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4058 #: ../en/ch03-concepts.xml:58
4059 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
4060 msgstr ""
4062 #. type: Content of: <book><chapter><sect1><sect2><title>
4063 #: ../en/ch03-concepts.xml:65
4064 msgid "Managing tracked files"
4065 msgstr "管理跟踪的文件"
4067 #. type: Content of: <book><chapter><sect1><sect2><para>
4068 #: ../en/ch03-concepts.xml:67
4069 msgid ""
4070 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
4071 "together information about the files that it tracks. Each entry in the "
4072 "manifest contains information about the files present in a single changeset. "
4073 "An entry records which files are present in the changeset, the revision of "
4074 "each file, and a few other pieces of file metadata."
4075 msgstr ""
4077 #. type: Content of: <book><chapter><sect1><sect2><title>
4078 #: ../en/ch03-concepts.xml:77
4079 msgid "Recording changeset information"
4080 msgstr "记录修改集信息"
4082 #. type: Content of: <book><chapter><sect1><sect2><para>
4083 #: ../en/ch03-concepts.xml:79
4084 msgid ""
4085 "The <emphasis>changelog</emphasis> contains information about each "
4086 "changeset. Each revision records who committed a change, the changeset "
4087 "comment, other pieces of changeset-related information, and the revision of "
4088 "the manifest to use."
4089 msgstr ""
4091 #. type: Content of: <book><chapter><sect1><sect2><title>
4092 #: ../en/ch03-concepts.xml:87
4093 msgid "Relationships between revisions"
4094 msgstr "版本之间的关系"
4096 #. type: Content of: <book><chapter><sect1><sect2><para>
4097 #: ../en/ch03-concepts.xml:89
4098 msgid ""
4099 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
4100 "to its immediate parent (or to its two parents, if it's a merge revision). "
4101 "As I mentioned above, there are also relationships between revisions "
4102 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
4103 "nature."
4104 msgstr ""
4106 #. type: Content of: <book><chapter><sect1><sect2><para>
4107 #: ../en/ch03-concepts.xml:96
4108 msgid ""
4109 "For every changeset in a repository, there is exactly one revision stored in "
4110 "the changelog. Each revision of the changelog contains a pointer to a single "
4111 "revision of the manifest. A revision of the manifest stores a pointer to a "
4112 "single revision of each filelog tracked when that changeset was created. "
4113 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
4114 "\"/>."
4115 msgstr ""
4117 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4118 #: ../en/ch03-concepts.xml:105
4119 msgid "Metadata relationships"
4120 msgstr "元数据之间的关系"
4122 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4123 #: ../en/ch03-concepts.xml:107
4124 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
4125 msgstr ""
4127 #. type: Content of: <book><chapter><sect1><sect2><para>
4128 #: ../en/ch03-concepts.xml:112
4129 msgid ""
4130 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
4131 "one</quote> relationship between revisions in the changelog, manifest, or "
4132 "filelog. If the manifest hasn't changed between two changesets, the changelog "
4133 "entries for those changesets will point to the same revision of the "
4134 "manifest. If a file that Mercurial tracks hasn't changed between two "
4135 "changesets, the entry for that file in the two revisions of the manifest will "
4136 "point to the same revision of its filelog."
4137 msgstr ""
4139 #. type: Content of: <book><chapter><sect1><title>
4140 #: ../en/ch03-concepts.xml:125
4141 msgid "Safe, efficient storage"
4142 msgstr "安全,高效的存储"
4144 #. type: Content of: <book><chapter><sect1><para>
4145 #: ../en/ch03-concepts.xml:127
4146 msgid ""
4147 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
4148 "single structure called the <emphasis>revlog</emphasis>."
4149 msgstr ""
4151 #. type: Content of: <book><chapter><sect1><sect2><title>
4152 #: ../en/ch03-concepts.xml:132
4153 msgid "Efficient storage"
4154 msgstr "高效存储"
4156 #. type: Content of: <book><chapter><sect1><sect2><para>
4157 #: ../en/ch03-concepts.xml:134
4158 msgid ""
4159 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
4160 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
4161 "revision, it stores the changes needed to transform an older revision into "
4162 "the new revision. For many kinds of file data, these deltas are typically a "
4163 "fraction of a percent of the size of a full copy of a file."
4164 msgstr ""
4166 #. type: Content of: <book><chapter><sect1><sect2><para>
4167 #: ../en/ch03-concepts.xml:142
4168 msgid ""
4169 "Some obsolete revision control systems can only work with deltas of text "
4170 "files. They must either store binary files as complete snapshots or encoded "
4171 "into a text representation, both of which are wasteful approaches. Mercurial "
4172 "can efficiently handle deltas of files with arbitrary binary contents; it "
4173 "doesn't need to treat text as special."
4174 msgstr ""
4176 #. type: Content of: <book><chapter><sect1><sect2><title>
4177 #: ../en/ch03-concepts.xml:151
4178 msgid "Safe operation"
4179 msgstr "安全操作"
4181 #. type: Content of: <book><chapter><sect1><sect2><para>
4182 #: ../en/ch03-concepts.xml:153
4183 msgid ""
4184 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
4185 "file. It never modifies a section of a file after it has written it. This is "
4186 "both more robust and efficient than schemes that need to modify or rewrite "
4187 "data."
4188 msgstr ""
4190 #. type: Content of: <book><chapter><sect1><sect2><para>
4191 #: ../en/ch03-concepts.xml:159
4192 msgid ""
4193 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
4194 "emphasis> that can span a number of files. A transaction is "
4195 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
4196 "effects are all visible to readers in one go, or the whole thing is undone. "
4197 "This guarantee of atomicity means that if you're running two copies of "
4198 "Mercurial, where one is reading data and one is writing it, the reader will "
4199 "never see a partially written result that might confuse it."
4200 msgstr ""
4202 #. type: Content of: <book><chapter><sect1><sect2><para>
4203 #: ../en/ch03-concepts.xml:169
4204 msgid ""
4205 "The fact that Mercurial only appends to files makes it easier to provide this "
4206 "transactional guarantee. The easier it is to do stuff like this, the more "
4207 "confident you should be that it's done correctly."
4208 msgstr ""
4210 #. type: Content of: <book><chapter><sect1><sect2><title>
4211 #: ../en/ch03-concepts.xml:176
4212 msgid "Fast retrieval"
4213 msgstr "快速检索"
4215 #. type: Content of: <book><chapter><sect1><sect2><para>
4216 #: ../en/ch03-concepts.xml:178
4217 msgid ""
4218 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
4219 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
4220 "revision control systems store the contents of a revision as an incremental "
4221 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
4222 "specific revision, you must first read the snapshot, and then every one of "
4223 "the revisions between the snapshot and your target revision. The more "
4224 "history that a file accumulates, the more revisions you must read, hence the "
4225 "longer it takes to reconstruct a particular revision."
4226 msgstr ""
4228 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4229 #: ../en/ch03-concepts.xml:190
4230 msgid "Snapshot of a revlog, with incremental deltas"
4231 msgstr "版本日志的快照,以及增量差异"
4233 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4234 #: ../en/ch03-concepts.xml:192
4235 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
4236 msgstr ""
4238 #. type: Content of: <book><chapter><sect1><sect2><para>
4239 #: ../en/ch03-concepts.xml:197
4240 msgid ""
4241 "The innovation that Mercurial applies to this problem is simple but "
4242 "effective. Once the cumulative amount of delta information stored since the "
4243 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
4244 "(compressed, of course), instead of another delta. This makes it possible to "
4245 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
4246 "approach works so well that it has since been copied by several other "
4247 "revision control systems."
4248 msgstr ""
4250 #. type: Content of: <book><chapter><sect1><sect2><para>
4251 #: ../en/ch03-concepts.xml:206
4252 msgid ""
4253 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
4254 "in a revlog's index file, Mercurial stores the range of entries from the data "
4255 "file that it must read to reconstruct a particular revision."
4256 msgstr ""
4258 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4259 #: ../en/ch03-concepts.xml:212
4260 msgid "Aside: the influence of video compression"
4261 msgstr "旁白: 视频压缩的影响"
4263 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4264 #: ../en/ch03-concepts.xml:214
4265 msgid ""
4266 "If you're familiar with video compression or have ever watched a TV feed "
4267 "through a digital cable or satellite service, you may know that most video "
4268 "compression schemes store each frame of video as a delta against its "
4269 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
4270 "compression techniques to increase the compression ratio, so visual errors "
4271 "accumulate over the course of a number of inter-frame deltas."
4272 msgstr ""
4274 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4275 #: ../en/ch03-concepts.xml:223
4276 msgid ""
4277 "Because it's possible for a video stream to <quote>drop out</quote> "
4278 "occasionally due to signal glitches, and to limit the accumulation of "
4279 "artefacts introduced by the lossy compression process, video encoders "
4280 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
4281 "the video stream; the next delta is generated against that frame. This means "
4282 "that if the video signal gets interrupted, it will resume once the next key "
4283 "frame is received. Also, the accumulation of encoding errors restarts anew "
4284 "with each key frame."
4285 msgstr ""
4287 #. type: Content of: <book><chapter><sect1><sect2><title>
4288 #: ../en/ch03-concepts.xml:237
4289 msgid "Identification and strong integrity"
4290 msgstr "鉴别和强完整性"
4292 #. type: Content of: <book><chapter><sect1><sect2><para>
4293 #: ../en/ch03-concepts.xml:239
4294 msgid ""
4295 "Along with delta or snapshot information, a revlog entry contains a "
4296 "cryptographic hash of the data that it represents. This makes it difficult "
4297 "to forge the contents of a revision, and easy to detect accidental corruption."
4298 msgstr ""
4300 #. type: Content of: <book><chapter><sect1><sect2><para>
4301 #: ../en/ch03-concepts.xml:244
4302 msgid ""
4303 "Hashes provide more than a mere check against corruption; they are used as "
4304 "the identifiers for revisions. The changeset identification hashes that you "
4305 "see as an end user are from revisions of the changelog. Although filelogs "
4306 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
4307 msgstr ""
4309 #. type: Content of: <book><chapter><sect1><sect2><para>
4310 #: ../en/ch03-concepts.xml:251
4311 msgid ""
4312 "Mercurial verifies that hashes are correct when it retrieves file revisions "
4313 "and when it pulls changes from another repository. If it encounters an "
4314 "integrity problem, it will complain and stop whatever it's doing."
4315 msgstr ""
4317 #. type: Content of: <book><chapter><sect1><sect2><para>
4318 #: ../en/ch03-concepts.xml:256
4319 msgid ""
4320 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
4321 "periodic snapshots makes it more robust against partial data corruption. If "
4322 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
4323 "often possible to reconstruct some or most revisions from the uncorrupted "
4324 "sections of the revlog, both before and after the corrupted section. This "
4325 "would not be possible with a delta-only storage model."
4326 msgstr ""
4328 #. type: Content of: <book><chapter><sect1><title>
4329 #: ../en/ch03-concepts.xml:268
4330 msgid "Revision history, branching, and merging"
4331 msgstr "修订历史,分支与合并"
4333 #. type: Content of: <book><chapter><sect1><para>
4334 #: ../en/ch03-concepts.xml:270
4335 msgid ""
4336 "Every entry in a Mercurial revlog knows the identity of its immediate "
4337 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
4338 "In fact, a revision contains room for not one parent, but two. Mercurial "
4339 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
4340 "<quote>there is no parent here</quote>. This hash is simply a string of "
4341 "zeroes."
4342 msgstr ""
4344 #. type: Content of: <book><chapter><sect1><para>
4345 #: ../en/ch03-concepts.xml:278
4346 msgid ""
4347 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
4348 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
4349 "have this same structure; they differ only in the kind of data stored in each "
4350 "delta or snapshot."
4351 msgstr ""
4353 #. type: Content of: <book><chapter><sect1><para>
4354 #: ../en/ch03-concepts.xml:284
4355 msgid ""
4356 "The first revision in a revlog (at the bottom of the image) has the null ID "
4357 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
4358 "parent slot contains the ID of its parent revision, and its second contains "
4359 "the null ID, indicating that the revision has only one real parent. Any two "
4360 "revisions that have the same parent ID are branches. A revision that "
4361 "represents a merge between branches has two normal revision IDs in its parent "
4362 "slots."
4363 msgstr ""
4365 #. type: Content of: <book><chapter><sect1><figure><title>
4366 #: ../en/ch03-concepts.xml:294
4367 msgid "The conceptual structure of a revlog"
4368 msgstr "版本日志的设计结构"
4370 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4371 #: ../en/ch03-concepts.xml:296
4372 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
4373 msgstr ""
4375 #. type: Content of: <book><chapter><sect1><title>
4376 #: ../en/ch03-concepts.xml:303
4377 msgid "The working directory"
4378 msgstr "工作目录"
4380 #. type: Content of: <book><chapter><sect1><para>
4381 #: ../en/ch03-concepts.xml:305
4382 msgid ""
4383 "In the working directory, Mercurial stores a snapshot of the files from the "
4384 "repository as of a particular changeset."
4385 msgstr ""
4387 #. type: Content of: <book><chapter><sect1><para>
4388 #: ../en/ch03-concepts.xml:308
4389 msgid ""
4390 "The working directory <quote>knows</quote> which changeset it contains. When "
4391 "you update the working directory to contain a particular changeset, Mercurial "
4392 "looks up the appropriate revision of the manifest to find out which files it "
4393 "was tracking at the time that changeset was committed, and which revision of "
4394 "each file was then current. It then recreates a copy of each of those files, "
4395 "with the same contents it had when the changeset was committed."
4396 msgstr ""
4398 #. type: Content of: <book><chapter><sect1><para>
4399 #: ../en/ch03-concepts.xml:317
4400 msgid ""
4401 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
4402 "working directory. This details which changeset the working directory is "
4403 "updated to, and all of the files that Mercurial is tracking in the working "
4404 "directory."
4405 msgstr ""
4407 #. type: Content of: <book><chapter><sect1><para>
4408 #: ../en/ch03-concepts.xml:323
4409 msgid ""
4410 "Just as a revision of a revlog has room for two parents, so that it can "
4411 "represent either a normal revision (with one parent) or a merge of two "
4412 "earlier revisions, the dirstate has slots for two parents. When you use the "
4413 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
4414 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
4415 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
4416 "another changeset, the first parent remains unchanged, and the second parent "
4417 "is filled in with the changeset you're merging with. The <command role=\"hg-"
4418 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
4419 "are."
4420 msgstr ""
4422 #. type: Content of: <book><chapter><sect1><sect2><title>
4423 #: ../en/ch03-concepts.xml:337
4424 msgid "What happens when you commit"
4425 msgstr "当你提交时发生的事情"
4427 #. type: Content of: <book><chapter><sect1><sect2><para>
4428 #: ../en/ch03-concepts.xml:339
4429 msgid ""
4430 "The dirstate stores parent information for more than just book-keeping "
4431 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
4432 "parents of a new changeset</emphasis> when you perform a commit."
4433 msgstr ""
4435 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4436 #: ../en/ch03-concepts.xml:345
4437 msgid "The working directory can have two parents"
4438 msgstr "工作目录可以有两个父亲"
4440 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4441 #: ../en/ch03-concepts.xml:347
4442 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
4443 msgstr ""
4445 #. type: Content of: <book><chapter><sect1><sect2><para>
4446 #: ../en/ch03-concepts.xml:352
4447 msgid ""
4448 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
4449 "directory, where it has a single changeset as parent. That changeset is the "
4450 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
4451 "children."
4452 msgstr ""
4454 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4455 #: ../en/ch03-concepts.xml:359
4456 msgid "The working directory gains new parents after a commit"
4457 msgstr "提交之后,工作目录的父亲就改变了"
4459 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4460 #: ../en/ch03-concepts.xml:362
4461 msgid ""
4462 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
4463 msgstr ""
4465 #. type: Content of: <book><chapter><sect1><sect2><para>
4466 #: ../en/ch03-concepts.xml:367
4467 msgid ""
4468 "It's useful to think of the working directory as <quote>the changeset I'm "
4469 "about to commit</quote>. Any files that you tell Mercurial that you've "
4470 "added, removed, renamed, or copied will be reflected in that changeset, as "
4471 "will modifications to any files that Mercurial is already tracking; the new "
4472 "changeset will have the parents of the working directory as its parents."
4473 msgstr ""
4475 #. type: Content of: <book><chapter><sect1><sect2><para>
4476 #: ../en/ch03-concepts.xml:375
4477 msgid ""
4478 "After a commit, Mercurial will update the parents of the working directory, "
4479 "so that the first parent is the ID of the new changeset, and the second is "
4480 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
4481 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
4482 "you commit; it just modifies the dirstate to note its new parents."
4483 msgstr ""
4485 #. type: Content of: <book><chapter><sect1><sect2><title>
4486 #: ../en/ch03-concepts.xml:386
4487 msgid "Creating a new head"
4488 msgstr "创建新顶点"
4490 #. type: Content of: <book><chapter><sect1><sect2><para>
4491 #: ../en/ch03-concepts.xml:388
4492 msgid ""
4493 "It's perfectly normal to update the working directory to a changeset other "
4494 "than the current tip. For example, you might want to know what your project "
4495 "looked like last Tuesday, or you could be looking through changesets to see "
4496 "which one introduced a bug. In cases like this, the natural thing to do is "
4497 "update the working directory to the changeset you're interested in, and then "
4498 "examine the files in the working directory directly to see their contents as "
4499 "they were when you committed that changeset. The effect of this is shown in "
4500 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
4501 msgstr ""
4503 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4504 #: ../en/ch03-concepts.xml:400
4505 msgid "The working directory, updated to an older changeset"
4506 msgstr "同步到旧修改集的工作目录"
4508 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4509 #: ../en/ch03-concepts.xml:403
4510 msgid ""
4511 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
4512 msgstr ""
4514 #. type: Content of: <book><chapter><sect1><sect2><para>
4515 #: ../en/ch03-concepts.xml:408
4516 msgid ""
4517 "Having updated the working directory to an older changeset, what happens if "
4518 "you make some changes, and then commit? Mercurial behaves in the same way as "
4519 "I outlined above. The parents of the working directory become the parents of "
4520 "the new changeset. This new changeset has no children, so it becomes the new "
4521 "tip. And the repository now contains two changesets that have no children; "
4522 "we call these <emphasis>heads</emphasis>. You can see the structure that "
4523 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
4524 msgstr ""
4526 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4527 #: ../en/ch03-concepts.xml:420
4528 msgid "After a commit made while synced to an older changeset"
4529 msgstr "对同步到旧修改集的工作目录提交之后"
4531 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4532 #: ../en/ch03-concepts.xml:423
4533 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
4534 msgstr ""
4536 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4537 #: ../en/ch03-concepts.xml:429
4538 msgid ""
4539 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
4540 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
4541 "command without any options. By default, the <command role=\"hg-cmd\">hg "
4542 "pull</command> command <emphasis>does not</emphasis> update the working "
4543 "directory, so you'll bring new changesets into your repository, but the "
4544 "working directory will stay synced at the same changeset as before the pull. "
4545 "If you make some changes and commit afterwards, you'll thus create a new "
4546 "head, because your working directory isn't synced to whatever the current tip "
4547 "is."
4548 msgstr ""
4550 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4551 #: ../en/ch03-concepts.xml:441
4552 msgid ""
4553 "I put the word <quote>error</quote> in quotes because all that you need to do "
4554 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
4555 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
4556 "almost never has negative consequences; it's just something of a surprise for "
4557 "newcomers. I'll discuss other ways to avoid this behavior, and why Mercurial "
4558 "behaves in this initially surprising way, later on."
4559 msgstr ""
4561 #. type: Content of: <book><chapter><sect1><sect2><title>
4562 #: ../en/ch03-concepts.xml:453
4563 msgid "Merging changes"
4564 msgstr "合并修改"
4566 #. type: Content of: <book><chapter><sect1><sect2><para>
4567 #: ../en/ch03-concepts.xml:455
4568 msgid ""
4569 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
4570 "Mercurial leaves the first parent of the working directory unchanged, and "
4571 "sets the second parent to the changeset you're merging with, as shown in "
4572 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
4573 msgstr ""
4575 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4576 #: ../en/ch03-concepts.xml:462
4577 msgid "Merging two heads"
4578 msgstr "合并两个顶点"
4580 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4581 #: ../en/ch03-concepts.xml:464
4582 msgid ""
4583 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
4584 msgstr ""
4586 #. type: Content of: <book><chapter><sect1><sect2><para>
4587 #: ../en/ch03-concepts.xml:471
4588 msgid ""
4589 "Mercurial also has to modify the working directory, to merge the files "
4590 "managed in the two changesets. Simplified a little, the merging process goes "
4591 "like this, for every file in the manifests of both changesets."
4592 msgstr ""
4594 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4595 #: ../en/ch03-concepts.xml:476
4596 msgid "If neither changeset has modified a file, do nothing with that file."
4597 msgstr ""
4599 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4600 #: ../en/ch03-concepts.xml:479
4601 msgid ""
4602 "If one changeset has modified a file, and the other hasn't, create the "
4603 "modified copy of the file in the working directory."
4604 msgstr ""
4606 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4607 #: ../en/ch03-concepts.xml:483
4608 msgid ""
4609 "If one changeset has removed a file, and the other hasn't (or has also "
4610 "deleted it), delete the file from the working directory."
4611 msgstr ""
4613 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4614 #: ../en/ch03-concepts.xml:487
4615 msgid ""
4616 "If one changeset has removed a file, but the other has modified the file, ask "
4617 "the user what to do: keep the modified file, or remove it?"
4618 msgstr ""
4620 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4621 #: ../en/ch03-concepts.xml:491
4622 msgid ""
4623 "If both changesets have modified a file, invoke an external merge program to "
4624 "choose the new contents for the merged file. This may require input from the "
4625 "user."
4626 msgstr ""
4628 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4629 #: ../en/ch03-concepts.xml:496
4630 msgid ""
4631 "If one changeset has modified a file, and the other has renamed or copied the "
4632 "file, make sure that the changes follow the new name of the file."
4633 msgstr ""
4635 #. type: Content of: <book><chapter><sect1><sect2><para>
4636 #: ../en/ch03-concepts.xml:500
4637 msgid ""
4638 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
4639 "these are the most common choices that are involved in a merge. As you can "
4640 "see, most cases are completely automatic, and indeed most merges finish "
4641 "automatically, without requiring your input to resolve any conflicts."
4642 msgstr ""
4644 #. type: Content of: <book><chapter><sect1><sect2><para>
4645 #: ../en/ch03-concepts.xml:507
4646 msgid ""
4647 "When you're thinking about what happens when you commit after a merge, once "
4648 "again the working directory is <quote>the changeset I'm about to commit</"
4649 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
4650 "completes, the working directory has two parents; these will become the "
4651 "parents of the new changeset."
4652 msgstr ""
4654 #. type: Content of: <book><chapter><sect1><sect2><para>
4655 #: ../en/ch03-concepts.xml:514
4656 msgid ""
4657 "Mercurial lets you perform multiple merges, but you must commit the results "
4658 "of each individual merge as you go. This is necessary because Mercurial only "
4659 "tracks two parents for both revisions and the working directory. While it "
4660 "would be technically possible to merge multiple changesets at once, the "
4661 "prospect of user confusion and making a terrible mess of a merge immediately "
4662 "becomes overwhelming."
4663 msgstr ""
4665 #. type: Content of: <book><chapter><sect1><sect2><title>
4666 #: ../en/ch03-concepts.xml:525
4667 msgid "Merging and renames"
4668 msgstr "合并与改名"
4670 #. type: Content of: <book><chapter><sect1><sect2><para>
4671 #: ../en/ch03-concepts.xml:527
4672 msgid ""
4673 "A surprising number of revision control systems pay little or no attention to "
4674 "a file's <emphasis>name</emphasis> over time. For instance, it used to be "
4675 "common that if a file got renamed on one side of a merge, the changes from "
4676 "the other side would be silently dropped."
4677 msgstr ""
4679 #. type: Content of: <book><chapter><sect1><sect2><para>
4680 #: ../en/ch03-concepts.xml:533
4681 msgid ""
4682 "Mercurial records metadata when you tell it to perform a rename or copy. It "
4683 "uses this metadata during a merge to do the right thing in the case of a "
4684 "merge. For instance, if I rename a file, and you edit it without renaming "
4685 "it, when we merge our work the file will be renamed and have your edits "
4686 "applied."
4687 msgstr ""
4689 #. type: Content of: <book><chapter><sect1><title>
4690 #: ../en/ch03-concepts.xml:543
4691 msgid "Other interesting design features"
4692 msgstr "其它有趣的设计特性"
4694 #. type: Content of: <book><chapter><sect1><para>
4695 #: ../en/ch03-concepts.xml:545
4696 msgid ""
4697 "In the sections above, I've tried to highlight some of the most important "
4698 "aspects of Mercurial's design, to illustrate that it pays careful attention "
4699 "to reliability and performance. However, the attention to detail doesn't "
4700 "stop there. There are a number of other aspects of Mercurial's construction "
4701 "that I personally find interesting. I'll detail a few of them here, separate "
4702 "from the <quote>big ticket</quote> items above, so that if you're interested, "
4703 "you can gain a better idea of the amount of thinking that goes into a well-"
4704 "designed system."
4705 msgstr ""
4707 #. type: Content of: <book><chapter><sect1><sect2><title>
4708 #: ../en/ch03-concepts.xml:556
4709 msgid "Clever compression"
4710 msgstr "智能压缩"
4712 #. type: Content of: <book><chapter><sect1><sect2><para>
4713 #: ../en/ch03-concepts.xml:558
4714 msgid ""
4715 "When appropriate, Mercurial will store both snapshots and deltas in "
4716 "compressed form. It does this by always <emphasis>trying to</emphasis> "
4717 "compress a snapshot or delta, but only storing the compressed version if it's "
4718 "smaller than the uncompressed version."
4719 msgstr ""
4721 #. type: Content of: <book><chapter><sect1><sect2><para>
4722 #: ../en/ch03-concepts.xml:564
4723 msgid ""
4724 "This means that Mercurial does <quote>the right thing</quote> when storing a "
4725 "file whose native form is compressed, such as a <literal>zip</literal> "
4726 "archive or a JPEG image. When these types of files are compressed a second "
4727 "time, the resulting file is usually bigger than the once-compressed form, and "
4728 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
4729 msgstr ""
4731 #. type: Content of: <book><chapter><sect1><sect2><para>
4732 #: ../en/ch03-concepts.xml:572
4733 msgid ""
4734 "Deltas between revisions of a compressed file are usually larger than "
4735 "snapshots of the file, and Mercurial again does <quote>the right thing</"
4736 "quote> in these cases. It finds that such a delta exceeds the threshold at "
4737 "which it should store a complete snapshot of the file, so it stores the "
4738 "snapshot, again saving space compared to a naive delta-only approach."
4739 msgstr ""
4741 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4742 #: ../en/ch03-concepts.xml:581
4743 msgid "Network recompression"
4744 msgstr "网络重新压缩"
4746 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4747 #: ../en/ch03-concepts.xml:583
4748 msgid ""
4749 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
4750 "compression algorithm (the same one used by the popular <literal>zip</"
4751 "literal> archive format), which balances good speed with a respectable "
4752 "compression ratio. However, when transmitting revision data over a network "
4753 "connection, Mercurial uncompresses the compressed revision data."
4754 msgstr ""
4756 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4757 #: ../en/ch03-concepts.xml:591
4758 msgid ""
4759 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
4760 "data using a compression algorithm that gives a better compression ratio (the "
4761 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
4762 "compression package). This combination of algorithm and compression of the "
4763 "entire stream (instead of a revision at a time) substantially reduces the "
4764 "number of bytes to be transferred, yielding better network performance over "
4765 "most kinds of network."
4766 msgstr ""
4768 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4769 #: ../en/ch03-concepts.xml:601
4770 msgid ""
4771 "(If the connection is over <command>ssh</command>, Mercurial "
4772 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
4773 "command> can already do this itself.)"
4774 msgstr ""
4776 #. type: Content of: <book><chapter><sect1><sect2><title>
4777 #: ../en/ch03-concepts.xml:609
4778 msgid "Read/write ordering and atomicity"
4779 msgstr "读写顺序与原子性"
4781 #. type: Content of: <book><chapter><sect1><sect2><para>
4782 #: ../en/ch03-concepts.xml:611
4783 msgid ""
4784 "Appending to files isn't the whole story when it comes to guaranteeing that a "
4785 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
4786 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
4787 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
4788 "is deliberate."
4789 msgstr ""
4791 #. type: Content of: <book><chapter><sect1><sect2><para>
4792 #: ../en/ch03-concepts.xml:619
4793 msgid ""
4794 "A writer starts a transaction by writing filelog and manifest data, and "
4795 "doesn't write any changelog data until those are finished. A reader starts "
4796 "by reading changelog data, then manifest data, followed by filelog data."
4797 msgstr ""
4799 #. type: Content of: <book><chapter><sect1><sect2><para>
4800 #: ../en/ch03-concepts.xml:624
4801 msgid ""
4802 "Since the writer has always finished writing filelog and manifest data before "
4803 "it writes to the changelog, a reader will never read a pointer to a partially "
4804 "written manifest revision from the changelog, and it will never read a "
4805 "pointer to a partially written filelog revision from the manifest."
4806 msgstr ""
4808 #. type: Content of: <book><chapter><sect1><sect2><title>
4809 #: ../en/ch03-concepts.xml:632
4810 msgid "Concurrent access"
4811 msgstr "并发访问"
4813 #. type: Content of: <book><chapter><sect1><sect2><para>
4814 #: ../en/ch03-concepts.xml:634
4815 msgid ""
4816 "The read/write ordering and atomicity guarantees mean that Mercurial never "
4817 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
4818 "if the repository is being written to while the read is occurring. This has a "
4819 "big effect on scalability; you can have an arbitrary number of Mercurial "
4820 "processes safely reading data from a repository safely all at once, no matter "
4821 "whether it's being written to or not."
4822 msgstr ""
4824 #. type: Content of: <book><chapter><sect1><sect2><para>
4825 #: ../en/ch03-concepts.xml:643
4826 msgid ""
4827 "The lockless nature of reading means that if you're sharing a repository on a "
4828 "multi-user system, you don't need to grant other local users permission to "
4829 "<emphasis>write</emphasis> to your repository in order for them to be able to "
4830 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
4831 "permission. (This is <emphasis>not</emphasis> a common feature among "
4832 "revision control systems, so don't take it for granted! Most require readers "
4833 "to be able to lock a repository to access it safely, and this requires write "
4834 "permission on at least one directory, which of course makes for all kinds of "
4835 "nasty and annoying security and administrative problems.)"
4836 msgstr ""
4838 #. type: Content of: <book><chapter><sect1><sect2><para>
4839 #: ../en/ch03-concepts.xml:656
4840 msgid ""
4841 "Mercurial uses locks to ensure that only one process can write to a "
4842 "repository at a time (the locking mechanism is safe even over filesystems "
4843 "that are notoriously hostile to locking, such as NFS). If a repository is "
4844 "locked, a writer will wait for a while to retry if the repository becomes "
4845 "unlocked, but if the repository remains locked for too long, the process "
4846 "attempting to write will time out after a while. This means that your daily "
4847 "automated scripts won't get stuck forever and pile up if a system crashes "
4848 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
4849 "infinity.)"
4850 msgstr ""
4852 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4853 #: ../en/ch03-concepts.xml:668
4854 msgid "Safe dirstate access"
4855 msgstr "安全的目录状态访问"
4857 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4858 #: ../en/ch03-concepts.xml:670
4859 msgid ""
4860 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
4861 "file; it does acquire a lock to write it. To avoid the possibility of "
4862 "reading a partially written copy of the dirstate file, Mercurial writes to a "
4863 "file with a unique name in the same directory as the dirstate file, then "
4864 "renames the temporary file atomically to <filename>dirstate</filename>. The "
4865 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
4866 "not partially written."
4867 msgstr ""
4869 #. type: Content of: <book><chapter><sect1><sect2><title>
4870 #: ../en/ch03-concepts.xml:683
4871 msgid "Avoiding seeks"
4872 msgstr "避免查找"
4874 #. type: Content of: <book><chapter><sect1><sect2><para>
4875 #: ../en/ch03-concepts.xml:685
4876 msgid ""
4877 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
4878 "head, since any seek is far more expensive than even a comparatively large "
4879 "read operation."
4880 msgstr ""
4882 #. type: Content of: <book><chapter><sect1><sect2><para>
4883 #: ../en/ch03-concepts.xml:689
4884 msgid ""
4885 "This is why, for example, the dirstate is stored in a single file. If there "
4886 "were a dirstate file per directory that Mercurial tracked, the disk would "
4887 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
4888 "file in one step."
4889 msgstr ""
4891 #. type: Content of: <book><chapter><sect1><sect2><para>
4892 #: ../en/ch03-concepts.xml:695
4893 msgid ""
4894 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
4895 "repository on local storage. Instead of copying every revlog file from the "
4896 "old repository into the new repository, it makes a <quote>hard link</quote>, "
4897 "which is a shorthand way to say <quote>these two names point to the same "
4898 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
4899 "it checks to see if the number of names pointing at the file is greater than "
4900 "one. If it is, more than one repository is using the file, so Mercurial "
4901 "makes a new copy of the file that is private to this repository."
4902 msgstr ""
4904 #. type: Content of: <book><chapter><sect1><sect2><para>
4905 #: ../en/ch03-concepts.xml:706
4906 msgid ""
4907 "A few revision control developers have pointed out that this idea of making a "
4908 "complete private copy of a file is not very efficient in its use of storage. "
4909 "While this is true, storage is cheap, and this method gives the highest "
4910 "performance while deferring most book-keeping to the operating system. An "
4911 "alternative scheme would most likely reduce performance and increase the "
4912 "complexity of the software, each of which is much more important to the "
4913 "<quote>feel</quote> of day-to-day use."
4914 msgstr ""
4916 #. type: Content of: <book><chapter><sect1><sect2><title>
4917 #: ../en/ch03-concepts.xml:718
4918 msgid "Other contents of the dirstate"
4919 msgstr "目录状态的其它内容"
4921 #. type: Content of: <book><chapter><sect1><sect2><para>
4922 #: ../en/ch03-concepts.xml:720
4923 msgid ""
4924 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
4925 "it uses the dirstate to store some extra information so it can determine "
4926 "efficiently whether you have modified a file. For each file in the working "
4927 "directory, it stores the time that it last modified the file itself, and the "
4928 "size of the file at that time."
4929 msgstr ""
4931 #. type: Content of: <book><chapter><sect1><sect2><para>
4932 #: ../en/ch03-concepts.xml:727
4933 msgid ""
4934 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
4935 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
4936 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
4937 "dirstate so that it knows what to do with those files when you commit."
4938 msgstr ""
4940 #. type: Content of: <book><chapter><sect1><sect2><para>
4941 #: ../en/ch03-concepts.xml:734
4942 msgid ""
4943 "When Mercurial is checking the states of files in the working directory, it "
4944 "first checks a file's modification time. If that has not changed, the file "
4945 "must not have been modified. If the file's size has changed, the file must "
4946 "have been modified. If the modification time has changed, but the size has "
4947 "not, only then does Mercurial need to read the actual contents of the file to "
4948 "see if they've changed. Storing these few extra pieces of information "
4949 "dramatically reduces the amount of data that Mercurial needs to read, which "
4950 "yields large performance improvements compared to other revision control "
4951 "systems."
4952 msgstr ""
4954 #. type: Content of: <book><chapter><title>
4955 #: ../en/ch04-daily.xml:5
4956 msgid "Mercurial in daily use"
4957 msgstr "Mercurial 的日常使用"
4959 #. type: Content of: <book><chapter><sect1><title>
4960 #: ../en/ch04-daily.xml:8
4961 msgid "Telling Mercurial which files to track"
4962 msgstr "告诉 Mercurial 要跟踪哪些文件"
4964 #. type: Content of: <book><chapter><sect1><para>
4965 #: ../en/ch04-daily.xml:10
4966 msgid ""
4967 "Mercurial does not work with files in your repository unless you tell it to "
4968 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
4969 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
4970 "</literal></quote> to display such files."
4971 msgstr ""
4974 #. type: Content of: <book><chapter><sect1><para>
4975 #: ../en/ch04-daily.xml:17
4976 msgid ""
4977 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
4978 "command> command. Once you have added a file, the entry in the output of "
4979 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
4980 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
4981 msgstr ""
4983 #. type: Content of: <book><chapter><sect1><para>
4984 #: ../en/ch04-daily.xml:26
4985 msgid ""
4986 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
4987 "you added before the commit will no longer be listed in the output of "
4988 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that by "
4989 "default, <command role=\"hg-cmd\">hg status</command> only tells you about "
4990 "<quote>interesting</quote> files&emdash;those that you have (for example) "
4991 "modified, removed, or renamed. If you have a repository that contains "
4992 "thousands of files, you will rarely want to know about files that Mercurial "
4993 "is tracking, but that have not changed. (You can still get this information; "
4994 "we'll return to this later.)"
4995 msgstr ""
4997 #. type: Content of: <book><chapter><sect1><para>
4998 #: ../en/ch04-daily.xml:38
4999 msgid ""
5000 "Once you add a file, Mercurial doesn't do anything with it immediately. "
5001 "Instead, it will take a snapshot of the file's state the next time you "
5002 "perform a commit. It will then continue to track the changes you make to the "
5003 "file every time you commit, until you remove the file."
5004 msgstr ""
5006 #. type: Content of: <book><chapter><sect1><sect2><title>
5007 #: ../en/ch04-daily.xml:45
5008 msgid "Explicit versus implicit file naming"
5009 msgstr "明确与隐含文件命名"
5011 #. type: Content of: <book><chapter><sect1><sect2><para>
5012 #: ../en/ch04-daily.xml:47
5013 msgid ""
5014 "A useful behavior that Mercurial has is that if you pass the name of a "
5015 "directory to a command, every Mercurial command will treat this as <quote>I "
5016 "want to operate on every file in this directory and its subdirectories</"
5017 "quote>."
5018 msgstr ""
5020 #. type: Content of: <book><chapter><sect1><sect2><para>
5021 #: ../en/ch04-daily.xml:54
5022 msgid ""
5023 "Notice in this example that Mercurial printed the names of the files it "
5024 "added, whereas it didn't do so when we added the file named <filename>myfile."
5025 "txt</filename> in the earlier example."
5026 msgstr ""
5028 #. type: Content of: <book><chapter><sect1><sect2><para>
5029 #: ../en/ch04-daily.xml:59
5030 msgid ""
5031 "What's going on is that in the former case, we explicitly named the file to "
5032 "add on the command line. The assumption that Mercurial makes in such cases "
5033 "is that we know what we are doing, and it doesn't print any output."
5034 msgstr ""
5036 #. type: Content of: <book><chapter><sect1><sect2><para>
5037 #: ../en/ch04-daily.xml:64
5038 msgid ""
5039 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
5040 "name of a directory, Mercurial takes the extra step of printing the name of "
5041 "each file that it does something with. This makes it more clear what is "
5042 "happening, and reduces the likelihood of a silent and nasty surprise. This "
5043 "behavior is common to most Mercurial commands."
5044 msgstr ""
5046 #. type: Content of: <book><chapter><sect1><sect2><title>
5047 #: ../en/ch04-daily.xml:73
5048 msgid "Mercurial tracks files, not directories"
5049 msgstr "Mercurial 只跟踪文件,不跟踪目录"
5051 #. type: Content of: <book><chapter><sect1><sect2><para>
5052 #: ../en/ch04-daily.xml:75
5053 msgid ""
5054 "Mercurial does not track directory information. Instead, it tracks the path "
5055 "to a file. Before creating a file, it first creates any missing directory "
5056 "components of the path. After it deletes a file, it then deletes any empty "
5057 "directories that were in the deleted file's path. This sounds like a trivial "
5058 "distinction, but it has one minor practical consequence: it is not possible "
5059 "to represent a completely empty directory in Mercurial."
5060 msgstr ""
5062 #. type: Content of: <book><chapter><sect1><sect2><para>
5063 #: ../en/ch04-daily.xml:84
5064 msgid ""
5065 "Empty directories are rarely useful, and there are unintrusive workarounds "
5066 "that you can use to achieve an appropriate effect. The developers of "
5067 "Mercurial thus felt that the complexity that would be required to manage "
5068 "empty directories was not worth the limited benefit this feature would bring."
5069 msgstr ""
5071 #. type: Content of: <book><chapter><sect1><sect2><para>
5072 #: ../en/ch04-daily.xml:91
5073 msgid ""
5074 "If you need an empty directory in your repository, there are a few ways to "
5075 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
5076 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
5077 "systems, any file name that begins with a period (<quote><literal>.</"
5078 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
5079 "approach is illustrated below."
5080 msgstr ""
5082 #. type: Content of: <book><chapter><sect1><sect2><para>
5083 #: ../en/ch04-daily.xml:102
5084 msgid ""
5085 "Another way to tackle a need for an empty directory is to simply create one "
5086 "in your automated build scripts before they will need it."
5087 msgstr ""
5089 #. type: Content of: <book><chapter><sect1><title>
5090 #: ../en/ch04-daily.xml:109
5091 msgid "How to stop tracking a file"
5092 msgstr "如何停止跟踪文件"
5094 #. type: Content of: <book><chapter><sect1><para>
5095 #: ../en/ch04-daily.xml:111
5096 msgid ""
5097 "Once you decide that a file no longer belongs in your repository, use the "
5098 "<command role=\"hg-cmd\">hg remove</command> command. This deletes the file, "
5099 "and tells Mercurial to stop tracking it. A removed file is represented in "
5100 "the output of <command role=\"hg-cmd\">hg status</command> with a "
5101 "<quote><literal>R</literal></quote>."
5102 msgstr ""
5104 #. type: Content of: <book><chapter><sect1><para>
5105 #: ../en/ch04-daily.xml:120
5106 msgid ""
5107 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
5108 "no longer track changes to that file, even if you recreate a file with the "
5109 "same name in your working directory. If you do recreate a file with the same "
5110 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
5111 "\">hg add</command> it. Mercurial will know that the newly added file is not "
5112 "related to the old file of the same name."
5113 msgstr ""
5115 #. type: Content of: <book><chapter><sect1><sect2><title>
5116 #: ../en/ch04-daily.xml:129
5117 msgid "Removing a file does not affect its history"
5118 msgstr "删除文件不影响历史"
5120 #. type: Content of: <book><chapter><sect1><sect2><para>
5121 #: ../en/ch04-daily.xml:131
5122 msgid "It is important to understand that removing a file has only two effects."
5123 msgstr ""
5125 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5126 #: ../en/ch04-daily.xml:134
5127 msgid "It removes the current version of the file from the working directory."
5128 msgstr ""
5130 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5131 #: ../en/ch04-daily.xml:137
5132 msgid ""
5133 "It stops Mercurial from tracking changes to the file, from the time of the "
5134 "next commit."
5135 msgstr ""
5137 #. type: Content of: <book><chapter><sect1><sect2><para>
5138 #: ../en/ch04-daily.xml:140
5139 msgid ""
5140 "Removing a file <emphasis>does not</emphasis> in any way alter the "
5141 "<emphasis>history</emphasis> of the file."
5142 msgstr ""
5144 #. type: Content of: <book><chapter><sect1><sect2><para>
5145 #: ../en/ch04-daily.xml:143
5146 msgid ""
5147 "If you update the working directory to a changeset that was committed when it "
5148 "was still tracking a file that you later removed, the file will reappear in "
5149 "the working directory, with the contents it had when you committed that "
5150 "changeset. If you then update the working directory to a later changeset, in "
5151 "which the file had been removed, Mercurial will once again remove the file "
5152 "from the working directory."
5153 msgstr ""
5155 #. type: Content of: <book><chapter><sect1><sect2><title>
5156 #: ../en/ch04-daily.xml:154
5157 msgid "Missing files"
5158 msgstr "丢失的文件"
5160 #. type: Content of: <book><chapter><sect1><sect2><para>
5161 #: ../en/ch04-daily.xml:156
5162 msgid ""
5163 "Mercurial considers a file that you have deleted, but not used <command role="
5164 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
5165 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
5166 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
5167 "Mercurial commands will not generally do anything with missing files."
5168 msgstr ""
5170 #. type: Content of: <book><chapter><sect1><sect2><para>
5171 #: ../en/ch04-daily.xml:166
5172 msgid ""
5173 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
5174 "command> reports as missing, and you want the file to stay gone, you can run "
5175 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
5176 "option></command> at any time later on, to tell Mercurial that you really did "
5177 "mean to remove the file."
5178 msgstr ""
5180 #. type: Content of: <book><chapter><sect1><sect2><para>
5181 #: ../en/ch04-daily.xml:176
5182 msgid ""
5183 "On the other hand, if you deleted the missing file by accident, give <command "
5184 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
5185 "reappear, in unmodified form."
5186 msgstr ""
5188 #. type: Content of: <book><chapter><sect1><sect2><title>
5189 #: ../en/ch04-daily.xml:185
5190 msgid "Aside: why tell Mercurial explicitly to remove a file?"
5191 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
5193 #. type: Content of: <book><chapter><sect1><sect2><para>
5194 #: ../en/ch04-daily.xml:188
5195 msgid ""
5196 "You might wonder why Mercurial requires you to explicitly tell it that you "
5197 "are deleting a file. Early during the development of Mercurial, it let you "
5198 "delete a file however you pleased; Mercurial would notice the absence of the "
5199 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
5200 "command>, and stop tracking the file. In practice, this made it too easy to "
5201 "accidentally remove a file without noticing."
5202 msgstr ""
5204 #. type: Content of: <book><chapter><sect1><sect2><title>
5205 #: ../en/ch04-daily.xml:199
5206 msgid "Useful shorthand&emdash;adding and removing files in one step"
5207 msgstr "有用的速记—一个步骤添加和删除文件"
5209 #. type: Content of: <book><chapter><sect1><sect2><para>
5210 #: ../en/ch04-daily.xml:202
5211 msgid ""
5212 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
5213 "addremove</command>, that adds untracked files and marks missing files as "
5214 "removed."
5215 msgstr ""
5217 #. type: Content of: <book><chapter><sect1><sect2><para>
5218 #: ../en/ch04-daily.xml:208
5219 msgid ""
5220 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
5221 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
5222 "and-remove, immediately followed by a commit."
5223 msgstr ""
5225 #. type: Content of: <book><chapter><sect1><title>
5226 #: ../en/ch04-daily.xml:218
5227 msgid "Copying files"
5228 msgstr "复制文件"
5230 #. type: Content of: <book><chapter><sect1><para>
5231 #: ../en/ch04-daily.xml:220
5232 msgid ""
5233 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
5234 "lets you make a new copy of a file. When you copy a file using this command, "
5235 "Mercurial makes a record of the fact that the new file is a copy of the "
5236 "original file. It treats these copied files specially when you merge your "
5237 "work with someone else's."
5238 msgstr ""
5240 #. type: Content of: <book><chapter><sect1><sect2><title>
5241 #: ../en/ch04-daily.xml:228
5242 msgid "The results of copying during a merge"
5243 msgstr "合并期间的复制结果"
5245 #. type: Content of: <book><chapter><sect1><sect2><para>
5246 #: ../en/ch04-daily.xml:230
5247 msgid ""
5248 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
5249 "best illustrate what this means, let's create an example. We'll start with "
5250 "the usual tiny repository that contains a single file."
5251 msgstr ""
5253 #. type: Content of: <book><chapter><sect1><sect2><para>
5254 #: ../en/ch04-daily.xml:237
5255 msgid ""
5256 "We need to do some work in parallel, so that we'll have something to merge. "
5257 "So let's clone our repository."
5258 msgstr ""
5260 #. type: Content of: <book><chapter><sect1><sect2><para>
5261 #: ../en/ch04-daily.xml:243
5262 msgid ""
5263 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
5264 "copy</command> command to make a copy of the first file we created."
5265 msgstr ""
5267 #. type: Content of: <book><chapter><sect1><sect2><para>
5268 #: ../en/ch04-daily.xml:249
5269 msgid ""
5270 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
5271 "command afterwards, the copied file looks just like a normal added file."
5272 msgstr ""
5274 #. type: Content of: <book><chapter><sect1><sect2><para>
5275 #: ../en/ch04-daily.xml:255
5276 msgid ""
5277 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
5278 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
5279 "output: this is the file that our newly-added file was copied <emphasis>from</"
5280 "emphasis>."
5281 msgstr ""
5283 #. type: Content of: <book><chapter><sect1><sect2><para>
5284 #: ../en/ch04-daily.xml:263
5285 msgid ""
5286 "Now, back in the repository we cloned, let's make a change in parallel. "
5287 "We'll add a line of content to the original file that we created."
5288 msgstr ""
5290 #. type: Content of: <book><chapter><sect1><sect2><para>
5291 #: ../en/ch04-daily.xml:269
5292 msgid ""
5293 "Now we have a modified <filename>file</filename> in this repository. When we "
5294 "pull the changes from the first repository, and merge the two heads, "
5295 "Mercurial will propagate the changes that we made locally to <filename>file</"
5296 "filename> into its copy, <filename>new-file</filename>."
5297 msgstr ""
5299 #. type: Content of: <book><chapter><sect1><sect2><title>
5300 #: ../en/ch04-daily.xml:279
5301 msgid "Why should changes follow copies?"
5302 msgstr "为什么复制后需要后续修改?"
5304 #. type: Content of: <book><chapter><sect1><sect2><para>
5305 #: ../en/ch04-daily.xml:281
5306 msgid ""
5307 "This behavior&emdash;of changes to a file propagating out to copies of the "
5308 "file&emdash;might seem esoteric, but in most cases it's highly desirable."
5309 msgstr ""
5311 #. type: Content of: <book><chapter><sect1><sect2><para>
5312 #: ../en/ch04-daily.xml:285
5313 msgid ""
5314 "First of all, remember that this propagation <emphasis>only</emphasis> "
5315 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
5316 "a file, and subsequently modify the original file during the normal course of "
5317 "your work, nothing will happen."
5318 msgstr ""
5320 #. type: Content of: <book><chapter><sect1><sect2><para>
5321 #: ../en/ch04-daily.xml:291
5322 msgid ""
5323 "The second thing to know is that modifications will only propagate across a "
5324 "copy as long as the changeset that you're merging changes from "
5325 "<emphasis>hasn't yet seen</emphasis> the copy."
5326 msgstr ""
5328 #. type: Content of: <book><chapter><sect1><sect2><para>
5329 #: ../en/ch04-daily.xml:296
5330 msgid ""
5331 "The reason that Mercurial does this is as follows. Let's say I make an "
5332 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
5333 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
5334 "repository, without knowing about the bug or having seen the fix, and you "
5335 "have started hacking on your copy of the file."
5336 msgstr ""
5338 #. type: Content of: <book><chapter><sect1><sect2><para>
5339 #: ../en/ch04-daily.xml:303
5340 msgid ""
5341 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
5342 "emphasis> propagate changes across copies, your new source file would now "
5343 "contain the bug, and unless you knew to propagate the bug fix by hand, the "
5344 "bug would <emphasis>remain</emphasis> in your copy of the file."
5345 msgstr ""
5347 #. type: Content of: <book><chapter><sect1><sect2><para>
5348 #: ../en/ch04-daily.xml:309
5349 msgid ""
5350 "By automatically propagating the change that fixed the bug from the original "
5351 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
5352 "Mercurial is the <emphasis>only</emphasis> revision control system that "
5353 "propagates changes across copies like this."
5354 msgstr ""
5356 #. type: Content of: <book><chapter><sect1><sect2><para>
5357 #: ../en/ch04-daily.xml:315
5358 msgid ""
5359 "Once your change history has a record that the copy and subsequent merge "
5360 "occurred, there's usually no further need to propagate changes from the "
5361 "original file to the copied file, and that's why Mercurial only propagates "
5362 "changes across copies at the first merge, and not afterwards."
5363 msgstr ""
5365 #. type: Content of: <book><chapter><sect1><sect2><title>
5366 #: ../en/ch04-daily.xml:323
5367 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
5368 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
5370 #. type: Content of: <book><chapter><sect1><sect2><para>
5371 #: ../en/ch04-daily.xml:326
5372 msgid ""
5373 "If, for some reason, you decide that this business of automatically "
5374 "propagating changes across copies is not for you, simply use your system's "
5375 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
5376 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
5377 "new copy by hand. Before you do so, though, please do reread <xref linkend="
5378 "\"sec:daily:why-copy\"/>, and make an informed decision that this behavior is "
5379 "not appropriate to your specific case."
5380 msgstr ""
5382 #. type: Content of: <book><chapter><sect1><sect2><title>
5383 #: ../en/ch04-daily.xml:339
5384 msgid "Behavior of the <command role=\"hg-cmd\">hg copy</command> command"
5385 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
5387 #. type: Content of: <book><chapter><sect1><sect2><para>
5388 #: ../en/ch04-daily.xml:342
5389 msgid ""
5390 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
5391 "Mercurial makes a copy of each source file as it currently stands in the "
5392 "working directory. This means that if you make some modifications to a file, "
5393 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
5394 "committed those changes, the new copy will also contain the modifications you "
5395 "have made up until that point. (I find this behavior a little "
5396 "counterintuitive, which is why I mention it here.)"
5397 msgstr ""
5399 #. type: Content of: <book><chapter><sect1><sect2><para>
5400 #: ../en/ch04-daily.xml:352
5401 msgid ""
5402 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
5403 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
5404 "\">hg cp</command> alias if you prefer). We must supply two or more "
5405 "arguments, of which the last is treated as the <emphasis>destination</"
5406 "emphasis>, and all others are <emphasis>sources</emphasis>."
5407 msgstr ""
5409 #. type: Content of: <book><chapter><sect1><sect2><para>
5410 #: ../en/ch04-daily.xml:360
5411 msgid ""
5412 "If you pass <command role=\"hg-cmd\">hg copy</command> a single file as the "
5413 "source, and the destination does not exist, it creates a new file with that "
5414 "name."
5415 msgstr ""
5417 #. type: Content of: <book><chapter><sect1><sect2><para>
5418 #: ../en/ch04-daily.xml:366
5419 msgid ""
5420 "If the destination is a directory, Mercurial copies its sources into that "
5421 "directory."
5422 msgstr ""
5424 #. type: Content of: <book><chapter><sect1><sect2><para>
5425 #: ../en/ch04-daily.xml:371
5426 msgid ""
5427 "Copying a directory is recursive, and preserves the directory structure of "
5428 "the source."
5429 msgstr ""
5431 #. type: Content of: <book><chapter><sect1><sect2><para>
5432 #: ../en/ch04-daily.xml:377
5433 msgid ""
5434 "If the source and destination are both directories, the source tree is "
5435 "recreated in the destination directory."
5436 msgstr ""
5438 #. type: Content of: <book><chapter><sect1><sect2><para>
5439 #: ../en/ch04-daily.xml:382
5440 msgid ""
5441 "As with the <command role=\"hg-cmd\">hg remove</command> command, if you copy "
5442 "a file manually and then want Mercurial to know that you've copied the file, "
5443 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
5444 "<command role=\"hg-cmd\">hg copy</command>."
5445 msgstr ""
5447 #. type: Content of: <book><chapter><sect1><title>
5448 #: ../en/ch04-daily.xml:393
5449 msgid "Renaming files"
5450 msgstr "改名文件"
5452 #. type: Content of: <book><chapter><sect1><para>
5453 #: ../en/ch04-daily.xml:395
5454 msgid ""
5455 "It's rather more common to need to rename a file than to make a copy of it. "
5456 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
5457 "before talking about renaming files is that Mercurial treats a rename in "
5458 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
5459 "when you copy a file tells you what to expect when you rename a file."
5460 msgstr ""
5462 #. type: Content of: <book><chapter><sect1><para>
5463 #: ../en/ch04-daily.xml:403
5464 msgid ""
5465 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
5466 "Mercurial makes a copy of each source file, then deletes it and marks the "
5467 "file as removed."
5468 msgstr ""
5470 #. type: Content of: <book><chapter><sect1><para>
5471 #: ../en/ch04-daily.xml:409
5472 msgid ""
5473 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
5474 "copied file as added, and the copied-from file as removed."
5475 msgstr ""
5477 #. type: Content of: <book><chapter><sect1><para>
5478 #: ../en/ch04-daily.xml:415
5479 msgid ""
5480 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
5481 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
5482 "\"hg-cmd\">hg status</command> to see that the added file is really being "
5483 "tracked by Mercurial as a copy of the original, now removed, file."
5484 msgstr ""
5486 #. type: Content of: <book><chapter><sect1><para>
5487 #: ../en/ch04-daily.xml:424
5488 msgid ""
5489 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
5490 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
5491 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
5492 "other respects, the behavior of the <command role=\"hg-cmd\">hg rename</"
5493 "command> command, and the options it accepts, are similar to the <command "
5494 "role=\"hg-cmd\">hg copy</command> command."
5495 msgstr ""
5497 #. type: Content of: <book><chapter><sect1><para>
5498 #: ../en/ch04-daily.xml:433
5499 msgid ""
5500 "If you're familiar with the Unix command line, you'll be glad to know that "
5501 "<command role=\"hg-cmd\">hg rename</command> command can be invoked as "
5502 "<command role=\"hg-cmd\">hg mv</command>."
5503 msgstr ""
5505 #. type: Content of: <book><chapter><sect1><sect2><title>
5506 #: ../en/ch04-daily.xml:439
5507 msgid "Renaming files and merging changes"
5508 msgstr "改名文件与合并修改"
5510 #. type: Content of: <book><chapter><sect1><sect2><para>
5511 #: ../en/ch04-daily.xml:441
5512 msgid ""
5513 "Since Mercurial's rename is implemented as copy-and-remove, the same "
5514 "propagation of changes happens when you merge after a rename as after a copy."
5515 msgstr ""
5517 #. type: Content of: <book><chapter><sect1><sect2><para>
5518 #: ../en/ch04-daily.xml:445
5519 msgid ""
5520 "If I modify a file, and you rename it to a new name, and then we merge our "
5521 "respective changes, my modifications to the file under its original name will "
5522 "be propagated into the file under its new name. (This is something you might "
5523 "expect to <quote>simply work,</quote> but not all revision control systems "
5524 "actually do this.)"
5525 msgstr ""
5527 #. type: Content of: <book><chapter><sect1><sect2><para>
5528 #: ../en/ch04-daily.xml:452
5529 msgid ""
5530 "Whereas having changes follow a copy is a feature where you can perhaps nod "
5531 "and say <quote>yes, that might be useful,</quote> it should be clear that "
5532 "having them follow a rename is definitely important. Without this facility, "
5533 "it would simply be too easy for changes to become orphaned when files are "
5534 "renamed."
5535 msgstr ""
5537 #. type: Content of: <book><chapter><sect1><sect2><title>
5538 #: ../en/ch04-daily.xml:461
5539 msgid "Divergent renames and merging"
5540 msgstr "改名与合并的分歧"
5542 #. type: Content of: <book><chapter><sect1><sect2><para>
5543 #: ../en/ch04-daily.xml:463
5544 msgid ""
5545 "The case of diverging names occurs when two developers start with a "
5546 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
5547 "repositories."
5548 msgstr ""
5550 #. type: Content of: <book><chapter><sect1><sect2><para>
5551 #: ../en/ch04-daily.xml:470
5552 msgid "Anne renames the file to <filename>bar</filename>."
5553 msgstr ""
5555 #. type: Content of: <book><chapter><sect1><sect2><para>
5556 #: ../en/ch04-daily.xml:474
5557 msgid ""
5558 "Meanwhile, Bob renames it to <filename>quux</filename>. (Remember that "
5559 "<command role=\"hg-cmd\">hg mv</command> is an alias for <command role=\"hg-"
5560 "cmd\">hg rename</command>.)"
5561 msgstr ""
5563 #. type: Content of: <book><chapter><sect1><sect2><para>
5564 #: ../en/ch04-daily.xml:481
5565 msgid ""
5566 "I like to think of this as a conflict because each developer has expressed "
5567 "different intentions about what the file ought to be named."
5568 msgstr ""
5570 #. type: Content of: <book><chapter><sect1><sect2><para>
5571 #: ../en/ch04-daily.xml:485
5572 msgid ""
5573 "What do you think should happen when they merge their work? Mercurial's "
5574 "actual behavior is that it always preserves <emphasis>both</emphasis> names "
5575 "when it merges changesets that contain divergent renames."
5576 msgstr ""
5578 #. type: Content of: <book><chapter><sect1><sect2><para>
5579 #: ../en/ch04-daily.xml:492
5580 msgid ""
5581 "Notice that while Mercurial warns about the divergent renames, it leaves it "
5582 "up to you to do something about the divergence after the merge."
5583 msgstr ""
5585 #. type: Content of: <book><chapter><sect1><sect2><title>
5586 #: ../en/ch04-daily.xml:498
5587 msgid "Convergent renames and merging"
5588 msgstr "收敛改名与合并"
5590 #. type: Content of: <book><chapter><sect1><sect2><para>
5591 #: ../en/ch04-daily.xml:500
5592 msgid ""
5593 "Another kind of rename conflict occurs when two people choose to rename "
5594 "different <emphasis>source</emphasis> files to the same "
5595 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
5596 "merge machinery, and lets you guide it to a suitable resolution."
5597 msgstr ""
5599 #. type: Content of: <book><chapter><sect1><sect2><title>
5600 #: ../en/ch04-daily.xml:508
5601 msgid "Other name-related corner cases"
5602 msgstr "其它名称相关的角落"
5604 #. type: Content of: <book><chapter><sect1><sect2><para>
5605 #: ../en/ch04-daily.xml:510
5606 msgid ""
5607 "Mercurial has a longstanding bug in which it fails to handle a merge where "
5608 "one side has a file with a given name, while another has a directory with the "
5609 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
5610 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
5611 msgstr ""
5613 #. type: Content of: <book><chapter><sect1><title>
5614 #: ../en/ch04-daily.xml:523
5615 msgid "Recovering from mistakes"
5616 msgstr "从错误恢复"
5618 #. type: Content of: <book><chapter><sect1><para>
5619 #: ../en/ch04-daily.xml:525
5620 msgid ""
5621 "Mercurial has some useful commands that will help you to recover from some "
5622 "common mistakes."
5623 msgstr ""
5625 #. type: Content of: <book><chapter><sect1><para>
5626 #: ../en/ch04-daily.xml:528
5627 msgid ""
5628 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
5629 "changes that you have made to your working directory. For example, if you "
5630 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
5631 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
5632 "added, and while the file won't be touched in any way, it won't be tracked "
5633 "for adding by Mercurial any longer, either. You can also use <command role="
5634 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
5635 msgstr ""
5637 #. type: Content of: <book><chapter><sect1><para>
5638 #: ../en/ch04-daily.xml:538
5639 msgid ""
5640 "It's good to remember that the <command role=\"hg-cmd\">hg revert</command> "
5641 "command is useful for changes that you have not yet committed. Once you've "
5642 "committed a change, if you decide it was a mistake, you can still do "
5643 "something about it, though your options may be more limited."
5644 msgstr ""
5646 #. type: Content of: <book><chapter><sect1><para>
5647 #: ../en/ch04-daily.xml:544
5648 msgid ""
5649 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
5650 "command, and details about how to deal with changes you have already "
5651 "committed, see <xref linkend=\"chap:undo\"/>."
5652 msgstr ""
5654 #. type: Content of: <book><chapter><sect1><title>
5655 #: ../en/ch04-daily.xml:551
5656 msgid "Dealing with tricky merges"
5657 msgstr "合并的技巧"
5659 #. type: Content of: <book><chapter><sect1><para>
5660 #: ../en/ch04-daily.xml:553
5661 msgid ""
5662 "In a complicated or large project, it's not unusual for a merge of two "
5663 "changesets to result in some headaches. Suppose there's a big source file "
5664 "that's been extensively edited by each side of a merge: this is almost "
5665 "inevitably going to result in conflicts, some of which can take a few tries "
5666 "to sort out."
5667 msgstr ""
5669 #. type: Content of: <book><chapter><sect1><para>
5670 #: ../en/ch04-daily.xml:560
5671 msgid ""
5672 "Let's develop a simple case of this and see how to deal with it. We'll start "
5673 "off with a repository containing one file, and clone it twice."
5674 msgstr ""
5676 #. type: Content of: <book><chapter><sect1><para>
5677 #: ../en/ch04-daily.xml:566
5678 msgid "In one clone, we'll modify the file in one way."
5679 msgstr ""
5681 #. type: Content of: <book><chapter><sect1><para>
5682 #: ../en/ch04-daily.xml:570
5683 msgid "In another, we'll modify the file differently."
5684 msgstr ""
5686 #. type: Content of: <book><chapter><sect1><para>
5687 #: ../en/ch04-daily.xml:574
5688 msgid "Next, we'll pull each set of changes into our original repo."
5689 msgstr ""
5691 #. type: Content of: <book><chapter><sect1><para>
5692 #: ../en/ch04-daily.xml:579
5693 msgid "We expect our repository to now contain two heads."
5694 msgstr ""
5696 #. type: Content of: <book><chapter><sect1><para>
5697 #: ../en/ch04-daily.xml:583
5698 msgid ""
5699 "Normally, if we run <command role=\"hg-cmd\">hg merge</command> at this "
5700 "point, it will drop us into a GUI that will let us manually resolve the "
5701 "conflicting edits to <filename>myfile.txt</filename>. However, to simplify "
5702 "things for presentation here, we'd like the merge to fail immediately "
5703 "instead. Here's one way we can do so."
5704 msgstr ""
5706 #. type: Content of: <book><chapter><sect1><para>
5707 #: ../en/ch04-daily.xml:592
5708 msgid ""
5709 "We've told Mercurial's merge machinery to run the command <command>false</"
5710 "command> (which, as we desire, fails immediately) if it detects a merge that "
5711 "it can't sort out automatically."
5712 msgstr ""
5714 #. type: Content of: <book><chapter><sect1><para>
5715 #: ../en/ch04-daily.xml:597
5716 msgid ""
5717 "If we now fire up <command role=\"hg-cmd\">hg merge</command>, it should "
5718 "grind to a halt and report a failure."
5719 msgstr ""
5721 #. type: Content of: <book><chapter><sect1><para>
5722 #: ../en/ch04-daily.xml:603
5723 msgid ""
5724 "Even if we don't notice that the merge failed, Mercurial will prevent us from "
5725 "accidentally committing the result of a failed merge."
5726 msgstr ""
5728 #. type: Content of: <book><chapter><sect1><para>
5729 #: ../en/ch04-daily.xml:609
5730 msgid ""
5731 "When <command role=\"hg-cmd\">hg commit</command> fails in this case, it "
5732 "suggests that we use the unfamiliar <command role=\"hg-cmd\">hg resolve</"
5733 "command> command. As usual, <command role=\"hg-cmd\">hg help resolve</"
5734 "command> will print a helpful synopsis."
5735 msgstr ""
5737 #. type: Content of: <book><chapter><sect1><sect2><title>
5738 #: ../en/ch04-daily.xml:616
5739 msgid "File resolution states"
5740 msgstr ""
5742 #. type: Content of: <book><chapter><sect1><sect2><para>
5743 #: ../en/ch04-daily.xml:618
5744 msgid ""
5745 "When a merge occurs, most files will usually remain unmodified. For each "
5746 "file where Mercurial has to do something, it tracks the state of the file."
5747 msgstr ""
5749 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5750 #: ../en/ch04-daily.xml:624
5751 msgid ""
5752 "A <emphasis>resolved</emphasis> file has been successfully merged, either "
5753 "automatically by Mercurial or manually with human intervention."
5754 msgstr ""
5756 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5757 #: ../en/ch04-daily.xml:629
5758 msgid ""
5759 "An <emphasis>unresolved</emphasis> file was not merged successfully, and "
5760 "needs more attention."
5761 msgstr ""
5763 #. type: Content of: <book><chapter><sect1><sect2><para>
5764 #: ../en/ch04-daily.xml:634
5765 msgid ""
5766 "If Mercurial sees <emphasis>any</emphasis> file in the unresolved state after "
5767 "a merge, it considers the merge to have failed. Fortunately, we do not need "
5768 "to restart the entire merge from scratch."
5769 msgstr ""
5771 #. type: Content of: <book><chapter><sect1><sect2><para>
5772 #: ../en/ch04-daily.xml:639
5773 msgid ""
5774 "The <option role=\"hg-opt-resolve\">--list</option> or <option role=\"hg-opt-"
5775 "resolve\">-l</option> option to <command role=\"hg-cmd\">hg resolve</command> "
5776 "prints out the state of each merged file."
5777 msgstr ""
5779 #. type: Content of: <book><chapter><sect1><sect2><para>
5780 #: ../en/ch04-daily.xml:646
5781 msgid ""
5782 "In the output from <command role=\"hg-cmd\">hg resolve</command>, a resolved "
5783 "file is marked with <literal>R</literal>, while an unresolved file is marked "
5784 "with <literal>U</literal>. If any files are listed with <literal>U</"
5785 "literal>, we know that an attempt to commit the results of the merge will "
5786 "fail."
5787 msgstr ""
5789 #. type: Content of: <book><chapter><sect1><sect2><title>
5790 #: ../en/ch04-daily.xml:655
5791 msgid "Resolving a file merge"
5792 msgstr "合并文件"
5794 #. type: Content of: <book><chapter><sect1><sect2><para>
5795 #: ../en/ch04-daily.xml:657
5796 msgid ""
5797 "We have several options to move a file from the unresolved into the resolved "
5798 "state. By far the most common is to rerun <command role=\"hg-cmd\">hg "
5799 "resolve</command>. If we pass the names of individual files or directories, "
5800 "it will retry the merges of any unresolved files present in those locations. "
5801 "We can also pass the <option role=\"hg-opt-resolve\">--all</option> or "
5802 "<option role=\"hg-opt-resolve\">-a</option> option, which will retry the "
5803 "merges of <emphasis>all</emphasis> unresolved files."
5804 msgstr ""
5806 #. type: Content of: <book><chapter><sect1><sect2><para>
5807 #: ../en/ch04-daily.xml:667
5808 msgid ""
5809 "Mercurial also lets us modify the resolution state of a file directly. We "
5810 "can manually mark a file as resolved using the <option role=\"hg-opt-resolve"
5811 "\">--mark</option> option, or as unresolved using the <option role=\"hg-opt-"
5812 "resolve\">--unmark</option> option. This allows us to clean up a "
5813 "particularly messy merge by hand, and to keep track of our progress with each "
5814 "file as we go."
5815 msgstr ""
5817 #. type: Content of: <book><chapter><title>
5818 #: ../en/ch05-collab.xml:5
5819 msgid "Collaborating with other people"
5820 msgstr "团体协作"
5822 #. type: Content of: <book><chapter><para>
5823 #: ../en/ch05-collab.xml:7
5824 msgid ""
5825 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
5826 "how people ought to work with each other. However, if you're new to "
5827 "distributed revision control, it helps to have some tools and examples in "
5828 "mind when you're thinking about possible workflow models."
5829 msgstr ""
5831 #. type: Content of: <book><chapter><sect1><title>
5832 #: ../en/ch05-collab.xml:14
5833 msgid "Mercurial's web interface"
5834 msgstr "Mercurial 的 web 接口"
5836 #. type: Content of: <book><chapter><sect1><para>
5837 #: ../en/ch05-collab.xml:16
5838 msgid ""
5839 "Mercurial has a powerful web interface that provides several useful "
5840 "capabilities."
5841 msgstr ""
5843 #. type: Content of: <book><chapter><sect1><para>
5844 #: ../en/ch05-collab.xml:19
5845 msgid ""
5846 "For interactive use, the web interface lets you browse a single repository or "
5847 "a collection of repositories. You can view the history of a repository, "
5848 "examine each change (comments and diffs), and view the contents of each "
5849 "directory and file. You can even get a view of history that gives a "
5850 "graphical view of the relationships between individual changes and merges."
5851 msgstr ""
5853 #. type: Content of: <book><chapter><sect1><para>
5854 #: ../en/ch05-collab.xml:26
5855 msgid ""
5856 "Also for human consumption, the web interface provides Atom and RSS feeds of "
5857 "the changes in a repository. This lets you <quote>subscribe</quote> to a "
5858 "repository using your favorite feed reader, and be automatically notified of "
5859 "activity in that repository as soon as it happens. I find this capability "
5860 "much more convenient than the model of subscribing to a mailing list to which "
5861 "notifications are sent, as it requires no additional configuration on the "
5862 "part of whoever is serving the repository."
5863 msgstr ""
5865 #. type: Content of: <book><chapter><sect1><para>
5866 #: ../en/ch05-collab.xml:36
5867 msgid ""
5868 "The web interface also lets remote users clone a repository, pull changes "
5869 "from it, and (when the server is configured to permit it) push changes back "
5870 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
5871 "that it works efficiently even over low-bandwidth network connections."
5872 msgstr ""
5874 #. type: Content of: <book><chapter><sect1><para>
5875 #: ../en/ch05-collab.xml:42
5876 msgid ""
5877 "The easiest way to get started with the web interface is to use your web "
5878 "browser to visit an existing repository, such as the master Mercurial "
5879 "repository at <ulink url=\"http://www.selenic.com/repo/hg\">http://www."
5880 "selenic.com/repo/hg</ulink>."
5881 msgstr ""
5883 #. type: Content of: <book><chapter><sect1><para>
5884 #: ../en/ch05-collab.xml:47
5885 msgid ""
5886 "If you're interested in providing a web interface to your own repositories, "
5887 "there are several good ways to do this."
5888 msgstr ""
5890 #. type: Content of: <book><chapter><sect1><para>
5891 #: ../en/ch05-collab.xml:51
5892 msgid ""
5893 "The easiest and fastest way to get started in an informal environment is to "
5894 "use the <command role=\"hg-cmd\">hg serve</command> command, which is best "
5895 "suited to short-term <quote>lightweight</quote> serving. See <xref linkend="
5896 "\"sec:collab:serve\"/> below for details of how to use this command."
5897 msgstr ""
5899 #. type: Content of: <book><chapter><sect1><para>
5900 #: ../en/ch05-collab.xml:58
5901 msgid ""
5902 "For longer-lived repositories that you'd like to have permanently available, "
5903 "there are several public hosting services available."
5904 msgstr ""
5906 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
5907 #: ../en/ch05-collab.xml:64
5908 msgid ""
5909 "Bitbucket, at <ulink url=\"http://bitbucket.org/\">http://bitbucket.org/</"
5910 "ulink>, provides free hosting for open source projects, and paid hosting for "
5911 "commercial projects."
5912 msgstr ""
5914 #. type: Content of: <book><chapter><sect1><para>
5915 #: ../en/ch05-collab.xml:71
5916 msgid ""
5917 "If you would prefer to host your own repositories, Mercurial has built-in "
5918 "support for several popular hosting technologies, most notably CGI (Common "
5919 "Gateway Interface), and WSGI (Web Services Gateway Interface). See <xref "
5920 "linkend=\"sec:collab:cgi\"/> for details of CGI and WSGI configuration."
5921 msgstr ""
5923 #. type: Content of: <book><chapter><sect1><title>
5924 #: ../en/ch05-collab.xml:80
5925 msgid "Collaboration models"
5926 msgstr "协作模型"
5928 #. type: Content of: <book><chapter><sect1><para>
5929 #: ../en/ch05-collab.xml:82
5930 msgid ""
5931 "With a suitably flexible tool, making decisions about workflow is much more "
5932 "of a social engineering challenge than a technical one. Mercurial imposes few "
5933 "limitations on how you can structure the flow of work in a project, so it's "
5934 "up to you and your group to set up and live with a model that matches your "
5935 "own particular needs."
5936 msgstr ""
5938 #. type: Content of: <book><chapter><sect1><sect2><title>
5939 #: ../en/ch05-collab.xml:90
5940 msgid "Factors to keep in mind"
5941 msgstr "要牢记的因素"
5943 #. type: Content of: <book><chapter><sect1><sect2><para>
5944 #: ../en/ch05-collab.xml:92
5945 msgid ""
5946 "The most important aspect of any model that you must keep in mind is how well "
5947 "it matches the needs and capabilities of the people who will be using it. "
5948 "This might seem self-evident; even so, you still can't afford to forget it "
5949 "for a moment."
5950 msgstr ""
5952 #. type: Content of: <book><chapter><sect1><sect2><para>
5953 #: ../en/ch05-collab.xml:98
5954 msgid ""
5955 "I once put together a workflow model that seemed to make perfect sense to me, "
5956 "but that caused a considerable amount of consternation and strife within my "
5957 "development team. In spite of my attempts to explain why we needed a complex "
5958 "set of branches, and how changes ought to flow between them, a few team "
5959 "members revolted. Even though they were smart people, they didn't want to "
5960 "pay attention to the constraints we were operating under, or face the "
5961 "consequences of those constraints in the details of the model that I was "
5962 "advocating."
5963 msgstr ""
5965 #. type: Content of: <book><chapter><sect1><sect2><para>
5966 #: ../en/ch05-collab.xml:108
5967 msgid ""
5968 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
5969 "scheme you put into effect, you should plan for mistakes and problem "
5970 "scenarios. Consider adding automated machinery to prevent, or quickly "
5971 "recover from, trouble that you can anticipate. As an example, if you intend "
5972 "to have a branch with not-for-release changes in it, you'd do well to think "
5973 "early about the possibility that someone might accidentally merge those "
5974 "changes into a release branch. You could avoid this particular problem by "
5975 "writing a hook that prevents changes from being merged from an inappropriate "
5976 "branch."
5977 msgstr ""
5979 #. type: Content of: <book><chapter><sect1><sect2><title>
5980 #: ../en/ch05-collab.xml:122
5981 msgid "Informal anarchy"
5982 msgstr "无政府状态"
5984 #. type: Content of: <book><chapter><sect1><sect2><para>
5985 #: ../en/ch05-collab.xml:124
5986 msgid ""
5987 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
5988 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
5989 "well in a few unusual situations."
5990 msgstr ""
5992 #. type: Content of: <book><chapter><sect1><sect2><para>
5993 #: ../en/ch05-collab.xml:129
5994 msgid ""
5995 "As one example, many projects have a loose-knit group of collaborators who "
5996 "rarely physically meet each other. Some groups like to overcome the "
5997 "isolation of working at a distance by organizing occasional <quote>sprints</"
5998 "quote>. In a sprint, a number of people get together in a single location (a "
5999 "company's conference room, a hotel meeting room, that kind of place) and "
6000 "spend several days more or less locked in there, hacking intensely on a "
6001 "handful of projects."
6002 msgstr ""
6004 #. type: Content of: <book><chapter><sect1><sect2><para>
6005 #: ../en/ch05-collab.xml:138
6006 msgid ""
6007 "A sprint or a hacking session in a coffee shop are the perfect places to use "
6008 "the <command role=\"hg-cmd\">hg serve</command> command, since <command role="
6009 "\"hg-cmd\">hg serve</command> does not require any fancy server "
6010 "infrastructure. You can get started with <command role=\"hg-cmd\">hg serve</"
6011 "command> in moments, by reading <xref linkend=\"sec:collab:serve\"/> below. "
6012 "Then simply tell the person next to you that you're running a server, send "
6013 "the URL to them in an instant message, and you immediately have a quick-"
6014 "turnaround way to work together. They can type your URL into their web "
6015 "browser and quickly review your changes; or they can pull a bugfix from you "
6016 "and verify it; or they can clone a branch containing a new feature and try it "
6017 "out."
6018 msgstr ""
6020 #. type: Content of: <book><chapter><sect1><sect2><para>
6021 #: ../en/ch05-collab.xml:152
6022 msgid ""
6023 "The charm, and the problem, with doing things in an ad hoc fashion like this "
6024 "is that only people who know about your changes, and where they are, can see "
6025 "them. Such an informal approach simply doesn't scale beyond a handful "
6026 "people, because each individual needs to know about <emphasis>n</emphasis> "
6027 "different repositories to pull from."
6028 msgstr ""
6030 #. type: Content of: <book><chapter><sect1><sect2><title>
6031 #: ../en/ch05-collab.xml:162
6032 msgid "A single central repository"
6033 msgstr "单一中央版本库"
6035 #. type: Content of: <book><chapter><sect1><sect2><para>
6036 #: ../en/ch05-collab.xml:164
6037 msgid ""
6038 "For smaller projects migrating from a centralised revision control tool, "
6039 "perhaps the easiest way to get started is to have changes flow through a "
6040 "single shared central repository. This is also the most common "
6041 "<quote>building block</quote> for more ambitious workflow schemes."
6042 msgstr ""
6044 #. type: Content of: <book><chapter><sect1><sect2><para>
6045 #: ../en/ch05-collab.xml:170
6046 msgid ""
6047 "Contributors start by cloning a copy of this repository. They can pull "
6048 "changes from it whenever they need to, and some (perhaps all) developers have "
6049 "permission to push a change back when they're ready for other people to see "
6050 "it."
6051 msgstr ""
6053 #. type: Content of: <book><chapter><sect1><sect2><para>
6054 #: ../en/ch05-collab.xml:175
6055 msgid ""
6056 "Under this model, it can still often make sense for people to pull changes "
6057 "directly from each other, without going through the central repository. "
6058 "Consider a case in which I have a tentative bug fix, but I am worried that if "
6059 "I were to publish it to the central repository, it might subsequently break "
6060 "everyone else's trees as they pull it. To reduce the potential for damage, I "
6061 "can ask you to clone my repository into a temporary repository of your own "
6062 "and test it. This lets us put off publishing the potentially unsafe change "
6063 "until it has had a little testing."
6064 msgstr ""
6066 #. type: Content of: <book><chapter><sect1><sect2><para>
6067 #: ../en/ch05-collab.xml:186
6068 msgid ""
6069 "If a team is hosting its own repository in this kind of scenario, people will "
6070 "usually use the <command>ssh</command> protocol to securely push changes to "
6071 "the central repository, as documented in <xref linkend=\"sec:collab:ssh\"/>. "
6072 "It's also usual to publish a read-only copy of the repository over HTTP, as "
6073 "in <xref linkend=\"sec:collab:cgi\"/>. Publishing over HTTP satisfies the "
6074 "needs of people who don't have push access, and those who want to use web "
6075 "browsers to browse the repository's history."
6076 msgstr ""
6078 #. type: Content of: <book><chapter><sect1><sect2><title>
6079 #: ../en/ch05-collab.xml:199
6080 msgid "A hosted central repository"
6081 msgstr "托管的中央版本库"
6083 #. type: Content of: <book><chapter><sect1><sect2><para>
6084 #: ../en/ch05-collab.xml:201
6085 msgid ""
6086 "A wonderful thing about public hosting services like <ulink url=\"http://"
6087 "bitbucket.org/\">Bitbucket</ulink> is that not only do they handle the fiddly "
6088 "server configuration details, such as user accounts, authentication, and "
6089 "secure wire protocols, they provide additional infrastructure to make this "
6090 "model work well."
6091 msgstr ""
6093 #. type: Content of: <book><chapter><sect1><sect2><para>
6094 #: ../en/ch05-collab.xml:208
6095 msgid ""
6096 "For instance, a well-engineered hosting service will let people clone their "
6097 "own copies of a repository with a single click. This lets people work in "
6098 "separate spaces and share their changes when they're ready."
6099 msgstr ""
6101 #. type: Content of: <book><chapter><sect1><sect2><para>
6102 #: ../en/ch05-collab.xml:213
6103 msgid ""
6104 "In addition, a good hosting service will let people communicate with each "
6105 "other, for instance to say <quote>there are changes ready for you to review "
6106 "in this tree</quote>."
6107 msgstr ""
6109 #. type: Content of: <book><chapter><sect1><sect2><title>
6110 #: ../en/ch05-collab.xml:220
6111 msgid "Working with multiple branches"
6112 msgstr "使用多个分支工作"
6114 #. type: Content of: <book><chapter><sect1><sect2><para>
6115 #: ../en/ch05-collab.xml:222
6116 msgid ""
6117 "Projects of any significant size naturally tend to make progress on several "
6118 "fronts simultaneously. In the case of software, it's common for a project to "
6119 "go through periodic official releases. A release might then go into "
6120 "<quote>maintenance mode</quote> for a while after its first publication; "
6121 "maintenance releases tend to contain only bug fixes, not new features. In "
6122 "parallel with these maintenance releases, one or more future releases may be "
6123 "under development. People normally use the word <quote>branch</quote> to "
6124 "refer to one of these many slightly different directions in which development "
6125 "is proceeding."
6126 msgstr ""
6128 #. type: Content of: <book><chapter><sect1><sect2><para>
6129 #: ../en/ch05-collab.xml:235
6130 msgid ""
6131 "Mercurial is particularly well suited to managing a number of simultaneous, "
6132 "but not identical, branches. Each <quote>development direction</quote> can "
6133 "live in its own central repository, and you can merge changes from one to "
6134 "another as the need arises. Because repositories are independent of each "
6135 "other, unstable changes in a development branch will never affect a stable "
6136 "branch unless someone explicitly merges those changes into the stable branch."
6137 msgstr ""
6139 #. type: Content of: <book><chapter><sect1><sect2><para>
6140 #: ../en/ch05-collab.xml:244
6141 msgid ""
6142 "Here's an example of how this can work in practice. Let's say you have one "
6143 "<quote>main branch</quote> on a central server."
6144 msgstr ""
6146 #. type: Content of: <book><chapter><sect1><sect2><para>
6147 #: ../en/ch05-collab.xml:250
6148 msgid "People clone it, make changes locally, test them, and push them back."
6149 msgstr ""
6151 #. type: Content of: <book><chapter><sect1><sect2><para>
6152 #: ../en/ch05-collab.xml:253
6153 msgid ""
6154 "Once the main branch reaches a release milestone, you can use the <command "
6155 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
6156 "milestone revision."
6157 msgstr ""
6159 #. type: Content of: <book><chapter><sect1><sect2><para>
6160 #: ../en/ch05-collab.xml:259
6161 msgid "Let's say some ongoing development occurs on the main branch."
6162 msgstr ""
6164 #. type: Content of: <book><chapter><sect1><sect2><para>
6165 #: ../en/ch05-collab.xml:264
6166 msgid ""
6167 "Using the tag that was recorded at the milestone, people who clone that "
6168 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
6169 "update</command> to get a copy of the working directory exactly as it was "
6170 "when that tagged revision was committed."
6171 msgstr ""
6173 #. type: Content of: <book><chapter><sect1><sect2><para>
6174 #: ../en/ch05-collab.xml:272
6175 msgid ""
6176 "In addition, immediately after the main branch is tagged, we can then clone "
6177 "the main branch on the server to a new <quote>stable</quote> branch, also on "
6178 "the server."
6179 msgstr ""
6181 #. type: Content of: <book><chapter><sect1><sect2><para>
6182 #: ../en/ch05-collab.xml:278
6183 msgid ""
6184 "If we need to make a change to the stable branch, we can then clone "
6185 "<emphasis>that</emphasis> repository, make our changes, commit, and push our "
6186 "changes back there."
6187 msgstr ""
6189 #. type: Content of: <book><chapter><sect1><sect2><para>
6190 #: ../en/ch05-collab.xml:285
6191 msgid ""
6192 "Because Mercurial repositories are independent, and Mercurial doesn't move "
6193 "changes around automatically, the stable and main branches are "
6194 "<emphasis>isolated</emphasis> from each other. The changes that we made on "
6195 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
6196 "versa."
6197 msgstr ""
6199 #. type: Content of: <book><chapter><sect1><sect2><para>
6200 #: ../en/ch05-collab.xml:292
6201 msgid ""
6202 "We'll often want all of our bugfixes on the stable branch to show up on the "
6203 "main branch, too. Rather than rewrite a bugfix on the main branch, we can "
6204 "simply pull and merge changes from the stable to the main branch, and "
6205 "Mercurial will bring those bugfixes in for us."
6206 msgstr ""
6208 #. type: Content of: <book><chapter><sect1><sect2><para>
6209 #: ../en/ch05-collab.xml:300
6210 msgid ""
6211 "The main branch will still contain changes that are not on the stable branch, "
6212 "but it will also contain all of the bugfixes from the stable branch. The "
6213 "stable branch remains unaffected by these changes, since changes are only "
6214 "flowing from the stable to the main branch, and not the other way."
6215 msgstr ""
6217 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
6218 #: ../en/ch05-collab.xml:309 ../en/ch05-collab.xml:319
6219 msgid "Feature branches"
6220 msgstr "特性分支"
6222 #. type: Content of: <book><chapter><sect1><sect2><para>
6223 #: ../en/ch05-collab.xml:311
6224 msgid ""
6225 "For larger projects, an effective way to manage change is to break up a team "
6226 "into smaller groups. Each group has a shared branch of its own, cloned from "
6227 "a single <quote>master</quote> branch used by the entire project. People "
6228 "working on an individual branch are typically quite isolated from "
6229 "developments on other branches."
6230 msgstr ""
6232 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
6233 #: ../en/ch05-collab.xml:321
6234 msgid ""
6235 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
6236 "></imageobject>"
6237 msgstr ""
6239 #. type: Content of: <book><chapter><sect1><sect2><para>
6240 #: ../en/ch05-collab.xml:326
6241 msgid ""
6242 "When a particular feature is deemed to be in suitable shape, someone on that "
6243 "feature team pulls and merges from the master branch into the feature branch, "
6244 "then pushes back up to the master branch."
6245 msgstr ""
6247 #. type: Content of: <book><chapter><sect1><sect2><title>
6248 #: ../en/ch05-collab.xml:333
6249 msgid "The release train"
6250 msgstr "发布列车"
6252 #. type: Content of: <book><chapter><sect1><sect2><para>
6253 #: ../en/ch05-collab.xml:335
6254 msgid ""
6255 "Some projects are organized on a <quote>train</quote> basis: a release is "
6256 "scheduled to happen every few months, and whatever features are ready when "
6257 "the <quote>train</quote> is ready to leave are allowed in."
6258 msgstr ""
6260 #. type: Content of: <book><chapter><sect1><sect2><para>
6261 #: ../en/ch05-collab.xml:340
6262 msgid ""
6263 "This model resembles working with feature branches. The difference is that "
6264 "when a feature branch misses a train, someone on the feature team pulls and "
6265 "merges the changes that went out on that train release into the feature "
6266 "branch, and the team continues its work on top of that release so that their "
6267 "feature can make the next release."
6268 msgstr ""
6270 #. type: Content of: <book><chapter><sect1><sect2><title>
6271 #: ../en/ch05-collab.xml:349
6272 msgid "The Linux kernel model"
6273 msgstr "Linux 内核模型"
6275 #. type: Content of: <book><chapter><sect1><sect2><para>
6276 #: ../en/ch05-collab.xml:351
6277 msgid ""
6278 "The development of the Linux kernel has a shallow hierarchical structure, "
6279 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
6280 "<command>git</command>, a distributed revision control tool with capabilities "
6281 "similar to Mercurial, it's useful to describe the way work flows in that "
6282 "environment; if you like the ideas, the approach translates well across tools."
6283 msgstr ""
6285 #. type: Content of: <book><chapter><sect1><sect2><para>
6286 #: ../en/ch05-collab.xml:359
6287 msgid ""
6288 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
6289 "publishes a single source repository that is considered the "
6290 "<quote>authoritative</quote> current tree by the entire developer community. "
6291 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
6292 "pulls from."
6293 msgstr ""
6295 #. type: Content of: <book><chapter><sect1><sect2><para>
6296 #: ../en/ch05-collab.xml:366
6297 msgid ""
6298 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
6299 "he pulls whatever changes they publish, in most cases without even reviewing "
6300 "those changes. Some of those lieutenants are generally agreed to be "
6301 "<quote>maintainers</quote>, responsible for specific subsystems within the "
6302 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
6303 "they want to end up in Linus's tree, they must find out who the subsystem's "
6304 "maintainer is, and ask that maintainer to take their change. If the "
6305 "maintainer reviews their changes and agrees to take them, they'll pass them "
6306 "along to Linus in due course."
6307 msgstr ""
6309 #. type: Content of: <book><chapter><sect1><sect2><para>
6310 #: ../en/ch05-collab.xml:378
6311 msgid ""
6312 "Individual lieutenants have their own approaches to reviewing, accepting, and "
6313 "publishing changes; and for deciding when to feed them to Linus. In "
6314 "addition, there are several well known branches that people use for different "
6315 "purposes. For example, a few people maintain <quote>stable</quote> "
6316 "repositories of older versions of the kernel, to which they apply critical "
6317 "fixes as needed. Some maintainers publish multiple trees: one for "
6318 "experimental changes; one for changes that they are about to feed upstream; "
6319 "and so on. Others just publish a single tree."
6320 msgstr ""
6322 #. type: Content of: <book><chapter><sect1><sect2><para>
6323 #: ../en/ch05-collab.xml:389
6324 msgid ""
6325 "This model has two notable features. The first is that it's <quote>pull "
6326 "only</quote>. You have to ask, convince, or beg another developer to take a "
6327 "change from you, because there are almost no trees to which more than one "
6328 "person can push, and there's no way to push changes into a tree that someone "
6329 "else controls."
6330 msgstr ""
6332 #. type: Content of: <book><chapter><sect1><sect2><para>
6333 #: ../en/ch05-collab.xml:396
6334 msgid ""
6335 "The second is that it's based on reputation and acclaim. If you're an "
6336 "unknown, Linus will probably ignore changes from you without even "
6337 "responding. But a subsystem maintainer will probably review them, and will "
6338 "likely take them if they pass their criteria for suitability. The more "
6339 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
6340 "they are to trust your judgment and accept your changes. If you're well-"
6341 "known and maintain a long-lived branch for something Linus hasn't yet "
6342 "accepted, people with similar interests may pull your changes regularly to "
6343 "keep up with your work."
6344 msgstr ""
6346 #. type: Content of: <book><chapter><sect1><sect2><para>
6347 #: ../en/ch05-collab.xml:407
6348 msgid ""
6349 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
6350 "quote> boundaries. If you're a respected but specialised storage hacker, and "
6351 "you try to fix a networking bug, that change will receive a level of scrutiny "
6352 "from a network maintainer comparable to a change from a complete stranger."
6353 msgstr ""
6355 #. type: Content of: <book><chapter><sect1><sect2><para>
6356 #: ../en/ch05-collab.xml:414
6357 msgid ""
6358 "To people who come from more orderly project backgrounds, the comparatively "
6359 "chaotic Linux kernel development process often seems completely insane. It's "
6360 "subject to the whims of individuals; people make sweeping changes whenever "
6361 "they deem it appropriate; and the pace of development is astounding. And yet "
6362 "Linux is a highly successful, well-regarded piece of software."
6363 msgstr ""
6365 #. type: Content of: <book><chapter><sect1><sect2><title>
6366 #: ../en/ch05-collab.xml:424
6367 msgid "Pull-only versus shared-push collaboration"
6368 msgstr "只读与共享写协作"
6370 #. type: Content of: <book><chapter><sect1><sect2><para>
6371 #: ../en/ch05-collab.xml:426
6372 msgid ""
6373 "A perpetual source of heat in the open source community is whether a "
6374 "development model in which people only ever pull changes from others is "
6375 "<quote>better than</quote> one in which multiple people can push changes to a "
6376 "shared repository."
6377 msgstr ""
6379 #. type: Content of: <book><chapter><sect1><sect2><para>
6380 #: ../en/ch05-collab.xml:432
6381 msgid ""
6382 "Typically, the backers of the shared-push model use tools that actively "
6383 "enforce this approach. If you're using a centralised revision control tool "
6384 "such as Subversion, there's no way to make a choice over which model you'll "
6385 "use: the tool gives you shared-push, and if you want to do anything else, "
6386 "you'll have to roll your own approach on top (such as applying a patch by "
6387 "hand)."
6388 msgstr ""
6390 #. type: Content of: <book><chapter><sect1><sect2><para>
6391 #: ../en/ch05-collab.xml:440
6392 msgid ""
6393 "A good distributed revision control tool will support both models. You and "
6394 "your collaborators can then structure how you work together based on your own "
6395 "needs and preferences, not on what contortions your tools force you into."
6396 msgstr ""
6398 #. type: Content of: <book><chapter><sect1><sect2><title>
6399 #: ../en/ch05-collab.xml:447
6400 msgid "Where collaboration meets branch management"
6401 msgstr "协作与分支管理"
6403 #. type: Content of: <book><chapter><sect1><sect2><para>
6404 #: ../en/ch05-collab.xml:449
6405 msgid ""
6406 "Once you and your team set up some shared repositories and start propagating "
6407 "changes back and forth between local and shared repos, you begin to face a "
6408 "related, but slightly different challenge: that of managing the multiple "
6409 "directions in which your team may be moving at once. Even though this "
6410 "subject is intimately related to how your team collaborates, it's dense "
6411 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
6412 msgstr ""
6414 #. type: Content of: <book><chapter><sect1><title>
6415 #: ../en/ch05-collab.xml:461
6416 msgid "The technical side of sharing"
6417 msgstr "共享的技术因素"
6419 #. type: Content of: <book><chapter><sect1><para>
6420 #: ../en/ch05-collab.xml:463
6421 msgid ""
6422 "The remainder of this chapter is devoted to the question of sharing changes "
6423 "with your collaborators."
6424 msgstr ""
6426 #. type: Content of: <book><chapter><sect1><title>
6427 #: ../en/ch05-collab.xml:468
6428 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
6429 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
6431 #. type: Content of: <book><chapter><sect1><para>
6432 #: ../en/ch05-collab.xml:471
6433 msgid ""
6434 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
6435 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
6436 "It also provides a great way to get a feel for using Mercurial commands over "
6437 "a network."
6438 msgstr ""
6440 #. type: Content of: <book><chapter><sect1><para>
6441 #: ../en/ch05-collab.xml:476
6442 msgid ""
6443 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
6444 "under a second it will bring up a specialised HTTP server; this will accept "
6445 "connections from any client, and serve up data for that repository until you "
6446 "terminate it. Anyone who knows the URL of the server you just started, and "
6447 "can talk to your computer over the network, can then use a web browser or "
6448 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
6449 "cmd\">hg serve</command> instance running on a laptop is likely to look "
6450 "something like <literal>http://my-laptop.local:8000/</literal>."
6451 msgstr ""
6453 #. type: Content of: <book><chapter><sect1><para>
6454 #: ../en/ch05-collab.xml:487
6455 msgid ""
6456 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
6457 "emphasis> a general-purpose web server. It can do only two things:"
6458 msgstr ""
6460 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6461 #: ../en/ch05-collab.xml:491
6462 msgid ""
6463 "Allow people to browse the history of the repository it's serving, from their "
6464 "normal web browsers."
6465 msgstr ""
6467 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6468 #: ../en/ch05-collab.xml:495
6469 msgid ""
6470 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
6471 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
6472 "from that repository."
6473 msgstr ""
6475 #. type: Content of: <book><chapter><sect1><para>
6476 #: ../en/ch05-collab.xml:500
6477 msgid ""
6478 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
6479 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
6480 "only use."
6481 msgstr ""
6483 #. type: Content of: <book><chapter><sect1><para>
6484 #: ../en/ch05-collab.xml:504
6485 msgid ""
6486 "If you're getting started with Mercurial, there's nothing to prevent you from "
6487 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
6488 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
6489 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
6490 "to that server as if the repository was hosted remotely. This can help you to "
6491 "quickly get acquainted with using commands on network-hosted repositories."
6492 msgstr ""
6494 #. type: Content of: <book><chapter><sect1><sect2><title>
6495 #: ../en/ch05-collab.xml:514
6496 msgid "A few things to keep in mind"
6497 msgstr "要牢记的几件事"
6499 #. type: Content of: <book><chapter><sect1><sect2><para>
6500 #: ../en/ch05-collab.xml:516
6501 msgid ""
6502 "Because it provides unauthenticated read access to all clients, you should "
6503 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
6504 "you either don't care, or have complete control over, who can access your "
6505 "network and pull data from your repository."
6506 msgstr ""
6508 #. type: Content of: <book><chapter><sect1><sect2><para>
6509 #: ../en/ch05-collab.xml:522
6510 msgid ""
6511 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
6512 "any firewall software you might have installed on your system or network. It "
6513 "cannot detect or control your firewall software. If other people are unable "
6514 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
6515 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
6516 "they're using the correct URL) is check your firewall configuration."
6517 msgstr ""
6519 #. type: Content of: <book><chapter><sect1><sect2><para>
6520 #: ../en/ch05-collab.xml:531
6521 msgid ""
6522 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
6523 "connections on port 8000. If another process is already listening on the "
6524 "port you want to use, you can specify a different port to listen on using the "
6525 "<option role=\"hg-opt-serve\">-p</option> option."
6526 msgstr ""
6528 #. type: Content of: <book><chapter><sect1><sect2><para>
6529 #: ../en/ch05-collab.xml:537
6530 msgid ""
6531 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
6532 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
6533 "indeed running correctly, and find out what URL you should send to your "
6534 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
6535 "option."
6536 msgstr ""
6538 #. type: Content of: <book><chapter><sect1><title>
6539 #: ../en/ch05-collab.xml:547
6540 msgid "Using the Secure Shell (ssh) protocol"
6541 msgstr "使用 ssh 协议"
6543 #. type: Content of: <book><chapter><sect1><para>
6544 #: ../en/ch05-collab.xml:549
6545 msgid ""
6546 "You can pull and push changes securely over a network connection using the "
6547 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
6548 "you may have to do a little bit of configuration on the client or server "
6549 "sides."
6550 msgstr ""
6552 #. type: Content of: <book><chapter><sect1><para>
6553 #: ../en/ch05-collab.xml:554
6554 msgid ""
6555 "If you're not familiar with ssh, it's the name of both a command and a "
6556 "network protocol that let you securely communicate with another computer. To "
6557 "use it with Mercurial, you'll be setting up one or more user accounts on a "
6558 "server so that remote users can log in and execute commands."
6559 msgstr ""
6561 #. type: Content of: <book><chapter><sect1><para>
6562 #: ../en/ch05-collab.xml:560
6563 msgid ""
6564 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
6565 "of the material that follows to be elementary in nature.)"
6566 msgstr ""
6568 #. type: Content of: <book><chapter><sect1><sect2><title>
6569 #: ../en/ch05-collab.xml:565
6570 msgid "How to read and write ssh URLs"
6571 msgstr "如何读写 ssh 路径"
6573 #. type: Content of: <book><chapter><sect1><sect2><para>
6574 #: ../en/ch05-collab.xml:567
6575 msgid "An ssh URL tends to look like this:"
6576 msgstr ""
6578 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6579 #: ../en/ch05-collab.xml:570
6580 msgid ""
6581 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
6582 "ssh protocol."
6583 msgstr ""
6585 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6586 #: ../en/ch05-collab.xml:573
6587 msgid ""
6588 "The <quote><literal>bos@</literal></quote> component indicates what username "
6589 "to log into the server as. You can leave this out if the remote username is "
6590 "the same as your local username."
6591 msgstr ""
6593 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6594 #: ../en/ch05-collab.xml:578
6595 msgid ""
6596 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
6597 "the server to log into."
6598 msgstr ""
6600 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6601 #: ../en/ch05-collab.xml:582
6602 msgid ""
6603 "The <quote>:22</quote> identifies the port number to connect to the server "
6604 "on. The default port is 22, so you only need to specify a colon and port "
6605 "number if you're <emphasis>not</emphasis> using port 22."
6606 msgstr ""
6608 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6609 #: ../en/ch05-collab.xml:587
6610 msgid ""
6611 "The remainder of the URL is the local path to the repository on the server."
6612 msgstr ""
6614 #. type: Content of: <book><chapter><sect1><sect2><para>
6615 #: ../en/ch05-collab.xml:591
6616 msgid ""
6617 "There's plenty of scope for confusion with the path component of ssh URLs, as "
6618 "there is no standard way for tools to interpret it. Some programs behave "
6619 "differently than others when dealing with these paths. This isn't an ideal "
6620 "situation, but it's unlikely to change. Please read the following paragraphs "
6621 "carefully."
6622 msgstr ""
6624 #. type: Content of: <book><chapter><sect1><sect2><para>
6625 #: ../en/ch05-collab.xml:598
6626 msgid ""
6627 "Mercurial treats the path to a repository on the server as relative to the "
6628 "remote user's home directory. For example, if user <literal>foo</literal> on "
6629 "the server has a home directory of <filename class=\"directory\">/home/foo</"
6630 "filename>, then an ssh URL that contains a path component of <filename class="
6631 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
6632 "directory <filename class=\"directory\">/home/foo/bar</filename>."
6633 msgstr ""
6635 #. type: Content of: <book><chapter><sect1><sect2><para>
6636 #: ../en/ch05-collab.xml:607
6637 msgid ""
6638 "If you want to specify a path relative to another user's home directory, you "
6639 "can use a path that starts with a tilde character followed by the user's name "
6640 "(let's call them <literal>otheruser</literal>), like this."
6641 msgstr ""
6643 #. type: Content of: <book><chapter><sect1><sect2><para>
6644 #: ../en/ch05-collab.xml:613
6645 msgid ""
6646 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
6647 "the server, begin the path component with two slashes, as in this example."
6648 msgstr ""
6650 #. type: Content of: <book><chapter><sect1><sect2><title>
6651 #: ../en/ch05-collab.xml:620
6652 msgid "Finding an ssh client for your system"
6653 msgstr "为你的系统寻找 ssh 客户端"
6655 #. type: Content of: <book><chapter><sect1><sect2><para>
6656 #: ../en/ch05-collab.xml:622
6657 msgid ""
6658 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
6659 "using such a system, run <literal>which ssh</literal> to find out if the "
6660 "<command>ssh</command> command is installed (it's usually in <filename class="
6661 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
6662 "present, take a look at your system documentation to figure out how to "
6663 "install it."
6664 msgstr ""
6666 #. type: Content of: <book><chapter><sect1><sect2><para>
6667 #: ../en/ch05-collab.xml:630
6668 msgid ""
6669 "On Windows, the TortoiseHg package is bundled with a version of Simon "
6670 "Tatham's excellent <command>plink</command> command, and you should not need "
6671 "to do any further configuration."
6672 msgstr ""
6674 #. type: Content of: <book><chapter><sect1><sect2><title>
6675 #: ../en/ch05-collab.xml:637
6676 msgid "Generating a key pair"
6677 msgstr "产生密钥对"
6679 #. type: Content of: <book><chapter><sect1><sect2><para>
6680 #: ../en/ch05-collab.xml:639
6681 msgid ""
6682 "To avoid the need to repetitively type a password every time you need to use "
6683 "your ssh client, I recommend generating a key pair."
6684 msgstr ""
6686 #. type: Content of: <book><chapter><sect1><sect2><tip><title>
6687 #: ../en/ch05-collab.xml:644
6688 msgid "Key pairs are not mandatory"
6689 msgstr ""
6691 #. type: Content of: <book><chapter><sect1><sect2><tip><para>
6692 #: ../en/ch05-collab.xml:646
6693 msgid ""
6694 "Mercurial knows nothing about ssh authentication or key pairs. You can, if "
6695 "you like, safely ignore this section and the one that follows until you grow "
6696 "tired of repeatedly typing ssh passwords."
6697 msgstr ""
6699 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6700 #: ../en/ch05-collab.xml:654
6701 msgid ""
6702 "On a Unix-like system, the <command>ssh-keygen</command> command will do the "
6703 "trick."
6704 msgstr ""
6706 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6707 #: ../en/ch05-collab.xml:657
6708 msgid ""
6709 "On Windows, if you're using TortoiseHg, you may need to download a command "
6710 "named <command>puttygen</command> from <ulink url=\"http://www.chiark."
6711 "greenend.org.uk/~sgtatham/putty\">the PuTTY web site</ulink> to generate a "
6712 "key pair. See <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
6713 "Chapter8.html#pubkey-puttygen\">the <command>puttygen</command> "
6714 "documentation</ulink> for details of how use the command."
6715 msgstr ""
6717 #. type: Content of: <book><chapter><sect1><sect2><para>
6718 #: ../en/ch05-collab.xml:669
6719 msgid ""
6720 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
6721 "advisable to protect it with a passphrase. (The only time that you might not "
6722 "want to do this is when you're using the ssh protocol for automated tasks on "
6723 "a secure network.)"
6724 msgstr ""
6726 #. type: Content of: <book><chapter><sect1><sect2><para>
6727 #: ../en/ch05-collab.xml:675
6728 msgid ""
6729 "Simply generating a key pair isn't enough, however. You'll need to add the "
6730 "public key to the set of authorised keys for whatever user you're logging in "
6731 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
6732 "adding the public key to a list in a file called <filename role=\"special"
6733 "\">authorized_keys</filename> in their <filename role=\"special\" class="
6734 "\"directory\">.ssh</filename> directory."
6735 msgstr ""
6737 #. type: Content of: <book><chapter><sect1><sect2><para>
6738 #: ../en/ch05-collab.xml:684
6739 msgid ""
6740 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
6741 "extension. If you're using <command>puttygen</command> on Windows, you can "
6742 "save the public key to a file of your choosing, or paste it from the window "
6743 "it's displayed in straight into the <filename role=\"special"
6744 "\">authorized_keys</filename> file."
6745 msgstr ""
6747 #. type: Content of: <book><chapter><sect1><sect2><title>
6748 #: ../en/ch05-collab.xml:692
6749 msgid "Using an authentication agent"
6750 msgstr "使用认证代理"
6752 #. type: Content of: <book><chapter><sect1><sect2><para>
6753 #: ../en/ch05-collab.xml:694
6754 msgid ""
6755 "An authentication agent is a daemon that stores passphrases in memory (so it "
6756 "will forget passphrases if you log out and log back in again). An ssh client "
6757 "will notice if it's running, and query it for a passphrase. If there's no "
6758 "authentication agent running, or the agent doesn't store the necessary "
6759 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
6760 "communicate with a server on your behalf (e.g. whenever you pull or push "
6761 "changes)."
6762 msgstr ""
6764 #. type: Content of: <book><chapter><sect1><sect2><para>
6765 #: ../en/ch05-collab.xml:703
6766 msgid ""
6767 "The downside of storing passphrases in an agent is that it's possible for a "
6768 "well-prepared attacker to recover the plain text of your passphrases, in some "
6769 "cases even if your system has been power-cycled. You should make your own "
6770 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
6771 "of repeated typing."
6772 msgstr ""
6774 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6775 #: ../en/ch05-collab.xml:712
6776 msgid ""
6777 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
6778 "it's often run automatically for you when you log in. You'll need to use the "
6779 "<command>ssh-add</command> command to add passphrases to the agent's store."
6780 msgstr ""
6782 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6783 #: ../en/ch05-collab.xml:719
6784 msgid ""
6785 "On Windows, if you're using TortoiseHg, the <command>pageant</command> "
6786 "command acts as the agent. As with <command>puttygen</command>, you'll need "
6787 "to <ulink url=\"http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download."
6788 "html\">download <command>pageant</command></ulink> from the PuTTY web site "
6789 "and read <ulink url=\"http://the.earth.li/~sgtatham/putty/0.60/htmldoc/"
6790 "Chapter9.html#pageant\">its documentation</ulink>. The <command>pageant</"
6791 "command> command adds an icon to your system tray that will let you manage "
6792 "stored passphrases."
6793 msgstr ""
6795 #. type: Content of: <book><chapter><sect1><sect2><title>
6796 #: ../en/ch05-collab.xml:734
6797 msgid "Configuring the server side properly"
6798 msgstr "正确配置服务器端"
6800 #. type: Content of: <book><chapter><sect1><sect2><para>
6801 #: ../en/ch05-collab.xml:736
6802 msgid ""
6803 "Because ssh can be fiddly to set up if you're new to it, a variety of things "
6804 "can go wrong. Add Mercurial on top, and there's plenty more scope for head-"
6805 "scratching. Most of these potential problems occur on the server side, not "
6806 "the client side. The good news is that once you've gotten a configuration "
6807 "working, it will usually continue to work indefinitely."
6808 msgstr ""
6810 #. type: Content of: <book><chapter><sect1><sect2><para>
6811 #: ../en/ch05-collab.xml:744
6812 msgid ""
6813 "Before you try using Mercurial to talk to an ssh server, it's best to make "
6814 "sure that you can use the normal <command>ssh</command> or <command>putty</"
6815 "command> command to talk to the server first. If you run into problems with "
6816 "using these commands directly, Mercurial surely won't work. Worse, it will "
6817 "obscure the underlying problem. Any time you want to debug ssh-related "
6818 "Mercurial problems, you should drop back to making sure that plain ssh client "
6819 "commands work first, <emphasis>before</emphasis> you worry about whether "
6820 "there's a problem with Mercurial."
6821 msgstr ""
6823 #. type: Content of: <book><chapter><sect1><sect2><para>
6824 #: ../en/ch05-collab.xml:755
6825 msgid ""
6826 "The first thing to be sure of on the server side is that you can actually log "
6827 "in from another machine at all. If you can't use <command>ssh</command> or "
6828 "<command>putty</command> to log in, the error message you get may give you a "
6829 "few hints as to what's wrong. The most common problems are as follows."
6830 msgstr ""
6832 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6833 #: ../en/ch05-collab.xml:762
6834 msgid ""
6835 "If you get a <quote>connection refused</quote> error, either there isn't an "
6836 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
6837 "configuration."
6838 msgstr ""
6840 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6841 #: ../en/ch05-collab.xml:767
6842 msgid ""
6843 "If you get a <quote>no route to host</quote> error, you either have an "
6844 "incorrect address for the server or a seriously locked down firewall that "
6845 "won't admit its existence at all."
6846 msgstr ""
6848 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6849 #: ../en/ch05-collab.xml:772
6850 msgid ""
6851 "If you get a <quote>permission denied</quote> error, you may have mistyped "
6852 "the username on the server, or you could have mistyped your key's passphrase "
6853 "or the remote user's password."
6854 msgstr ""
6856 #. type: Content of: <book><chapter><sect1><sect2><para>
6857 #: ../en/ch05-collab.xml:777
6858 msgid ""
6859 "In summary, if you're having trouble talking to the server's ssh daemon, "
6860 "first make sure that one is running at all. On many systems it will be "
6861 "installed, but disabled, by default. Once you're done with this step, you "
6862 "should then check that the server's firewall is configured to allow incoming "
6863 "connections on the port the ssh daemon is listening on (usually 22). Don't "
6864 "worry about more exotic possibilities for misconfiguration until you've "
6865 "checked these two first."
6866 msgstr ""
6868 #. type: Content of: <book><chapter><sect1><sect2><para>
6869 #: ../en/ch05-collab.xml:787
6870 msgid ""
6871 "If you're using an authentication agent on the client side to store "
6872 "passphrases for your keys, you ought to be able to log into the server "
6873 "without being prompted for a passphrase or a password. If you're prompted "
6874 "for a passphrase, there are a few possible culprits."
6875 msgstr ""
6877 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6878 #: ../en/ch05-collab.xml:793
6879 msgid ""
6880 "You might have forgotten to use <command>ssh-add</command> or "
6881 "<command>pageant</command> to store the passphrase."
6882 msgstr ""
6884 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6885 #: ../en/ch05-collab.xml:797
6886 msgid "You might have stored the passphrase for the wrong key."
6887 msgstr ""
6889 #. type: Content of: <book><chapter><sect1><sect2><para>
6890 #: ../en/ch05-collab.xml:800
6891 msgid ""
6892 "If you're being prompted for the remote user's password, there are another "
6893 "few possible problems to check."
6894 msgstr ""
6896 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6897 #: ../en/ch05-collab.xml:803
6898 msgid ""
6899 "Either the user's home directory or their <filename role=\"special\" class="
6900 "\"directory\">.ssh</filename> directory might have excessively liberal "
6901 "permissions. As a result, the ssh daemon will not trust or read their "
6902 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
6903 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
6904 "filename> directory will often cause this symptom."
6905 msgstr ""
6907 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6908 #: ../en/ch05-collab.xml:812
6909 msgid ""
6910 "The user's <filename role=\"special\">authorized_keys</filename> file may "
6911 "have a problem. If anyone other than the user owns or can write to that file, "
6912 "the ssh daemon will not trust or read it."
6913 msgstr ""
6915 #. type: Content of: <book><chapter><sect1><sect2><para>
6916 #: ../en/ch05-collab.xml:819
6917 msgid ""
6918 "In the ideal world, you should be able to run the following command "
6919 "successfully, and it should print exactly one line of output, the current "
6920 "date and time."
6921 msgstr ""
6923 #. type: Content of: <book><chapter><sect1><sect2><para>
6924 #: ../en/ch05-collab.xml:824
6925 msgid ""
6926 "If, on your server, you have login scripts that print banners or other junk "
6927 "even when running non-interactive commands like this, you should fix them "
6928 "before you continue, so that they only print output if they're run "
6929 "interactively. Otherwise these banners will at least clutter up Mercurial's "
6930 "output. Worse, they could potentially cause problems with running Mercurial "
6931 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
6932 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
6933 "you're editing your login scripts on your server, the usual way to see if a "
6934 "login script is running in an interactive shell is to check the return code "
6935 "from the command <literal>tty -s</literal>.)"
6936 msgstr ""
6938 #. type: Content of: <book><chapter><sect1><sect2><para>
6939 #: ../en/ch05-collab.xml:838
6940 msgid ""
6941 "Once you've verified that plain old ssh is working with your server, the next "
6942 "step is to ensure that Mercurial runs on the server. The following command "
6943 "should run successfully:"
6944 msgstr ""
6946 #. type: Content of: <book><chapter><sect1><sect2><para>
6947 #: ../en/ch05-collab.xml:845
6948 msgid ""
6949 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
6950 "version</command> output, this is usually because you haven't installed "
6951 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
6952 "if this is the case; you don't need to do that. But you should check for a "
6953 "few possible problems."
6954 msgstr ""
6956 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6957 #: ../en/ch05-collab.xml:852
6958 msgid ""
6959 "Is Mercurial really installed on the server at all? I know this sounds "
6960 "trivial, but it's worth checking!"
6961 msgstr ""
6963 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6964 #: ../en/ch05-collab.xml:856
6965 msgid ""
6966 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
6967 "environment variable) is simply misconfigured."
6968 msgstr ""
6970 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6971 #: ../en/ch05-collab.xml:860
6972 msgid ""
6973 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
6974 "point to the location of the <command>hg</command> executable if the login "
6975 "session is interactive. This can happen if you're setting the path in the "
6976 "wrong shell login script. See your shell's documentation for details."
6977 msgstr ""
6979 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6980 #: ../en/ch05-collab.xml:867
6981 msgid ""
6982 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
6983 "path to the Mercurial Python modules. It might not be set at all; it could "
6984 "be incorrect; or it may be set only if the login is interactive."
6985 msgstr ""
6987 #. type: Content of: <book><chapter><sect1><sect2><para>
6988 #: ../en/ch05-collab.xml:874
6989 msgid ""
6990 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
6991 "connection, well done! You've got the server and client sorted out. You "
6992 "should now be able to use Mercurial to access repositories hosted by that "
6993 "username on that server. If you run into problems with Mercurial and ssh at "
6994 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
6995 "option to get a clearer picture of what's going on."
6996 msgstr ""
6998 #. type: Content of: <book><chapter><sect1><sect2><title>
6999 #: ../en/ch05-collab.xml:883
7000 msgid "Using compression with ssh"
7001 msgstr "通过 ssh 使用压缩"
7003 #. type: Content of: <book><chapter><sect1><sect2><para>
7004 #: ../en/ch05-collab.xml:885
7005 msgid ""
7006 "Mercurial does not compress data when it uses the ssh protocol, because the "
7007 "ssh protocol can transparently compress data. However, the default behavior "
7008 "of ssh clients is <emphasis>not</emphasis> to request compression."
7009 msgstr ""
7011 #. type: Content of: <book><chapter><sect1><sect2><para>
7012 #: ../en/ch05-collab.xml:890
7013 msgid ""
7014 "Over any network other than a fast LAN (even a wireless network), using "
7015 "compression is likely to significantly speed up Mercurial's network "
7016 "operations. For example, over a WAN, someone measured compression as "
7017 "reducing the amount of time required to clone a particularly large repository "
7018 "from 51 minutes to 17 minutes."
7019 msgstr ""
7021 #. type: Content of: <book><chapter><sect1><sect2><para>
7022 #: ../en/ch05-collab.xml:897
7023 msgid ""
7024 "Both <command>ssh</command> and <command>plink</command> accept a <option "
7025 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
7026 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
7027 "compression for all of Mercurial's uses of the ssh protocol. Here is how to "
7028 "do so for regular <command>ssh</command> on Unix-like systems, for example."
7029 msgstr ""
7031 #. type: Content of: <book><chapter><sect1><sect2><para>
7032 #: ../en/ch05-collab.xml:907
7033 msgid ""
7034 "If you use <command>ssh</command> on a Unix-like system, you can configure it "
7035 "to always use compression when talking to your server. To do this, edit your "
7036 "<filename role=\"special\">.ssh/config</filename> file (which may not yet "
7037 "exist), as follows."
7038 msgstr ""
7040 #. type: Content of: <book><chapter><sect1><sect2><para>
7041 #: ../en/ch05-collab.xml:917
7042 msgid ""
7043 "This defines a hostname alias, <literal>hg</literal>. When you use that "
7044 "hostname on the <command>ssh</command> command line or in a Mercurial "
7045 "<literal>ssh</literal>-protocol URL, it will cause <command>ssh</command> to "
7046 "connect to <literal>hg.example.com</literal> and use compression. This gives "
7047 "you both a shorter name to type and compression, each of which is a good "
7048 "thing in its own right."
7049 msgstr ""
7051 #. type: Content of: <book><chapter><sect1><title>
7052 #: ../en/ch05-collab.xml:929
7053 msgid "Serving over HTTP using CGI"
7054 msgstr "使用 CGI 通过 HTTP 提供服务"
7056 #. type: Content of: <book><chapter><sect1><para>
7057 #: ../en/ch05-collab.xml:931
7058 msgid ""
7059 "The simplest way to host one or more repositories in a permanent way is to "
7060 "use a web server and Mercurial's CGI support."
7061 msgstr ""
7063 #. type: Content of: <book><chapter><sect1><para>
7064 #: ../en/ch05-collab.xml:935
7065 msgid ""
7066 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
7067 "take anything from a few moments to several hours."
7068 msgstr ""
7070 #. type: Content of: <book><chapter><sect1><para>
7071 #: ../en/ch05-collab.xml:939
7072 msgid ""
7073 "We'll begin with the simplest of examples, and work our way towards a more "
7074 "complex configuration. Even for the most basic case, you're almost certainly "
7075 "going to need to read and modify your web server's configuration."
7076 msgstr ""
7078 #. type: Content of: <book><chapter><sect1><note><title>
7079 #: ../en/ch05-collab.xml:945
7080 msgid "High pain tolerance required"
7081 msgstr ""
7083 #. type: Content of: <book><chapter><sect1><note><para>
7084 #: ../en/ch05-collab.xml:947
7085 msgid ""
7086 "Configuring a web server is a complex, fiddly, and highly system-dependent "
7087 "activity. I can't possibly give you instructions that will cover anything "
7088 "like all of the cases you will encounter. Please use your discretion and "
7089 "judgment in following the sections below. Be prepared to make plenty of "
7090 "mistakes, and to spend a lot of time reading your server's error logs."
7091 msgstr ""
7093 #. type: Content of: <book><chapter><sect1><note><para>
7094 #: ../en/ch05-collab.xml:955
7095 msgid ""
7096 "If you don't have a strong stomach for tweaking configurations over and over, "
7097 "or a compelling need to host your own services, you might want to try one of "
7098 "the public hosting services that I mentioned earlier."
7099 msgstr ""
7101 #. type: Content of: <book><chapter><sect1><sect2><title>
7102 #: ../en/ch05-collab.xml:962
7103 msgid "Web server configuration checklist"
7104 msgstr "Web 服务器配置检查表"
7106 #. type: Content of: <book><chapter><sect1><sect2><para>
7107 #: ../en/ch05-collab.xml:964
7108 msgid ""
7109 "Before you continue, do take a few moments to check a few aspects of your "
7110 "system's setup."
7111 msgstr ""
7113 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7114 #: ../en/ch05-collab.xml:968
7115 msgid ""
7116 "Do you have a web server installed at all? Mac OS X and some Linux "
7117 "distributions ship with Apache, but many other systems may not have a web "
7118 "server installed."
7119 msgstr ""
7121 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7122 #: ../en/ch05-collab.xml:973
7123 msgid ""
7124 "If you have a web server installed, is it actually running? On most systems, "
7125 "even if one is present, it will be disabled by default."
7126 msgstr ""
7128 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
7129 #: ../en/ch05-collab.xml:977
7130 msgid ""
7131 "Is your server configured to allow you to run CGI programs in the directory "
7132 "where you plan to do so? Most servers default to explicitly disabling the "
7133 "ability to run CGI programs."
7134 msgstr ""
7136 #. type: Content of: <book><chapter><sect1><sect2><para>
7137 #: ../en/ch05-collab.xml:983
7138 msgid ""
7139 "If you don't have a web server installed, and don't have substantial "
7140 "experience configuring Apache, you should consider using the "
7141 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
7142 "deserved reputation for baroque and confusing configuration. While "
7143 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
7144 "these capabilities are not relevant to serving Mercurial repositories. And "
7145 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
7146 "get started with than Apache."
7147 msgstr ""
7149 #. type: Content of: <book><chapter><sect1><sect2><title>
7150 #: ../en/ch05-collab.xml:996
7151 msgid "Basic CGI configuration"
7152 msgstr "基本 CGI 配置"
7154 #. type: Content of: <book><chapter><sect1><sect2><para>
7155 #: ../en/ch05-collab.xml:998
7156 msgid ""
7157 "On Unix-like systems, it's common for users to have a subdirectory named "
7158 "something like <filename class=\"directory\">public_html</filename> in their "
7159 "home directory, from which they can serve up web pages. A file named "
7160 "<filename>foo</filename> in this directory will be accessible at a URL of the "
7161 "form <literal>http://www.example.com/username/foo</literal>."
7162 msgstr ""
7164 #. type: Content of: <book><chapter><sect1><sect2><para>
7165 #: ../en/ch05-collab.xml:1006
7166 msgid ""
7167 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
7168 "script that should be present in your Mercurial installation. If you can't "
7169 "quickly find a local copy on your system, simply download one from the master "
7170 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
7171 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
7172 msgstr ""
7174 #. type: Content of: <book><chapter><sect1><sect2><para>
7175 #: ../en/ch05-collab.xml:1013 ../en/ch05-collab.xml:1182
7176 msgid ""
7177 "You'll need to copy this script into your <filename class=\"directory"
7178 "\">public_html</filename> directory, and ensure that it's executable."
7179 msgstr ""
7181 #. type: Content of: <book><chapter><sect1><sect2><para>
7182 #: ../en/ch05-collab.xml:1018
7183 msgid ""
7184 "The <literal>755</literal> argument to <command>chmod</command> is a little "
7185 "more general than just making the script executable: it ensures that the "
7186 "script is executable by anyone, and that <quote>group</quote> and "
7187 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
7188 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
7189 "literal> subsystem would likely refuse to execute the script. In fact, "
7190 "<literal>suexec</literal> also insists that the <emphasis>directory</"
7191 "emphasis> in which the script resides must not be writable by others."
7192 msgstr ""
7194 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7195 #: ../en/ch05-collab.xml:1032
7196 msgid "What could <emphasis>possibly</emphasis> go wrong?"
7197 msgstr "什么<emphasis>可能</emphasis>会出错?"
7199 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7200 #: ../en/ch05-collab.xml:1035
7201 msgid ""
7202 "Once you've copied the CGI script into place, go into a web browser, and try "
7203 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
7204 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
7205 "for instant failure. There's a high probability that trying to visit this "
7206 "URL will fail, and there are many possible reasons for this. In fact, you're "
7207 "likely to stumble over almost every one of the possible errors below, so "
7208 "please read carefully. The following are all of the problems I ran into on a "
7209 "system running Fedora 7, with a fresh installation of Apache, and a user "
7210 "account that I created specially to perform this exercise."
7211 msgstr ""
7213 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7214 #: ../en/ch05-collab.xml:1049
7215 msgid ""
7216 "Your web server may have per-user directories disabled. If you're using "
7217 "Apache, search your config file for a <literal>UserDir</literal> directive. "
7218 "If there's none present, per-user directories will be disabled. If one "
7219 "exists, but its value is <literal>disabled</literal>, then per-user "
7220 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
7221 "literal> gives the name of the subdirectory that Apache will look in under "
7222 "your home directory, for example <filename class=\"directory\">public_html</"
7223 "filename>."
7224 msgstr ""
7226 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7227 #: ../en/ch05-collab.xml:1060
7228 msgid ""
7229 "Your file access permissions may be too restrictive. The web server must be "
7230 "able to traverse your home directory and directories under your <filename "
7231 "class=\"directory\">public_html</filename> directory, and read files under "
7232 "the latter too. Here's a quick recipe to help you to make your permissions "
7233 "more appropriate."
7234 msgstr ""
7236 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7237 #: ../en/ch05-collab.xml:1070
7238 msgid ""
7239 "The other possibility with permissions is that you might get a completely "
7240 "empty window when you try to load the script. In this case, it's likely that "
7241 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
7242 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
7243 "world-writable, for example."
7244 msgstr ""
7246 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7247 #: ../en/ch05-collab.xml:1077
7248 msgid ""
7249 "Your web server may be configured to disallow execution of CGI programs in "
7250 "your per-user web directory. Here's Apache's default per-user configuration "
7251 "from my Fedora system."
7252 msgstr ""
7254 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7255 #: ../en/ch05-collab.xml:1084
7256 msgid ""
7257 "If you find a similar-looking <literal>Directory</literal> group in your "
7258 "Apache configuration, the directive to look at inside it is <literal>Options</"
7259 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
7260 "missing, and restart the web server."
7261 msgstr ""
7263 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7264 #: ../en/ch05-collab.xml:1091
7265 msgid ""
7266 "If you find that Apache serves you the text of the CGI script instead of "
7267 "executing it, you may need to either uncomment (if already present) or add a "
7268 "directive like this."
7269 msgstr ""
7271 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7272 #: ../en/ch05-collab.xml:1097
7273 msgid ""
7274 "The next possibility is that you might be served with a colourful Python "
7275 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
7276 "related module. This is actually progress! The server is now capable of "
7277 "executing your CGI script. This error is only likely to occur if you're "
7278 "running a private installation of Mercurial, instead of a system-wide "
7279 "version. Remember that the web server runs the CGI program without any of "
7280 "the environment variables that you take for granted in an interactive "
7281 "session. If this error happens to you, edit your copy of <filename role="
7282 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
7283 "correctly set your <envar>PYTHONPATH</envar> environment variable."
7284 msgstr ""
7286 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7287 #: ../en/ch05-collab.xml:1111
7288 msgid ""
7289 "Finally, you are <emphasis>certain</emphasis> to by served with another "
7290 "colourful Python backtrace: this one will complain that it can't find "
7291 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
7292 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
7293 "<filename class=\"directory\">/path/to/repository</filename> string with the "
7294 "complete path to the repository you want to serve up."
7295 msgstr ""
7297 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7298 #: ../en/ch05-collab.xml:1121
7299 msgid ""
7300 "At this point, when you try to reload the page, you should be presented with "
7301 "a nice HTML view of your repository's history. Whew!"
7302 msgstr ""
7304 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7305 #: ../en/ch05-collab.xml:1127
7306 msgid "Configuring lighttpd"
7307 msgstr "配置 lighttpd"
7309 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7310 #: ../en/ch05-collab.xml:1129
7311 msgid ""
7312 "To be exhaustive in my experiments, I tried configuring the increasingly "
7313 "popular <literal>lighttpd</literal> web server to serve the same repository "
7314 "as I described with Apache above. I had already overcome all of the problems "
7315 "I outlined with Apache, many of which are not server-specific. As a result, "
7316 "I was fairly sure that my file and directory permissions were good, and that "
7317 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
7318 msgstr ""
7320 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7321 #: ../en/ch05-collab.xml:1139
7322 msgid ""
7323 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
7324 "repository was a snap (in other words, even if you're trying to use "
7325 "<literal>lighttpd</literal>, you should read the Apache section). I first "
7326 "had to edit the <literal>mod_access</literal> section of its config file to "
7327 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
7328 "which were disabled by default on my system. I then added a few lines to the "
7329 "end of the config file, to configure these modules."
7330 msgstr ""
7332 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7333 #: ../en/ch05-collab.xml:1151
7334 msgid ""
7335 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
7336 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
7337 "have run into many of the same system-level configuration problems as I did "
7338 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
7339 "easier to configure than Apache, even though I've used Apache for over a "
7340 "decade, and this was my first exposure to <literal>lighttpd</literal>."
7341 msgstr ""
7343 #. type: Content of: <book><chapter><sect1><sect2><title>
7344 #: ../en/ch05-collab.xml:1164
7345 msgid "Sharing multiple repositories with one CGI script"
7346 msgstr "使用一个 CGI 脚本共享多个版本库"
7348 #. type: Content of: <book><chapter><sect1><sect2><para>
7349 #: ../en/ch05-collab.xml:1166
7350 msgid ""
7351 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
7352 "publish a single repository, which is an annoying restriction. If you want "
7353 "to publish more than one without wracking yourself with multiple copies of "
7354 "the same script, each with different names, a better choice is to use the "
7355 "<filename role=\"special\">hgwebdir.cgi</filename> script."
7356 msgstr ""
7358 #. type: Content of: <book><chapter><sect1><sect2><para>
7359 #: ../en/ch05-collab.xml:1174
7360 msgid ""
7361 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
7362 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
7363 "filename>. First, you must obtain a copy of the script. If you don't have "
7364 "one handy, you can download a copy from the master Mercurial repository at "
7365 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
7366 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
7367 msgstr ""
7369 #. type: Content of: <book><chapter><sect1><sect2><para>
7370 #: ../en/ch05-collab.xml:1189
7371 msgid ""
7372 "With basic configuration out of the way, try to visit <ulink url=\"http://"
7373 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
7374 "ulink> in your browser. It should display an empty list of repositories. If "
7375 "you get a blank window or error message, try walking through the list of "
7376 "potential problems in <xref linkend=\"sec:collab:wtf\"/>."
7377 msgstr ""
7379 #. type: Content of: <book><chapter><sect1><sect2><para>
7380 #: ../en/ch05-collab.xml:1198
7381 msgid ""
7382 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
7383 "external configuration file. By default, it searches for a file named "
7384 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
7385 "itself. You'll need to create this file, and make it world-readable. The "
7386 "format of the file is similar to a Windows <quote>ini</quote> file, as "
7387 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
7388 "configparser</citation> module."
7389 msgstr ""
7391 #. type: Content of: <book><chapter><sect1><sect2><para>
7392 #: ../en/ch05-collab.xml:1208
7393 msgid ""
7394 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
7395 "filename> is with a section named <literal>collections</literal>. This will "
7396 "automatically publish <emphasis>every</emphasis> repository under the "
7397 "directories you name. The section should look like this:"
7398 msgstr ""
7400 #. type: Content of: <book><chapter><sect1><sect2><para>
7401 #: ../en/ch05-collab.xml:1216
7402 msgid ""
7403 "Mercurial interprets this by looking at the directory name on the "
7404 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
7405 "quote> sign; finding repositories in that directory hierarchy; and using the "
7406 "text on the <emphasis>left</emphasis> to strip off matching text from the "
7407 "names it will actually list in the web interface. The remaining component of "
7408 "a path after this stripping has occurred is called a <quote>virtual path</"
7409 "quote>."
7410 msgstr ""
7412 #. type: Content of: <book><chapter><sect1><sect2><para>
7413 #: ../en/ch05-collab.xml:1225
7414 msgid ""
7415 "Given the example above, if we have a repository whose local path is "
7416 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
7417 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
7418 "the name, and publish the repository with a virtual path of <filename class="
7419 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
7420 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
7421 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
7422 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
7423 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
7424 msgstr ""
7426 #. type: Content of: <book><chapter><sect1><sect2><para>
7427 #: ../en/ch05-collab.xml:1239
7428 msgid ""
7429 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
7430 "hand side of this example with <filename class=\"directory\">/my</filename>, "
7431 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
7432 "<filename class=\"directory\">/my</filename> from the repository name, and "
7433 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
7434 "filename> instead of <filename class=\"directory\">this/repo</filename>."
7435 msgstr ""
7437 #. type: Content of: <book><chapter><sect1><sect2><para>
7438 #: ../en/ch05-collab.xml:1249
7439 msgid ""
7440 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
7441 "recursively search each directory listed in the <literal>collections</"
7442 "literal> section of its configuration file, but it will <literal>not</"
7443 "literal> recurse into the repositories it finds."
7444 msgstr ""
7446 #. type: Content of: <book><chapter><sect1><sect2><para>
7447 #: ../en/ch05-collab.xml:1255
7448 msgid ""
7449 "The <literal>collections</literal> mechanism makes it easy to publish many "
7450 "repositories in a <quote>fire and forget</quote> manner. You only need to "
7451 "set up the CGI script and configuration file one time. Afterwards, you can "
7452 "publish or unpublish a repository at any time by simply moving it into, or "
7453 "out of, the directory hierarchy in which you've configured <filename role="
7454 "\"special\">hgwebdir.cgi</filename> to look."
7455 msgstr ""
7457 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7458 #: ../en/ch05-collab.xml:1265
7459 msgid "Explicitly specifying which repositories to publish"
7460 msgstr "明确指出要发布的版本库"
7462 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7463 #: ../en/ch05-collab.xml:1268
7464 msgid ""
7465 "In addition to the <literal>collections</literal> mechanism, the <filename "
7466 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
7467 "specific list of repositories. To do so, create a <literal>paths</literal> "
7468 "section, with contents of the following form."
7469 msgstr ""
7471 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7472 #: ../en/ch05-collab.xml:1277
7473 msgid ""
7474 "In this case, the virtual path (the component that will appear in a URL) is "
7475 "on the left hand side of each definition, while the path to the repository is "
7476 "on the right. Notice that there does not need to be any relationship between "
7477 "the virtual path you choose and the location of a repository in your "
7478 "filesystem."
7479 msgstr ""
7481 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7482 #: ../en/ch05-collab.xml:1284
7483 msgid ""
7484 "If you wish, you can use both the <literal>collections</literal> and "
7485 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
7486 "file."
7487 msgstr ""
7489 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><title>
7490 #: ../en/ch05-collab.xml:1290
7491 msgid "Beware duplicate virtual paths"
7492 msgstr ""
7494 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
7495 #: ../en/ch05-collab.xml:1292
7496 msgid ""
7497 "If several repositories have the same virtual path, <filename role=\"special"
7498 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
7499 "unpredictably."
7500 msgstr ""
7502 #. type: Content of: <book><chapter><sect1><sect2><title>
7503 #: ../en/ch05-collab.xml:1301
7504 msgid "Downloading source archives"
7505 msgstr "下载源代码档案包"
7507 #. type: Content of: <book><chapter><sect1><sect2><para>
7508 #: ../en/ch05-collab.xml:1303
7509 msgid ""
7510 "Mercurial's web interface lets users download an archive of any revision. "
7511 "This archive will contain a snapshot of the working directory as of that "
7512 "revision, but it will not contain a copy of the repository data."
7513 msgstr ""
7515 #. type: Content of: <book><chapter><sect1><sect2><para>
7516 #: ../en/ch05-collab.xml:1308
7517 msgid ""
7518 "By default, this feature is not enabled. To enable it, you'll need to add an "
7519 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
7520 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
7521 "filename>; see below for details."
7522 msgstr ""
7524 #. type: Content of: <book><chapter><sect1><sect2><title>
7525 #: ../en/ch05-collab.xml:1315
7526 msgid "Web configuration options"
7527 msgstr "Web 配置选项"
7529 #. type: Content of: <book><chapter><sect1><sect2><para>
7530 #: ../en/ch05-collab.xml:1317
7531 msgid ""
7532 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
7533 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
7534 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
7535 "configuration options that you can set. These belong in a section named "
7536 "<literal role=\"rc-web\">web</literal>."
7537 msgstr ""
7539 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7540 #: ../en/ch05-collab.xml:1325
7541 msgid ""
7542 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
7543 "archive download mechanisms Mercurial supports. If you enable this feature, "
7544 "users of the web interface will be able to download an archive of whatever "
7545 "revision of a repository they are viewing. To enable the archive feature, "
7546 "this item must take the form of a sequence of words drawn from the list below."
7547 msgstr ""
7549 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7550 #: ../en/ch05-collab.xml:1334
7551 msgid ""
7552 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
7553 "<literal>bzip2</literal> compression. This has the best compression ratio, "
7554 "but uses the most CPU time on the server."
7555 msgstr ""
7557 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7558 #: ../en/ch05-collab.xml:1340
7559 msgid ""
7560 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
7561 "<literal>gzip</literal> compression."
7562 msgstr ""
7564 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7565 #: ../en/ch05-collab.xml:1344
7566 msgid ""
7567 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
7568 "LZW compression. This format has the worst compression ratio, but is widely "
7569 "used in the Windows world."
7570 msgstr ""
7572 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7573 #: ../en/ch05-collab.xml:1350
7574 msgid ""
7575 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
7576 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
7577 "is an example of how to enable all three supported formats."
7578 msgstr ""
7580 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7581 #: ../en/ch05-collab.xml:1357
7582 msgid ""
7583 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
7584 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
7585 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
7586 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
7587 "<quote>human-oriented</quote> portion of the web interface is available."
7588 msgstr ""
7590 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7591 #: ../en/ch05-collab.xml:1366
7592 msgid ""
7593 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
7594 "preferably brief) string identifying the person or group in charge of the "
7595 "repository. This often contains the name and email address of a person or "
7596 "mailing list. It often makes sense to place this entry in a repository's own "
7597 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
7598 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
7599 "repository has a single maintainer."
7600 msgstr ""
7602 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7603 #: ../en/ch05-collab.xml:1377
7604 msgid ""
7605 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
7606 "number of changesets to display in a single page of output."
7607 msgstr ""
7609 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7610 #: ../en/ch05-collab.xml:1381
7611 msgid ""
7612 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
7613 "number of modified files to display in a single page of output."
7614 msgstr ""
7616 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7617 #: ../en/ch05-collab.xml:1385
7618 msgid ""
7619 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
7620 "displays alternating <quote>stripes</quote> to make it easier to visually "
7621 "align rows when you are looking at a table, this number controls the number "
7622 "of rows in each stripe."
7623 msgstr ""
7625 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7626 #: ../en/ch05-collab.xml:1391
7627 msgid ""
7628 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
7629 "uses to display the web interface. Mercurial ships with several web "
7630 "templates."
7631 msgstr ""
7633 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7634 #: ../en/ch05-collab.xml:1397
7635 msgid "<literal>coal</literal> is monochromatic."
7636 msgstr ""
7638 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7639 #: ../en/ch05-collab.xml:1400
7640 msgid ""
7641 "<literal>gitweb</literal> emulates the visual style of git's web interface."
7642 msgstr ""
7644 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7645 #: ../en/ch05-collab.xml:1404
7646 msgid "<literal>monoblue</literal> uses solid blues and greys."
7647 msgstr ""
7649 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7650 #: ../en/ch05-collab.xml:1408
7651 msgid "<literal>paper</literal> is the default."
7652 msgstr ""
7654 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7655 #: ../en/ch05-collab.xml:1411
7656 msgid "<literal>spartan</literal> was the default for a long time."
7657 msgstr ""
7659 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7660 #: ../en/ch05-collab.xml:1415
7661 msgid ""
7662 "You can also specify a custom template of your own; see <xref linkend=\"chap:"
7663 "template\"/> for details. Here, you can see how to enable the "
7664 "<literal>gitweb</literal> style."
7665 msgstr ""
7667 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7668 #: ../en/ch05-collab.xml:1423
7669 msgid ""
7670 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
7671 "to search for template files. By default, Mercurial searches in the "
7672 "directory in which it was installed."
7673 msgstr ""
7675 #. type: Content of: <book><chapter><sect1><sect2><para>
7676 #: ../en/ch05-collab.xml:1428
7677 msgid ""
7678 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
7679 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
7680 "section of the <filename role=\"special\">hgweb.config</filename> file "
7681 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
7682 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
7683 "<envar role=\"rc-item-web\">style</envar>."
7684 msgstr ""
7686 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7687 #: ../en/ch05-collab.xml:1439
7688 msgid "Options specific to an individual repository"
7689 msgstr "针对单个版本库的选项"
7691 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7692 #: ../en/ch05-collab.xml:1441
7693 msgid ""
7694 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
7695 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
7696 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
7697 "filename>."
7698 msgstr ""
7700 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7701 #: ../en/ch05-collab.xml:1446
7702 msgid ""
7703 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
7704 "preferably brief) string that describes the contents or purpose of the "
7705 "repository."
7706 msgstr ""
7708 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7709 #: ../en/ch05-collab.xml:1451
7710 msgid ""
7711 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
7712 "repository in the web interface. This overrides the default name, which is "
7713 "the last component of the repository's path."
7714 msgstr ""
7716 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7717 #: ../en/ch05-collab.xml:1459
7718 msgid ""
7719 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
7720 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
7722 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7723 #: ../en/ch05-collab.xml:1462
7724 msgid ""
7725 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
7726 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
7727 "<command role=\"hg-cmd\">hg serve</command> command."
7728 msgstr ""
7730 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7731 #: ../en/ch05-collab.xml:1468
7732 msgid ""
7733 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
7734 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
7735 "serve</command> command writes this information to standard output, not to a "
7736 "file. Log entries are written in the standard <quote>combined</quote> file "
7737 "format used by almost all web servers."
7738 msgstr ""
7740 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7741 #: ../en/ch05-collab.xml:1476
7742 msgid ""
7743 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
7744 "which the server should listen for incoming connections. By default, the "
7745 "server listens on all addresses."
7746 msgstr ""
7748 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7749 #: ../en/ch05-collab.xml:1481
7750 msgid ""
7751 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
7752 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
7753 "serve</command> command writes this information to standard error, not to a "
7754 "file."
7755 msgstr ""
7757 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7758 #: ../en/ch05-collab.xml:1487
7759 msgid ""
7760 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
7761 "protocol. By default, IPv6 is not used."
7762 msgstr ""
7764 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7765 #: ../en/ch05-collab.xml:1491
7766 msgid ""
7767 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
7768 "which the server should listen. The default port number used is 8000."
7769 msgstr ""
7771 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7772 #: ../en/ch05-collab.xml:1498
7773 msgid ""
7774 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
7775 "<literal role=\"rc-web\">web</literal> items to"
7776 msgstr ""
7777 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
7778 "role=\"rc-web\">web</literal> 条目"
7780 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7781 #: ../en/ch05-collab.xml:1502
7782 msgid ""
7783 "It is important to remember that a web server like Apache or "
7784 "<literal>lighttpd</literal> will run under a user ID that is different to "
7785 "yours. CGI scripts run by your server, such as <filename role=\"special"
7786 "\">hgweb.cgi</filename>, will usually also run under that user ID."
7787 msgstr ""
7789 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7790 #: ../en/ch05-collab.xml:1509
7791 msgid ""
7792 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
7793 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
7794 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
7795 "thus only affect the behavior of the <command role=\"hg-cmd\">hg serve</"
7796 "command> command when you run it. To cause CGI scripts to see your settings, "
7797 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
7798 "home directory of the user ID that runs your web server, or add those "
7799 "settings to a system-wide <filename role=\"special\">hgrc</filename> file."
7800 msgstr ""
7802 #. type: Content of: <book><chapter><sect1><title>
7803 #: ../en/ch05-collab.xml:1524
7804 msgid "System-wide configuration"
7805 msgstr "全局配置"
7807 #. type: Content of: <book><chapter><sect1><para>
7808 #: ../en/ch05-collab.xml:1526
7809 msgid ""
7810 "On Unix-like systems shared by multiple users (such as a server to which "
7811 "people publish changes), it often makes sense to set up some global default "
7812 "behaviors, such as what theme to use in web interfaces."
7813 msgstr ""
7815 #. type: Content of: <book><chapter><sect1><para>
7816 #: ../en/ch05-collab.xml:1531
7817 msgid ""
7818 "If a file named <filename>/etc/mercurial/hgrc</filename> exists, Mercurial "
7819 "will read it at startup time and apply any configuration settings it finds in "
7820 "that file. It will also look for files ending in a <literal>.rc</literal> "
7821 "extension in a directory named <filename>/etc/mercurial/hgrc.d</filename>, "
7822 "and apply any configuration settings it finds in each of those files."
7823 msgstr ""
7825 #. type: Content of: <book><chapter><sect1><sect2><title>
7826 #: ../en/ch05-collab.xml:1540
7827 msgid "Making Mercurial more trusting"
7828 msgstr "让 Mercurial 更可信"
7830 #. type: Content of: <book><chapter><sect1><sect2><para>
7831 #: ../en/ch05-collab.xml:1542
7832 msgid ""
7833 "One situation in which a global <filename>hgrc</filename> can be useful is if "
7834 "users are pulling changes owned by other users. By default, Mercurial will "
7835 "not trust most of the configuration items in a <filename>.hg/hgrc</filename> "
7836 "file inside a repository that is owned by a different user. If we clone or "
7837 "pull changes from such a repository, Mercurial will print a warning stating "
7838 "that it does not trust their <filename>.hg/hgrc</filename>."
7839 msgstr ""
7841 #. type: Content of: <book><chapter><sect1><sect2><para>
7842 #: ../en/ch05-collab.xml:1551
7843 msgid ""
7844 "If everyone in a particular Unix group is on the same team and "
7845 "<emphasis>should</emphasis> trust each other's configuration settings, or we "
7846 "want to trust particular users, we can override Mercurial's skeptical "
7847 "defaults by creating a system-wide <filename>hgrc</filename> file such as the "
7848 "following:"
7849 msgstr ""
7851 #. type: Content of: <book><chapter><title>
7852 #: ../en/ch06-filenames.xml:5
7853 msgid "File names and pattern matching"
7854 msgstr "文件名称与模式匹配"
7856 #. type: Content of: <book><chapter><para>
7857 #: ../en/ch06-filenames.xml:7
7858 msgid ""
7859 "Mercurial provides mechanisms that let you work with file names in a "
7860 "consistent and expressive way."
7861 msgstr ""
7863 #. type: Content of: <book><chapter><sect1><title>
7864 #: ../en/ch06-filenames.xml:11
7865 msgid "Simple file naming"
7866 msgstr "简单文件名称"
7868 #. type: Content of: <book><chapter><sect1><para>
7869 #: ../en/ch06-filenames.xml:13
7870 msgid ""
7871 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
7872 "handle file names. Every command behaves uniformly with respect to file "
7873 "names. The way in which commands work with file names is as follows."
7874 msgstr ""
7876 #. type: Content of: <book><chapter><sect1><para>
7877 #: ../en/ch06-filenames.xml:18
7878 msgid ""
7879 "If you explicitly name real files on the command line, Mercurial works with "
7880 "exactly those files, as you would expect. &interaction.filenames.files;"
7881 msgstr ""
7884 #. type: Content of: <book><chapter><sect1><para>
7885 #: ../en/ch06-filenames.xml:22
7886 msgid ""
7887 "When you provide a directory name, Mercurial will interpret this as "
7888 "<quote>operate on every file in this directory and its subdirectories</"
7889 "quote>. Mercurial traverses the files and subdirectories in a directory in "
7890 "alphabetical order. When it encounters a subdirectory, it will traverse that "
7891 "subdirectory before continuing with the current directory."
7892 msgstr ""
7894 #. type: Content of: <book><chapter><sect1><title>
7895 #: ../en/ch06-filenames.xml:33
7896 msgid "Running commands without any file names"
7897 msgstr "不提供文件名称的执行命令"
7899 #. type: Content of: <book><chapter><sect1><para>
7900 #: ../en/ch06-filenames.xml:35
7901 msgid ""
7902 "Mercurial's commands that work with file names have useful default behaviors "
7903 "when you invoke them without providing any file names or patterns. What kind "
7904 "of behavior you should expect depends on what the command does. Here are a "
7905 "few rules of thumb you can use to predict what a command is likely to do if "
7906 "you don't give it any names to work with."
7907 msgstr ""
7909 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7910 #: ../en/ch06-filenames.xml:42
7911 msgid ""
7912 "Most commands will operate on the entire working directory. This is what the "
7913 "<command role=\"hg-cmd\">hg add</command> command does, for example."
7914 msgstr ""
7916 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7917 #: ../en/ch06-filenames.xml:46
7918 msgid ""
7919 "If the command has effects that are difficult or impossible to reverse, it "
7920 "will force you to explicitly provide at least one name or pattern (see "
7921 "below). This protects you from accidentally deleting files by running "
7922 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
7923 msgstr ""
7925 #. type: Content of: <book><chapter><sect1><para>
7926 #: ../en/ch06-filenames.xml:54
7927 msgid ""
7928 "It's easy to work around these default behaviors if they don't suit you. If "
7929 "a command normally operates on the whole working directory, you can invoke it "
7930 "on just the current directory and its subdirectories by giving it the name "
7931 "<quote><filename class=\"directory\">.</filename></quote>."
7932 msgstr ""
7935 #. type: Content of: <book><chapter><sect1><para>
7936 #: ../en/ch06-filenames.xml:62
7937 msgid ""
7938 "Along the same lines, some commands normally print file names relative to the "
7939 "root of the repository, even if you're invoking them from a subdirectory. "
7940 "Such a command will print file names relative to your subdirectory if you "
7941 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
7942 "status</command> from a subdirectory, and get it to operate on the entire "
7943 "working directory while printing file names relative to our subdirectory, by "
7944 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
7945 "command."
7946 msgstr ""
7948 #. type: Content of: <book><chapter><sect1><title>
7949 #: ../en/ch06-filenames.xml:76
7950 msgid "Telling you what's going on"
7951 msgstr "告诉你正在做什么"
7953 #. type: Content of: <book><chapter><sect1><para>
7954 #: ../en/ch06-filenames.xml:78
7955 msgid ""
7956 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
7957 "section illustrates something else that's helpful about Mercurial commands. "
7958 "If a command operates on a file that you didn't name explicitly on the "
7959 "command line, it will usually print the name of the file, so that you will "
7960 "not be surprised what's going on."
7961 msgstr ""
7963 #. type: Content of: <book><chapter><sect1><para>
7964 #: ../en/ch06-filenames.xml:85
7965 msgid ""
7966 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
7967 "exactly named a file on the command line, there's no point in repeating it "
7968 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
7969 "emphasis>, e.g. because you provided no names, or a directory, or a pattern "
7970 "(see below), it is safest to tell you what files it's operating on."
7971 msgstr ""
7973 #. type: Content of: <book><chapter><sect1><para>
7974 #: ../en/ch06-filenames.xml:92
7975 msgid ""
7976 "For commands that behave this way, you can silence them using the <option "
7977 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
7978 "the name of every file, even those you've named explicitly, using the <option "
7979 "role=\"hg-opt-global\">-v</option> option."
7980 msgstr ""
7982 #. type: Content of: <book><chapter><sect1><title>
7983 #: ../en/ch06-filenames.xml:100
7984 msgid "Using patterns to identify files"
7985 msgstr "使用模式标识文件"
7987 #. type: Content of: <book><chapter><sect1><para>
7988 #: ../en/ch06-filenames.xml:102
7989 msgid ""
7990 "In addition to working with file and directory names, Mercurial lets you use "
7991 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
7992 "handling is expressive."
7993 msgstr ""
7995 #. type: Content of: <book><chapter><sect1><para>
7996 #: ../en/ch06-filenames.xml:106
7997 msgid ""
7998 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
7999 "patterns normally falls to the shell. On these systems, you must explicitly "
8000 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
8001 "expand patterns, so Mercurial will automatically identify names that are "
8002 "patterns, and expand them for you."
8003 msgstr ""
8005 #. type: Content of: <book><chapter><sect1><para>
8006 #: ../en/ch06-filenames.xml:113
8007 msgid ""
8008 "To provide a pattern in place of a regular name on the command line, the "
8009 "mechanism is simple:"
8010 msgstr ""
8012 #. type: Content of: <book><chapter><sect1><para>
8013 #: ../en/ch06-filenames.xml:116
8014 msgid ""
8015 "That is, a pattern is identified by a short text string that says what kind "
8016 "of pattern this is, followed by a colon, followed by the actual pattern."
8017 msgstr ""
8019 #. type: Content of: <book><chapter><sect1><para>
8020 #: ../en/ch06-filenames.xml:120
8021 msgid ""
8022 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
8023 "called <literal>glob</literal>; this is the same kind of pattern matching "
8024 "used by the Unix shell, and should be familiar to Windows command prompt "
8025 "users, too."
8026 msgstr ""
8028 #. type: Content of: <book><chapter><sect1><para>
8029 #: ../en/ch06-filenames.xml:125
8030 msgid ""
8031 "When Mercurial does automatic pattern matching on Windows, it uses "
8032 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
8033 "literal></quote> prefix on Windows, but it's safe to use it, too."
8034 msgstr ""
8036 #. type: Content of: <book><chapter><sect1><para>
8037 #: ../en/ch06-filenames.xml:130
8038 msgid ""
8039 "The <literal>re</literal> syntax is more powerful; it lets you specify "
8040 "patterns using regular expressions, also known as regexps."
8041 msgstr ""
8043 #. type: Content of: <book><chapter><sect1><para>
8044 #: ../en/ch06-filenames.xml:134
8045 msgid ""
8046 "By the way, in the examples that follow, notice that I'm careful to wrap all "
8047 "of my patterns in quote characters, so that they won't get expanded by the "
8048 "shell before Mercurial sees them."
8049 msgstr ""
8051 #. type: Content of: <book><chapter><sect1><sect2><title>
8052 #: ../en/ch06-filenames.xml:140
8053 msgid "Shell-style <literal>glob</literal> patterns"
8054 msgstr "外壳风格的 <literal>glob</literal> 模式"
8056 #. type: Content of: <book><chapter><sect1><sect2><para>
8057 #: ../en/ch06-filenames.xml:142
8058 msgid ""
8059 "This is an overview of the kinds of patterns you can use when you're matching "
8060 "on glob patterns."
8061 msgstr ""
8064 #. type: Content of: <book><chapter><sect1><sect2><para>
8065 #: ../en/ch06-filenames.xml:145
8066 msgid ""
8067 "The <quote><literal>*</literal></quote> character matches any string, within "
8068 "a single directory."
8069 msgstr ""
8072 #. type: Content of: <book><chapter><sect1><sect2><para>
8073 #: ../en/ch06-filenames.xml:150
8074 msgid ""
8075 "The <quote><literal>**</literal></quote> pattern matches any string, and "
8076 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
8077 "accepted by several popular Unix shells, and is very useful."
8078 msgstr ""
8081 #. type: Content of: <book><chapter><sect1><sect2><para>
8082 #: ../en/ch06-filenames.xml:157
8083 msgid ""
8084 "The <quote><literal>?</literal></quote> pattern matches any single character."
8085 msgstr ""
8087 #. type: Content of: <book><chapter><sect1><sect2><para>
8088 #: ../en/ch06-filenames.xml:162
8089 msgid ""
8090 "The <quote><literal>[</literal></quote> character begins a "
8091 "<emphasis>character class</emphasis>. This matches any single character "
8092 "within the class. The class ends with a <quote><literal>]</literal></quote> "
8093 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
8094 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
8095 "<quote><literal>abcdef</literal></quote>."
8096 msgstr ""
8098 #. type: Content of: <book><chapter><sect1><sect2><para>
8099 #: ../en/ch06-filenames.xml:172
8100 msgid ""
8101 "If the first character after the <quote><literal>[</literal></quote> in a "
8102 "character class is a <quote><literal>!</literal></quote>, it "
8103 "<emphasis>negates</emphasis> the class, making it match any single character "
8104 "not in the class."
8105 msgstr ""
8107 #. type: Content of: <book><chapter><sect1><sect2><para>
8108 #: ../en/ch06-filenames.xml:178
8109 msgid ""
8110 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
8111 "the whole group matches if any subpattern in the group matches. The "
8112 "<quote><literal>,</literal></quote> character separates subpatterns, and "
8113 "<quote><literal>}</literal></quote> ends the group."
8114 msgstr ""
8116 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8117 #: ../en/ch06-filenames.xml:187
8118 msgid "Watch out!"
8119 msgstr "千万小心!"
8122 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8123 #: ../en/ch06-filenames.xml:189
8124 msgid ""
8125 "Don't forget that if you want to match a pattern in any directory, you should "
8126 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
8127 "will only match within one directory. Instead, use the <quote><literal>**</"
8128 "literal></quote> token. This small example illustrates the difference "
8129 "between the two."
8130 msgstr ""
8132 #. type: Content of: <book><chapter><sect1><sect2><title>
8133 #: ../en/ch06-filenames.xml:201
8134 msgid "Regular expression matching with <literal>re</literal> patterns"
8135 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
8137 #. type: Content of: <book><chapter><sect1><sect2><para>
8138 #: ../en/ch06-filenames.xml:204
8139 msgid ""
8140 "Mercurial accepts the same regular expression syntax as the Python "
8141 "programming language (it uses Python's regexp engine internally). This is "
8142 "based on the Perl language's regexp syntax, which is the most popular dialect "
8143 "in use (it's also used in Java, for example)."
8144 msgstr ""
8146 #. type: Content of: <book><chapter><sect1><sect2><para>
8147 #: ../en/ch06-filenames.xml:210
8148 msgid ""
8149 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
8150 "not often used. Perl-style regexps are in any case already exhaustively "
8151 "documented on a multitude of web sites, and in many books. Instead, I will "
8152 "focus here on a few things you should know if you find yourself needing to "
8153 "use regexps with Mercurial."
8154 msgstr ""
8156 #. type: Content of: <book><chapter><sect1><sect2><para>
8157 #: ../en/ch06-filenames.xml:217
8158 msgid ""
8159 "A regexp is matched against an entire file name, relative to the root of the "
8160 "repository. In other words, even if you're already in subbdirectory "
8161 "<filename class=\"directory\">foo</filename>, if you want to match files "
8162 "under this directory, your pattern must start with <quote><literal>foo/</"
8163 "literal></quote>."
8164 msgstr ""
8166 #. type: Content of: <book><chapter><sect1><sect2><para>
8167 #: ../en/ch06-filenames.xml:224
8168 msgid ""
8169 "One thing to note, if you're familiar with Perl-style regexps, is that "
8170 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
8171 "matching against the beginning of a string; it doesn't look for a match "
8172 "anywhere within the string. To match anywhere in a string, start your "
8173 "pattern with <quote><literal>.*</literal></quote>."
8174 msgstr ""
8176 #. type: Content of: <book><chapter><sect1><title>
8177 #: ../en/ch06-filenames.xml:234
8178 msgid "Filtering files"
8179 msgstr "过滤文件"
8181 #. type: Content of: <book><chapter><sect1><para>
8182 #: ../en/ch06-filenames.xml:236
8183 msgid ""
8184 "Not only does Mercurial give you a variety of ways to specify files; it lets "
8185 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
8186 "that work with file names accept two filtering options."
8187 msgstr ""
8189 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8190 #: ../en/ch06-filenames.xml:241
8191 msgid ""
8192 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
8193 "\">--include</option>, lets you specify a pattern that file names must match "
8194 "in order to be processed."
8195 msgstr ""
8197 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8198 #: ../en/ch06-filenames.xml:246
8199 msgid ""
8200 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
8201 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
8202 "processing files, if they match this pattern."
8203 msgstr ""
8205 #. type: Content of: <book><chapter><sect1><para>
8206 #: ../en/ch06-filenames.xml:251
8207 msgid ""
8208 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
8209 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
8210 "intermix them as you please. Mercurial interprets the patterns you provide "
8211 "using glob syntax by default (but you can use regexps if you need to)."
8212 msgstr ""
8214 #. type: Content of: <book><chapter><sect1><para>
8215 #: ../en/ch06-filenames.xml:258
8216 msgid ""
8217 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
8218 "<quote>process only the files that match this filter</quote>."
8219 msgstr ""
8221 #. type: Content of: <book><chapter><sect1><para>
8222 #: ../en/ch06-filenames.xml:264
8223 msgid ""
8224 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
8225 "<quote>process only the files that don't match this pattern</quote>."
8226 msgstr ""
8228 #. type: Content of: <book><chapter><sect1><title>
8229 #: ../en/ch06-filenames.xml:272
8230 msgid "Permanently ignoring unwanted files and directories"
8231 msgstr "始终忽略不需要的文件和目录"
8233 #. type: Content of: <book><chapter><sect1><para>
8234 #: ../en/ch06-filenames.xml:274
8235 msgid ""
8236 "When you create a new repository, the chances are that over time it will grow "
8237 "to contain files that ought to <emphasis>not</emphasis> be managed by "
8238 "Mercurial, but which you don't want to see listed every time you run "
8239 "<command>hg status</command>. For instance, <quote>build products</quote> "
8240 "are files that are created as part of a build but which should not be managed "
8241 "by a revision control system. The most common build products are output "
8242 "files produced by software tools such as compilers. As another example, many "
8243 "text editors litter a directory with lock files, temporary working files, and "
8244 "backup files, which it also makes no sense to manage."
8245 msgstr ""
8247 #. type: Content of: <book><chapter><sect1><para>
8248 #: ../en/ch06-filenames.xml:286
8249 msgid ""
8250 "To have Mercurial permanently ignore such files, create a file named "
8251 "<filename>.hgignore</filename> in the root of your repository. You "
8252 "<emphasis>should</emphasis> <command>hg add</command> this file so that it "
8253 "gets tracked with the rest of your repository contents, since your "
8254 "collaborators will probably find it useful too."
8255 msgstr ""
8257 #. type: Content of: <book><chapter><sect1><para>
8258 #: ../en/ch06-filenames.xml:293
8259 msgid ""
8260 "By default, the <filename>.hgignore</filename> file should contain a list of "
8261 "regular expressions, one per line. Empty lines are skipped. Most people "
8262 "prefer to describe the files they want to ignore using the <quote>glob</"
8263 "quote> syntax that we described above, so a typical <filename>.hgignore</"
8264 "filename> file will start with this directive:"
8265 msgstr ""
8267 #. type: Content of: <book><chapter><sect1><para>
8268 #: ../en/ch06-filenames.xml:302
8269 msgid ""
8270 "This tells Mercurial to interpret the lines that follow as glob patterns, not "
8271 "regular expressions."
8272 msgstr ""
8274 #. type: Content of: <book><chapter><sect1><para>
8275 #: ../en/ch06-filenames.xml:305
8276 msgid "Here is a typical-looking <filename>.hgignore</filename> file."
8277 msgstr ""
8279 #. type: Content of: <book><chapter><sect1><title>
8280 #: ../en/ch06-filenames.xml:329
8281 msgid "Case sensitivity"
8282 msgstr "大小写敏感性"
8284 #. type: Content of: <book><chapter><sect1><para>
8285 #: ../en/ch06-filenames.xml:331
8286 msgid ""
8287 "If you're working in a mixed development environment that contains both Linux "
8288 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
8289 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
8290 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
8291 "very likely to affect you, and it's easy to deal with if it does, but it "
8292 "could surprise you if you don't know about it."
8293 msgstr ""
8295 #. type: Content of: <book><chapter><sect1><para>
8296 #: ../en/ch06-filenames.xml:340
8297 msgid ""
8298 "Operating systems and filesystems differ in the way they handle the "
8299 "<emphasis>case</emphasis> of characters in file and directory names. There "
8300 "are three common ways to handle case in names."
8301 msgstr ""
8303 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8304 #: ../en/ch06-filenames.xml:345
8305 msgid ""
8306 "Completely case insensitive. Uppercase and lowercase versions of a letter "
8307 "are treated as identical, both when creating a file and during subsequent "
8308 "accesses. This is common on older DOS-based systems."
8309 msgstr ""
8311 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8312 #: ../en/ch06-filenames.xml:350
8313 msgid ""
8314 "Case preserving, but insensitive. When a file or directory is created, the "
8315 "case of its name is stored, and can be retrieved and displayed by the "
8316 "operating system. When an existing file is being looked up, its case is "
8317 "ignored. This is the standard arrangement on Windows and MacOS. The names "
8318 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
8319 "file. This treatment of uppercase and lowercase letters as interchangeable "
8320 "is also referred to as <emphasis>case folding</emphasis>."
8321 msgstr ""
8323 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8324 #: ../en/ch06-filenames.xml:361
8325 msgid ""
8326 "Case sensitive. The case of a name is significant at all times. The names "
8327 "<filename>foo</filename> and {FoO} identify different files. This is the way "
8328 "Linux and Unix systems normally work."
8329 msgstr ""
8331 #. type: Content of: <book><chapter><sect1><para>
8332 #: ../en/ch06-filenames.xml:367
8333 msgid ""
8334 "On Unix-like systems, it is possible to have any or all of the above ways of "
8335 "handling case in action at once. For example, if you use a USB thumb drive "
8336 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
8337 "on that filesystem in a case preserving, but insensitive, way."
8338 msgstr ""
8340 #. type: Content of: <book><chapter><sect1><sect2><title>
8341 #: ../en/ch06-filenames.xml:374
8342 msgid "Safe, portable repository storage"
8343 msgstr "安全,可移植的版本库存储"
8345 #. type: Content of: <book><chapter><sect1><sect2><para>
8346 #: ../en/ch06-filenames.xml:376
8347 msgid ""
8348 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
8349 "It translates file names so that they can be safely stored on both case "
8350 "sensitive and case insensitive filesystems. This means that you can use "
8351 "normal file copying tools to transfer a Mercurial repository onto, for "
8352 "example, a USB thumb drive, and safely move that drive and repository back "
8353 "and forth between a Mac, a PC running Windows, and a Linux box."
8354 msgstr ""
8356 #. type: Content of: <book><chapter><sect1><sect2><title>
8357 #: ../en/ch06-filenames.xml:387
8358 msgid "Detecting case conflicts"
8359 msgstr "检测大小写冲突"
8361 #. type: Content of: <book><chapter><sect1><sect2><para>
8362 #: ../en/ch06-filenames.xml:389
8363 msgid ""
8364 "When operating in the working directory, Mercurial honours the naming policy "
8365 "of the filesystem where the working directory is located. If the filesystem "
8366 "is case preserving, but insensitive, Mercurial will treat names that differ "
8367 "only in case as the same."
8368 msgstr ""
8370 #. type: Content of: <book><chapter><sect1><sect2><para>
8371 #: ../en/ch06-filenames.xml:395
8372 msgid ""
8373 "An important aspect of this approach is that it is possible to commit a "
8374 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
8375 "cause trouble for users on case insensitive (usually Windows and MacOS) "
8376 "users. If a Linux user commits changes to two files, one named "
8377 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
8378 "filename>, they will be stored correctly in the repository. And in the "
8379 "working directories of other Linux users, they will be correctly represented "
8380 "as separate files."
8381 msgstr ""
8383 #. type: Content of: <book><chapter><sect1><sect2><para>
8384 #: ../en/ch06-filenames.xml:406
8385 msgid ""
8386 "If a Windows or Mac user pulls this change, they will not initially have a "
8387 "problem, because Mercurial's repository storage mechanism is case safe. "
8388 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
8389 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
8390 "command> with that changeset, Mercurial will spot the conflict between the "
8391 "two file names that the filesystem would treat as the same, and forbid the "
8392 "update or merge from occurring."
8393 msgstr ""
8395 #. type: Content of: <book><chapter><sect1><sect2><title>
8396 #: ../en/ch06-filenames.xml:418
8397 msgid "Fixing a case conflict"
8398 msgstr "修正大小写冲突"
8400 #. type: Content of: <book><chapter><sect1><sect2><para>
8401 #: ../en/ch06-filenames.xml:420
8402 msgid ""
8403 "If you are using Windows or a Mac in a mixed environment where some of your "
8404 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
8405 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
8406 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
8407 "is simple."
8408 msgstr ""
8410 #. type: Content of: <book><chapter><sect1><sect2><para>
8411 #: ../en/ch06-filenames.xml:427
8412 msgid ""
8413 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
8414 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
8415 "change the names of any offending files or directories so that they will no "
8416 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
8417 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
8418 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
8419 "update</command> to the revision with the non-conflicting names."
8420 msgstr ""
8422 #. type: Content of: <book><chapter><sect1><sect2><para>
8423 #: ../en/ch06-filenames.xml:437
8424 msgid ""
8425 "The changeset with case-conflicting names will remain in your project's "
8426 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
8427 "command> your working directory to that changeset on a Windows or MacOS "
8428 "system, but you can continue development unimpeded."
8429 msgstr ""
8431 #. type: Content of: <book><chapter><title>
8432 #: ../en/ch07-branch.xml:5
8433 msgid "Managing releases and branchy development"
8434 msgstr "发布管理与分支开发"
8436 #. type: Content of: <book><chapter><para>
8437 #: ../en/ch07-branch.xml:7
8438 msgid ""
8439 "Mercurial provides several mechanisms for you to manage a project that is "
8440 "making progress on multiple fronts at once. To understand these mechanisms, "
8441 "let's first take a brief look at a fairly normal software project structure."
8442 msgstr ""
8444 #. type: Content of: <book><chapter><para>
8445 #: ../en/ch07-branch.xml:12
8446 msgid ""
8447 "Many software projects issue periodic <quote>major</quote> releases that "
8448 "contain substantial new features. In parallel, they may issue <quote>minor</"
8449 "quote> releases. These are usually identical to the major releases off which "
8450 "they're based, but with a few bugs fixed."
8451 msgstr ""
8453 #. type: Content of: <book><chapter><para>
8454 #: ../en/ch07-branch.xml:18
8455 msgid ""
8456 "In this chapter, we'll start by talking about how to keep records of project "
8457 "milestones such as releases. We'll then continue on to talk about the flow "
8458 "of work between different phases of a project, and how Mercurial can help you "
8459 "to isolate and manage this work."
8460 msgstr ""
8462 #. type: Content of: <book><chapter><sect1><title>
8463 #: ../en/ch07-branch.xml:25
8464 msgid "Giving a persistent name to a revision"
8465 msgstr "给版本指定一个永久的名称"
8467 #. type: Content of: <book><chapter><sect1><para>
8468 #: ../en/ch07-branch.xml:27
8469 msgid ""
8470 "Once you decide that you'd like to call a particular revision a "
8471 "<quote>release</quote>, it's a good idea to record the identity of that "
8472 "revision. This will let you reproduce that release at a later date, for "
8473 "whatever purpose you might need at the time (reproducing a bug, porting to a "
8474 "new platform, etc). &interaction.tag.init;"
8475 msgstr ""
8478 #. type: Content of: <book><chapter><sect1><para>
8479 #: ../en/ch07-branch.xml:34
8480 msgid ""
8481 "Mercurial lets you give a permanent name to any revision using the <command "
8482 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
8483 "called <quote>tags</quote>."
8484 msgstr ""
8486 #. type: Content of: <book><chapter><sect1><para>
8487 #: ../en/ch07-branch.xml:40
8488 msgid ""
8489 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
8490 "Tags exist purely for your convenience, so that you have a handy permanent "
8491 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
8492 "in any way. Neither does Mercurial place any restrictions on the name of a "
8493 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
8494 "unambiguously. A tag name cannot contain any of the following characters:"
8495 msgstr ""
8497 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8498 #: ../en/ch07-branch.xml:49
8499 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
8500 msgstr ""
8502 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8503 #: ../en/ch07-branch.xml:52
8504 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
8505 msgstr ""
8507 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8508 #: ../en/ch07-branch.xml:55
8509 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
8510 msgstr ""
8512 #. type: Content of: <book><chapter><sect1><para>
8513 #: ../en/ch07-branch.xml:59
8514 msgid ""
8515 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
8516 "the tags present in your repository. In the output, each tagged revision is "
8517 "identified first by its name, then by revision number, and finally by the "
8518 "unique hash of the revision."
8519 msgstr ""
8521 #. type: Content of: <book><chapter><sect1><para>
8522 #: ../en/ch07-branch.xml:67
8523 msgid ""
8524 "Notice that <literal>tip</literal> is listed in the output of <command role="
8525 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
8526 "<quote>floating</quote> tag, which always identifies the newest revision in "
8527 "the repository."
8528 msgstr ""
8530 #. type: Content of: <book><chapter><sect1><para>
8531 #: ../en/ch07-branch.xml:73
8532 msgid ""
8533 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
8534 "are listed in reverse order, by revision number. This usually means that "
8535 "recent tags are listed before older tags. It also means that <literal>tip</"
8536 "literal> is always going to be the first tag listed in the output of <command "
8537 "role=\"hg-cmd\">hg tags</command>."
8538 msgstr ""
8540 #. type: Content of: <book><chapter><sect1><para>
8541 #: ../en/ch07-branch.xml:80
8542 msgid ""
8543 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
8544 "revision that has tags associated with it, it will print those tags."
8545 msgstr ""
8548 #. type: Content of: <book><chapter><sect1><para>
8549 #: ../en/ch07-branch.xml:86
8550 msgid ""
8551 "Any time you need to provide a revision ID to a Mercurial command, the "
8552 "command will accept a tag name in its place. Internally, Mercurial will "
8553 "translate your tag name into the corresponding revision ID, then use that."
8554 msgstr ""
8556 #. type: Content of: <book><chapter><sect1><para>
8557 #: ../en/ch07-branch.xml:93
8558 msgid ""
8559 "There's no limit on the number of tags you can have in a repository, or on "
8560 "the number of tags that a single revision can have. As a practical matter, "
8561 "it's not a great idea to have <quote>too many</quote> (a number which will "
8562 "vary from project to project), simply because tags are supposed to help you "
8563 "to find revisions. If you have lots of tags, the ease of using them to "
8564 "identify revisions diminishes rapidly."
8565 msgstr ""
8567 #. type: Content of: <book><chapter><sect1><para>
8568 #: ../en/ch07-branch.xml:101
8569 msgid ""
8570 "For example, if your project has milestones as frequent as every few days, "
8571 "it's perfectly reasonable to tag each one of those. But if you have a "
8572 "continuous build system that makes sure every revision can be built cleanly, "
8573 "you'd be introducing a lot of noise if you were to tag every clean build. "
8574 "Instead, you could tag failed builds (on the assumption that they're rare!), "
8575 "or simply not use tags to track buildability."
8576 msgstr ""
8578 #. type: Content of: <book><chapter><sect1><para>
8579 #: ../en/ch07-branch.xml:109
8580 msgid ""
8581 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
8582 "cmd\">hg tag --remove</command>."
8583 msgstr ""
8585 #. type: Content of: <book><chapter><sect1><para>
8586 #: ../en/ch07-branch.xml:114
8587 msgid ""
8588 "You can also modify a tag at any time, so that it identifies a different "
8589 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
8590 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
8591 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
8592 "the tag."
8593 msgstr ""
8595 #. type: Content of: <book><chapter><sect1><para>
8596 #: ../en/ch07-branch.xml:123
8597 msgid ""
8598 "There will still be a permanent record of the previous identity of the tag, "
8599 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
8600 "wrong revision; all you have to do is turn around and tag the correct "
8601 "revision once you discover your error."
8602 msgstr ""
8604 #. type: Content of: <book><chapter><sect1><para>
8605 #: ../en/ch07-branch.xml:129
8606 msgid ""
8607 "Mercurial stores tags in a normal revision-controlled file in your "
8608 "repository. If you've created any tags, you'll find them in a file in the "
8609 "root of your repository named <filename role=\"special\">.hgtags</filename>. "
8610 "When you run the <command role=\"hg-cmd\">hg tag</command> command, Mercurial "
8611 "modifies this file, then automatically commits the change to it. This means "
8612 "that every time you run <command role=\"hg-cmd\">hg tag</command>, you'll see "
8613 "a corresponding changeset in the output of <command role=\"hg-cmd\">hg log</"
8614 "command>."
8615 msgstr ""
8617 #. type: Content of: <book><chapter><sect1><sect2><title>
8618 #: ../en/ch07-branch.xml:142
8619 msgid "Handling tag conflicts during a merge"
8620 msgstr "在合并期间处理标签冲突"
8622 #. type: Content of: <book><chapter><sect1><sect2><para>
8623 #: ../en/ch07-branch.xml:144
8624 msgid ""
8625 "You won't often need to care about the <filename role=\"special\">.hgtags</"
8626 "filename> file, but it sometimes makes its presence known during a merge. "
8627 "The format of the file is simple: it consists of a series of lines. Each "
8628 "line starts with a changeset hash, followed by a space, followed by the name "
8629 "of a tag."
8630 msgstr ""
8632 #. type: Content of: <book><chapter><sect1><sect2><para>
8633 #: ../en/ch07-branch.xml:151
8634 msgid ""
8635 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
8636 "filename> file during a merge, there's one twist to modifying the <filename "
8637 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
8638 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
8639 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
8640 "<emphasis>most recently committed</emphasis> revision of the file."
8641 msgstr ""
8643 #. type: Content of: <book><chapter><sect1><sect2><para>
8644 #: ../en/ch07-branch.xml:161
8645 msgid ""
8646 "An unfortunate consequence of this design is that you can't actually verify "
8647 "that your merged <filename role=\"special\">.hgtags</filename> file is "
8648 "correct until <emphasis>after</emphasis> you've committed a change. So if "
8649 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
8650 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
8651 "command> after you commit. If it finds an error in the <filename role="
8652 "\"special\">.hgtags</filename> file, it will report the location of the "
8653 "error, which you can then fix and commit. You should then run <command role="
8654 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
8655 msgstr ""
8657 #. type: Content of: <book><chapter><sect1><sect2><title>
8658 #: ../en/ch07-branch.xml:176
8659 msgid "Tags and cloning"
8660 msgstr "标签与克隆"
8662 #. type: Content of: <book><chapter><sect1><sect2><para>
8663 #: ../en/ch07-branch.xml:178
8664 msgid ""
8665 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
8666 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
8667 "clone an exact copy of the repository as of a particular changeset. The new "
8668 "clone will not contain any project history that comes after the revision you "
8669 "specified. This has an interaction with tags that can surprise the unwary."
8670 msgstr ""
8672 #. type: Content of: <book><chapter><sect1><sect2><para>
8673 #: ../en/ch07-branch.xml:186
8674 msgid ""
8675 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
8676 "hgtags</filename> file, so that when you create a tag, the changeset in which "
8677 "it's recorded necessarily refers to an older changeset. When you run "
8678 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
8679 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
8680 "history that created the tag</emphasis> that you used to clone the "
8681 "repository. The result is that you'll get exactly the right subset of the "
8682 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
8683 "you might have expected."
8684 msgstr ""
8686 #. type: Content of: <book><chapter><sect1><sect2><title>
8687 #: ../en/ch07-branch.xml:201
8688 msgid "When permanent tags are too much"
8689 msgstr "当永久标签太多的时候"
8691 #. type: Content of: <book><chapter><sect1><sect2><para>
8692 #: ../en/ch07-branch.xml:203
8693 msgid ""
8694 "Since Mercurial's tags are revision controlled and carried around with a "
8695 "project's history, everyone you work with will see the tags you create. But "
8696 "giving names to revisions has uses beyond simply noting that revision "
8697 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
8698 "you're trying to track down a subtle bug, you might want a tag to remind you "
8699 "of something like <quote>Anne saw the symptoms with this revision</quote>."
8700 msgstr ""
8702 #. type: Content of: <book><chapter><sect1><sect2><para>
8703 #: ../en/ch07-branch.xml:213
8704 msgid ""
8705 "For cases like this, what you might want to use are <emphasis>local</"
8706 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
8707 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
8708 "command. This will store the tag in a file called <filename role=\"special"
8709 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
8710 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
8711 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
8712 "l</option> remain strictly local to the repository you're currently working "
8713 "in."
8714 msgstr ""
8716 #. type: Content of: <book><chapter><sect1><title>
8717 #: ../en/ch07-branch.xml:228
8718 msgid "The flow of changes&emdash;big picture vs. little"
8719 msgstr "修改流程—宏观与微观"
8721 #. type: Content of: <book><chapter><sect1><para>
8722 #: ../en/ch07-branch.xml:230
8723 msgid ""
8724 "To return to the outline I sketched at the beginning of a chapter, let's "
8725 "think about a project that has multiple concurrent pieces of work under "
8726 "development at once."
8727 msgstr ""
8729 #. type: Content of: <book><chapter><sect1><para>
8730 #: ../en/ch07-branch.xml:234
8731 msgid ""
8732 "There might be a push for a new <quote>main</quote> release; a new minor "
8733 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
8734 "quote> to an old release that is now in maintenance mode."
8735 msgstr ""
8737 #. type: Content of: <book><chapter><sect1><para>
8738 #: ../en/ch07-branch.xml:239
8739 msgid ""
8740 "The usual way people refer to these different concurrent directions of "
8741 "development is as <quote>branches</quote>. However, we've already seen "
8742 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
8743 "series of branches and merges. Really, what we have here is two ideas that "
8744 "are peripherally related, but which happen to share a name."
8745 msgstr ""
8747 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8748 #: ../en/ch07-branch.xml:246
8749 msgid ""
8750 "<quote>Big picture</quote> branches represent the sweep of a project's "
8751 "evolution; people give them names, and talk about them in conversation."
8752 msgstr ""
8754 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8755 #: ../en/ch07-branch.xml:250
8756 msgid ""
8757 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
8758 "activity of developing and merging changes. They expose the narrative of how "
8759 "the code was developed."
8760 msgstr ""
8762 #. type: Content of: <book><chapter><sect1><title>
8763 #: ../en/ch07-branch.xml:258
8764 msgid "Managing big-picture branches in repositories"
8765 msgstr "在版本库中管理分支"
8767 #. type: Content of: <book><chapter><sect1><para>
8768 #: ../en/ch07-branch.xml:260
8769 msgid ""
8770 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
8771 "is in a dedicated repository. If you have an existing shared "
8772 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
8773 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
8774 "maintenance releases on top of version 1.0 by tagging the revision from which "
8775 "you prepared the 1.0 release."
8776 msgstr ""
8778 #. type: Content of: <book><chapter><sect1><para>
8779 #: ../en/ch07-branch.xml:270
8780 msgid ""
8781 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
8782 "as of that tag."
8783 msgstr ""
8785 #. type: Content of: <book><chapter><sect1><para>
8786 #: ../en/ch07-branch.xml:276
8787 msgid ""
8788 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
8789 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
8790 "literal> repository, make their changes, and push them back."
8791 msgstr ""
8793 #. type: Content of: <book><chapter><sect1><para>
8794 #: ../en/ch07-branch.xml:283
8795 msgid ""
8796 "Meanwhile, development for the next major release can continue, isolated and "
8797 "unabated, in the <literal>myproject</literal> repository."
8798 msgstr ""
8800 #. type: Content of: <book><chapter><sect1><title>
8801 #: ../en/ch07-branch.xml:291
8802 msgid "Don't repeat yourself: merging across branches"
8803 msgstr "不要重复劳动:在分支间合并"
8805 #. type: Content of: <book><chapter><sect1><para>
8806 #: ../en/ch07-branch.xml:293
8807 msgid ""
8808 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
8809 "are good that the bug exists on your project's main branch (and possibly "
8810 "other maintenance branches, too). It's a rare developer who wants to fix the "
8811 "same bug multiple times, so let's look at a few ways that Mercurial can help "
8812 "you to manage these bugfixes without duplicating your work."
8813 msgstr ""
8815 #. type: Content of: <book><chapter><sect1><para>
8816 #: ../en/ch07-branch.xml:301
8817 msgid ""
8818 "In the simplest instance, all you need to do is pull changes from your "
8819 "maintenance branch into your local clone of the target branch."
8820 msgstr ""
8822 #. type: Content of: <book><chapter><sect1><para>
8823 #: ../en/ch07-branch.xml:307
8824 msgid ""
8825 "You'll then need to merge the heads of the two branches, and push back to the "
8826 "main branch."
8827 msgstr ""
8829 #. type: Content of: <book><chapter><sect1><title>
8830 #: ../en/ch07-branch.xml:314
8831 msgid "Naming branches within one repository"
8832 msgstr "版本库中的命名分支"
8834 #. type: Content of: <book><chapter><sect1><para>
8835 #: ../en/ch07-branch.xml:316
8836 msgid ""
8837 "In most instances, isolating branches in repositories is the right approach. "
8838 "Its simplicity makes it easy to understand; and so it's hard to make "
8839 "mistakes. There's a one-to-one relationship between branches you're working "
8840 "in and directories on your system. This lets you use normal (non-Mercurial-"
8841 "aware) tools to work on files within a branch/repository."
8842 msgstr ""
8844 #. type: Content of: <book><chapter><sect1><para>
8845 #: ../en/ch07-branch.xml:323
8846 msgid ""
8847 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
8848 "emphasis> your collaborators are too), there is an alternative way of "
8849 "handling branches that you can consider. I've already mentioned the human-"
8850 "level distinction between <quote>small picture</quote> and <quote>big "
8851 "picture</quote> branches. While Mercurial works with multiple <quote>small "
8852 "picture</quote> branches in a repository all the time (for example after you "
8853 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
8854 "work with multiple <quote>big picture</quote> branches."
8855 msgstr ""
8857 #. type: Content of: <book><chapter><sect1><para>
8858 #: ../en/ch07-branch.xml:334
8859 msgid ""
8860 "The key to working this way is that Mercurial lets you assign a persistent "
8861 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
8862 "<literal>default</literal>. Even before you start naming branches yourself, "
8863 "you can find traces of the <literal>default</literal> branch if you look for "
8864 "them."
8865 msgstr ""
8867 #. type: Content of: <book><chapter><sect1><para>
8868 #: ../en/ch07-branch.xml:341
8869 msgid ""
8870 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
8871 "command, and it pops up your editor so that you can enter a commit message, "
8872 "look for a line that contains the text <quote><literal>HG: branch default</"
8873 "literal></quote> at the bottom. This is telling you that your commit will "
8874 "occur on the branch named <literal>default</literal>."
8875 msgstr ""
8877 #. type: Content of: <book><chapter><sect1><para>
8878 #: ../en/ch07-branch.xml:348
8879 msgid ""
8880 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
8881 "branches</command> command. This command lists the named branches already "
8882 "present in your repository, telling you which changeset is the tip of each."
8883 msgstr ""
8885 #. type: Content of: <book><chapter><sect1><para>
8886 #: ../en/ch07-branch.xml:355
8887 msgid ""
8888 "Since you haven't created any named branches yet, the only one that exists is "
8889 "<literal>default</literal>."
8890 msgstr ""
8892 #. type: Content of: <book><chapter><sect1><para>
8893 #: ../en/ch07-branch.xml:358
8894 msgid ""
8895 "To find out what the <quote>current</quote> branch is, run the <command role="
8896 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
8897 "you what branch the parent of the current changeset is on."
8898 msgstr ""
8901 #. type: Content of: <book><chapter><sect1><para>
8902 #: ../en/ch07-branch.xml:365
8903 msgid ""
8904 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
8905 "command again. This time, give it one argument: the name of the branch you "
8906 "want to create."
8907 msgstr ""
8909 #. type: Content of: <book><chapter><sect1><para>
8910 #: ../en/ch07-branch.xml:371
8911 msgid ""
8912 "After you've created a branch, you might wonder what effect the <command role="
8913 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
8914 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
8915 "commands report?"
8916 msgstr ""
8918 #. type: Content of: <book><chapter><sect1><para>
8919 #: ../en/ch07-branch.xml:378
8920 msgid ""
8921 "Nothing has changed in the working directory, and there's been no new history "
8922 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
8923 "command> command has no permanent effect; it only tells Mercurial what branch "
8924 "name to use the <emphasis>next</emphasis> time you commit a changeset."
8925 msgstr ""
8927 #. type: Content of: <book><chapter><sect1><para>
8928 #: ../en/ch07-branch.xml:385
8929 msgid ""
8930 "When you commit a change, Mercurial records the name of the branch on which "
8931 "you committed. Once you've switched from the <literal>default</literal> "
8932 "branch to another and committed, you'll see the name of the new branch show "
8933 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
8934 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
8935 "output."
8936 msgstr ""
8938 #. type: Content of: <book><chapter><sect1><para>
8939 #: ../en/ch07-branch.xml:395
8940 msgid ""
8941 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
8942 "branch name of every changeset that's not on the <literal>default</literal> "
8943 "branch. As a result, if you never use named branches, you'll never see this "
8944 "information."
8945 msgstr ""
8947 #. type: Content of: <book><chapter><sect1><para>
8948 #: ../en/ch07-branch.xml:400
8949 msgid ""
8950 "Once you've named a branch and committed a change with that name, every "
8951 "subsequent commit that descends from that change will inherit the same branch "
8952 "name. You can change the name of a branch at any time, using the <command "
8953 "role=\"hg-cmd\">hg branch</command> command."
8954 msgstr ""
8956 #. type: Content of: <book><chapter><sect1><para>
8957 #: ../en/ch07-branch.xml:408
8958 msgid ""
8959 "In practice, this is something you won't do very often, as branch names tend "
8960 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
8961 msgstr ""
8963 #. type: Content of: <book><chapter><sect1><title>
8964 #: ../en/ch07-branch.xml:414
8965 msgid "Dealing with multiple named branches in a repository"
8966 msgstr "在版本库中处理多个命名分支"
8968 #. type: Content of: <book><chapter><sect1><para>
8969 #: ../en/ch07-branch.xml:417
8970 msgid ""
8971 "If you have more than one named branch in a repository, Mercurial will "
8972 "remember the branch that your working directory on when you start a command "
8973 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
8974 "\">hg pull -u</command>. It will update the working directory to the tip of "
8975 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
8976 "to a revision that's on a different named branch, you may need to use the "
8977 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
8978 "\">hg update</command>."
8979 msgstr ""
8981 #. type: Content of: <book><chapter><sect1><para>
8982 #: ../en/ch07-branch.xml:427
8983 msgid ""
8984 "This behavior is a little subtle, so let's see it in action. First, let's "
8985 "remind ourselves what branch we're currently on, and what branches are in our "
8986 "repository."
8987 msgstr ""
8989 #. type: Content of: <book><chapter><sect1><para>
8990 #: ../en/ch07-branch.xml:433
8991 msgid ""
8992 "We're on the <literal>bar</literal> branch, but there also exists an older "
8993 "<command role=\"hg-cmd\">hg foo</command> branch."
8994 msgstr ""
8996 #. type: Content of: <book><chapter><sect1><para>
8997 #: ../en/ch07-branch.xml:437
8998 msgid ""
8999 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
9000 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
9001 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
9002 "because this only involves going backwards and forwards linearly through our "
9003 "change history."
9004 msgstr ""
9007 #. type: Content of: <book><chapter><sect1><para>
9008 #: ../en/ch07-branch.xml:446
9009 msgid ""
9010 "If we go back to the <literal>foo</literal> branch and then run <command role="
9011 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
9012 "not move us to the tip of <literal>bar</literal>."
9013 msgstr ""
9016 #. type: Content of: <book><chapter><sect1><para>
9017 #: ../en/ch07-branch.xml:453
9018 msgid ""
9019 "Committing a new change on the <literal>foo</literal> branch introduces a new "
9020 "head."
9021 msgstr ""
9023 #. type: Content of: <book><chapter><sect1><title>
9024 #: ../en/ch07-branch.xml:460
9025 msgid "Branch names and merging"
9026 msgstr "分支名称与合并"
9028 #. type: Content of: <book><chapter><sect1><para>
9029 #: ../en/ch07-branch.xml:462
9030 msgid ""
9031 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
9032 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
9033 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
9034 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
9035 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
9036 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
9037 "records 23 as the first parent, and 17 as the second."
9038 msgstr ""
9040 #. type: Content of: <book><chapter><sect1><para>
9041 #: ../en/ch07-branch.xml:472
9042 msgid ""
9043 "This affects Mercurial's choice of branch name when you merge. After a "
9044 "merge, Mercurial will retain the branch name of the first parent when you "
9045 "commit the result of the merge. If your first parent's branch name is "
9046 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
9047 "name will still be <literal>foo</literal> after you merge."
9048 msgstr ""
9050 #. type: Content of: <book><chapter><sect1><para>
9051 #: ../en/ch07-branch.xml:479
9052 msgid ""
9053 "It's not unusual for a repository to contain multiple heads, each with the "
9054 "same branch name. Let's say I'm working on the <literal>foo</literal> "
9055 "branch, and so are you. We commit different changes; I pull your changes; I "
9056 "now have two heads, each claiming to be on the <literal>foo</literal> "
9057 "branch. The result of a merge will be a single head on the <literal>foo</"
9058 "literal> branch, as you might hope."
9059 msgstr ""
9062 #. type: Content of: <book><chapter><sect1><para>
9063 #: ../en/ch07-branch.xml:487
9064 msgid ""
9065 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
9066 "from the <literal>foo</literal> branch, the result will remain on the "
9067 "<literal>bar</literal> branch."
9068 msgstr ""
9070 #. type: Content of: <book><chapter><sect1><para>
9071 #: ../en/ch07-branch.xml:493
9072 msgid ""
9073 "To give a more concrete example, if I'm working on the <literal>bleeding-"
9074 "edge</literal> branch, and I want to bring in the latest fixes from the "
9075 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
9076 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
9077 "from <literal>stable</literal>."
9078 msgstr ""
9080 #. type: Content of: <book><chapter><sect1><title>
9081 #: ../en/ch07-branch.xml:502
9082 msgid "Branch naming is generally useful"
9083 msgstr "分支名称通常都很有用"
9085 #. type: Content of: <book><chapter><sect1><para>
9086 #: ../en/ch07-branch.xml:504
9087 msgid ""
9088 "You shouldn't think of named branches as applicable only to situations where "
9089 "you have multiple long-lived branches cohabiting in a single repository. "
9090 "They're very useful even in the one-branch-per-repository case."
9091 msgstr ""
9093 #. type: Content of: <book><chapter><sect1><para>
9094 #: ../en/ch07-branch.xml:509
9095 msgid ""
9096 "In the simplest case, giving a name to each branch gives you a permanent "
9097 "record of which branch a changeset originated on. This gives you more "
9098 "context when you're trying to follow the history of a long-lived branchy "
9099 "project."
9100 msgstr ""
9102 #. type: Content of: <book><chapter><sect1><para>
9103 #: ../en/ch07-branch.xml:514
9104 msgid ""
9105 "If you're working with shared repositories, you can set up a <literal role="
9106 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
9107 "changes that have the <quote>wrong</quote> branch name. This provides a "
9108 "simple, but effective, defence against people accidentally pushing changes "
9109 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
9110 "branch. Such a hook might look like this inside the shared repo's <filename "
9111 "role=\"special\"> /.hgrc</filename>."
9112 msgstr ""
9114 #. type: Content of: <book><chapter><title>
9115 #: ../en/ch08-undo.xml:5
9116 msgid "Finding and fixing mistakes"
9117 msgstr "查找和修改错误"
9119 #. type: Content of: <book><chapter><para>
9120 #: ../en/ch08-undo.xml:7
9121 msgid ""
9122 "To err might be human, but to really handle the consequences well takes a top-"
9123 "notch revision control system. In this chapter, we'll discuss some of the "
9124 "techniques you can use when you find that a problem has crept into your "
9125 "project. Mercurial has some highly capable features that will help you to "
9126 "isolate the sources of problems, and to handle them appropriately."
9127 msgstr ""
9129 #. type: Content of: <book><chapter><sect1><title>
9130 #: ../en/ch08-undo.xml:15
9131 msgid "Erasing local history"
9132 msgstr "销毁本地历史"
9134 #. type: Content of: <book><chapter><sect1><sect2><title>
9135 #: ../en/ch08-undo.xml:18
9136 msgid "The accidental commit"
9137 msgstr "意外的提交"
9139 #. type: Content of: <book><chapter><sect1><sect2><para>
9140 #: ../en/ch08-undo.xml:20
9141 msgid ""
9142 "I have the occasional but persistent problem of typing rather more quickly "
9143 "than I can think, which sometimes results in me committing a changeset that "
9144 "is either incomplete or plain wrong. In my case, the usual kind of "
9145 "incomplete changeset is one in which I've created a new source file, but "
9146 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
9147 "wrong</quote> changeset is not as common, but no less annoying."
9148 msgstr ""
9150 #. type: Content of: <book><chapter><sect1><sect2><title>
9151 #: ../en/ch08-undo.xml:31
9152 msgid "Rolling back a transaction"
9153 msgstr "回滚一个事务"
9155 #. type: Content of: <book><chapter><sect1><sect2><para>
9156 #: ../en/ch08-undo.xml:33
9157 msgid ""
9158 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
9159 "each modification of a repository as a <emphasis>transaction</emphasis>. "
9160 "Every time you commit a changeset or pull changes from another repository, "
9161 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
9162 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
9163 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
9164 "\"/> for an important caveat about the use of this command.)"
9165 msgstr ""
9167 #. type: Content of: <book><chapter><sect1><sect2><para>
9168 #: ../en/ch08-undo.xml:43
9169 msgid ""
9170 "Here's a mistake that I often find myself making: committing a change in "
9171 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
9172 "add</command> it."
9173 msgstr ""
9175 #. type: Content of: <book><chapter><sect1><sect2><para>
9176 #: ../en/ch08-undo.xml:50
9177 msgid ""
9178 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
9179 "the commit immediately confirms the error."
9180 msgstr ""
9182 #. type: Content of: <book><chapter><sect1><sect2><para>
9183 #: ../en/ch08-undo.xml:56
9184 msgid ""
9185 "The commit captured the changes to the file <filename>a</filename>, but not "
9186 "the new file <filename>b</filename>. If I were to push this changeset to a "
9187 "repository that I shared with a colleague, the chances are high that "
9188 "something in <filename>a</filename> would refer to <filename>b</filename>, "
9189 "which would not be present in their repository when they pulled my changes. "
9190 "I would thus become the object of some indignation."
9191 msgstr ""
9193 #. type: Content of: <book><chapter><sect1><sect2><para>
9194 #: ../en/ch08-undo.xml:65
9195 msgid ""
9196 "However, luck is with me&emdash;I've caught my error before I pushed the "
9197 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
9198 "and Mercurial makes that last changeset vanish."
9199 msgstr ""
9201 #. type: Content of: <book><chapter><sect1><sect2><para>
9202 #: ../en/ch08-undo.xml:72
9203 msgid ""
9204 "Notice that the changeset is no longer present in the repository's history, "
9205 "and the working directory once again thinks that the file <filename>a</"
9206 "filename> is modified. The commit and rollback have left the working "
9207 "directory exactly as it was prior to the commit; the changeset has been "
9208 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
9209 "command> the file <filename>b</filename>, and rerun my commit."
9210 msgstr ""
9212 #. type: Content of: <book><chapter><sect1><sect2><title>
9213 #: ../en/ch08-undo.xml:85
9214 msgid "The erroneous pull"
9215 msgstr "错误的抓取"
9217 #. type: Content of: <book><chapter><sect1><sect2><para>
9218 #: ../en/ch08-undo.xml:87
9219 msgid ""
9220 "It's common practice with Mercurial to maintain separate development branches "
9221 "of a project in different repositories. Your development team might have one "
9222 "shared repository for your project's <quote>0.9</quote> release, and another, "
9223 "containing different changes, for the <quote>1.0</quote> release."
9224 msgstr ""
9226 #. type: Content of: <book><chapter><sect1><sect2><para>
9227 #: ../en/ch08-undo.xml:94
9228 msgid ""
9229 "Given this, you can imagine that the consequences could be messy if you had a "
9230 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
9231 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
9232 "insufficient attention, and push those changes into the shared <quote>0.9</"
9233 "quote> tree, confusing your entire team (but don't worry, we'll return to "
9234 "this horror scenario later). However, it's more likely that you'll notice "
9235 "immediately, because Mercurial will display the URL it's pulling from, or you "
9236 "will see it pull a suspiciously large number of changes into the repository."
9237 msgstr ""
9239 #. type: Content of: <book><chapter><sect1><sect2><para>
9240 #: ../en/ch08-undo.xml:106
9241 msgid ""
9242 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
9243 "to expunge all of the changesets that you just pulled. Mercurial groups all "
9244 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
9245 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
9246 "need to undo this mistake."
9247 msgstr ""
9249 #. type: Content of: <book><chapter><sect1><sect2><title>
9250 #: ../en/ch08-undo.xml:115
9251 msgid "Rolling back is useless once you've pushed"
9252 msgstr "当完成推送后,回滚是无效的"
9254 #. type: Content of: <book><chapter><sect1><sect2><para>
9255 #: ../en/ch08-undo.xml:117
9256 msgid ""
9257 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
9258 "to zero once you've pushed your changes to another repository. Rolling back "
9259 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
9260 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
9261 "command>. Because a rollback eliminates history, there's no way for the "
9262 "disappearance of a change to propagate between repositories."
9263 msgstr ""
9265 #. type: Content of: <book><chapter><sect1><sect2><para>
9266 #: ../en/ch08-undo.xml:126
9267 msgid ""
9268 "If you've pushed a change to another repository&emdash;particularly if it's a "
9269 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
9270 "quote> and you'll have to recover from your mistake in a different way. What "
9271 "will happen if you push a changeset somewhere, then roll it back, then pull "
9272 "from the repository you pushed to, is that the changeset will reappear in "
9273 "your repository."
9274 msgstr ""
9276 #. type: Content of: <book><chapter><sect1><sect2><para>
9277 #: ../en/ch08-undo.xml:135
9278 msgid ""
9279 "(If you absolutely know for sure that the change you want to roll back is the "
9280 "most recent change in the repository that you pushed to, <emphasis>and</"
9281 "emphasis> you know that nobody else could have pulled it from that "
9282 "repository, you can roll back the changeset there, too, but you really should "
9283 "really not rely on this working reliably. If you do this, sooner or later a "
9284 "change really will make it into a repository that you don't directly control "
9285 "(or have forgotten about), and come back to bite you.)"
9286 msgstr ""
9288 #. type: Content of: <book><chapter><sect1><sect2><title>
9289 #: ../en/ch08-undo.xml:147
9290 msgid "You can only roll back once"
9291 msgstr "你只能回滚一次"
9293 #. type: Content of: <book><chapter><sect1><sect2><para>
9294 #: ../en/ch08-undo.xml:149
9295 msgid ""
9296 "Mercurial stores exactly one transaction in its transaction log; that "
9297 "transaction is the most recent one that occurred in the repository. This "
9298 "means that you can only roll back one transaction. If you expect to be able "
9299 "to roll back one transaction, then its predecessor, this is not the behavior "
9300 "you will get."
9301 msgstr ""
9303 #. type: Content of: <book><chapter><sect1><sect2><para>
9304 #: ../en/ch08-undo.xml:158
9305 msgid ""
9306 "Once you've rolled back one transaction in a repository, you can't roll back "
9307 "again in that repository until you perform another commit or pull."
9308 msgstr ""
9310 #. type: Content of: <book><chapter><sect1><title>
9311 #: ../en/ch08-undo.xml:165
9312 msgid "Reverting the mistaken change"
9313 msgstr "撤销错误的修改"
9315 #. type: Content of: <book><chapter><sect1><para>
9316 #: ../en/ch08-undo.xml:167
9317 msgid ""
9318 "If you make a modification to a file, and decide that you really didn't want "
9319 "to change the file at all, and you haven't yet committed your changes, the "
9320 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
9321 "It looks at the changeset that's the parent of the working directory, and "
9322 "restores the contents of the file to their state as of that changeset. "
9323 "(That's a long-winded way of saying that, in the normal case, it undoes your "
9324 "modifications.)"
9325 msgstr ""
9327 #. type: Content of: <book><chapter><sect1><para>
9328 #: ../en/ch08-undo.xml:176
9329 msgid ""
9330 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
9331 "works with yet another small example. We'll begin by modifying a file that "
9332 "Mercurial is already tracking."
9333 msgstr ""
9335 #. type: Content of: <book><chapter><sect1><para>
9336 #: ../en/ch08-undo.xml:183
9337 msgid ""
9338 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
9339 "revert</command> the file."
9340 msgstr ""
9342 #. type: Content of: <book><chapter><sect1><para>
9343 #: ../en/ch08-undo.xml:189
9344 msgid ""
9345 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
9346 "extra degree of safety by saving our modified file with a <filename>.orig</"
9347 "filename> extension."
9348 msgstr ""
9350 #. type: Content of: <book><chapter><sect1><para>
9351 #: ../en/ch08-undo.xml:196
9352 msgid ""
9353 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
9354 "command> command can deal with. We will describe each of these in more "
9355 "detail in the section that follows."
9356 msgstr ""
9358 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9359 #: ../en/ch08-undo.xml:201
9360 msgid "If you modify a file, it will restore the file to its unmodified state."
9361 msgstr ""
9363 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9364 #: ../en/ch08-undo.xml:204
9365 msgid ""
9366 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
9367 "<quote>added</quote> state of the file, but leave the file itself untouched."
9368 msgstr ""
9370 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9371 #: ../en/ch08-undo.xml:208
9372 msgid ""
9373 "If you delete a file without telling Mercurial, it will restore the file to "
9374 "its unmodified contents."
9375 msgstr ""
9377 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9378 #: ../en/ch08-undo.xml:211
9379 msgid ""
9380 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
9381 "a file, it will undo the <quote>removed</quote> state of the file, and "
9382 "restore the file to its unmodified contents."
9383 msgstr ""
9385 #. type: Content of: <book><chapter><sect1><sect2><title>
9386 #: ../en/ch08-undo.xml:218
9387 msgid "File management errors"
9388 msgstr "文件管理错误"
9390 #. type: Content of: <book><chapter><sect1><sect2><para>
9391 #: ../en/ch08-undo.xml:220
9392 msgid ""
9393 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
9394 "than just modified files. It lets you reverse the results of all of "
9395 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
9396 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
9397 msgstr ""
9400 #. type: Content of: <book><chapter><sect1><sect2><para>
9401 #: ../en/ch08-undo.xml:226
9402 msgid ""
9403 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
9404 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
9405 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
9406 "file in any way. It will just <quote>unmark</quote> the file."
9407 msgstr ""
9409 #. type: Content of: <book><chapter><sect1><sect2><para>
9410 #: ../en/ch08-undo.xml:234
9411 msgid ""
9412 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
9413 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
9414 "restore it to the contents it had as of the parent of the working directory. "
9415 "&interaction.daily.revert.remove; This works just as well for a file that you "
9416 "deleted by hand, without telling Mercurial (recall that in Mercurial "
9417 "terminology, this kind of file is called <quote>missing</quote>)."
9418 msgstr ""
9421 #. type: Content of: <book><chapter><sect1><sect2><para>
9422 #: ../en/ch08-undo.xml:245
9423 msgid ""
9424 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
9425 "file remains in your working directory afterwards, untracked. Since a copy "
9426 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
9427 "with the copied-from file."
9428 msgstr ""
9430 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9431 #: ../en/ch08-undo.xml:254
9432 msgid "A slightly special case: reverting a rename"
9433 msgstr "一个稍微特别的案例:撤销改名"
9435 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9436 #: ../en/ch08-undo.xml:256
9437 msgid ""
9438 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
9439 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
9440 "revert</command> a rename, it's not enough to provide the name of the renamed-"
9441 "to file, as you can see here."
9442 msgstr ""
9444 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9445 #: ../en/ch08-undo.xml:264
9446 msgid ""
9447 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
9448 "command>, the renamed-to file is no longer identified as added, but the "
9449 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
9450 "intuitive (at least to me), but at least it's easy to deal with."
9451 msgstr ""
9453 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9454 #: ../en/ch08-undo.xml:273
9455 msgid ""
9456 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
9457 "must provide <emphasis>both</emphasis> the source and destination names."
9458 msgstr ""
9460 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9461 #: ../en/ch08-undo.xml:278
9462 msgid "% TODO: the output doesn't look like it will be removed!"
9463 msgstr ""
9465 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9466 #: ../en/ch08-undo.xml:281
9467 msgid ""
9468 "(By the way, if you rename a file, then modify the renamed-to file, then "
9469 "revert both components of the rename, when Mercurial restores the file that "
9470 "was removed as part of the rename, it will be unmodified. If you need the "
9471 "modifications in the renamed-to file to show up in the renamed-from file, "
9472 "don't forget to copy them over.)"
9473 msgstr ""
9475 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9476 #: ../en/ch08-undo.xml:288
9477 msgid ""
9478 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
9479 "Mercurial."
9480 msgstr ""
9482 #. type: Content of: <book><chapter><sect1><title>
9483 #: ../en/ch08-undo.xml:295
9484 msgid "Dealing with committed changes"
9485 msgstr "处理已经提交的修改"
9487 #. type: Content of: <book><chapter><sect1><para>
9488 #: ../en/ch08-undo.xml:297
9489 msgid ""
9490 "Consider a case where you have committed a change $a$, and another change $b$ "
9491 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
9492 "you <quote>back out</quote> an entire changeset automatically, and building "
9493 "blocks that let you reverse part of a changeset by hand."
9494 msgstr ""
9496 #. type: Content of: <book><chapter><sect1><para>
9497 #: ../en/ch08-undo.xml:303
9498 msgid ""
9499 "Before you read this section, here's something to keep in mind: the <command "
9500 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
9501 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
9502 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
9503 "some change that has catastrophic consequences. To deal with those, see "
9504 "<xref linkend=\"sec:undo:aaaiiieee\"/>."
9505 msgstr ""
9507 #. type: Content of: <book><chapter><sect1><sect2><title>
9508 #: ../en/ch08-undo.xml:312
9509 msgid "Backing out a changeset"
9510 msgstr "恢复一个修改集"
9512 #. type: Content of: <book><chapter><sect1><sect2><para>
9513 #: ../en/ch08-undo.xml:314
9514 msgid ""
9515 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
9516 "<quote>undo</quote> the effects of an entire changeset in an automated "
9517 "fashion. Because Mercurial's history is immutable, this command "
9518 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
9519 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
9520 "effect of the to-be-undone changeset."
9521 msgstr ""
9524 #. type: Content of: <book><chapter><sect1><sect2><para>
9525 #: ../en/ch08-undo.xml:323
9526 msgid ""
9527 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
9528 "a little intricate, so let's illustrate it with some examples. First, we'll "
9529 "create a repository with some simple changes."
9530 msgstr ""
9532 #. type: Content of: <book><chapter><sect1><sect2><para>
9533 #: ../en/ch08-undo.xml:330
9534 msgid ""
9535 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
9536 "changeset ID as its argument; this is the changeset to back out. Normally, "
9537 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
9538 "editor to write a commit message, so you can record why you're backing the "
9539 "change out. In this example, we provide a commit message on the command line "
9540 "using the <option role=\"hg-opt-backout\">-m</option> option."
9541 msgstr ""
9543 #. type: Content of: <book><chapter><sect1><sect2><title>
9544 #: ../en/ch08-undo.xml:341
9545 msgid "Backing out the tip changeset"
9546 msgstr "恢复顶点修改集"
9548 #. type: Content of: <book><chapter><sect1><sect2><para>
9549 #: ../en/ch08-undo.xml:343
9550 msgid "We're going to start by backing out the last changeset we committed."
9551 msgstr ""
9553 #. type: Content of: <book><chapter><sect1><sect2><para>
9554 #: ../en/ch08-undo.xml:348
9555 msgid ""
9556 "You can see that the second line from <filename>myfile</filename> is no "
9557 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
9558 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
9559 "backout</command> command has done. &interaction.backout.simple.log; Notice "
9560 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
9561 "created is a child of the changeset we backed out. It's easier to see this "
9562 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
9563 "the change history. As you can see, the history is nice and linear."
9564 msgstr ""
9566 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9567 #: ../en/ch08-undo.xml:361 ../en/ch08-undo.xml:473
9568 msgid ""
9569 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
9570 "command"
9571 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
9573 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9574 #: ../en/ch08-undo.xml:364
9575 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
9576 msgstr ""
9578 #. type: Content of: <book><chapter><sect1><sect2><title>
9579 #: ../en/ch08-undo.xml:371
9580 msgid "Backing out a non-tip change"
9581 msgstr "恢复非顶点的修改"
9583 #. type: Content of: <book><chapter><sect1><sect2><para>
9584 #: ../en/ch08-undo.xml:373
9585 msgid ""
9586 "If you want to back out a change other than the last one you committed, pass "
9587 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
9588 "role=\"hg-cmd\">hg backout</command> command."
9589 msgstr ""
9591 #. type: Content of: <book><chapter><sect1><sect2><para>
9592 #: ../en/ch08-undo.xml:380
9593 msgid ""
9594 "This makes backing out any changeset a <quote>one-shot</quote> operation "
9595 "that's usually simple and fast."
9596 msgstr ""
9598 #. type: Content of: <book><chapter><sect1><sect2><para>
9599 #: ../en/ch08-undo.xml:386
9600 msgid ""
9601 "If you take a look at the contents of <filename>myfile</filename> after the "
9602 "backout finishes, you'll see that the first and third changes are present, "
9603 "but not the second."
9604 msgstr ""
9606 #. type: Content of: <book><chapter><sect1><sect2><para>
9607 #: ../en/ch08-undo.xml:393
9608 msgid ""
9609 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
9610 "illustrates, Mercurial actually commits <emphasis>two</emphasis> changes in "
9611 "this kind of situation (the box-shaped nodes are the ones that Mercurial "
9612 "commits automatically). Before Mercurial begins the backout process, it "
9613 "first remembers what the current parent of the working directory is. It then "
9614 "backs out the target changeset, and commits that as a changeset. Finally, it "
9615 "merges back to the previous parent of the working directory, and commits the "
9616 "result of the merge."
9617 msgstr ""
9619 #. type: Content of: <book><chapter><sect1><sect2><para>
9620 #: ../en/ch08-undo.xml:404
9621 msgid ""
9622 "% TODO: to me it looks like mercurial doesn't commit the second merge "
9623 "automatically!"
9624 msgstr ""
9626 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9627 #: ../en/ch08-undo.xml:408
9628 msgid ""
9629 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
9630 "backout</command> command"
9631 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
9633 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9634 #: ../en/ch08-undo.xml:411
9635 msgid ""
9636 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
9637 msgstr ""
9639 #. type: Content of: <book><chapter><sect1><sect2><para>
9640 #: ../en/ch08-undo.xml:416
9641 msgid ""
9642 "The result is that you end up <quote>back where you were</quote>, only with "
9643 "some extra history that undoes the effect of the changeset you wanted to back "
9644 "out."
9645 msgstr ""
9647 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9648 #: ../en/ch08-undo.xml:421
9649 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
9650 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
9652 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9653 #: ../en/ch08-undo.xml:424
9654 msgid ""
9655 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
9656 "will do the <quote>right thing</quote> whether or not the changeset you're "
9657 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
9658 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
9659 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
9660 msgstr ""
9662 #. type: Content of: <book><chapter><sect1><sect2><title>
9663 #: ../en/ch08-undo.xml:435
9664 msgid "Gaining more control of the backout process"
9665 msgstr "在恢复处理中获得更多控制"
9667 #. type: Content of: <book><chapter><sect1><sect2><para>
9668 #: ../en/ch08-undo.xml:437
9669 msgid ""
9670 "While I've recommended that you always use the <option role=\"hg-opt-backout"
9671 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
9672 "cmd\">hg backout</command> command lets you decide how to merge a backout "
9673 "changeset. Taking control of the backout process by hand is something you "
9674 "will rarely need to do, but it can be useful to understand what the <command "
9675 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
9676 "To illustrate this, let's clone our first repository, but omit the backout "
9677 "change that it contains."
9678 msgstr ""
9680 #. type: Content of: <book><chapter><sect1><sect2><para>
9681 #: ../en/ch08-undo.xml:450
9682 msgid ""
9683 "As with our earlier example, We'll commit a third changeset, then back out "
9684 "its parent, and see what happens."
9685 msgstr ""
9687 #. type: Content of: <book><chapter><sect1><sect2><para>
9688 #: ../en/ch08-undo.xml:456
9689 msgid ""
9690 "Our new changeset is again a descendant of the changeset we backout out; it's "
9691 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
9692 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
9693 "quite explicit in telling us this."
9694 msgstr ""
9696 #. type: Content of: <book><chapter><sect1><sect2><para>
9697 #: ../en/ch08-undo.xml:464
9698 msgid ""
9699 "Again, it's easier to see what has happened by looking at a graph of the "
9700 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
9701 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
9702 "back out a change other than the tip, Mercurial adds a new head to the "
9703 "repository (the change it committed is box-shaped)."
9704 msgstr ""
9706 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9707 #: ../en/ch08-undo.xml:476
9708 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
9709 msgstr ""
9711 #. type: Content of: <book><chapter><sect1><sect2><para>
9712 #: ../en/ch08-undo.xml:481
9713 msgid ""
9714 "After the <command role=\"hg-cmd\">hg backout</command> command has "
9715 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
9716 "of the working directory."
9717 msgstr ""
9719 #. type: Content of: <book><chapter><sect1><sect2><para>
9720 #: ../en/ch08-undo.xml:488
9721 msgid "Now we have two isolated sets of changes."
9722 msgstr ""
9724 #. type: Content of: <book><chapter><sect1><sect2><para>
9725 #: ../en/ch08-undo.xml:492
9726 msgid ""
9727 "Let's think about what we expect to see as the contents of <filename>myfile</"
9728 "filename> now. The first change should be present, because we've never "
9729 "backed it out. The second change should be missing, as that's the change we "
9730 "backed out. Since the history graph shows the third change as a separate "
9731 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
9732 "<filename>myfile</filename>."
9733 msgstr ""
9735 #. type: Content of: <book><chapter><sect1><sect2><para>
9736 #: ../en/ch08-undo.xml:502
9737 msgid ""
9738 "To get the third change back into the file, we just do a normal merge of our "
9739 "two heads."
9740 msgstr ""
9742 #. type: Content of: <book><chapter><sect1><sect2><para>
9743 #: ../en/ch08-undo.xml:507
9744 msgid ""
9745 "Afterwards, the graphical history of our repository looks like <xref linkend="
9746 "\"fig:undo:backout-manual-merge\"/>."
9747 msgstr ""
9749 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9750 #: ../en/ch08-undo.xml:512
9751 msgid "Manually merging a backout change"
9752 msgstr "手工合并恢复修改"
9754 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9755 #: ../en/ch08-undo.xml:514
9756 msgid ""
9757 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
9758 msgstr ""
9760 #. type: Content of: <book><chapter><sect1><sect2><title>
9761 #: ../en/ch08-undo.xml:521
9762 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
9763 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
9765 #. type: Content of: <book><chapter><sect1><sect2><para>
9766 #: ../en/ch08-undo.xml:524
9767 msgid ""
9768 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
9769 "command> command works."
9770 msgstr ""
9772 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9773 #: ../en/ch08-undo.xml:527
9774 msgid ""
9775 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
9776 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
9777 msgstr ""
9779 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9780 #: ../en/ch08-undo.xml:531
9781 msgid ""
9782 "It remembers the current parent of the working directory. Let's call this "
9783 "changeset <literal>orig</literal>"
9784 msgstr ""
9786 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9787 #: ../en/ch08-undo.xml:535
9788 msgid ""
9789 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
9790 "sync the working directory to the changeset you want to back out. Let's call "
9791 "this changeset <literal>backout</literal>"
9792 msgstr ""
9794 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9795 #: ../en/ch08-undo.xml:540
9796 msgid ""
9797 "It finds the parent of that changeset. Let's call that changeset "
9798 "<literal>parent</literal>."
9799 msgstr ""
9801 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9802 #: ../en/ch08-undo.xml:543
9803 msgid ""
9804 "For each file that the <literal>backout</literal> changeset affected, it does "
9805 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
9806 "that file, to restore it to the contents it had before that changeset was "
9807 "committed."
9808 msgstr ""
9810 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9811 #: ../en/ch08-undo.xml:550
9812 msgid ""
9813 "It commits the result as a new changeset. This changeset has "
9814 "<literal>backout</literal> as its parent."
9815 msgstr ""
9817 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9818 #: ../en/ch08-undo.xml:554
9819 msgid ""
9820 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
9821 "command line, it merges with <literal>orig</literal>, and commits the result "
9822 "of the merge."
9823 msgstr ""
9825 #. type: Content of: <book><chapter><sect1><sect2><para>
9826 #: ../en/ch08-undo.xml:560
9827 msgid ""
9828 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
9829 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
9830 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
9831 "patch\">--reverse</option> option to the <command>patch</command> command to "
9832 "reverse the effect of the change without fiddling with the working "
9833 "directory. This sounds much simpler, but it would not work nearly as well."
9834 msgstr ""
9836 #. type: Content of: <book><chapter><sect1><sect2><para>
9837 #: ../en/ch08-undo.xml:570
9838 msgid ""
9839 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
9840 "a commit, a merge, and another commit is to give the merge machinery the best "
9841 "chance to do a good job when dealing with all the changes <emphasis>between</"
9842 "emphasis> the change you're backing out and the current tip."
9843 msgstr ""
9845 #. type: Content of: <book><chapter><sect1><sect2><para>
9846 #: ../en/ch08-undo.xml:577
9847 msgid ""
9848 "If you're backing out a changeset that's 100 revisions back in your project's "
9849 "history, the chances that the <command>patch</command> command will be able "
9850 "to apply a reverse diff cleanly are not good, because intervening changes are "
9851 "likely to have <quote>broken the context</quote> that <command>patch</"
9852 "command> uses to determine whether it can apply a patch (if this sounds like "
9853 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
9854 "<command>patch</command> command). Also, Mercurial's merge machinery will "
9855 "handle files and directories being renamed, permission changes, and "
9856 "modifications to binary files, none of which <command>patch</command> can "
9857 "deal with."
9858 msgstr ""
9860 #. type: Content of: <book><chapter><sect1><title>
9861 #: ../en/ch08-undo.xml:594
9862 msgid "Changes that should never have been"
9863 msgstr "不该发生的修改"
9865 #. type: Content of: <book><chapter><sect1><para>
9866 #: ../en/ch08-undo.xml:596
9867 msgid ""
9868 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
9869 "is exactly what you need if you want to undo the effects of a change. It "
9870 "leaves a permanent record of exactly what you did, both when committing the "
9871 "original changeset and when you cleaned up after it."
9872 msgstr ""
9874 #. type: Content of: <book><chapter><sect1><para>
9875 #: ../en/ch08-undo.xml:602
9876 msgid ""
9877 "On rare occasions, though, you may find that you've committed a change that "
9878 "really should not be present in the repository at all. For example, it would "
9879 "be very unusual, and usually considered a mistake, to commit a software "
9880 "project's object files as well as its source files. Object files have almost "
9881 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
9882 "the size of the repository and the amount of time it takes to clone or pull "
9883 "changes."
9884 msgstr ""
9886 #. type: Content of: <book><chapter><sect1><para>
9887 #: ../en/ch08-undo.xml:611
9888 msgid ""
9889 "Before I discuss the options that you have if you commit a <quote>brown paper "
9890 "bag</quote> change (the kind that's so bad that you want to pull a brown "
9891 "paper bag over your head), let me first discuss some approaches that probably "
9892 "won't work."
9893 msgstr ""
9895 #. type: Content of: <book><chapter><sect1><para>
9896 #: ../en/ch08-undo.xml:616
9897 msgid ""
9898 "Since Mercurial treats history as accumulative&emdash;every change builds on "
9899 "top of all changes that preceded it&emdash;you generally can't just make "
9900 "disastrous changes disappear. The one exception is when you've just "
9901 "committed a change, and it hasn't been pushed or pulled into another "
9902 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
9903 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
9904 "\"/>."
9905 msgstr ""
9907 #. type: Content of: <book><chapter><sect1><para>
9908 #: ../en/ch08-undo.xml:625
9909 msgid ""
9910 "After you've pushed a bad change to another repository, you <emphasis>could</"
9911 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
9912 "your local copy of the change disappear, but it won't have the consequences "
9913 "you want. The change will still be present in the remote repository, so it "
9914 "will reappear in your local repository the next time you pull."
9915 msgstr ""
9917 #. type: Content of: <book><chapter><sect1><para>
9918 #: ../en/ch08-undo.xml:633
9919 msgid ""
9920 "If a situation like this arises, and you know which repositories your bad "
9921 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
9922 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
9923 "is, of course, not a satisfactory solution: if you miss even a single "
9924 "repository while you're expunging, the change is still <quote>in the wild</"
9925 "quote>, and could propagate further."
9926 msgstr ""
9928 #. type: Content of: <book><chapter><sect1><para>
9929 #: ../en/ch08-undo.xml:641
9930 msgid ""
9931 "If you've committed one or more changes <emphasis>after</emphasis> the change "
9932 "that you'd like to see disappear, your options are further reduced. Mercurial "
9933 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
9934 "changesets intact."
9935 msgstr ""
9937 #. type: Content of: <book><chapter><sect1><para>
9938 #: ../en/ch08-undo.xml:647
9939 msgid ""
9940 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
9941 "<literal>examples</literal> directory works, but doesn't handle merge "
9942 "changesets. Kind of an important omission."
9943 msgstr ""
9945 #. type: Content of: <book><chapter><sect1><sect2><title>
9946 #: ../en/ch08-undo.xml:653
9947 msgid "Protect yourself from <quote>escaped</quote> changes"
9948 msgstr "使用<quote>校验</quote>修改来保护你自己"
9950 #. type: Content of: <book><chapter><sect1><sect2><para>
9951 #: ../en/ch08-undo.xml:656
9952 msgid ""
9953 "If you've committed some changes to your local repository and they've been "
9954 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
9955 "protect yourself ahead of time against some classes of bad changeset. This "
9956 "is particularly easy if your team usually pulls changes from a central "
9957 "repository."
9958 msgstr ""
9960 #. type: Content of: <book><chapter><sect1><sect2><para>
9961 #: ../en/ch08-undo.xml:663
9962 msgid ""
9963 "By configuring some hooks on that repository to validate incoming changesets "
9964 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
9965 "some kinds of bad changeset from being pushed to the central repository at "
9966 "all. With such a configuration in place, some kinds of bad changeset will "
9967 "naturally tend to <quote>die out</quote> because they can't propagate into "
9968 "the central repository. Better yet, this happens without any need for "
9969 "explicit intervention."
9970 msgstr ""
9972 #. type: Content of: <book><chapter><sect1><sect2><para>
9973 #: ../en/ch08-undo.xml:673
9974 msgid ""
9975 "For instance, an incoming change hook that verifies that a changeset will "
9976 "actually compile can prevent people from inadvertantly <quote>breaking the "
9977 "build</quote>."
9978 msgstr ""
9980 #. type: Content of: <book><chapter><sect1><title>
9981 #: ../en/ch08-undo.xml:680
9982 msgid "Finding the source of a bug"
9983 msgstr "查找问题的根源"
9985 #. type: Content of: <book><chapter><sect1><para>
9986 #: ../en/ch08-undo.xml:682
9987 msgid ""
9988 "While it's all very well to be able to back out a changeset that introduced a "
9989 "bug, this requires that you know which changeset to back out. Mercurial "
9990 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
9991 "command>, that helps you to automate this process and accomplish it very "
9992 "efficiently."
9993 msgstr ""
9995 #. type: Content of: <book><chapter><sect1><para>
9996 #: ../en/ch08-undo.xml:689
9997 msgid ""
9998 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
9999 "that a changeset has introduced some change of behavior that you can identify "
10000 "with a simple binary test. You don't know which piece of code introduced the "
10001 "change, but you know how to test for the presence of the bug. The <command "
10002 "role=\"hg-cmd\">hg bisect</command> command uses your test to direct its "
10003 "search for the changeset that introduced the code that caused the bug."
10004 msgstr ""
10006 #. type: Content of: <book><chapter><sect1><para>
10007 #: ../en/ch08-undo.xml:698
10008 msgid ""
10009 "Here are a few scenarios to help you understand how you might apply this "
10010 "command."
10011 msgstr ""
10013 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10014 #: ../en/ch08-undo.xml:701
10015 msgid ""
10016 "The most recent version of your software has a bug that you remember wasn't "
10017 "present a few weeks ago, but you don't know when it was introduced. Here, "
10018 "your binary test checks for the presence of that bug."
10019 msgstr ""
10021 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10022 #: ../en/ch08-undo.xml:706
10023 msgid ""
10024 "You fixed a bug in a rush, and now it's time to close the entry in your "
10025 "team's bug database. The bug database requires a changeset ID when you close "
10026 "an entry, but you don't remember which changeset you fixed the bug in. Once "
10027 "again, your binary test checks for the presence of the bug."
10028 msgstr ""
10030 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10031 #: ../en/ch08-undo.xml:713
10032 msgid ""
10033 "Your software works correctly, but runs 15% slower than the last time you "
10034 "measured it. You want to know which changeset introduced the performance "
10035 "regression. In this case, your binary test measures the performance of your "
10036 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
10037 msgstr ""
10039 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10040 #: ../en/ch08-undo.xml:720
10041 msgid ""
10042 "The sizes of the components of your project that you ship exploded recently, "
10043 "and you suspect that something changed in the way you build your project."
10044 msgstr ""
10046 #. type: Content of: <book><chapter><sect1><para>
10047 #: ../en/ch08-undo.xml:725
10048 msgid ""
10049 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
10050 "bisect</command> command is not useful only for finding the sources of bugs. "
10051 "You can use it to find any <quote>emergent property</quote> of a repository "
10052 "(anything that you can't find from a simple text search of the files in the "
10053 "tree) for which you can write a binary test."
10054 msgstr ""
10056 #. type: Content of: <book><chapter><sect1><para>
10057 #: ../en/ch08-undo.xml:732
10058 msgid ""
10059 "We'll introduce a little bit of terminology here, just to make it clear which "
10060 "parts of the search process are your responsibility, and which are "
10061 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
10062 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
10063 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
10064 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
10065 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
10066 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
10067 "command> command</quote>."
10068 msgstr ""
10070 #. type: Content of: <book><chapter><sect1><para>
10071 #: ../en/ch08-undo.xml:745
10072 msgid ""
10073 "One simple way to automate the searching process would be simply to probe "
10074 "every changeset. However, this scales poorly. If it took ten minutes to "
10075 "test a single changeset, and you had 10,000 changesets in your repository, "
10076 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
10077 "find the changeset that introduced a bug. Even if you knew that the bug was "
10078 "introduced by one of the last 500 changesets, and limited your search to "
10079 "those, you'd still be looking at over 40 hours to find the changeset that "
10080 "introduced your bug."
10081 msgstr ""
10083 #. type: Content of: <book><chapter><sect1><para>
10084 #: ../en/ch08-undo.xml:755
10085 msgid ""
10086 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
10087 "knowledge of the <quote>shape</quote> of your project's revision history to "
10088 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
10089 "of the number of changesets to check (the kind of search it performs is "
10090 "called a dichotomic search). With this approach, searching through 10,000 "
10091 "changesets will take less than three hours, even at ten minutes per test (the "
10092 "search will require about 14 tests). Limit your search to the last hundred "
10093 "changesets, and it will take only about an hour (roughly seven tests)."
10094 msgstr ""
10096 #. type: Content of: <book><chapter><sect1><para>
10097 #: ../en/ch08-undo.xml:766
10098 msgid ""
10099 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
10100 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
10101 "it has no problems dealing with branches, merges, or multiple heads in a "
10102 "repository. It can prune entire branches of history with a single probe, "
10103 "which is how it operates so efficiently."
10104 msgstr ""
10106 #. type: Content of: <book><chapter><sect1><sect2><title>
10107 #: ../en/ch08-undo.xml:774
10108 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
10109 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
10111 #. type: Content of: <book><chapter><sect1><sect2><para>
10112 #: ../en/ch08-undo.xml:777
10113 msgid ""
10114 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
10115 msgstr ""
10117 #. type: Content of: <book><chapter><sect1><sect2><note><para>
10118 #: ../en/ch08-undo.xml:781
10119 msgid ""
10120 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
10121 "bisect</command> was not a core command: it was distributed with Mercurial as "
10122 "an extension. This section describes the built-in command, not the old "
10123 "extension."
10124 msgstr ""
10126 #. type: Content of: <book><chapter><sect1><sect2><para>
10127 #: ../en/ch08-undo.xml:788
10128 msgid ""
10129 "Now let's create a repository, so that we can try out the <command role=\"hg-"
10130 "cmd\">hg bisect</command> command in isolation."
10131 msgstr ""
10133 #. type: Content of: <book><chapter><sect1><sect2><para>
10134 #: ../en/ch08-undo.xml:794
10135 msgid ""
10136 "We'll simulate a project that has a bug in it in a simple-minded way: create "
10137 "trivial changes in a loop, and nominate one specific change that will have "
10138 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
10139 "single file to the repository. We'll represent our <quote>bug</quote> with a "
10140 "file that contains the text <quote>i have a gub</quote>."
10141 msgstr ""
10143 #. type: Content of: <book><chapter><sect1><sect2><para>
10144 #: ../en/ch08-undo.xml:804
10145 msgid ""
10146 "The next thing that we'd like to do is figure out how to use the <command "
10147 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
10148 "built-in help mechanism for this."
10149 msgstr ""
10151 #. type: Content of: <book><chapter><sect1><sect2><para>
10152 #: ../en/ch08-undo.xml:811
10153 msgid ""
10154 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
10155 "Each step proceeds as follows."
10156 msgstr ""
10158 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10159 #: ../en/ch08-undo.xml:814
10160 msgid "You run your binary test."
10161 msgstr ""
10163 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
10164 #: ../en/ch08-undo.xml:816
10165 msgid ""
10166 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
10167 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
10168 msgstr ""
10170 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
10171 #: ../en/ch08-undo.xml:821
10172 msgid ""
10173 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
10174 "command."
10175 msgstr ""
10177 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10178 #: ../en/ch08-undo.xml:825
10179 msgid ""
10180 "The command uses your information to decide which changeset to test next."
10181 msgstr ""
10183 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
10184 #: ../en/ch08-undo.xml:828
10185 msgid ""
10186 "It updates the working directory to that changeset, and the process begins "
10187 "again."
10188 msgstr ""
10190 #. type: Content of: <book><chapter><sect1><sect2><para>
10191 #: ../en/ch08-undo.xml:831
10192 msgid ""
10193 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
10194 "a unique changeset that marks the point where your test transitioned from "
10195 "<quote>succeeding</quote> to <quote>failing</quote>."
10196 msgstr ""
10199 #. type: Content of: <book><chapter><sect1><sect2><para>
10200 #: ../en/ch08-undo.xml:836
10201 msgid ""
10202 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
10203 "reset</command> command."
10204 msgstr ""
10206 #. type: Content of: <book><chapter><sect1><sect2><para>
10207 #: ../en/ch08-undo.xml:841
10208 msgid ""
10209 "In our case, the binary test we use is simple: we check to see if any file in "
10210 "the repository contains the string <quote>i have a gub</quote>. If it does, "
10211 "this changeset contains the change that <quote>caused the bug</quote>. By "
10212 "convention, a changeset that has the property we're searching for is "
10213 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
10214 msgstr ""
10216 #. type: Content of: <book><chapter><sect1><sect2><para>
10217 #: ../en/ch08-undo.xml:849
10218 msgid ""
10219 "Most of the time, the revision to which the working directory is synced "
10220 "(usually the tip) already exhibits the problem introduced by the buggy "
10221 "change, so we'll mark it as <quote>bad</quote>."
10222 msgstr ""
10225 #. type: Content of: <book><chapter><sect1><sect2><para>
10226 #: ../en/ch08-undo.xml:856
10227 msgid ""
10228 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
10229 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
10230 "command will <quote>bracket</quote> its search between the first pair of good "
10231 "and bad changesets. In our case, we know that revision 10 didn't have the "
10232 "bug. (I'll have more words about choosing the first <quote>good</quote> "
10233 "changeset later.)"
10234 msgstr ""
10236 #. type: Content of: <book><chapter><sect1><sect2><para>
10237 #: ../en/ch08-undo.xml:866
10238 msgid "Notice that this command printed some output."
10239 msgstr ""
10241 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10242 #: ../en/ch08-undo.xml:868
10243 msgid ""
10244 "It told us how many changesets it must consider before it can identify the "
10245 "one that introduced the bug, and how many tests that will require."
10246 msgstr ""
10248 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10249 #: ../en/ch08-undo.xml:872
10250 msgid ""
10251 "It updated the working directory to the next changeset to test, and told us "
10252 "which changeset it's testing."
10253 msgstr ""
10255 #. type: Content of: <book><chapter><sect1><sect2><para>
10256 #: ../en/ch08-undo.xml:877
10257 msgid ""
10258 "We now run our test in the working directory. We use the <command>grep</"
10259 "command> command to see if our <quote>bad</quote> file is present in the "
10260 "working directory. If it is, this revision is bad; if not, this revision is "
10261 "good. &interaction.bisect.search.step1;"
10262 msgstr ""
10264 #. type: Content of: <book><chapter><sect1><sect2><para>
10265 #: ../en/ch08-undo.xml:883
10266 msgid ""
10267 "This test looks like a perfect candidate for automation, so let's turn it "
10268 "into a shell function."
10269 msgstr ""
10271 #. type: Content of: <book><chapter><sect1><sect2><para>
10272 #: ../en/ch08-undo.xml:887
10273 msgid ""
10274 "We can now run an entire test step with a single command, <literal>mytest</"
10275 "literal>."
10276 msgstr ""
10278 #. type: Content of: <book><chapter><sect1><sect2><para>
10279 #: ../en/ch08-undo.xml:892
10280 msgid "A few more invocations of our canned test step command, and we're done."
10281 msgstr ""
10283 #. type: Content of: <book><chapter><sect1><sect2><para>
10284 #: ../en/ch08-undo.xml:897
10285 msgid ""
10286 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
10287 "\">hg bisect</command> command let us find the changeset that introduced our "
10288 "<quote>bug</quote> with only five tests. Because the number of tests that "
10289 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
10290 "logarithmically with the number of changesets to search, the advantage that "
10291 "it has over the <quote>brute force</quote> search approach increases with "
10292 "every changeset you add."
10293 msgstr ""
10295 #. type: Content of: <book><chapter><sect1><sect2><title>
10296 #: ../en/ch08-undo.xml:908
10297 msgid "Cleaning up after your search"
10298 msgstr "搜索后的清理"
10301 #. type: Content of: <book><chapter><sect1><sect2><para>
10302 #: ../en/ch08-undo.xml:910
10303 msgid ""
10304 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
10305 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
10306 "reset</command> command to drop the information it was using to drive your "
10307 "search. The command doesn't use much space, so it doesn't matter if you "
10308 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
10309 "command> won't let you start a new search in that repository until you do a "
10310 "<command role=\"hg-cmd\">hg bisect reset</command>."
10311 msgstr ""
10313 #. type: Content of: <book><chapter><sect1><title>
10314 #: ../en/ch08-undo.xml:925
10315 msgid "Tips for finding bugs effectively"
10316 msgstr "有效查找问题的技巧"
10318 #. type: Content of: <book><chapter><sect1><sect2><title>
10319 #: ../en/ch08-undo.xml:928
10320 msgid "Give consistent input"
10321 msgstr "给出一致的输入"
10323 #. type: Content of: <book><chapter><sect1><sect2><para>
10324 #: ../en/ch08-undo.xml:930
10325 msgid ""
10326 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
10327 "correctly report the result of every test you perform. If you tell it that a "
10328 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
10329 "to detect the inconsistency. If it can identify an inconsistency in your "
10330 "reports, it will tell you that a particular changeset is both good and bad. "
10331 "However, it can't do this perfectly; it's about as likely to report the wrong "
10332 "changeset as the source of the bug."
10333 msgstr ""
10335 #. type: Content of: <book><chapter><sect1><sect2><title>
10336 #: ../en/ch08-undo.xml:942
10337 msgid "Automate as much as possible"
10338 msgstr "尽量自动"
10340 #. type: Content of: <book><chapter><sect1><sect2><para>
10341 #: ../en/ch08-undo.xml:944
10342 msgid ""
10343 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
10344 "command, I tried a few times to run my tests by hand, on the command line. "
10345 "This is an approach that I, at least, am not suited to. After a few tries, I "
10346 "found that I was making enough mistakes that I was having to restart my "
10347 "searches several times before finally getting correct results."
10348 msgstr ""
10350 #. type: Content of: <book><chapter><sect1><sect2><para>
10351 #: ../en/ch08-undo.xml:952
10352 msgid ""
10353 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
10354 "command> command by hand occurred even with simple searches on small "
10355 "repositories; if the problem you're looking for is more subtle, or the number "
10356 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
10357 "increases, the likelihood of operator error ruining the search is much "
10358 "higher. Once I started automating my tests, I had much better results."
10359 msgstr ""
10361 #. type: Content of: <book><chapter><sect1><sect2><para>
10362 #: ../en/ch08-undo.xml:961
10363 msgid "The key to automated testing is twofold:"
10364 msgstr ""
10366 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10367 #: ../en/ch08-undo.xml:963
10368 msgid "always test for the same symptom, and"
10369 msgstr ""
10371 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10372 #: ../en/ch08-undo.xml:965
10373 msgid ""
10374 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
10375 "command> command."
10376 msgstr ""
10378 #. type: Content of: <book><chapter><sect1><sect2><para>
10379 #: ../en/ch08-undo.xml:968
10380 msgid ""
10381 "In my tutorial example above, the <command>grep</command> command tests for "
10382 "the symptom, and the <literal>if</literal> statement takes the result of this "
10383 "check and ensures that we always feed the same input to the <command role="
10384 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
10385 "function marries these together in a reproducible way, so that every test is "
10386 "uniform and consistent."
10387 msgstr ""
10389 #. type: Content of: <book><chapter><sect1><sect2><title>
10390 #: ../en/ch08-undo.xml:978
10391 msgid "Check your results"
10392 msgstr "检查你的结果"
10394 #. type: Content of: <book><chapter><sect1><sect2><para>
10395 #: ../en/ch08-undo.xml:980
10396 msgid ""
10397 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
10398 "is only as good as the input you give it, don't take the changeset it reports "
10399 "as the absolute truth. A simple way to cross-check its report is to manually "
10400 "run your test at each of the following changesets:"
10401 msgstr ""
10403 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10404 #: ../en/ch08-undo.xml:986
10405 msgid ""
10406 "The changeset that it reports as the first bad revision. Your test should "
10407 "still report this as bad."
10408 msgstr ""
10410 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10411 #: ../en/ch08-undo.xml:990
10412 msgid ""
10413 "The parent of that changeset (either parent, if it's a merge). Your test "
10414 "should report this changeset as good."
10415 msgstr ""
10417 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
10418 #: ../en/ch08-undo.xml:994
10419 msgid ""
10420 "A child of that changeset. Your test should report this changeset as bad."
10421 msgstr ""
10423 #. type: Content of: <book><chapter><sect1><sect2><title>
10424 #: ../en/ch08-undo.xml:1000
10425 msgid "Beware interference between bugs"
10426 msgstr "谨防问题之间的冲突"
10428 #. type: Content of: <book><chapter><sect1><sect2><para>
10429 #: ../en/ch08-undo.xml:1002
10430 msgid ""
10431 "It's possible that your search for one bug could be disrupted by the presence "
10432 "of another. For example, let's say your software crashes at revision 100, "
10433 "and worked correctly at revision 50. Unknown to you, someone else introduced "
10434 "a different crashing bug at revision 60, and fixed it at revision 80. This "
10435 "could distort your results in one of several ways."
10436 msgstr ""
10438 #. type: Content of: <book><chapter><sect1><sect2><para>
10439 #: ../en/ch08-undo.xml:1010
10440 msgid ""
10441 "It is possible that this other bug completely <quote>masks</quote> yours, "
10442 "which is to say that it occurs before your bug has a chance to manifest "
10443 "itself. If you can't avoid that other bug (for example, it prevents your "
10444 "project from building), and so can't tell whether your bug is present in a "
10445 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
10446 "command cannot help you directly. Instead, you can mark a changeset as "
10447 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
10448 msgstr ""
10450 #. type: Content of: <book><chapter><sect1><sect2><para>
10451 #: ../en/ch08-undo.xml:1020
10452 msgid ""
10453 "A different problem could arise if your test for a bug's presence is not "
10454 "specific enough. If you check for <quote>my program crashes</quote>, then "
10455 "both your crashing bug and an unrelated crashing bug that masks it will look "
10456 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
10457 msgstr ""
10459 #. type: Content of: <book><chapter><sect1><sect2><para>
10460 #: ../en/ch08-undo.xml:1027
10461 msgid ""
10462 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
10463 "skip</command> is if you can't test a revision because your project was in a "
10464 "broken and hence untestable state at that revision, perhaps because someone "
10465 "checked in a change that prevented the project from building."
10466 msgstr ""
10468 #. type: Content of: <book><chapter><sect1><sect2><title>
10469 #: ../en/ch08-undo.xml:1036
10470 msgid "Bracket your search lazily"
10471 msgstr "减少你的查找工作"
10473 #. type: Content of: <book><chapter><sect1><sect2><para>
10474 #: ../en/ch08-undo.xml:1038
10475 msgid ""
10476 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
10477 "will mark the end points of your search is often easy, but it bears a little "
10478 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
10479 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
10480 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
10481 msgstr ""
10483 #. type: Content of: <book><chapter><sect1><sect2><para>
10484 #: ../en/ch08-undo.xml:1046
10485 msgid ""
10486 "If you're having trouble remembering when a suitable <quote>good</quote> "
10487 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
10488 "command>, you could do worse than testing changesets at random. Just "
10489 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
10490 "because the feature with the bug isn't present yet) and those where another "
10491 "problem masks the bug (as I discussed above)."
10492 msgstr ""
10494 #. type: Content of: <book><chapter><sect1><sect2><para>
10495 #: ../en/ch08-undo.xml:1055
10496 msgid ""
10497 "Even if you end up <quote>early</quote> by thousands of changesets or months "
10498 "of history, you will only add a handful of tests to the total number that "
10499 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
10500 "logarithmic behavior."
10501 msgstr ""
10503 #. type: Content of: <book><chapter><title>
10504 #: ../en/ch09-hook.xml:5
10505 msgid "Handling repository events with hooks"
10506 msgstr "使用钩子处理版本库事件"
10508 #. type: Content of: <book><chapter><para>
10509 #: ../en/ch09-hook.xml:7
10510 msgid ""
10511 "Mercurial offers a powerful mechanism to let you perform automated actions in "
10512 "response to events that occur in a repository. In some cases, you can even "
10513 "control Mercurial's response to those events."
10514 msgstr ""
10516 #. type: Content of: <book><chapter><para>
10517 #: ../en/ch09-hook.xml:12
10518 msgid ""
10519 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
10520 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
10521 "systems, but the two names refer to the same idea."
10522 msgstr ""
10524 #. type: Content of: <book><chapter><sect1><title>
10525 #: ../en/ch09-hook.xml:18
10526 msgid "An overview of hooks in Mercurial"
10527 msgstr "Mercurial 钩子概述"
10529 #. type: Content of: <book><chapter><sect1><para>
10530 #: ../en/ch09-hook.xml:20
10531 msgid ""
10532 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
10533 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
10534 msgstr ""
10536 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10537 #: ../en/ch09-hook.xml:25
10538 msgid ""
10539 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
10540 "changesets has been brought into the repository from elsewhere."
10541 msgstr ""
10543 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10544 #: ../en/ch09-hook.xml:29
10545 msgid ""
10546 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
10547 "has been created in the local repository."
10548 msgstr ""
10550 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10551 #: ../en/ch09-hook.xml:33
10552 msgid ""
10553 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
10554 "changeset that is brought into the repository from elsewhere. Notice the "
10555 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
10556 "once per <emphasis>group</emphasis> of changesets brought in."
10557 msgstr ""
10559 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10560 #: ../en/ch09-hook.xml:40
10561 msgid ""
10562 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
10563 "changesets has been transmitted from this repository."
10564 msgstr ""
10566 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10567 #: ../en/ch09-hook.xml:44
10568 msgid ""
10569 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
10570 "to bring a group of changesets into the repository."
10571 msgstr ""
10573 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10574 #: ../en/ch09-hook.xml:49
10575 msgid ""
10576 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
10577 "starting a commit."
10578 msgstr ""
10580 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10581 #: ../en/ch09-hook.xml:53
10582 msgid ""
10583 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
10584 "starting to transmit a group of changesets from this repository."
10585 msgstr ""
10587 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10588 #: ../en/ch09-hook.xml:58
10589 msgid ""
10590 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
10591 "creating a tag."
10592 msgstr ""
10594 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10595 #: ../en/ch09-hook.xml:62
10596 msgid ""
10597 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
10598 "after a group of changesets has been brought into the local repository from "
10599 "another, but before the transaction completes that will make the changes "
10600 "permanent in the repository."
10601 msgstr ""
10603 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10604 #: ../en/ch09-hook.xml:70
10605 msgid ""
10606 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
10607 "a new changeset has been created in the local repository, but before the "
10608 "transaction completes that will make it permanent."
10609 msgstr ""
10611 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10612 #: ../en/ch09-hook.xml:76
10613 msgid ""
10614 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
10615 "starting an update or merge of the working directory."
10616 msgstr ""
10618 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10619 #: ../en/ch09-hook.xml:81
10620 msgid ""
10621 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
10622 msgstr ""
10624 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10625 #: ../en/ch09-hook.xml:85
10626 msgid ""
10627 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
10628 "of the working directory has finished."
10629 msgstr ""
10631 #. type: Content of: <book><chapter><sect1><para>
10632 #: ../en/ch09-hook.xml:90
10633 msgid ""
10634 "Each of the hooks whose description begins with the word <quote>Controlling</"
10635 "quote> has the ability to determine whether an activity can proceed. If the "
10636 "hook succeeds, the activity may proceed; if it fails, the activity is either "
10637 "not permitted or undone, depending on the hook."
10638 msgstr ""
10640 #. type: Content of: <book><chapter><sect1><title>
10641 #: ../en/ch09-hook.xml:99
10642 msgid "Hooks and security"
10643 msgstr "钩子与安全性"
10645 #. type: Content of: <book><chapter><sect1><sect2><title>
10646 #: ../en/ch09-hook.xml:102
10647 msgid "Hooks are run with your privileges"
10648 msgstr "钩子以你的特权执行"
10650 #. type: Content of: <book><chapter><sect1><sect2><para>
10651 #: ../en/ch09-hook.xml:104
10652 msgid ""
10653 "When you run a Mercurial command in a repository, and the command causes a "
10654 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
10655 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
10656 "privilege level. Since hooks are arbitrary pieces of executable code, you "
10657 "should treat them with an appropriate level of suspicion. Do not install a "
10658 "hook unless you are confident that you know who created it and what it does."
10659 msgstr ""
10661 #. type: Content of: <book><chapter><sect1><sect2><para>
10662 #: ../en/ch09-hook.xml:115
10663 msgid ""
10664 "In some cases, you may be exposed to hooks that you did not install "
10665 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
10666 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
10667 "filename> file."
10668 msgstr ""
10670 #. type: Content of: <book><chapter><sect1><sect2><para>
10671 #: ../en/ch09-hook.xml:122
10672 msgid ""
10673 "If you are working with a repository owned by another user, Mercurial can run "
10674 "hooks defined in that user's repository, but it will still run them as "
10675 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
10676 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
10677 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
10678 "that hook will run under your user account, even though you don't own that "
10679 "repository."
10680 msgstr ""
10682 #. type: Content of: <book><chapter><sect1><sect2><note><para>
10683 #: ../en/ch09-hook.xml:134
10684 msgid ""
10685 "This only applies if you are pulling from a repository on a local or network "
10686 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
10687 "\">outgoing</literal> hook will run under whatever account is executing the "
10688 "server process, on the server."
10689 msgstr ""
10691 #. type: Content of: <book><chapter><sect1><sect2><para>
10692 #: ../en/ch09-hook.xml:142
10693 msgid ""
10694 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
10695 "cmd\">hg config hooks</command> command. If you are working in one "
10696 "repository, but talking to another that you do not own (e.g. using <command "
10697 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
10698 "command>), remember that it is the other repository's hooks you should be "
10699 "checking, not your own."
10700 msgstr ""
10702 #. type: Content of: <book><chapter><sect1><sect2><title>
10703 #: ../en/ch09-hook.xml:153
10704 msgid "Hooks do not propagate"
10705 msgstr "钩子不会传播"
10707 #. type: Content of: <book><chapter><sect1><sect2><para>
10708 #: ../en/ch09-hook.xml:155
10709 msgid ""
10710 "In Mercurial, hooks are not revision controlled, and do not propagate when "
10711 "you clone, or pull from, a repository. The reason for this is simple: a hook "
10712 "is a completely arbitrary piece of executable code. It runs under your user "
10713 "identity, with your privilege level, on your machine."
10714 msgstr ""
10716 #. type: Content of: <book><chapter><sect1><sect2><para>
10717 #: ../en/ch09-hook.xml:162
10718 msgid ""
10719 "It would be extremely reckless for any distributed revision control system to "
10720 "implement revision-controlled hooks, as this would offer an easily "
10721 "exploitable way to subvert the accounts of users of the revision control "
10722 "system."
10723 msgstr ""
10725 #. type: Content of: <book><chapter><sect1><sect2><para>
10726 #: ../en/ch09-hook.xml:168
10727 msgid ""
10728 "Since Mercurial does not propagate hooks, if you are collaborating with other "
10729 "people on a common project, you should not assume that they are using the "
10730 "same Mercurial hooks as you are, or that theirs are correctly configured. "
10731 "You should document the hooks you expect people to use."
10732 msgstr ""
10734 #. type: Content of: <book><chapter><sect1><sect2><para>
10735 #: ../en/ch09-hook.xml:175
10736 msgid ""
10737 "In a corporate intranet, this is somewhat easier to control, as you can for "
10738 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
10739 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
10740 "file to define hooks that all users will see. However, this too has its "
10741 "limits; see below."
10742 msgstr ""
10744 #. type: Content of: <book><chapter><sect1><sect2><title>
10745 #: ../en/ch09-hook.xml:184
10746 msgid "Hooks can be overridden"
10747 msgstr "钩子可以被覆盖"
10749 #. type: Content of: <book><chapter><sect1><sect2><para>
10750 #: ../en/ch09-hook.xml:186
10751 msgid ""
10752 "Mercurial allows you to override a hook definition by redefining the hook. "
10753 "You can disable it by setting its value to the empty string, or change its "
10754 "behavior as you wish."
10755 msgstr ""
10757 #. type: Content of: <book><chapter><sect1><sect2><para>
10758 #: ../en/ch09-hook.xml:191
10759 msgid ""
10760 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
10761 "filename> file that defines some hooks, you should thus understand that your "
10762 "users can disable or override those hooks."
10763 msgstr ""
10765 #. type: Content of: <book><chapter><sect1><sect2><title>
10766 #: ../en/ch09-hook.xml:199
10767 msgid "Ensuring that critical hooks are run"
10768 msgstr "确保关键钩子的执行"
10770 #. type: Content of: <book><chapter><sect1><sect2><para>
10771 #: ../en/ch09-hook.xml:201
10772 msgid ""
10773 "Sometimes you may want to enforce a policy that you do not want others to be "
10774 "able to work around. For example, you may have a requirement that every "
10775 "changeset must pass a rigorous set of tests. Defining this requirement via a "
10776 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
10777 "for remote users on laptops, and of course local users can subvert it at will "
10778 "by overriding the hook."
10779 msgstr ""
10781 #. type: Content of: <book><chapter><sect1><sect2><para>
10782 #: ../en/ch09-hook.xml:210
10783 msgid ""
10784 "Instead, you can set up your policies for use of Mercurial so that people are "
10785 "expected to propagate changes through a well-known <quote>canonical</quote> "
10786 "server that you have locked down and configured appropriately."
10787 msgstr ""
10789 #. type: Content of: <book><chapter><sect1><sect2><para>
10790 #: ../en/ch09-hook.xml:216
10791 msgid ""
10792 "One way to do this is via a combination of social engineering and "
10793 "technology. Set up a restricted-access account; users can push changes over "
10794 "the network to repositories managed by this account, but they cannot log into "
10795 "the account and run normal shell commands. In this scenario, a user can "
10796 "commit a changeset that contains any old garbage they want."
10797 msgstr ""
10799 #. type: Content of: <book><chapter><sect1><sect2><para>
10800 #: ../en/ch09-hook.xml:225
10801 msgid ""
10802 "When someone pushes a changeset to the server that everyone pulls from, the "
10803 "server will test the changeset before it accepts it as permanent, and reject "
10804 "it if it fails to pass the test suite. If people only pull changes from this "
10805 "filtering server, it will serve to ensure that all changes that people pull "
10806 "have been automatically vetted."
10807 msgstr ""
10809 #. type: Content of: <book><chapter><sect1><title>
10810 #: ../en/ch09-hook.xml:236
10811 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
10812 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
10814 #. type: Content of: <book><chapter><sect1><para>
10815 #: ../en/ch09-hook.xml:239
10816 msgid ""
10817 "If you want to use hooks to do some automated work in a repository that a "
10818 "number of people have shared access to, you need to be careful in how you do "
10819 "this."
10820 msgstr ""
10822 #. type: Content of: <book><chapter><sect1><para>
10823 #: ../en/ch09-hook.xml:244
10824 msgid ""
10825 "Mercurial only locks a repository when it is writing to the repository, and "
10826 "only the parts of Mercurial that write to the repository pay attention to "
10827 "locks. Write locks are necessary to prevent multiple simultaneous writers "
10828 "from scribbling on each other's work, corrupting the repository."
10829 msgstr ""
10831 #. type: Content of: <book><chapter><sect1><para>
10832 #: ../en/ch09-hook.xml:251
10833 msgid ""
10834 "Because Mercurial is careful with the order in which it reads and writes "
10835 "data, it does not need to acquire a lock when it wants to read data from the "
10836 "repository. The parts of Mercurial that read from the repository never pay "
10837 "attention to locks. This lockless reading scheme greatly increases "
10838 "performance and concurrency."
10839 msgstr ""
10841 #. type: Content of: <book><chapter><sect1><para>
10842 #: ../en/ch09-hook.xml:259
10843 msgid ""
10844 "With great performance comes a trade-off, though, one which has the potential "
10845 "to cause you trouble unless you're aware of it. To describe this requires a "
10846 "little detail about how Mercurial adds changesets to a repository and reads "
10847 "those changes."
10848 msgstr ""
10850 #. type: Content of: <book><chapter><sect1><para>
10851 #: ../en/ch09-hook.xml:266
10852 msgid ""
10853 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
10854 "into the destination file. It writes file data first, then manifest data "
10855 "(which contains pointers to the new file data), then changelog data (which "
10856 "contains pointers to the new manifest data). Before the first write to each "
10857 "file, it stores a record of where the end of the file was in its transaction "
10858 "log. If the transaction must be rolled back, Mercurial simply truncates each "
10859 "file back to the size it was before the transaction began."
10860 msgstr ""
10862 #. type: Content of: <book><chapter><sect1><para>
10863 #: ../en/ch09-hook.xml:277
10864 msgid ""
10865 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
10866 "first, then everything else. Since a reader will only access parts of the "
10867 "manifest or file metadata that it can see in the changelog, it can never see "
10868 "partially written data."
10869 msgstr ""
10871 #. type: Content of: <book><chapter><sect1><para>
10872 #: ../en/ch09-hook.xml:283
10873 msgid ""
10874 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
10875 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
10876 "almost complete. All of the metadata has been written, but Mercurial can "
10877 "still roll the transaction back and cause the newly-written data to disappear."
10878 msgstr ""
10880 #. type: Content of: <book><chapter><sect1><para>
10881 #: ../en/ch09-hook.xml:291
10882 msgid ""
10883 "If one of these hooks runs for long, it opens a window of time during which a "
10884 "reader can see the metadata for changesets that are not yet permanent, and "
10885 "should not be thought of as <quote>really there</quote>. The longer the hook "
10886 "runs, the longer that window is open."
10887 msgstr ""
10889 #. type: Content of: <book><chapter><sect1><sect2><title>
10890 #: ../en/ch09-hook.xml:299
10891 msgid "The problem illustrated"
10892 msgstr "问题的演示"
10894 #. type: Content of: <book><chapter><sect1><sect2><para>
10895 #: ../en/ch09-hook.xml:301
10896 msgid ""
10897 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
10898 "literal> hook would be to automatically build and test incoming changes "
10899 "before they are accepted into a central repository. This could let you "
10900 "guarantee that nobody can push changes to this repository that <quote>break "
10901 "the build</quote>. But if a client can pull changes while they're being "
10902 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
10903 "untested changes, potentially breaking their build."
10904 msgstr ""
10906 #. type: Content of: <book><chapter><sect1><sect2><para>
10907 #: ../en/ch09-hook.xml:312
10908 msgid ""
10909 "The safest technological answer to this challenge is to set up such a "
10910 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
10911 "Let it take changes pushed in from the outside, but do not allow anyone to "
10912 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
10913 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
10914 "literal> hook so that if a build or test succeeds, the hook will push the new "
10915 "changes out to another repository that people <emphasis>can</emphasis> pull "
10916 "from."
10917 msgstr ""
10919 #. type: Content of: <book><chapter><sect1><sect2><para>
10920 #: ../en/ch09-hook.xml:324
10921 msgid ""
10922 "In practice, putting a centralised bottleneck like this in place is not often "
10923 "a good idea, and transaction visibility has nothing to do with the problem. "
10924 "As the size of a project&emdash;and the time it takes to build and "
10925 "test&emdash;grows, you rapidly run into a wall with this <quote>try before "
10926 "you buy</quote> approach, where you have more changesets to test than time in "
10927 "which to deal with them. The inevitable result is frustration on the part of "
10928 "all involved."
10929 msgstr ""
10931 #. type: Content of: <book><chapter><sect1><sect2><para>
10932 #: ../en/ch09-hook.xml:335
10933 msgid ""
10934 "An approach that scales better is to get people to build and test before they "
10935 "push, then run automated builds and tests centrally <emphasis>after</"
10936 "emphasis> a push, to be sure all is well. The advantage of this approach is "
10937 "that it does not impose a limit on the rate at which the repository can "
10938 "accept changes."
10939 msgstr ""
10941 #. type: Content of: <book><chapter><sect1><title>
10942 #: ../en/ch09-hook.xml:346
10943 msgid "A short tutorial on using hooks"
10944 msgstr "使用钩子的简短指南"
10946 #. type: Content of: <book><chapter><sect1><para>
10947 #: ../en/ch09-hook.xml:348
10948 msgid ""
10949 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
10950 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
10951 "the hash of the changeset you just created. The hook is called <literal role="
10952 "\"hook\">commit</literal>."
10953 msgstr ""
10955 #. type: Content of: <book><chapter><sect1><para>
10956 #: ../en/ch09-hook.xml:355
10957 msgid "All hooks follow the pattern in this example."
10958 msgstr ""
10960 #. type: Content of: <book><chapter><sect1><para>
10961 #: ../en/ch09-hook.xml:359
10962 msgid ""
10963 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
10964 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
10965 "of the event to trigger on; on the right is the action to take. As you can "
10966 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
10967 "extra information to the hook using environment variables (look for "
10968 "<envar>HG_NODE</envar> in the example)."
10969 msgstr ""
10971 #. type: Content of: <book><chapter><sect1><sect2><title>
10972 #: ../en/ch09-hook.xml:369
10973 msgid "Performing multiple actions per event"
10974 msgstr "每个事件执行多个操作"
10976 #. type: Content of: <book><chapter><sect1><sect2><para>
10977 #: ../en/ch09-hook.xml:371
10978 msgid ""
10979 "Quite often, you will want to define more than one hook for a particular kind "
10980 "of event, as shown below."
10981 msgstr ""
10983 #. type: Content of: <book><chapter><sect1><sect2><para>
10984 #: ../en/ch09-hook.xml:376
10985 msgid ""
10986 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
10987 "end of a hook's name. You extend a hook's name by giving the name of the "
10988 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
10989 "character), followed by some more text of your choosing. For example, "
10990 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
10991 "bar</literal> when the <literal>commit</literal> event occurs."
10992 msgstr ""
10994 #. type: Content of: <book><chapter><sect1><sect2><para>
10995 #: ../en/ch09-hook.xml:387
10996 msgid ""
10997 "To give a well-defined order of execution when there are multiple hooks "
10998 "defined for an event, Mercurial sorts hooks by extension, and executes the "
10999 "hook commands in this sorted order. In the above example, it will execute "
11000 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
11001 "<literal>commit</literal> before both."
11002 msgstr ""
11004 #. type: Content of: <book><chapter><sect1><sect2><para>
11005 #: ../en/ch09-hook.xml:396
11006 msgid ""
11007 "It is a good idea to use a somewhat descriptive extension when you define a "
11008 "new hook. This will help you to remember what the hook was for. If the hook "
11009 "fails, you'll get an error message that contains the hook name and extension, "
11010 "so using a descriptive extension could give you an immediate hint as to why "
11011 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
11012 msgstr ""
11014 #. type: Content of: <book><chapter><sect1><sect2><title>
11015 #: ../en/ch09-hook.xml:407
11016 msgid "Controlling whether an activity can proceed"
11017 msgstr "控制处理的活动"
11019 #. type: Content of: <book><chapter><sect1><sect2><para>
11020 #: ../en/ch09-hook.xml:409
11021 msgid ""
11022 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
11023 "hook, which is run after a commit has completed. This is one of several "
11024 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
11025 "of influencing the activity itself."
11026 msgstr ""
11028 #. type: Content of: <book><chapter><sect1><sect2><para>
11029 #: ../en/ch09-hook.xml:416
11030 msgid ""
11031 "Mercurial defines a number of events that occur before an activity starts; or "
11032 "after it starts, but before it finishes. Hooks that trigger on these events "
11033 "have the added ability to choose whether the activity can continue, or will "
11034 "abort."
11035 msgstr ""
11037 #. type: Content of: <book><chapter><sect1><sect2><para>
11038 #: ../en/ch09-hook.xml:422
11039 msgid ""
11040 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
11041 "has all but completed. In other words, the metadata representing the "
11042 "changeset has been written out to disk, but the transaction has not yet been "
11043 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
11044 "has the ability to decide whether the transaction can complete, or must be "
11045 "rolled back."
11046 msgstr ""
11048 #. type: Content of: <book><chapter><sect1><sect2><para>
11049 #: ../en/ch09-hook.xml:431
11050 msgid ""
11051 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
11052 "code of zero, the transaction is allowed to complete; the commit finishes; "
11053 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
11054 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
11055 "the transaction is rolled back; the metadata representing the changeset is "
11056 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
11057 msgstr ""
11059 #. type: Content of: <book><chapter><sect1><sect2><para>
11060 #: ../en/ch09-hook.xml:443
11061 msgid ""
11062 "The hook in the example above checks that a commit comment contains a bug "
11063 "ID. If it does, the commit can complete. If not, the commit is rolled back."
11064 msgstr ""
11066 #. type: Content of: <book><chapter><sect1><title>
11067 #: ../en/ch09-hook.xml:451
11068 msgid "Writing your own hooks"
11069 msgstr "编写钩子"
11071 #. type: Content of: <book><chapter><sect1><para>
11072 #: ../en/ch09-hook.xml:453
11073 msgid ""
11074 "When you are writing a hook, you might find it useful to run Mercurial either "
11075 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
11076 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
11077 "When you do so, Mercurial will print a message before it calls each hook."
11078 msgstr ""
11080 #. type: Content of: <book><chapter><sect1><sect2><title>
11081 #: ../en/ch09-hook.xml:462
11082 msgid "Choosing how your hook should run"
11083 msgstr "选择钩子的执行方式"
11085 #. type: Content of: <book><chapter><sect1><sect2><para>
11086 #: ../en/ch09-hook.xml:464
11087 msgid ""
11088 "You can write a hook either as a normal program&emdash;typically a shell "
11089 "script&emdash;or as a Python function that is executed within the Mercurial "
11090 "process."
11091 msgstr ""
11093 #. type: Content of: <book><chapter><sect1><sect2><para>
11094 #: ../en/ch09-hook.xml:469
11095 msgid ""
11096 "Writing a hook as an external program has the advantage that it requires no "
11097 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
11098 "to get any added information you need. The trade-off is that external hooks "
11099 "are slower than in-process hooks."
11100 msgstr ""
11102 #. type: Content of: <book><chapter><sect1><sect2><para>
11103 #: ../en/ch09-hook.xml:476
11104 msgid ""
11105 "An in-process Python hook has complete access to the Mercurial API, and does "
11106 "not <quote>shell out</quote> to another process, so it is inherently faster "
11107 "than an external hook. It is also easier to obtain much of the information "
11108 "that a hook requires by using the Mercurial API than by running Mercurial "
11109 "commands."
11110 msgstr ""
11112 #. type: Content of: <book><chapter><sect1><sect2><para>
11113 #: ../en/ch09-hook.xml:484
11114 msgid ""
11115 "If you are comfortable with Python, or require high performance, writing your "
11116 "hooks in Python may be a good choice. However, when you have a "
11117 "straightforward hook to write and you don't need to care about performance "
11118 "(probably the majority of hooks), a shell script is perfectly fine."
11119 msgstr ""
11121 #. type: Content of: <book><chapter><sect1><sect2><title>
11122 #: ../en/ch09-hook.xml:493
11123 msgid "Hook parameters"
11124 msgstr "钩子的参数"
11126 #. type: Content of: <book><chapter><sect1><sect2><para>
11127 #: ../en/ch09-hook.xml:495
11128 msgid ""
11129 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
11130 "a parameter is passed as a keyword argument to your hook function. For an "
11131 "external program, a parameter is passed as an environment variable."
11132 msgstr ""
11134 #. type: Content of: <book><chapter><sect1><sect2><para>
11135 #: ../en/ch09-hook.xml:501
11136 msgid ""
11137 "Whether your hook is written in Python or as a shell script, the hook-"
11138 "specific parameter names and values will be the same. A boolean parameter "
11139 "will be represented as a boolean value in Python, but as the number 1 (for "
11140 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
11141 "variable for an external hook. If a hook parameter is named <literal>foo</"
11142 "literal>, the keyword argument for a Python hook will also be named "
11143 "<literal>foo</literal>, while the environment variable for an external hook "
11144 "will be named <literal>HG_FOO</literal>."
11145 msgstr ""
11147 #. type: Content of: <book><chapter><sect1><sect2><title>
11148 #: ../en/ch09-hook.xml:515
11149 msgid "Hook return values and activity control"
11150 msgstr "钩子的返回值与活动控制"
11152 #. type: Content of: <book><chapter><sect1><sect2><para>
11153 #: ../en/ch09-hook.xml:517
11154 msgid ""
11155 "A hook that executes successfully must exit with a status of zero if "
11156 "external, or return boolean <quote>false</quote> if in-process. Failure is "
11157 "indicated with a non-zero exit status from an external hook, or an in-process "
11158 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
11159 "exception, the hook is considered to have failed."
11160 msgstr ""
11162 #. type: Content of: <book><chapter><sect1><sect2><para>
11163 #: ../en/ch09-hook.xml:525
11164 msgid ""
11165 "For a hook that controls whether an activity can proceed, zero/false means "
11166 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
11167 msgstr ""
11169 #. type: Content of: <book><chapter><sect1><sect2><title>
11170 #: ../en/ch09-hook.xml:532
11171 msgid "Writing an external hook"
11172 msgstr "编写外部钩子"
11174 #. type: Content of: <book><chapter><sect1><sect2><para>
11175 #: ../en/ch09-hook.xml:534
11176 msgid ""
11177 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
11178 "filename> and the hook is run, its value is passed to your shell, which "
11179 "interprets it. This means that you can use normal shell constructs in the "
11180 "body of the hook."
11181 msgstr ""
11183 #. type: Content of: <book><chapter><sect1><sect2><para>
11184 #: ../en/ch09-hook.xml:541
11185 msgid ""
11186 "An executable hook is always run with its current directory set to a "
11187 "repository's root directory."
11188 msgstr ""
11190 #. type: Content of: <book><chapter><sect1><sect2><para>
11191 #: ../en/ch09-hook.xml:545
11192 msgid ""
11193 "Each hook parameter is passed in as an environment variable; the name is "
11194 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
11195 "quote>."
11196 msgstr ""
11198 #. type: Content of: <book><chapter><sect1><sect2><para>
11199 #: ../en/ch09-hook.xml:550
11200 msgid ""
11201 "With the exception of hook parameters, Mercurial does not set or modify any "
11202 "environment variables when running a hook. This is useful to remember if you "
11203 "are writing a site-wide hook that may be run by a number of different users "
11204 "with differing environment variables set. In multi-user situations, you "
11205 "should not rely on environment variables being set to the values you have in "
11206 "your environment when testing the hook."
11207 msgstr ""
11209 #. type: Content of: <book><chapter><sect1><sect2><title>
11210 #: ../en/ch09-hook.xml:561
11211 msgid "Telling Mercurial to use an in-process hook"
11212 msgstr "让 Mercurial 使用进程内钩子"
11214 #. type: Content of: <book><chapter><sect1><sect2><para>
11215 #: ../en/ch09-hook.xml:563
11216 msgid ""
11217 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
11218 "process hook is slightly different than for an executable hook. The value of "
11219 "the hook must start with the text <quote><literal>python:</literal></quote>, "
11220 "and continue with the fully-qualified name of a callable object to use as the "
11221 "hook's value."
11222 msgstr ""
11224 #. type: Content of: <book><chapter><sect1><sect2><para>
11225 #: ../en/ch09-hook.xml:571
11226 msgid ""
11227 "The module in which a hook lives is automatically imported when a hook is "
11228 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
11229 "right, it should <quote>just work</quote>."
11230 msgstr ""
11232 #. type: Content of: <book><chapter><sect1><sect2><para>
11233 #: ../en/ch09-hook.xml:577
11234 msgid ""
11235 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
11236 "illustrates the syntax and meaning of the notions we just described."
11237 msgstr ""
11239 #. type: Content of: <book><chapter><sect1><sect2><para>
11240 #: ../en/ch09-hook.xml:583
11241 msgid ""
11242 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
11243 "<literal>mymodule.submodule</literal>, looks for the callable object named "
11244 "<literal>myhook</literal>, and calls it."
11245 msgstr ""
11247 #. type: Content of: <book><chapter><sect1><sect2><title>
11248 #: ../en/ch09-hook.xml:591
11249 msgid "Writing an in-process hook"
11250 msgstr "编写进程内钩子"
11252 #. type: Content of: <book><chapter><sect1><sect2><para>
11253 #: ../en/ch09-hook.xml:593
11254 msgid ""
11255 "The simplest in-process hook does nothing, but illustrates the basic shape of "
11256 "the hook API:"
11257 msgstr ""
11259 #. type: Content of: <book><chapter><sect1><sect2><para>
11260 #: ../en/ch09-hook.xml:598
11261 msgid ""
11262 "The first argument to a Python hook is always a <literal role=\"py-mod-"
11263 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
11264 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
11265 "localrepo\">localrepository</literal>. Following these two arguments are "
11266 "other keyword arguments. Which ones are passed in depends on the hook being "
11267 "called, but a hook can ignore arguments it doesn't care about by dropping "
11268 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
11269 msgstr ""
11271 #. type: Content of: <book><chapter><sect1><title>
11272 #: ../en/ch09-hook.xml:613
11273 msgid "Some hook examples"
11274 msgstr "钩子样例"
11276 #. type: Content of: <book><chapter><sect1><sect2><title>
11277 #: ../en/ch09-hook.xml:616
11278 msgid "Writing meaningful commit messages"
11279 msgstr "编写有意义的提交日志"
11281 #. type: Content of: <book><chapter><sect1><sect2><para>
11282 #: ../en/ch09-hook.xml:618
11283 msgid ""
11284 "It's hard to imagine a useful commit message being very short. The simple "
11285 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
11286 "prevent you from committing a changeset with a message that is less than ten "
11287 "bytes long."
11288 msgstr ""
11290 #. type: Content of: <book><chapter><sect1><sect2><title>
11291 #: ../en/ch09-hook.xml:628
11292 msgid "Checking for trailing whitespace"
11293 msgstr "检查行尾空格"
11295 #. type: Content of: <book><chapter><sect1><sect2><para>
11296 #: ../en/ch09-hook.xml:630
11297 msgid ""
11298 "An interesting use of a commit-related hook is to help you to write cleaner "
11299 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
11300 "change should not add any new lines of text that contain <quote>trailing "
11301 "whitespace</quote>. Trailing whitespace is a series of space and tab "
11302 "characters at the end of a line of text. In most cases, trailing whitespace "
11303 "is unnecessary, invisible noise, but it is occasionally problematic, and "
11304 "people often prefer to get rid of it."
11305 msgstr ""
11307 #. type: Content of: <book><chapter><sect1><sect2><para>
11308 #: ../en/ch09-hook.xml:641
11309 msgid ""
11310 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
11311 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
11312 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
11313 "literal> hook, the hook will not know which files you are committing, so it "
11314 "will have to check every modified file in the repository for trailing white "
11315 "space. If you want to commit a change to just the file <filename>foo</"
11316 "filename>, but the file <filename>bar</filename> contains trailing "
11317 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
11318 "hook will prevent you from committing <filename>foo</filename> due to the "
11319 "problem with <filename>bar</filename>. This doesn't seem right."
11320 msgstr ""
11322 #. type: Content of: <book><chapter><sect1><sect2><para>
11323 #: ../en/ch09-hook.xml:657
11324 msgid ""
11325 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
11326 "check won't occur until just before the transaction for the commit "
11327 "completes. This will allow you to check for problems only the exact files "
11328 "that are being committed. However, if you entered the commit message "
11329 "interactively and the hook fails, the transaction will roll back; you'll have "
11330 "to re-enter the commit message after you fix the trailing whitespace and run "
11331 "<command role=\"hg-cmd\">hg commit</command> again."
11332 msgstr ""
11334 #. type: Content of: <book><chapter><sect1><sect2><para>
11335 #: ../en/ch09-hook.xml:670
11336 msgid ""
11337 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
11338 "literal> hook that checks for trailing whitespace. This hook is short, but "
11339 "not very helpful. It exits with an error status if a change adds a line with "
11340 "trailing whitespace to any file, but does not print any information that "
11341 "might help us to identify the offending file or line. It also has the nice "
11342 "property of not paying attention to unmodified lines; only lines that "
11343 "introduce new trailing whitespace cause problems."
11344 msgstr ""
11346 #. type: Content of: <book><chapter><sect1><sect2><para>
11347 #: ../en/ch09-hook.xml:681
11348 msgid ""
11349 "The above version is much more complex, but also more useful. It parses a "
11350 "unified diff to see if any lines add trailing whitespace, and prints the name "
11351 "of the file and the line number of each such occurrence. Even better, if the "
11352 "change adds trailing whitespace, this hook saves the commit comment and "
11353 "prints the name of the save file before exiting and telling Mercurial to roll "
11354 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
11355 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
11356 "reuse the saved commit message once you've corrected the problem."
11357 msgstr ""
11359 #. type: Content of: <book><chapter><sect1><sect2><para>
11360 #: ../en/ch09-hook.xml:695
11361 msgid ""
11362 "As a final aside, note in the example above the use of <command>perl</"
11363 "command>'s in-place editing feature to get rid of trailing whitespace from a "
11364 "file. This is concise and useful enough that I will reproduce it here."
11365 msgstr ""
11367 #. type: Content of: <book><chapter><sect1><title>
11368 #: ../en/ch09-hook.xml:705
11369 msgid "Bundled hooks"
11370 msgstr "内置的钩子"
11372 #. type: Content of: <book><chapter><sect1><para>
11373 #: ../en/ch09-hook.xml:707
11374 msgid ""
11375 "Mercurial ships with several bundled hooks. You can find them in the "
11376 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
11377 "source tree. If you are using a Mercurial binary package, the hooks will be "
11378 "located in the <filename class=\"directory\">hgext</filename> directory of "
11379 "wherever your package installer put Mercurial."
11380 msgstr ""
11382 #. type: Content of: <book><chapter><sect1><sect2><title>
11383 #: ../en/ch09-hook.xml:716
11384 msgid ""
11385 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
11386 "repository"
11387 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
11389 #. type: Content of: <book><chapter><sect1><sect2><para>
11390 #: ../en/ch09-hook.xml:719
11391 msgid ""
11392 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
11393 "remote users are allowed to push changesets to a networked server. You can "
11394 "protect any portion of a repository (including the entire repo), so that a "
11395 "specific remote user can push changes that do not affect the protected "
11396 "portion."
11397 msgstr ""
11399 #. type: Content of: <book><chapter><sect1><sect2><para>
11400 #: ../en/ch09-hook.xml:727
11401 msgid ""
11402 "This extension implements access control based on the identity of the user "
11403 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
11404 "they're pushing. It makes sense to use this hook only if you have a locked-"
11405 "down server environment that authenticates remote users, and you want to be "
11406 "sure that only specific users are allowed to push changes to that server."
11407 msgstr ""
11409 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11410 #: ../en/ch09-hook.xml:737
11411 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
11412 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
11414 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11415 #: ../en/ch09-hook.xml:740
11416 msgid ""
11417 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
11418 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
11419 "literal> hook. This lets it see which files are modified by each incoming "
11420 "changeset, and roll back a group of changesets if they modify "
11421 "<quote>forbidden</quote> files. Example:"
11422 msgstr ""
11424 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11425 #: ../en/ch09-hook.xml:750
11426 msgid ""
11427 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
11428 "three sections."
11429 msgstr ""
11431 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11432 #: ../en/ch09-hook.xml:754
11433 msgid ""
11434 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
11435 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
11436 "changesets that the hook should pay attention to. You don't normally need to "
11437 "configure this section."
11438 msgstr ""
11440 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11441 #: ../en/ch09-hook.xml:761
11442 msgid ""
11443 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
11444 "are arriving from a remote repository over http or ssh. This is the default "
11445 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
11446 "setting you'll need for this configuration item."
11447 msgstr ""
11449 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11450 #: ../en/ch09-hook.xml:769
11451 msgid ""
11452 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
11453 "are arriving via a pull from a local repository."
11454 msgstr ""
11456 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11457 #: ../en/ch09-hook.xml:774
11458 msgid ""
11459 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
11460 "are arriving via a push from a local repository."
11461 msgstr ""
11463 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11464 #: ../en/ch09-hook.xml:779
11465 msgid ""
11466 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
11467 "are arriving from another repository via a bundle."
11468 msgstr ""
11470 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11471 #: ../en/ch09-hook.xml:785
11472 msgid ""
11473 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
11474 "users that are allowed to add changesets to the repository. If this section "
11475 "is not present, all users that are not explicitly denied are allowed. If "
11476 "this section is present, all users that are not explicitly allowed are denied "
11477 "(so an empty section means that all users are denied)."
11478 msgstr ""
11480 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11481 #: ../en/ch09-hook.xml:794
11482 msgid ""
11483 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
11484 "users are denied from adding changesets to the repository. If this section "
11485 "is not present or is empty, no users are denied."
11486 msgstr ""
11488 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11489 #: ../en/ch09-hook.xml:800
11490 msgid ""
11491 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
11492 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
11493 "the left of each entry is a glob pattern that matches files or directories, "
11494 "relative to the root of the repository; on the right, a user name."
11495 msgstr ""
11497 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11498 #: ../en/ch09-hook.xml:808
11499 msgid ""
11500 "In the following example, the user <literal>docwriter</literal> can only push "
11501 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
11502 "repository, while <literal>intern</literal> can push changes to any file or "
11503 "directory except <filename class=\"directory\">source/sensitive</filename>."
11504 msgstr ""
11506 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11507 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1279
11508 msgid "Testing and troubleshooting"
11509 msgstr "测试与问题处理"
11511 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11512 #: ../en/ch09-hook.xml:824
11513 msgid ""
11514 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
11515 "with Mercurial's debugging output enabled. Since you'll probably be running "
11516 "it on a server where it's not convenient (or sometimes possible) to pass in "
11517 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
11518 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
11519 "filename>:"
11520 msgstr ""
11522 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11523 #: ../en/ch09-hook.xml:835
11524 msgid ""
11525 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
11526 "enough information to let you figure out why it is allowing or forbidding "
11527 "pushes from specific users."
11528 msgstr ""
11530 #. type: Content of: <book><chapter><sect1><sect2><title>
11531 #: ../en/ch09-hook.xml:844
11532 msgid ""
11533 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
11534 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
11536 #. type: Content of: <book><chapter><sect1><sect2><para>
11537 #: ../en/ch09-hook.xml:848
11538 msgid ""
11539 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
11540 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
11541 "comment. You can install this hook on a shared server, so that any time a "
11542 "remote user pushes changes to this server, the hook gets run."
11543 msgstr ""
11545 #. type: Content of: <book><chapter><sect1><sect2><para>
11546 #: ../en/ch09-hook.xml:855
11547 msgid ""
11548 "It adds a comment to the bug that looks like this (you can configure the "
11549 "contents of the comment&emdash;see below):"
11550 msgstr ""
11552 #. type: Content of: <book><chapter><sect1><sect2><para>
11553 #: ../en/ch09-hook.xml:864
11554 msgid ""
11555 "The value of this hook is that it automates the process of updating a bug any "
11556 "time a changeset refers to it. If you configure the hook properly, it makes "
11557 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
11558 "refers to that bug."
11559 msgstr ""
11561 #. type: Content of: <book><chapter><sect1><sect2><para>
11562 #: ../en/ch09-hook.xml:871
11563 msgid ""
11564 "You can use the code in this hook as a starting point for some more exotic "
11565 "Bugzilla integration recipes. Here are a few possibilities:"
11566 msgstr ""
11568 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11569 #: ../en/ch09-hook.xml:876
11570 msgid ""
11571 "Require that every changeset pushed to the server have a valid bug ID in its "
11572 "commit comment. In this case, you'd want to configure the hook as a <literal "
11573 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
11574 "reject changes that didn't contain bug IDs."
11575 msgstr ""
11577 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11578 #: ../en/ch09-hook.xml:884
11579 msgid ""
11580 "Allow incoming changesets to automatically modify the <emphasis>state</"
11581 "emphasis> of a bug, as well as simply adding a comment. For example, the "
11582 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
11583 "that it should update the state of bug 31337 to <quote>requires testing</"
11584 "quote>."
11585 msgstr ""
11587 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11588 #: ../en/ch09-hook.xml:894
11589 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
11590 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
11592 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11593 #: ../en/ch09-hook.xml:897
11594 msgid ""
11595 "You should configure this hook in your server's <filename role=\"special\">~/."
11596 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
11597 "example as follows:"
11598 msgstr ""
11600 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11601 #: ../en/ch09-hook.xml:905
11602 msgid ""
11603 "Because of the specialised nature of this hook, and because Bugzilla was not "
11604 "written with this kind of integration in mind, configuring this hook is a "
11605 "somewhat involved process."
11606 msgstr ""
11608 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11609 #: ../en/ch09-hook.xml:911
11610 msgid ""
11611 "Before you begin, you must install the MySQL bindings for Python on the host"
11612 "(s) where you'll be running the hook. If this is not available as a binary "
11613 "package for your system, you can download it from <citation>web:mysql-python</"
11614 "citation>."
11615 msgstr ""
11617 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11618 #: ../en/ch09-hook.xml:918
11619 msgid ""
11620 "Configuration information for this hook lives in the <literal role=\"rc-"
11621 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
11622 "hgrc</filename>."
11623 msgstr ""
11625 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11626 #: ../en/ch09-hook.xml:923
11627 msgid ""
11628 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
11629 "installed on the server. The database schema that Bugzilla uses changes "
11630 "occasionally, so this hook has to know exactly which schema to use. At the "
11631 "moment, the only version supported is <literal>2.16</literal>."
11632 msgstr ""
11634 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11635 #: ../en/ch09-hook.xml:932
11636 msgid ""
11637 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
11638 "server that stores your Bugzilla data. The database must be configured to "
11639 "allow connections from whatever host you are running the <literal role=\"hook"
11640 "\">bugzilla</literal> hook on."
11641 msgstr ""
11643 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11644 #: ../en/ch09-hook.xml:939
11645 msgid ""
11646 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
11647 "connect to the MySQL server. The database must be configured to allow this "
11648 "user to connect from whatever host you are running the <literal role=\"hook"
11649 "\">bugzilla</literal> hook on. This user must be able to access and modify "
11650 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
11651 "which is the standard name of the Bugzilla user in a MySQL database."
11652 msgstr ""
11654 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11655 #: ../en/ch09-hook.xml:950
11656 msgid ""
11657 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
11658 "user you configured above. This is stored as plain text, so you should make "
11659 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
11660 "hgrc</filename> file where you store this information."
11661 msgstr ""
11663 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11664 #: ../en/ch09-hook.xml:959
11665 msgid ""
11666 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
11667 "database on the MySQL server. The default value of this item is "
11668 "<literal>bugs</literal>, which is the standard name of the MySQL database "
11669 "where Bugzilla stores its data."
11670 msgstr ""
11672 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11673 #: ../en/ch09-hook.xml:966
11674 msgid ""
11675 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
11676 "out a notification email to subscribers after this hook has added a comment "
11677 "to a bug, you will need this hook to run a command whenever it updates the "
11678 "database. The command to run depends on where you have installed Bugzilla, "
11679 "but it will typically look something like this, if you have Bugzilla "
11680 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
11681 msgstr ""
11683 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11684 #: ../en/ch09-hook.xml:979
11685 msgid ""
11686 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
11687 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
11688 "and an email address. It also expects to be able to write to some files in "
11689 "the directory that it runs in. If Bugzilla and this hook are not installed "
11690 "on the same machine, you will need to find a way to run <literal>processmail</"
11691 "literal> on the server where Bugzilla is installed."
11692 msgstr ""
11694 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11695 #: ../en/ch09-hook.xml:994
11696 msgid "Mapping committer names to Bugzilla user names"
11697 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
11699 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11700 #: ../en/ch09-hook.xml:996
11701 msgid ""
11702 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
11703 "the email address of a changeset's committer as the Bugzilla user name with "
11704 "which to update a bug. If this does not suit your needs, you can map "
11705 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
11706 "usermap\">usermap</literal> section."
11707 msgstr ""
11709 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11710 #: ../en/ch09-hook.xml:1005
11711 msgid ""
11712 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
11713 "contains an email address on the left, and a Bugzilla user name on the right."
11714 msgstr ""
11716 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11717 #: ../en/ch09-hook.xml:1012
11718 msgid ""
11719 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
11720 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
11721 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
11722 "an external <filename>usermap</filename> file. In the latter case, you can "
11723 "store <filename>usermap</filename> data by itself in (for example) a user-"
11724 "modifiable repository. This makes it possible to let your users maintain "
11725 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
11726 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
11727 msgstr ""
11729 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11730 #: ../en/ch09-hook.xml:1028
11731 msgid ""
11732 "While the <filename>usermap</filename> file that it refers to might look like "
11733 "this:"
11734 msgstr ""
11736 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11737 #: ../en/ch09-hook.xml:1036
11738 msgid "Configuring the text that gets added to a bug"
11739 msgstr "配置增加到问题中的正文"
11741 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11742 #: ../en/ch09-hook.xml:1038
11743 msgid ""
11744 "You can configure the text that this hook adds as a comment; you specify it "
11745 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
11746 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
11747 "literal> section) control this behavior."
11748 msgstr ""
11750 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11751 #: ../en/ch09-hook.xml:1045
11752 msgid ""
11753 "<literal>strip</literal>: The number of leading path elements to strip from a "
11754 "repository's path name to construct a partial path for a URL. For example, if "
11755 "the repositories on your server live under <filename class=\"directory\">/"
11756 "home/hg/repos</filename>, and you have a repository whose path is <filename "
11757 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
11758 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
11759 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
11760 "partial path available when expanding a template, as <literal>webroot</"
11761 "literal>."
11762 msgstr ""
11764 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11765 #: ../en/ch09-hook.xml:1059
11766 msgid ""
11767 "<literal>template</literal>: The text of the template to use. In addition to "
11768 "the usual changeset-related variables, this template can use <literal>hgweb</"
11769 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
11770 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
11771 "literal> above)."
11772 msgstr ""
11774 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11775 #: ../en/ch09-hook.xml:1069
11776 msgid ""
11777 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
11778 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
11779 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
11780 "literal> hook will make this available when expanding a template, as the base "
11781 "string to use when constructing a URL that will let users browse from a "
11782 "Bugzilla comment to view a changeset. Example:"
11783 msgstr ""
11785 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11786 #: ../en/ch09-hook.xml:1081
11787 msgid ""
11788 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
11789 "config information."
11790 msgstr ""
11792 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11793 #: ../en/ch09-hook.xml:1091
11794 msgid ""
11795 "The most common problems with configuring the <literal role=\"hg-ext"
11796 "\">bugzilla</literal> hook relate to running Bugzilla's "
11797 "<filename>processmail</filename> script and mapping committer names to user "
11798 "names."
11799 msgstr ""
11801 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11802 #: ../en/ch09-hook.xml:1097
11803 msgid ""
11804 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
11805 "that runs the Mercurial process on the server is also the one that will run "
11806 "the <filename>processmail</filename> script. The <filename>processmail</"
11807 "filename> script sometimes causes Bugzilla to write to files in its "
11808 "configuration directory, and Bugzilla's configuration files are usually owned "
11809 "by the user that your web server runs under."
11810 msgstr ""
11812 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11813 #: ../en/ch09-hook.xml:1108
11814 msgid ""
11815 "You can cause <filename>processmail</filename> to be run with the suitable "
11816 "user's identity using the <command>sudo</command> command. Here is an "
11817 "example entry for a <filename>sudoers</filename> file."
11818 msgstr ""
11820 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11821 #: ../en/ch09-hook.xml:1115
11822 msgid ""
11823 "This allows the <literal>hg_user</literal> user to run a "
11824 "<filename>processmail-wrapper</filename> program under the identity of "
11825 "<literal>httpd_user</literal>."
11826 msgstr ""
11828 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11829 #: ../en/ch09-hook.xml:1120
11830 msgid ""
11831 "This indirection through a wrapper script is necessary, because "
11832 "<filename>processmail</filename> expects to be run with its current directory "
11833 "set to wherever you installed Bugzilla; you can't specify that kind of "
11834 "constraint in a <filename>sudoers</filename> file. The contents of the "
11835 "wrapper script are simple:"
11836 msgstr ""
11838 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11839 #: ../en/ch09-hook.xml:1129
11840 msgid ""
11841 "It doesn't seem to matter what email address you pass to "
11842 "<filename>processmail</filename>."
11843 msgstr ""
11845 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11846 #: ../en/ch09-hook.xml:1133
11847 msgid ""
11848 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
11849 "correctly, users will see an error message from the <literal role=\"hg-ext"
11850 "\">bugzilla</literal> hook when they push changes to the server. The error "
11851 "message will look like this:"
11852 msgstr ""
11854 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11855 #: ../en/ch09-hook.xml:1140
11856 msgid ""
11857 "What this means is that the committer's address, <literal>john.q."
11858 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
11859 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
11860 "maps it to a valid Bugzilla user name."
11861 msgstr ""
11863 #. type: Content of: <book><chapter><sect1><sect2><title>
11864 #: ../en/ch09-hook.xml:1150
11865 msgid ""
11866 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
11867 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
11869 #. type: Content of: <book><chapter><sect1><sect2><para>
11870 #: ../en/ch09-hook.xml:1153
11871 msgid ""
11872 "Although Mercurial's built-in web server provides RSS feeds of changes in "
11873 "every repository, many people prefer to receive change notifications via "
11874 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
11875 "notifications to a set of email addresses whenever changesets arrive that "
11876 "those subscribers are interested in."
11877 msgstr ""
11879 #. type: Content of: <book><chapter><sect1><sect2><para>
11880 #: ../en/ch09-hook.xml:1161
11881 msgid ""
11882 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
11883 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
11884 "customise the contents of the notification messages that it sends."
11885 msgstr ""
11887 #. type: Content of: <book><chapter><sect1><sect2><para>
11888 #: ../en/ch09-hook.xml:1167
11889 msgid ""
11890 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
11891 "diff of every changeset that it sends out; you can limit the size of the "
11892 "diff, or turn this feature off entirely. It is useful for letting "
11893 "subscribers review changes immediately, rather than clicking to follow a URL."
11894 msgstr ""
11896 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11897 #: ../en/ch09-hook.xml:1175
11898 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
11899 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
11901 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11902 #: ../en/ch09-hook.xml:1178
11903 msgid ""
11904 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
11905 "email message per incoming changeset, or one per incoming group of changesets "
11906 "(all those that arrived in a single pull or push)."
11907 msgstr ""
11909 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11910 #: ../en/ch09-hook.xml:1190
11911 msgid ""
11912 "Configuration information for this hook lives in the <literal role=\"rc-notify"
11913 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
11914 "filename> file."
11915 msgstr ""
11917 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11918 #: ../en/ch09-hook.xml:1195
11919 msgid ""
11920 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
11921 "send out email at all; instead, it prints the message that it "
11922 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
11923 "to allow email to be sent. The reason that sending of email is turned off by "
11924 "default is that it takes several tries to configure this extension exactly as "
11925 "you would like, and it would be bad form to spam subscribers with a number of "
11926 "<quote>broken</quote> notifications while you debug your configuration."
11927 msgstr ""
11929 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11930 #: ../en/ch09-hook.xml:1207
11931 msgid ""
11932 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
11933 "file that contains subscription information. This is kept separate from the "
11934 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
11935 "it in a repository of its own. People can then clone that repository, update "
11936 "their subscriptions, and push the changes back to your server."
11937 msgstr ""
11939 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11940 #: ../en/ch09-hook.xml:1216
11941 msgid ""
11942 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
11943 "separator characters to strip from a repository's path, when deciding whether "
11944 "a repository has subscribers. For example, if the repositories on your "
11945 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
11946 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
11947 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
11948 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
11949 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
11950 "down to <filename class=\"directory\">shared/test</filename>, and it will "
11951 "match subscribers against that."
11952 msgstr ""
11954 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11955 #: ../en/ch09-hook.xml:1233
11956 msgid ""
11957 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
11958 "when sending messages. This specifies both the contents of the message "
11959 "header and its body."
11960 msgstr ""
11962 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11963 #: ../en/ch09-hook.xml:1239
11964 msgid ""
11965 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
11966 "of diff data to append to the end of a message. If a diff is longer than "
11967 "this, it is truncated. By default, this is set to 300. Set this to "
11968 "<literal>0</literal> to omit diffs from notification emails."
11969 msgstr ""
11971 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11972 #: ../en/ch09-hook.xml:1248
11973 msgid ""
11974 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
11975 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
11976 "literal> to only sending out email about changes that remote users pushed "
11977 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
11978 "sources\"/> for the sources you can specify here."
11979 msgstr ""
11981 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11982 #: ../en/ch09-hook.xml:1259
11983 msgid ""
11984 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
11985 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
11986 "it will be available as <literal>webroot</literal>."
11987 msgstr ""
11989 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11990 #: ../en/ch09-hook.xml:1265
11991 msgid ""
11992 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
11993 "configuration information."
11994 msgstr ""
11996 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11997 #: ../en/ch09-hook.xml:1271
11998 msgid "This will produce a message that looks like the following:"
11999 msgstr ""
12001 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12002 #: ../en/ch09-hook.xml:1281
12003 msgid ""
12004 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
12005 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
12006 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
12007 "to <literal>false</literal>. Until you do that, it simply prints the message "
12008 "it <emphasis>would</emphasis> send."
12009 msgstr ""
12011 #. type: Content of: <book><chapter><sect1><title>
12012 #: ../en/ch09-hook.xml:1293
12013 msgid "Information for writers of hooks"
12014 msgstr "编写钩子的信息"
12016 #. type: Content of: <book><chapter><sect1><sect2><title>
12017 #: ../en/ch09-hook.xml:1296
12018 msgid "In-process hook execution"
12019 msgstr "进程内钩子的执行"
12021 #. type: Content of: <book><chapter><sect1><sect2><para>
12022 #: ../en/ch09-hook.xml:1298
12023 msgid "An in-process hook is called with arguments of the following form:"
12024 msgstr ""
12026 #. type: Content of: <book><chapter><sect1><sect2><para>
12027 #: ../en/ch09-hook.xml:1302
12028 msgid ""
12029 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
12030 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
12031 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
12032 "names and values of the <literal>**kwargs</literal> parameters depend on the "
12033 "hook being invoked, with the following common features:"
12034 msgstr ""
12036 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12037 #: ../en/ch09-hook.xml:1311
12038 msgid ""
12039 "If a parameter is named <literal>node</literal> or <literal>parentN</"
12040 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
12041 "used to represent <quote>null changeset ID</quote> instead of a string of "
12042 "zeroes."
12043 msgstr ""
12045 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12046 #: ../en/ch09-hook.xml:1318
12047 msgid ""
12048 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
12049 "remote repository, if that can be determined."
12050 msgstr ""
12052 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12053 #: ../en/ch09-hook.xml:1323
12054 msgid ""
12055 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
12056 "objects."
12057 msgstr ""
12059 #. type: Content of: <book><chapter><sect1><sect2><para>
12060 #: ../en/ch09-hook.xml:1328
12061 msgid ""
12062 "An in-process hook is called without a change to the process's working "
12063 "directory (unlike external hooks, which are run in the root of the "
12064 "repository). It must not change the process's working directory, or it will "
12065 "cause any calls it makes into the Mercurial API to fail."
12066 msgstr ""
12068 #. type: Content of: <book><chapter><sect1><sect2><para>
12069 #: ../en/ch09-hook.xml:1335
12070 msgid ""
12071 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
12072 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
12073 "an exception, it is considered to have failed. A useful way to think of the "
12074 "calling convention is <quote>tell me if you fail</quote>."
12075 msgstr ""
12077 #. type: Content of: <book><chapter><sect1><sect2><para>
12078 #: ../en/ch09-hook.xml:1342
12079 msgid ""
12080 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
12081 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
12082 "from hex to binary, use the <literal>bin</literal> function."
12083 msgstr ""
12085 #. type: Content of: <book><chapter><sect1><sect2><title>
12086 #: ../en/ch09-hook.xml:1350
12087 msgid "External hook execution"
12088 msgstr "外部钩子的执行"
12090 #. type: Content of: <book><chapter><sect1><sect2><para>
12091 #: ../en/ch09-hook.xml:1352
12092 msgid ""
12093 "An external hook is passed to the shell of the user running Mercurial. "
12094 "Features of that shell, such as variable substitution and command "
12095 "redirection, are available. The hook is run in the root directory of the "
12096 "repository (unlike in-process hooks, which are run in the same directory that "
12097 "Mercurial was run in)."
12098 msgstr ""
12100 #. type: Content of: <book><chapter><sect1><sect2><para>
12101 #: ../en/ch09-hook.xml:1360
12102 msgid ""
12103 "Hook parameters are passed to the hook as environment variables. Each "
12104 "environment variable's name is converted in upper case and prefixed with the "
12105 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
12106 "parameter is <quote><literal>node</literal></quote>, the name of the "
12107 "environment variable representing that parameter will be "
12108 "<quote><literal>HG_NODE</literal></quote>."
12109 msgstr ""
12111 #. type: Content of: <book><chapter><sect1><sect2><para>
12112 #: ../en/ch09-hook.xml:1369
12113 msgid ""
12114 "A boolean parameter is represented as the string <quote><literal>1</literal></"
12115 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
12116 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
12117 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
12118 "changeset ID represented as a hexadecimal string. The empty string is used "
12119 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
12120 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
12121 "the URL of a remote repository, if that can be determined."
12122 msgstr ""
12124 #. type: Content of: <book><chapter><sect1><sect2><para>
12125 #: ../en/ch09-hook.xml:1381
12126 msgid ""
12127 "If a hook exits with a status of zero, it is considered to have succeeded. "
12128 "If it exits with a non-zero status, it is considered to have failed."
12129 msgstr ""
12131 #. type: Content of: <book><chapter><sect1><sect2><title>
12132 #: ../en/ch09-hook.xml:1388
12133 msgid "Finding out where changesets come from"
12134 msgstr "检查修改集来自何处"
12136 #. type: Content of: <book><chapter><sect1><sect2><para>
12137 #: ../en/ch09-hook.xml:1390
12138 msgid ""
12139 "A hook that involves the transfer of changesets between a local repository "
12140 "and another may be able to find out information about the <quote>far side</"
12141 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
12142 "transferred, and in many cases <emphasis>where</emphasis> they are being "
12143 "transferred to or from."
12144 msgstr ""
12146 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
12147 #: ../en/ch09-hook.xml:1399
12148 msgid "Sources of changesets"
12149 msgstr "修改集的来源"
12151 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12152 #: ../en/ch09-hook.xml:1401
12153 msgid ""
12154 "Mercurial will tell a hook what means are, or were, used to transfer "
12155 "changesets between repositories. This is provided by Mercurial in a Python "
12156 "parameter named <literal>source</literal>, or an environment variable named "
12157 "<envar>HG_SOURCE</envar>."
12158 msgstr ""
12160 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12161 #: ../en/ch09-hook.xml:1409
12162 msgid ""
12163 "<literal>serve</literal>: Changesets are transferred to or from a remote "
12164 "repository over http or ssh."
12165 msgstr ""
12167 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12168 #: ../en/ch09-hook.xml:1414
12169 msgid ""
12170 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
12171 "repository into another."
12172 msgstr ""
12174 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12175 #: ../en/ch09-hook.xml:1419
12176 msgid ""
12177 "<literal>push</literal>: Changesets are being transferred via a push from one "
12178 "repository into another."
12179 msgstr ""
12181 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12182 #: ../en/ch09-hook.xml:1424
12183 msgid ""
12184 "<literal>bundle</literal>: Changesets are being transferred to or from a "
12185 "bundle."
12186 msgstr ""
12188 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
12189 #: ../en/ch09-hook.xml:1431
12190 msgid "Where changes are going&emdash;remote repository URLs"
12191 msgstr "修改集要到哪里—远程版本库的地址"
12193 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12194 #: ../en/ch09-hook.xml:1434
12195 msgid ""
12196 "When possible, Mercurial will tell a hook the location of the <quote>far "
12197 "side</quote> of an activity that transfers changeset data between "
12198 "repositories. This is provided by Mercurial in a Python parameter named "
12199 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
12200 "envar>."
12201 msgstr ""
12203 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
12204 #: ../en/ch09-hook.xml:1442
12205 msgid ""
12206 "This information is not always known. If a hook is invoked in a repository "
12207 "that is being served via http or ssh, Mercurial cannot tell where the remote "
12208 "repository is, but it may know where the client is connecting from. In such "
12209 "cases, the URL will take one of the following forms:"
12210 msgstr ""
12212 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12213 #: ../en/ch09-hook.xml:1449
12214 msgid ""
12215 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
12216 "address <literal>1.2.3.4</literal>."
12217 msgstr ""
12219 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12220 #: ../en/ch09-hook.xml:1454
12221 msgid ""
12222 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
12223 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
12224 "of the form <literal>remote:https:1.2.3.4</literal>."
12225 msgstr ""
12227 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
12228 #: ../en/ch09-hook.xml:1461
12229 msgid "Empty&emdash;no information could be discovered about the remote client."
12230 msgstr ""
12232 #. type: Content of: <book><chapter><sect1><title>
12233 #: ../en/ch09-hook.xml:1470
12234 msgid "Hook reference"
12235 msgstr "钩子参考"
12237 #. type: Content of: <book><chapter><sect1><sect2><title>
12238 #: ../en/ch09-hook.xml:1473
12239 msgid ""
12240 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
12241 "added"
12242 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
12244 #. type: Content of: <book><chapter><sect1><sect2><para>
12245 #: ../en/ch09-hook.xml:1476
12246 msgid ""
12247 "This hook is run after a group of pre-existing changesets has been added to "
12248 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
12249 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
12250 "operation that added one or more changesets. This is in contrast to the "
12251 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
12252 "changeset, regardless of whether the changesets arrive in a group."
12253 msgstr ""
12255 #. type: Content of: <book><chapter><sect1><sect2><para>
12256 #: ../en/ch09-hook.xml:1486
12257 msgid ""
12258 "Some possible uses for this hook include kicking off an automated build or "
12259 "test of the added changesets, updating a bug database, or notifying "
12260 "subscribers that a repository contains new changes."
12261 msgstr ""
12263 #. type: Content of: <book><chapter><sect1><sect2><para>
12264 #: ../en/ch09-hook.xml:1492 ../en/ch09-hook.xml:1532 ../en/ch09-hook.xml:1576
12265 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
12266 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1783 ../en/ch09-hook.xml:1846
12267 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1940 ../en/ch09-hook.xml:1967
12268 msgid "Parameters to this hook:"
12269 msgstr ""
12271 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12272 #: ../en/ch09-hook.xml:1495 ../en/ch09-hook.xml:1849
12273 msgid ""
12274 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
12275 "changeset in the group that was added. All changesets between this and "
12276 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
12277 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
12278 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
12279 msgstr ""
12281 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12282 #: ../en/ch09-hook.xml:1504 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
12283 #: ../en/ch09-hook.xml:1859
12284 msgid ""
12285 "<literal>source</literal>: A string. The source of these changes. See <xref "
12286 "linkend=\"sec:hook:sources\"/> for details."
12287 msgstr ""
12289 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12290 #: ../en/ch09-hook.xml:1509 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
12291 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1762 ../en/ch09-hook.xml:1864
12292 msgid ""
12293 "<literal>url</literal>: A URL. The location of the remote repository, if "
12294 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
12295 msgstr ""
12297 #. type: Content of: <book><chapter><sect1><sect2><para>
12298 #: ../en/ch09-hook.xml:1515
12299 msgid ""
12300 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
12301 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
12302 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
12303 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12304 msgstr ""
12306 #. type: Content of: <book><chapter><sect1><sect2><title>
12307 #: ../en/ch09-hook.xml:1526
12308 msgid ""
12309 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
12310 "created"
12311 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
12313 #. type: Content of: <book><chapter><sect1><sect2><para>
12314 #: ../en/ch09-hook.xml:1529
12315 msgid "This hook is run after a new changeset has been created."
12316 msgstr ""
12318 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12319 #: ../en/ch09-hook.xml:1535 ../en/ch09-hook.xml:1907
12320 msgid ""
12321 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
12322 "committed changeset."
12323 msgstr ""
12325 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12326 #: ../en/ch09-hook.xml:1539 ../en/ch09-hook.xml:1911
12327 msgid ""
12328 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12329 "parent of the newly committed changeset."
12330 msgstr ""
12332 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12333 #: ../en/ch09-hook.xml:1544 ../en/ch09-hook.xml:1916
12334 msgid ""
12335 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12336 "parent of the newly committed changeset."
12337 msgstr ""
12339 #. type: Content of: <book><chapter><sect1><sect2><para>
12340 #: ../en/ch09-hook.xml:1550
12341 msgid ""
12342 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12343 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
12344 "linkend=\"sec:hook:pretxncommit\"/>)"
12345 msgstr ""
12347 #. type: Content of: <book><chapter><sect1><sect2><title>
12348 #: ../en/ch09-hook.xml:1559
12349 msgid ""
12350 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
12351 "is added"
12352 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
12354 #. type: Content of: <book><chapter><sect1><sect2><para>
12355 #: ../en/ch09-hook.xml:1562
12356 msgid ""
12357 "This hook is run after a pre-existing changeset has been added to the "
12358 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
12359 "a group of changesets was added in a single operation, this hook is called "
12360 "once for each added changeset."
12361 msgstr ""
12363 #. type: Content of: <book><chapter><sect1><sect2><para>
12364 #: ../en/ch09-hook.xml:1569
12365 msgid ""
12366 "You can use this hook for the same purposes as the <literal role=\"hook"
12367 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
12368 "it's simply more convenient sometimes to run a hook once per group of "
12369 "changesets, while other times it's handier once per changeset."
12370 msgstr ""
12372 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12373 #: ../en/ch09-hook.xml:1579
12374 msgid ""
12375 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
12376 msgstr ""
12378 #. type: Content of: <book><chapter><sect1><sect2><para>
12379 #: ../en/ch09-hook.xml:1594
12380 msgid ""
12381 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12382 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
12383 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
12384 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
12385 ">)"
12386 msgstr ""
12388 #. type: Content of: <book><chapter><sect1><sect2><title>
12389 #: ../en/ch09-hook.xml:1605
12390 msgid ""
12391 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
12392 "propagated"
12393 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
12395 #. type: Content of: <book><chapter><sect1><sect2><para>
12396 #: ../en/ch09-hook.xml:1608
12397 msgid ""
12398 "This hook is run after a group of changesets has been propagated out of this "
12399 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
12400 "<command role=\"hg-cmd\">hg bundle</command> command."
12401 msgstr ""
12403 #. type: Content of: <book><chapter><sect1><sect2><para>
12404 #: ../en/ch09-hook.xml:1614
12405 msgid ""
12406 "One possible use for this hook is to notify administrators that changes have "
12407 "been pulled."
12408 msgstr ""
12410 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12411 #: ../en/ch09-hook.xml:1621
12412 msgid ""
12413 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
12414 "changeset of the group that was sent."
12415 msgstr ""
12417 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12418 #: ../en/ch09-hook.xml:1626
12419 msgid ""
12420 "<literal>source</literal>: A string. The source of the of the operation (see "
12421 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
12422 "from this repository, <literal>source</literal> will be <literal>serve</"
12423 "literal>. If the client that obtained changes from this repository was "
12424 "local, <literal>source</literal> will be <literal>bundle</literal>, "
12425 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
12426 "operation the client performed."
12427 msgstr ""
12429 #. type: Content of: <book><chapter><sect1><sect2><para>
12430 #: ../en/ch09-hook.xml:1645
12431 msgid ""
12432 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
12433 "hook:preoutgoing\"/>)"
12434 msgstr ""
12436 #. type: Content of: <book><chapter><sect1><sect2><title>
12437 #: ../en/ch09-hook.xml:1652
12438 msgid ""
12439 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
12440 "remote changesets"
12441 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
12443 #. type: Content of: <book><chapter><sect1><sect2><para>
12444 #: ../en/ch09-hook.xml:1656
12445 msgid ""
12446 "This controlling hook is run before Mercurial begins to add a group of "
12447 "changesets from another repository."
12448 msgstr ""
12450 #. type: Content of: <book><chapter><sect1><sect2><para>
12451 #: ../en/ch09-hook.xml:1660
12452 msgid ""
12453 "This hook does not have any information about the changesets to be added, "
12454 "because it is run before transmission of those changesets is allowed to "
12455 "begin. If this hook fails, the changesets will not be transmitted."
12456 msgstr ""
12458 #. type: Content of: <book><chapter><sect1><sect2><para>
12459 #: ../en/ch09-hook.xml:1666
12460 msgid ""
12461 "One use for this hook is to prevent external changes from being added to a "
12462 "repository. For example, you could use this to <quote>freeze</quote> a "
12463 "server-hosted branch temporarily or permanently so that users cannot push to "
12464 "it, while still allowing a local administrator to modify the repository."
12465 msgstr ""
12467 #. type: Content of: <book><chapter><sect1><sect2><para>
12468 #: ../en/ch09-hook.xml:1687
12469 msgid ""
12470 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12471 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12472 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
12473 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12474 msgstr ""
12476 #. type: Content of: <book><chapter><sect1><sect2><title>
12477 #: ../en/ch09-hook.xml:1698
12478 msgid ""
12479 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
12480 "changeset"
12481 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
12483 #. type: Content of: <book><chapter><sect1><sect2><para>
12484 #: ../en/ch09-hook.xml:1701
12485 msgid ""
12486 "This hook is run before Mercurial begins to commit a new changeset. It is run "
12487 "before Mercurial has any of the metadata for the commit, such as the files to "
12488 "be committed, the commit message, or the commit date."
12489 msgstr ""
12491 #. type: Content of: <book><chapter><sect1><sect2><para>
12492 #: ../en/ch09-hook.xml:1707
12493 msgid ""
12494 "One use for this hook is to disable the ability to commit new changesets, "
12495 "while still allowing incoming changesets. Another is to run a build or test, "
12496 "and only allow the commit to begin if the build or test succeeds."
12497 msgstr ""
12499 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12500 #: ../en/ch09-hook.xml:1716
12501 msgid ""
12502 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12503 "parent of the working directory."
12504 msgstr ""
12506 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12507 #: ../en/ch09-hook.xml:1721
12508 msgid ""
12509 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12510 "parent of the working directory."
12511 msgstr ""
12513 #. type: Content of: <book><chapter><sect1><sect2><para>
12514 #: ../en/ch09-hook.xml:1726
12515 msgid ""
12516 "If the commit proceeds, the parents of the working directory will become the "
12517 "parents of the new changeset."
12518 msgstr ""
12520 #. type: Content of: <book><chapter><sect1><sect2><para>
12521 #: ../en/ch09-hook.xml:1730
12522 msgid ""
12523 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
12524 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
12525 "\"sec:hook:pretxncommit\"/>)"
12526 msgstr ""
12528 #. type: Content of: <book><chapter><sect1><sect2><title>
12529 #: ../en/ch09-hook.xml:1738
12530 msgid ""
12531 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
12532 "propagate changesets"
12533 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
12535 #. type: Content of: <book><chapter><sect1><sect2><para>
12536 #: ../en/ch09-hook.xml:1741
12537 msgid ""
12538 "This hook is invoked before Mercurial knows the identities of the changesets "
12539 "to be transmitted."
12540 msgstr ""
12542 #. type: Content of: <book><chapter><sect1><sect2><para>
12543 #: ../en/ch09-hook.xml:1745
12544 msgid ""
12545 "One use for this hook is to prevent changes from being transmitted to another "
12546 "repository."
12547 msgstr ""
12549 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12550 #: ../en/ch09-hook.xml:1752
12551 msgid ""
12552 "<literal>source</literal>: A string. The source of the operation that is "
12553 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
12554 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
12555 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
12556 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
12557 msgstr ""
12559 #. type: Content of: <book><chapter><sect1><sect2><para>
12560 #: ../en/ch09-hook.xml:1768
12561 msgid ""
12562 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
12563 "outgoing\"/>)"
12564 msgstr ""
12566 #. type: Content of: <book><chapter><sect1><sect2><title>
12567 #: ../en/ch09-hook.xml:1775
12568 msgid ""
12569 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
12570 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
12572 #. type: Content of: <book><chapter><sect1><sect2><para>
12573 #: ../en/ch09-hook.xml:1778
12574 msgid ""
12575 "This controlling hook is run before a tag is created. If the hook succeeds, "
12576 "creation of the tag proceeds. If the hook fails, the tag is not created."
12577 msgstr ""
12579 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12580 #: ../en/ch09-hook.xml:1786
12581 msgid ""
12582 "<literal>local</literal>: A boolean. Whether the tag is local to this "
12583 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
12584 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
12585 "hgtags</filename>)."
12586 msgstr ""
12588 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12589 #: ../en/ch09-hook.xml:1793
12590 msgid ""
12591 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
12592 "tagged."
12593 msgstr ""
12595 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12596 #: ../en/ch09-hook.xml:1797
12597 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
12598 msgstr ""
12600 #. type: Content of: <book><chapter><sect1><sect2><para>
12601 #: ../en/ch09-hook.xml:1802
12602 msgid ""
12603 "If the tag to be created is revision-controlled, the <literal role=\"hook"
12604 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
12605 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
12606 "pretxncommit\"/>) will also be run."
12607 msgstr ""
12609 #. type: Content of: <book><chapter><sect1><sect2><para>
12610 #: ../en/ch09-hook.xml:1810
12611 msgid ""
12612 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
12613 "\"/>)"
12614 msgstr ""
12616 #. type: Content of: <book><chapter><sect1><sect2><title>
12617 #: ../en/ch09-hook.xml:1815
12618 msgid ""
12619 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
12620 "addition of remote changesets"
12621 msgstr ""
12622 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
12624 #. type: Content of: <book><chapter><sect1><sect2><para>
12625 #: ../en/ch09-hook.xml:1819
12626 msgid ""
12627 "This controlling hook is run before a transaction&emdash;that manages the "
12628 "addition of a group of new changesets from outside the repository&emdash;"
12629 "completes. If the hook succeeds, the transaction completes, and all of the "
12630 "changesets become permanent within this repository. If the hook fails, the "
12631 "transaction is rolled back, and the data for the changesets is erased."
12632 msgstr ""
12634 #. type: Content of: <book><chapter><sect1><sect2><para>
12635 #: ../en/ch09-hook.xml:1828
12636 msgid ""
12637 "This hook can access the metadata associated with the almost-added "
12638 "changesets, but it should not do anything permanent with this data. It must "
12639 "also not modify the working directory."
12640 msgstr ""
12642 #. type: Content of: <book><chapter><sect1><sect2><para>
12643 #: ../en/ch09-hook.xml:1834
12644 msgid ""
12645 "While this hook is running, if other Mercurial processes access this "
12646 "repository, they will be able to see the almost-added changesets as if they "
12647 "are permanent. This may lead to race conditions if you do not take steps to "
12648 "avoid them."
12649 msgstr ""
12651 #. type: Content of: <book><chapter><sect1><sect2><para>
12652 #: ../en/ch09-hook.xml:1841
12653 msgid ""
12654 "This hook can be used to automatically vet a group of changesets. If the "
12655 "hook fails, all of the changesets are <quote>rejected</quote> when the "
12656 "transaction rolls back."
12657 msgstr ""
12659 #. type: Content of: <book><chapter><sect1><sect2><para>
12660 #: ../en/ch09-hook.xml:1870
12661 msgid ""
12662 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12663 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12664 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
12665 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
12666 msgstr ""
12668 #. type: Content of: <book><chapter><sect1><sect2><title>
12669 #: ../en/ch09-hook.xml:1881
12670 msgid ""
12671 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
12672 "of new changeset"
12673 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
12675 #. type: Content of: <book><chapter><sect1><sect2><para>
12676 #: ../en/ch09-hook.xml:1884
12677 msgid ""
12678 "This controlling hook is run before a transaction&emdash;that manages a new "
12679 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
12680 "the changeset becomes permanent within this repository. If the hook fails, "
12681 "the transaction is rolled back, and the commit data is erased."
12682 msgstr ""
12684 #. type: Content of: <book><chapter><sect1><sect2><para>
12685 #: ../en/ch09-hook.xml:1892
12686 msgid ""
12687 "This hook can access the metadata associated with the almost-new changeset, "
12688 "but it should not do anything permanent with this data. It must also not "
12689 "modify the working directory."
12690 msgstr ""
12692 #. type: Content of: <book><chapter><sect1><sect2><para>
12693 #: ../en/ch09-hook.xml:1898
12694 msgid ""
12695 "While this hook is running, if other Mercurial processes access this "
12696 "repository, they will be able to see the almost-new changeset as if it is "
12697 "permanent. This may lead to race conditions if you do not take steps to "
12698 "avoid them."
12699 msgstr ""
12701 #. type: Content of: <book><chapter><sect1><sect2><para>
12702 #: ../en/ch09-hook.xml:1922
12703 msgid ""
12704 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12705 "hook:precommit\"/>)"
12706 msgstr ""
12707 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
12708 "precommit\"/>)"
12710 #. type: Content of: <book><chapter><sect1><sect2><title>
12711 #: ../en/ch09-hook.xml:1929
12712 msgid ""
12713 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
12714 "working directory"
12715 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
12717 #. type: Content of: <book><chapter><sect1><sect2><para>
12718 #: ../en/ch09-hook.xml:1932
12719 msgid ""
12720 "This controlling hook is run before an update or merge of the working "
12721 "directory begins. It is run only if Mercurial's normal pre-update checks "
12722 "determine that the update or merge can proceed. If the hook succeeds, the "
12723 "update or merge may proceed; if it fails, the update or merge does not start."
12724 msgstr ""
12726 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12727 #: ../en/ch09-hook.xml:1943
12728 msgid ""
12729 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12730 "working directory is to be updated to. If the working directory is being "
12731 "merged, it will not change this parent."
12732 msgstr ""
12734 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12735 #: ../en/ch09-hook.xml:1949
12736 msgid ""
12737 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
12738 "is being merged. The ID of the revision that the working directory is being "
12739 "merged with."
12740 msgstr ""
12742 #. type: Content of: <book><chapter><sect1><sect2><para>
12743 #: ../en/ch09-hook.xml:1956
12744 msgid ""
12745 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
12746 "update\"/>)"
12747 msgstr ""
12749 #. type: Content of: <book><chapter><sect1><sect2><title>
12750 #: ../en/ch09-hook.xml:1961
12751 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
12752 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
12754 #. type: Content of: <book><chapter><sect1><sect2><para>
12755 #: ../en/ch09-hook.xml:1964
12756 msgid "This hook is run after a tag has been created."
12757 msgstr ""
12759 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12760 #: ../en/ch09-hook.xml:1970
12761 msgid ""
12762 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
12763 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
12764 "localtags</filename>) or managed by Mercurial (stored in <filename role="
12765 "\"special\">.hgtags</filename>)."
12766 msgstr ""
12768 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12769 #: ../en/ch09-hook.xml:1978
12770 msgid ""
12771 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
12772 "tagged."
12773 msgstr ""
12775 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12776 #: ../en/ch09-hook.xml:1982
12777 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
12778 msgstr ""
12780 #. type: Content of: <book><chapter><sect1><sect2><para>
12781 #: ../en/ch09-hook.xml:1987
12782 msgid ""
12783 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
12784 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
12785 "this hook."
12786 msgstr ""
12788 #. type: Content of: <book><chapter><sect1><sect2><para>
12789 #: ../en/ch09-hook.xml:1992
12790 msgid ""
12791 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
12792 "pretag\"/>)"
12793 msgstr ""
12794 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
12795 "\"/>)"
12797 #. type: Content of: <book><chapter><sect1><sect2><title>
12798 #: ../en/ch09-hook.xml:1998
12799 msgid ""
12800 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
12801 "working directory"
12802 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
12804 #. type: Content of: <book><chapter><sect1><sect2><para>
12805 #: ../en/ch09-hook.xml:2001
12806 msgid ""
12807 "This hook is run after an update or merge of the working directory "
12808 "completes. Since a merge can fail (if the external <command>hgmerge</"
12809 "command> command fails to resolve conflicts in a file), this hook "
12810 "communicates whether the update or merge completed cleanly."
12811 msgstr ""
12813 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12814 #: ../en/ch09-hook.xml:2009
12815 msgid ""
12816 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
12817 "completed successfully."
12818 msgstr ""
12820 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12821 #: ../en/ch09-hook.xml:2014
12822 msgid ""
12823 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12824 "working directory was updated to. If the working directory was merged, it "
12825 "will not have changed this parent."
12826 msgstr ""
12828 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12829 #: ../en/ch09-hook.xml:2020
12830 msgid ""
12831 "<literal>parent2</literal>: A changeset ID. Only set if the working "
12832 "directory was merged. The ID of the revision that the working directory was "
12833 "merged with."
12834 msgstr ""
12836 #. type: Content of: <book><chapter><sect1><sect2><para>
12837 #: ../en/ch09-hook.xml:2026
12838 msgid ""
12839 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
12840 "hook:preupdate\"/>)"
12841 msgstr ""
12843 #. type: Content of: <book><chapter><title>
12844 #: ../en/ch10-template.xml:5
12845 msgid "Customising the output of Mercurial"
12846 msgstr "定制 Mercurial 的输出"
12848 #. type: Content of: <book><chapter><para>
12849 #: ../en/ch10-template.xml:7
12850 msgid ""
12851 "Mercurial provides a powerful mechanism to let you control how it displays "
12852 "information. The mechanism is based on templates. You can use templates to "
12853 "generate specific output for a single command, or to customise the entire "
12854 "appearance of the built-in web interface."
12855 msgstr ""
12857 #. type: Content of: <book><chapter><sect1><title>
12858 #: ../en/ch10-template.xml:14
12859 msgid "Using precanned output styles"
12860 msgstr "使用预定义的输出样式"
12862 #. type: Content of: <book><chapter><sect1><para>
12863 #: ../en/ch10-template.xml:16
12864 msgid ""
12865 "Packaged with Mercurial are some output styles that you can use immediately. "
12866 "A style is simply a precanned template that someone wrote and installed "
12867 "somewhere that Mercurial can find."
12868 msgstr ""
12870 #. type: Content of: <book><chapter><sect1><para>
12871 #: ../en/ch10-template.xml:21
12872 msgid ""
12873 "Before we take a look at Mercurial's bundled styles, let's review its normal "
12874 "output."
12875 msgstr ""
12877 #. type: Content of: <book><chapter><sect1><para>
12878 #: ../en/ch10-template.xml:26
12879 msgid ""
12880 "This is somewhat informative, but it takes up a lot of space&emdash;five "
12881 "lines of output per changeset. The <literal>compact</literal> style reduces "
12882 "this to three lines, presented in a sparse manner."
12883 msgstr ""
12885 #. type: Content of: <book><chapter><sect1><para>
12886 #: ../en/ch10-template.xml:33
12887 msgid ""
12888 "The <literal>changelog</literal> style hints at the expressive power of "
12889 "Mercurial's templating engine. This style attempts to follow the GNU "
12890 "Project's changelog guidelines<citation>web:changelog</citation>."
12891 msgstr ""
12893 #. type: Content of: <book><chapter><sect1><para>
12894 #: ../en/ch10-template.xml:40
12895 msgid ""
12896 "You will not be shocked to learn that Mercurial's default output style is "
12897 "named <literal>default</literal>."
12898 msgstr ""
12900 #. type: Content of: <book><chapter><sect1><sect2><title>
12901 #: ../en/ch10-template.xml:44
12902 msgid "Setting a default style"
12903 msgstr "设置默认样式"
12905 #. type: Content of: <book><chapter><sect1><sect2><para>
12906 #: ../en/ch10-template.xml:46
12907 msgid ""
12908 "You can modify the output style that Mercurial will use for every command by "
12909 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
12910 "style you would prefer to use."
12911 msgstr ""
12913 #. type: Content of: <book><chapter><sect1><sect2><para>
12914 #: ../en/ch10-template.xml:54
12915 msgid ""
12916 "If you write a style of your own, you can use it by either providing the path "
12917 "to your style file, or copying your style file into a location where "
12918 "Mercurial can find it (typically the <literal>templates</literal> "
12919 "subdirectory of your Mercurial install directory)."
12920 msgstr ""
12922 #. type: Content of: <book><chapter><sect1><title>
12923 #: ../en/ch10-template.xml:63
12924 msgid "Commands that support styles and templates"
12925 msgstr "支持样式和模版的命令"
12927 #. type: Content of: <book><chapter><sect1><para>
12928 #: ../en/ch10-template.xml:65
12929 msgid ""
12930 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
12931 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
12932 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
12933 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
12934 msgstr ""
12936 #. type: Content of: <book><chapter><sect1><para>
12937 #: ../en/ch10-template.xml:72
12938 msgid ""
12939 "As I write this manual, these are so far the only commands that support "
12940 "styles and templates. Since these are the most important commands that need "
12941 "customisable output, there has been little pressure from the Mercurial user "
12942 "community to add style and template support to other commands."
12943 msgstr ""
12945 #. type: Content of: <book><chapter><sect1><title>
12946 #: ../en/ch10-template.xml:80
12947 msgid "The basics of templating"
12948 msgstr "模版基础"
12950 #. type: Content of: <book><chapter><sect1><para>
12951 #: ../en/ch10-template.xml:82
12952 msgid ""
12953 "At its simplest, a Mercurial template is a piece of text. Some of the text "
12954 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
12955 "replaced with new text, when necessary."
12956 msgstr ""
12958 #. type: Content of: <book><chapter><sect1><para>
12959 #: ../en/ch10-template.xml:87
12960 msgid ""
12961 "Before we continue, let's look again at a simple example of Mercurial's "
12962 "normal output."
12963 msgstr ""
12965 #. type: Content of: <book><chapter><sect1><para>
12966 #: ../en/ch10-template.xml:92
12967 msgid ""
12968 "Now, let's run the same command, but using a template to change its output."
12969 msgstr ""
12971 #. type: Content of: <book><chapter><sect1><para>
12972 #: ../en/ch10-template.xml:97
12973 msgid ""
12974 "The example above illustrates the simplest possible template; it's just a "
12975 "piece of static text, printed once for each changeset. The <option role=\"hg-"
12976 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
12977 "command> command tells Mercurial to use the given text as the template when "
12978 "printing each changeset."
12979 msgstr ""
12981 #. type: Content of: <book><chapter><sect1><para>
12982 #: ../en/ch10-template.xml:105
12983 msgid ""
12984 "Notice that the template string above ends with the text <quote><literal>\\n</"
12985 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
12986 "Mercurial to print a newline at the end of each template item. If you omit "
12987 "this newline, Mercurial will run each piece of output together. See <xref "
12988 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
12989 msgstr ""
12991 #. type: Content of: <book><chapter><sect1><para>
12992 #: ../en/ch10-template.xml:113
12993 msgid ""
12994 "A template that prints a fixed string of text all the time isn't very useful; "
12995 "let's try something a bit more complex."
12996 msgstr ""
12998 #. type: Content of: <book><chapter><sect1><para>
12999 #: ../en/ch10-template.xml:119
13000 msgid ""
13001 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
13002 "template has been replaced in the output with the description of each "
13003 "changeset. Every time Mercurial finds text enclosed in curly braces "
13004 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
13005 "quote>), it will try to replace the braces and text with the expansion of "
13006 "whatever is inside. To print a literal curly brace, you must escape it, as "
13007 "described in <xref linkend=\"sec:template:escape\"/>."
13008 msgstr ""
13010 #. type: Content of: <book><chapter><sect1><title>
13011 #: ../en/ch10-template.xml:131
13012 msgid "Common template keywords"
13013 msgstr "模版关键字"
13015 #. type: Content of: <book><chapter><sect1><para>
13016 #: ../en/ch10-template.xml:133
13017 msgid ""
13018 "You can start writing simple templates immediately using the keywords below."
13019 msgstr ""
13021 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13022 #: ../en/ch10-template.xml:137
13023 msgid ""
13024 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
13025 "author of the changeset."
13026 msgstr ""
13028 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13029 #: ../en/ch10-template.xml:141
13030 msgid ""
13031 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
13032 "the branch on which the changeset was committed. Will be empty if the branch "
13033 "name was <literal>default</literal>."
13034 msgstr ""
13036 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13037 #: ../en/ch10-template.xml:147
13038 msgid ""
13039 "<literal role=\"template-keyword\">date</literal>: Date information. The "
13040 "date when the changeset was committed. This is <emphasis>not</emphasis> "
13041 "human-readable; you must pass it through a filter that will render it "
13042 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
13043 "information on filters. The date is expressed as a pair of numbers. The "
13044 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
13045 "second is the offset of the committer's timezone from UTC, in seconds."
13046 msgstr ""
13048 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13049 #: ../en/ch10-template.xml:158
13050 msgid ""
13051 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
13052 "changeset description."
13053 msgstr ""
13055 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13056 #: ../en/ch10-template.xml:161
13057 msgid ""
13058 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
13059 "files modified, added, or removed by this changeset."
13060 msgstr ""
13062 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13063 #: ../en/ch10-template.xml:166
13064 msgid ""
13065 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
13066 "Files added by this changeset."
13067 msgstr ""
13069 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13070 #: ../en/ch10-template.xml:170
13071 msgid ""
13072 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
13073 "Files removed by this changeset."
13074 msgstr ""
13076 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13077 #: ../en/ch10-template.xml:174
13078 msgid ""
13079 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
13080 "identification hash, as a 40-character hexadecimal string."
13081 msgstr ""
13083 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13084 #: ../en/ch10-template.xml:178
13085 msgid ""
13086 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
13087 "parents of the changeset."
13088 msgstr ""
13090 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13091 #: ../en/ch10-template.xml:182
13092 msgid ""
13093 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
13094 "local changeset revision number."
13095 msgstr ""
13097 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13098 #: ../en/ch10-template.xml:186
13099 msgid ""
13100 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
13101 "associated with the changeset."
13102 msgstr ""
13104 #. type: Content of: <book><chapter><sect1><para>
13105 #: ../en/ch10-template.xml:191
13106 msgid ""
13107 "A few simple experiments will show us what to expect when we use these "
13108 "keywords; you can see the results below."
13109 msgstr ""
13111 #. type: Content of: <book><chapter><sect1><para>
13112 #: ../en/ch10-template.xml:196
13113 msgid ""
13114 "As we noted above, the date keyword does not produce human-readable output, "
13115 "so we must treat it specially. This involves using a <emphasis>filter</"
13116 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
13117 msgstr ""
13119 #. type: Content of: <book><chapter><sect1><title>
13120 #: ../en/ch10-template.xml:205
13121 msgid "Escape sequences"
13122 msgstr "转义序列"
13124 #. type: Content of: <book><chapter><sect1><para>
13125 #: ../en/ch10-template.xml:207
13126 msgid ""
13127 "Mercurial's templating engine recognises the most commonly used escape "
13128 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
13129 "literal></quote>) character, it looks at the following character and "
13130 "substitutes the two characters with a single replacement, as described below."
13131 msgstr ""
13133 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13134 #: ../en/ch10-template.xml:214
13135 msgid ""
13136 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
13137 "134."
13138 msgstr ""
13140 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13141 #: ../en/ch10-template.xml:218
13142 msgid "<literal>\\n</literal>: Newline, ASCII 12."
13143 msgstr ""
13145 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13146 #: ../en/ch10-template.xml:221
13147 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
13148 msgstr ""
13150 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13151 #: ../en/ch10-template.xml:224
13152 msgid "<literal>\\t</literal>: Tab, ASCII 11."
13153 msgstr ""
13155 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13156 #: ../en/ch10-template.xml:227
13157 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
13158 msgstr ""
13160 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13161 #: ../en/ch10-template.xml:230
13162 msgid ""
13163 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
13164 "ASCII 173."
13165 msgstr ""
13167 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13168 #: ../en/ch10-template.xml:234
13169 msgid ""
13170 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
13171 "ASCII 175."
13172 msgstr ""
13174 #. type: Content of: <book><chapter><sect1><para>
13175 #: ../en/ch10-template.xml:239
13176 msgid ""
13177 "As indicated above, if you want the expansion of a template to contain a "
13178 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
13179 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
13180 msgstr ""
13182 #. type: Content of: <book><chapter><sect1><title>
13183 #: ../en/ch10-template.xml:247
13184 msgid "Filtering keywords to change their results"
13185 msgstr "通过过滤关键字来修改输出结果"
13187 #. type: Content of: <book><chapter><sect1><para>
13188 #: ../en/ch10-template.xml:249
13189 msgid ""
13190 "Some of the results of template expansion are not immediately easy to use. "
13191 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
13192 "to modify the result of expanding a keyword. You have already seen a common "
13193 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
13194 "above, to make a date readable."
13195 msgstr ""
13197 #. type: Content of: <book><chapter><sect1><para>
13198 #: ../en/ch10-template.xml:256
13199 msgid ""
13200 "Below is a list of the most commonly used filters that Mercurial supports. "
13201 "While some filters can be applied to any text, others can only be used in "
13202 "specific circumstances. The name of each filter is followed first by an "
13203 "indication of where it can be used, then a description of its effect."
13204 msgstr ""
13206 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13207 #: ../en/ch10-template.xml:263
13208 msgid ""
13209 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
13210 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
13211 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
13212 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
13213 msgstr ""
13215 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13216 #: ../en/ch10-template.xml:270
13217 msgid ""
13218 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
13219 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
13220 "relative to the current time. Yields a string like <quote><literal>10 "
13221 "minutes</literal></quote>."
13222 msgstr ""
13224 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13225 #: ../en/ch10-template.xml:277
13226 msgid ""
13227 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
13228 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
13229 "its relatives. Treat the text as a path, and return the basename. For "
13230 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
13231 "<quote><literal>baz</literal></quote>."
13232 msgstr ""
13234 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13235 #: ../en/ch10-template.xml:286
13236 msgid ""
13237 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
13238 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
13239 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
13240 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
13241 "15:13:13 2006 -0700</literal></quote>."
13242 msgstr ""
13244 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13245 #: ../en/ch10-template.xml:294
13246 msgid ""
13247 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
13248 "most useful for the <literal role=\"template-keyword\">author</literal> "
13249 "keyword. Finds the first string that looks like an email address, and "
13250 "extract just the domain component. For example, <quote><literal>Bryan "
13251 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
13252 "<quote><literal>serpentine.com</literal></quote>."
13253 msgstr ""
13255 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13256 #: ../en/ch10-template.xml:304
13257 msgid ""
13258 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
13259 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13260 "Extract the first string that looks like an email address. For example, "
13261 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13262 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
13263 msgstr ""
13265 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13266 #: ../en/ch10-template.xml:313
13267 msgid ""
13268 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
13269 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
13270 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
13271 "quote> with XML entities."
13272 msgstr ""
13274 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13275 #: ../en/ch10-template.xml:321
13276 msgid ""
13277 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
13278 "to fit in 68 columns. This is useful before you pass text through the "
13279 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
13280 "it to fit in an 80-column fixed-font window."
13281 msgstr ""
13283 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13284 #: ../en/ch10-template.xml:329
13285 msgid ""
13286 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
13287 "to fit in 76 columns."
13288 msgstr ""
13290 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13291 #: ../en/ch10-template.xml:333
13292 msgid ""
13293 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
13294 "first line of text, without any trailing newlines."
13295 msgstr ""
13297 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13298 #: ../en/ch10-template.xml:338
13299 msgid ""
13300 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
13301 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
13302 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
13303 "literal></quote>."
13304 msgstr ""
13306 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13307 #: ../en/ch10-template.xml:345
13308 msgid ""
13309 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
13310 "\"template-keyword\">date</literal> keyword. Render the date as a text "
13311 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
13312 "15:13:13 -0700</literal></quote>."
13313 msgstr ""
13315 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13316 #: ../en/ch10-template.xml:352
13317 msgid ""
13318 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
13319 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13320 "Yield the input text rendered as a sequence of XML entities. This helps to "
13321 "defeat some particularly stupid screen-scraping email harvesting spambots."
13322 msgstr ""
13324 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13325 #: ../en/ch10-template.xml:360
13326 msgid ""
13327 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
13328 "most useful for the <literal role=\"template-keyword\">author</literal> "
13329 "keyword. Yield the text before an email address. For example, "
13330 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13331 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
13332 msgstr ""
13334 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13335 #: ../en/ch10-template.xml:369
13336 msgid ""
13337 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
13338 "\"template-keyword\">date</literal> keyword. Render a date using the same "
13339 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
13340 "Sep 2006 15:13:13 -0700</literal></quote>."
13341 msgstr ""
13343 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13344 #: ../en/ch10-template.xml:376
13345 msgid ""
13346 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
13347 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
13348 "string."
13349 msgstr ""
13351 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13352 #: ../en/ch10-template.xml:381
13353 msgid ""
13354 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
13355 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
13356 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
13357 "quote>."
13358 msgstr ""
13360 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13361 #: ../en/ch10-template.xml:387
13362 msgid ""
13363 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
13364 "leading and trailing whitespace from the string."
13365 msgstr ""
13367 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13368 #: ../en/ch10-template.xml:391
13369 msgid ""
13370 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
13371 "text, with every line except the first starting with a tab character."
13372 msgstr ""
13374 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13375 #: ../en/ch10-template.xml:396
13376 msgid ""
13377 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
13378 "characters that are considered <quote>special</quote> by URL parsers. For "
13379 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
13380 msgstr ""
13382 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
13383 #: ../en/ch10-template.xml:403
13384 msgid ""
13385 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
13386 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
13387 "Return the <quote>user</quote> portion of an email address. For example, "
13388 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
13389 "becomes <quote><literal>bos</literal></quote>."
13390 msgstr ""
13392 #. type: Content of: <book><chapter><sect1><note><para>
13393 #: ../en/ch10-template.xml:416
13394 msgid ""
13395 "If you try to apply a filter to a piece of data that it cannot process, "
13396 "Mercurial will fail and print a Python exception. For example, trying to run "
13397 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
13398 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
13399 "not a good idea."
13400 msgstr ""
13402 #. type: Content of: <book><chapter><sect1><sect2><title>
13403 #: ../en/ch10-template.xml:425
13404 msgid "Combining filters"
13405 msgstr "组合过滤器"
13407 #. type: Content of: <book><chapter><sect1><sect2><para>
13408 #: ../en/ch10-template.xml:427
13409 msgid ""
13410 "It is easy to combine filters to yield output in the form you would like. "
13411 "The following chain of filters tidies up a description, then makes sure that "
13412 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
13413 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
13414 "wide)."
13415 msgstr ""
13417 #. type: Content of: <book><chapter><sect1><sect2><para>
13418 #: ../en/ch10-template.xml:436
13419 msgid ""
13420 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
13421 "the template to force the first line to be indented; this is necessary since "
13422 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
13423 "<emphasis>except</emphasis> the first."
13424 msgstr ""
13426 #. type: Content of: <book><chapter><sect1><sect2><para>
13427 #: ../en/ch10-template.xml:442
13428 msgid ""
13429 "Keep in mind that the order of filters in a chain is significant. The first "
13430 "filter is applied to the result of the keyword; the second to the result of "
13431 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
13432 "literal> gives very different results from <literal>tabindent|fill68</"
13433 "literal>."
13434 msgstr ""
13436 #. type: Content of: <book><chapter><sect1><title>
13437 #: ../en/ch10-template.xml:453
13438 msgid "From templates to styles"
13439 msgstr "从模版到样式"
13441 #. type: Content of: <book><chapter><sect1><para>
13442 #: ../en/ch10-template.xml:455
13443 msgid ""
13444 "A command line template provides a quick and simple way to format some "
13445 "output. Templates can become verbose, though, and it's useful to be able to "
13446 "give a template a name. A style file is a template with a name, stored in a "
13447 "file."
13448 msgstr ""
13450 #. type: Content of: <book><chapter><sect1><para>
13451 #: ../en/ch10-template.xml:460
13452 msgid ""
13453 "More than that, using a style file unlocks the power of Mercurial's "
13454 "templating engine in ways that are not possible using the command line "
13455 "<option role=\"hg-opt-log\">--template</option> option."
13456 msgstr ""
13458 #. type: Content of: <book><chapter><sect1><sect2><title>
13459 #: ../en/ch10-template.xml:466
13460 msgid "The simplest of style files"
13461 msgstr "最简单的样式文件"
13463 #. type: Content of: <book><chapter><sect1><sect2><para>
13464 #: ../en/ch10-template.xml:468
13465 msgid "Our simple style file contains just one line:"
13466 msgstr ""
13468 #. type: Content of: <book><chapter><sect1><sect2><para>
13469 #: ../en/ch10-template.xml:472
13470 msgid ""
13471 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
13472 "the right as the template</quote>."
13473 msgstr ""
13475 #. type: Content of: <book><chapter><sect1><sect2><title>
13476 #: ../en/ch10-template.xml:478
13477 msgid "Style file syntax"
13478 msgstr "样式文件语法"
13480 #. type: Content of: <book><chapter><sect1><sect2><para>
13481 #: ../en/ch10-template.xml:480
13482 msgid "The syntax rules for a style file are simple."
13483 msgstr ""
13485 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13486 #: ../en/ch10-template.xml:483
13487 msgid "The file is processed one line at a time."
13488 msgstr ""
13490 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13491 #: ../en/ch10-template.xml:486
13492 msgid "Leading and trailing white space are ignored."
13493 msgstr ""
13495 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13496 #: ../en/ch10-template.xml:489
13497 msgid "Empty lines are skipped."
13498 msgstr ""
13500 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13501 #: ../en/ch10-template.xml:491
13502 msgid ""
13503 "If a line starts with either of the characters <quote><literal>#</literal></"
13504 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
13505 "a comment, and skipped as if empty."
13506 msgstr ""
13508 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13509 #: ../en/ch10-template.xml:496
13510 msgid ""
13511 "A line starts with a keyword. This must start with an alphabetic character "
13512 "or underscore, and can subsequently contain any alphanumeric character or "
13513 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
13514 "Za-z0-9_]*</literal>.)"
13515 msgstr ""
13517 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13518 #: ../en/ch10-template.xml:502
13519 msgid ""
13520 "The next element must be an <quote><literal>=</literal></quote> character, "
13521 "which can be preceded or followed by an arbitrary amount of white space."
13522 msgstr ""
13524 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13525 #: ../en/ch10-template.xml:507
13526 msgid ""
13527 "If the rest of the line starts and ends with matching quote characters "
13528 "(either single or double quote), it is treated as a template body."
13529 msgstr ""
13531 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13532 #: ../en/ch10-template.xml:511
13533 msgid ""
13534 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
13535 "character, it is treated as the name of a file; the contents of this file "
13536 "will be read and used as a template body."
13537 msgstr ""
13539 #. type: Content of: <book><chapter><sect1><title>
13540 #: ../en/ch10-template.xml:520
13541 msgid "Style files by example"
13542 msgstr "样式文件例子"
13544 #. type: Content of: <book><chapter><sect1><para>
13545 #: ../en/ch10-template.xml:522
13546 msgid ""
13547 "To illustrate how to write a style file, we will construct a few by example. "
13548 "Rather than provide a complete style file and walk through it, we'll mirror "
13549 "the usual process of developing a style file by starting with something very "
13550 "simple, and walking through a series of successively more complete examples."
13551 msgstr ""
13553 #. type: Content of: <book><chapter><sect1><sect2><title>
13554 #: ../en/ch10-template.xml:529
13555 msgid "Identifying mistakes in style files"
13556 msgstr "在样式文件中定位错误"
13558 #. type: Content of: <book><chapter><sect1><sect2><para>
13559 #: ../en/ch10-template.xml:531
13560 msgid ""
13561 "If Mercurial encounters a problem in a style file you are working on, it "
13562 "prints a terse error message that, once you figure out what it means, is "
13563 "actually quite useful."
13564 msgstr ""
13566 #. type: Content of: <book><chapter><sect1><sect2><para>
13567 #: ../en/ch10-template.xml:537
13568 msgid ""
13569 "Notice that <filename>broken.style</filename> attempts to define a "
13570 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
13571 "When instructed to use this style file, Mercurial promptly complains."
13572 msgstr ""
13574 #. type: Content of: <book><chapter><sect1><sect2><para>
13575 #: ../en/ch10-template.xml:544
13576 msgid "This error message looks intimidating, but it is not too hard to follow."
13577 msgstr ""
13579 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13580 #: ../en/ch10-template.xml:548
13581 msgid ""
13582 "The first component is simply Mercurial's way of saying <quote>I am giving "
13583 "up</quote>."
13584 msgstr ""
13586 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13587 #: ../en/ch10-template.xml:552
13588 msgid "Next comes the name of the style file that contains the error."
13589 msgstr ""
13591 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13592 #: ../en/ch10-template.xml:556
13593 msgid ""
13594 "Following the file name is the line number where the error was encountered."
13595 msgstr ""
13597 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13598 #: ../en/ch10-template.xml:560
13599 msgid "Finally, a description of what went wrong."
13600 msgstr ""
13602 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13603 #: ../en/ch10-template.xml:564
13604 msgid ""
13605 "The description of the problem is not always clear (as in this case), but "
13606 "even when it is cryptic, it is almost always trivial to visually inspect the "
13607 "offending line in the style file and see what is wrong."
13608 msgstr ""
13610 #. type: Content of: <book><chapter><sect1><sect2><title>
13611 #: ../en/ch10-template.xml:572
13612 msgid "Uniquely identifying a repository"
13613 msgstr "版本库的唯一标识"
13615 #. type: Content of: <book><chapter><sect1><sect2><para>
13616 #: ../en/ch10-template.xml:574
13617 msgid ""
13618 "If you would like to be able to identify a Mercurial repository <quote>fairly "
13619 "uniquely</quote> using a short string as an identifier, you can use the first "
13620 "revision in the repository."
13621 msgstr ""
13623 #. type: Content of: <book><chapter><sect1><sect2><para>
13624 #: ../en/ch10-template.xml:581
13625 msgid ""
13626 "This is not guaranteed to be unique, but it is nevertheless useful in many "
13627 "cases."
13628 msgstr ""
13630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13631 #: ../en/ch10-template.xml:584
13632 msgid ""
13633 "It will not work in a completely empty repository, because such a repository "
13634 "does not have a revision zero."
13635 msgstr ""
13637 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13638 #: ../en/ch10-template.xml:588
13639 msgid ""
13640 "Neither will it work in the (extremely rare) case where a repository is a "
13641 "merge of two or more formerly independent repositories, and you still have "
13642 "those repositories around."
13643 msgstr ""
13645 #. type: Content of: <book><chapter><sect1><sect2><para>
13646 #: ../en/ch10-template.xml:593
13647 msgid "Here are some uses to which you could put this identifier:"
13648 msgstr ""
13650 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13651 #: ../en/ch10-template.xml:596
13652 msgid ""
13653 "As a key into a table for a database that manages repositories on a server."
13654 msgstr ""
13656 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13657 #: ../en/ch10-template.xml:599
13658 msgid ""
13659 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
13660 "emphasis>} tuple. Save this information away when you run an automated build "
13661 "or other activity, so that you can <quote>replay</quote> the build later if "
13662 "necessary."
13663 msgstr ""
13665 #. type: Content of: <book><chapter><sect1><sect2><title>
13666 #: ../en/ch10-template.xml:608
13667 msgid "Mimicking Subversion's output"
13668 msgstr "模仿 Subversion 的输出"
13671 #. type: Content of: <book><chapter><sect1><sect2><para>
13672 #: ../en/ch10-template.xml:610
13673 msgid ""
13674 "Let's try to emulate the default output format used by another revision "
13675 "control tool, Subversion."
13676 msgstr ""
13679 #. type: Content of: <book><chapter><sect1><sect2><para>
13680 #: ../en/ch10-template.xml:615
13681 msgid ""
13682 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
13683 "paste a hunk of its output into a file, and replace the text produced above "
13684 "by Subversion with the template values we'd like to see expanded."
13685 msgstr ""
13687 #. type: Content of: <book><chapter><sect1><sect2><para>
13688 #: ../en/ch10-template.xml:622
13689 msgid ""
13690 "There are a few small ways in which this template deviates from the output "
13691 "produced by Subversion."
13692 msgstr ""
13694 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13695 #: ../en/ch10-template.xml:625
13696 msgid ""
13697 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
13698 "Sep 2006</literal></quote> in the example output above) in parentheses. "
13699 "Mercurial's templating engine does not provide a way to display a date in "
13700 "this format without also printing the time and time zone."
13701 msgstr ""
13703 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13704 #: ../en/ch10-template.xml:632
13705 msgid ""
13706 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
13707 "<quote><literal>-</literal></quote> characters by ending the template with "
13708 "such a line. We use the templating engine's <literal role=\"template-keyword"
13709 "\">header</literal> keyword to print a separator line as the first line of "
13710 "output (see below), thus achieving similar output to Subversion."
13711 msgstr ""
13713 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13714 #: ../en/ch10-template.xml:641
13715 msgid ""
13716 "Subversion's output includes a count in the header of the number of lines in "
13717 "the commit message. We cannot replicate this in Mercurial; the templating "
13718 "engine does not currently provide a filter that counts the number of lines "
13719 "the template generates."
13720 msgstr ""
13723 #. type: Content of: <book><chapter><sect1><sect2><para>
13724 #: ../en/ch10-template.xml:647
13725 msgid ""
13726 "It took me no more than a minute or two of work to replace literal text from "
13727 "an example of Subversion's output with some keywords and filters to give the "
13728 "template above. The style file simply refers to the template."
13729 msgstr ""
13731 #. type: Content of: <book><chapter><sect1><sect2><para>
13732 #: ../en/ch10-template.xml:654
13733 msgid ""
13734 "We could have included the text of the template file directly in the style "
13735 "file by enclosing it in quotes and replacing the newlines with "
13736 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
13737 "style file too difficult to read. Readability is a good guide when you're "
13738 "trying to decide whether some text belongs in a style file, or in a template "
13739 "file that the style file points to. If the style file will look too big or "
13740 "cluttered if you insert a literal piece of text, drop it into a template "
13741 "instead."
13742 msgstr ""
13744 #. type: Content of: <book><chapter><title>
13745 #: ../en/ch11-mq.xml:5
13746 msgid "Managing change with Mercurial Queues"
13747 msgstr "使用 MQ 管理修改"
13749 #. type: Content of: <book><chapter><sect1><title>
13750 #: ../en/ch11-mq.xml:8
13751 msgid "The patch management problem"
13752 msgstr "补丁的管理问题"
13754 #. type: Content of: <book><chapter><sect1><para>
13755 #: ../en/ch11-mq.xml:10
13756 msgid ""
13757 "Here is a common scenario: you need to install a software package from "
13758 "source, but you find a bug that you must fix in the source before you can "
13759 "start using the package. You make your changes, forget about the package for "
13760 "a while, and a few months later you need to upgrade to a newer version of the "
13761 "package. If the newer version of the package still has the bug, you must "
13762 "extract your fix from the older source tree and apply it against the newer "
13763 "version. This is a tedious task, and it's easy to make mistakes."
13764 msgstr ""
13766 #. type: Content of: <book><chapter><sect1><para>
13767 #: ../en/ch11-mq.xml:20
13768 msgid ""
13769 "This is a simple case of the <quote>patch management</quote> problem. You "
13770 "have an <quote>upstream</quote> source tree that you can't change; you need "
13771 "to make some local changes on top of the upstream tree; and you'd like to be "
13772 "able to keep those changes separate, so that you can apply them to newer "
13773 "versions of the upstream source."
13774 msgstr ""
13776 #. type: Content of: <book><chapter><sect1><para>
13777 #: ../en/ch11-mq.xml:27
13778 msgid ""
13779 "The patch management problem arises in many situations. Probably the most "
13780 "visible is that a user of an open source software project will contribute a "
13781 "bug fix or new feature to the project's maintainers in the form of a patch."
13782 msgstr ""
13784 #. type: Content of: <book><chapter><sect1><para>
13785 #: ../en/ch11-mq.xml:32
13786 msgid ""
13787 "Distributors of operating systems that include open source software often "
13788 "need to make changes to the packages they distribute so that they will build "
13789 "properly in their environments."
13790 msgstr ""
13792 #. type: Content of: <book><chapter><sect1><para>
13793 #: ../en/ch11-mq.xml:37
13794 msgid ""
13795 "When you have few changes to maintain, it is easy to manage a single patch "
13796 "using the standard <command>diff</command> and <command>patch</command> "
13797 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
13798 "tools). Once the number of changes grows, it starts to make sense to maintain "
13799 "patches as discrete <quote>chunks of work,</quote> so that for example a "
13800 "single patch will contain only one bug fix (the patch might modify several "
13801 "files, but it's doing <quote>only one thing</quote>), and you may have a "
13802 "number of such patches for different bugs you need fixed and local changes "
13803 "you require. In this situation, if you submit a bug fix patch to the "
13804 "upstream maintainers of a package and they include your fix in a subsequent "
13805 "release, you can simply drop that single patch when you're updating to the "
13806 "newer release."
13807 msgstr ""
13809 #. type: Content of: <book><chapter><sect1><para>
13810 #: ../en/ch11-mq.xml:52
13811 msgid ""
13812 "Maintaining a single patch against an upstream tree is a little tedious and "
13813 "error-prone, but not difficult. However, the complexity of the problem grows "
13814 "rapidly as the number of patches you have to maintain increases. With more "
13815 "than a tiny number of patches in hand, understanding which ones you have "
13816 "applied and maintaining them moves from messy to overwhelming."
13817 msgstr ""
13819 #. type: Content of: <book><chapter><sect1><para>
13820 #: ../en/ch11-mq.xml:59
13821 msgid ""
13822 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
13823 "simply <quote>MQ</quote>), that massively simplifies the patch management "
13824 "problem."
13825 msgstr ""
13827 #. type: Content of: <book><chapter><sect1><title>
13828 #: ../en/ch11-mq.xml:65
13829 msgid "The prehistory of Mercurial Queues"
13830 msgstr "MQ 的历史"
13832 #. type: Content of: <book><chapter><sect1><para>
13833 #: ../en/ch11-mq.xml:67
13834 msgid ""
13835 "During the late 1990s, several Linux kernel developers started to maintain "
13836 "<quote>patch series</quote> that modified the behavior of the Linux kernel. "
13837 "Some of these series were focused on stability, some on feature coverage, and "
13838 "others were more speculative."
13839 msgstr ""
13841 #. type: Content of: <book><chapter><sect1><para>
13842 #: ../en/ch11-mq.xml:73
13843 msgid ""
13844 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
13845 "published some shell scripts he had been using to automate the task of "
13846 "managing his patch queues. Andrew was successfully using these scripts to "
13847 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
13848 msgstr ""
13850 #. type: Content of: <book><chapter><sect1><sect2><title>
13851 #: ../en/ch11-mq.xml:80
13852 msgid "A patchwork quilt"
13853 msgstr ""
13855 #. type: Content of: <book><chapter><sect1><sect2><para>
13856 #: ../en/ch11-mq.xml:82
13857 msgid ""
13858 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
13859 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
13860 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
13861 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
13862 "quilt substantially automated patch management, it rapidly gained a large "
13863 "following among open source software developers."
13864 msgstr ""
13866 #. type: Content of: <book><chapter><sect1><sect2><para>
13867 #: ../en/ch11-mq.xml:91
13868 msgid ""
13869 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
13870 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
13871 "files you want to manage; it stores away the names and contents of those "
13872 "files. To fix a bug, you create a new patch (using a single command), edit "
13873 "the files you need to fix, then <quote>refresh</quote> the patch."
13874 msgstr ""
13876 #. type: Content of: <book><chapter><sect1><sect2><para>
13877 #: ../en/ch11-mq.xml:99
13878 msgid ""
13879 "The refresh step causes quilt to scan the directory tree; it updates the "
13880 "patch with all of the changes you have made. You can create another patch on "
13881 "top of the first, which will track the changes required to modify the tree "
13882 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
13883 "patches applied</quote>."
13884 msgstr ""
13886 #. type: Content of: <book><chapter><sect1><sect2><para>
13887 #: ../en/ch11-mq.xml:106
13888 msgid ""
13889 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
13890 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
13891 "from the directory tree. Quilt remembers which patches you have popped, "
13892 "though, so you can <quote>push</quote> a popped patch again, and the "
13893 "directory tree will be restored to contain the modifications in the patch. "
13894 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
13895 "and the topmost applied patch will be updated. This means that you can, at "
13896 "any time, change both which patches are applied and what modifications those "
13897 "patches make."
13898 msgstr ""
13900 #. type: Content of: <book><chapter><sect1><sect2><para>
13901 #: ../en/ch11-mq.xml:118
13902 msgid ""
13903 "Quilt knows nothing about revision control tools, so it works equally well on "
13904 "top of an unpacked tarball or a Subversion working copy."
13905 msgstr ""
13907 #. type: Content of: <book><chapter><sect1><sect2><title>
13908 #: ../en/ch11-mq.xml:124
13909 msgid "From patchwork quilt to Mercurial Queues"
13910 msgstr "从 patchwork quilt 到 MQ"
13912 #. type: Content of: <book><chapter><sect1><sect2><para>
13913 #: ../en/ch11-mq.xml:126
13914 msgid ""
13915 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
13916 "that he called Mercurial Queues, which added quilt-like behavior to Mercurial."
13917 msgstr ""
13919 #. type: Content of: <book><chapter><sect1><sect2><para>
13920 #: ../en/ch11-mq.xml:130
13921 msgid ""
13922 "The key difference between quilt and MQ is that quilt knows nothing about "
13923 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
13924 "Mercurial. Each patch that you push is represented as a Mercurial "
13925 "changeset. Pop a patch, and the changeset goes away."
13926 msgstr ""
13928 #. type: Content of: <book><chapter><sect1><sect2><para>
13929 #: ../en/ch11-mq.xml:136
13930 msgid ""
13931 "Because quilt does not care about revision control tools, it is still a "
13932 "tremendously useful piece of software to know about for situations where you "
13933 "cannot use Mercurial and MQ."
13934 msgstr ""
13936 #. type: Content of: <book><chapter><sect1><title>
13937 #: ../en/ch11-mq.xml:144
13938 msgid "The huge advantage of MQ"
13939 msgstr "MQ 的巨大优势"
13941 #. type: Content of: <book><chapter><sect1><para>
13942 #: ../en/ch11-mq.xml:146
13943 msgid ""
13944 "I cannot overstate the value that MQ offers through the unification of "
13945 "patches and revision control."
13946 msgstr ""
13948 #. type: Content of: <book><chapter><sect1><para>
13949 #: ../en/ch11-mq.xml:149
13950 msgid ""
13951 "A major reason that patches have persisted in the free software and open "
13952 "source world&emdash;in spite of the availability of increasingly capable "
13953 "revision control tools over the years&emdash;is the <emphasis>agility</"
13954 "emphasis> they offer."
13955 msgstr ""
13957 #. type: Content of: <book><chapter><sect1><para>
13958 #: ../en/ch11-mq.xml:155
13959 msgid ""
13960 "Traditional revision control tools make a permanent, irreversible record of "
13961 "everything that you do. While this has great value, it's also somewhat "
13962 "stifling. If you want to perform a wild-eyed experiment, you have to be "
13963 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
13964 "misleading or destabilising&emdash;traces of your missteps and errors in the "
13965 "permanent revision record."
13966 msgstr ""
13968 #. type: Content of: <book><chapter><sect1><para>
13969 #: ../en/ch11-mq.xml:163
13970 msgid ""
13971 "By contrast, MQ's marriage of distributed revision control with patches makes "
13972 "it much easier to isolate your work. Your patches live on top of normal "
13973 "revision history, and you can make them disappear or reappear at will. If "
13974 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
13975 "it to be, simply fix it&emdash;as many times as you need to, until you have "
13976 "refined it into the form you desire."
13977 msgstr ""
13979 #. type: Content of: <book><chapter><sect1><para>
13980 #: ../en/ch11-mq.xml:171
13981 msgid ""
13982 "As an example, the integration of patches with revision control makes "
13983 "understanding patches and debugging their effects&emdash;and their interplay "
13984 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
13985 "Since every applied patch has an associated changeset, you can give <command "
13986 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
13987 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
13988 "bisect</command> command to binary-search through all changesets and applied "
13989 "patches to see where a bug got introduced or fixed. You can use the <command "
13990 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
13991 "modified a particular line of a source file. And so on."
13992 msgstr ""
13994 #. type: Content of: <book><chapter><sect1><para>
13995 #: ../en/ch11-mq.xml:189
13996 msgid ""
13997 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
13998 "understand what patches are, and a little about the tools that work with them."
13999 msgstr ""
14001 #. type: Content of: <book><chapter><sect1><para>
14002 #: ../en/ch11-mq.xml:193
14003 msgid ""
14004 "The traditional Unix <command>diff</command> command compares two files, and "
14005 "prints a list of differences between them. The <command>patch</command> "
14006 "command understands these differences as <emphasis>modifications</emphasis> "
14007 "to make to a file. Take a look below for a simple example of these commands "
14008 "in action."
14009 msgstr ""
14011 #. type: Content of: <book><chapter><sect1><para>
14012 #: ../en/ch11-mq.xml:202
14013 msgid ""
14014 "The type of file that <command>diff</command> generates (and <command>patch</"
14015 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
14016 "quote>; there is no difference between a patch and a diff. (We'll use the "
14017 "term <quote>patch</quote>, since it's more commonly used.)"
14018 msgstr ""
14020 #. type: Content of: <book><chapter><sect1><para>
14021 #: ../en/ch11-mq.xml:208
14022 msgid ""
14023 "A patch file can start with arbitrary text; the <command>patch</command> "
14024 "command ignores this text, but MQ uses it as the commit message when creating "
14025 "changesets. To find the beginning of the patch content, <command>patch</"
14026 "command> searches for the first line that starts with the string "
14027 "<quote><literal>diff -</literal></quote>."
14028 msgstr ""
14030 #. type: Content of: <book><chapter><sect1><para>
14031 #: ../en/ch11-mq.xml:215
14032 msgid ""
14033 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
14034 "can accept several other diff formats, but MQ doesn't). A unified diff "
14035 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
14036 "the file being modified; it contains the name of the file to modify. When "
14037 "<command>patch</command> sees a new file header, it looks for a file with "
14038 "that name to start modifying."
14039 msgstr ""
14041 #. type: Content of: <book><chapter><sect1><para>
14042 #: ../en/ch11-mq.xml:223
14043 msgid ""
14044 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
14045 "hunk starts with a header; this identifies the range of line numbers within "
14046 "the file that the hunk should modify. Following the header, a hunk starts "
14047 "and ends with a few (usually three) lines of text from the unmodified file; "
14048 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
14049 "only a small amount of context between successive hunks, <command>diff</"
14050 "command> doesn't print a new hunk header; it just runs the hunks together, "
14051 "with a few lines of context between modifications."
14052 msgstr ""
14054 #. type: Content of: <book><chapter><sect1><para>
14055 #: ../en/ch11-mq.xml:235
14056 msgid ""
14057 "Each line of context begins with a space character. Within the hunk, a line "
14058 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
14059 "line,</quote> while a line that begins with <quote><literal>+</literal></"
14060 "quote> means <quote>insert this line.</quote> For example, a line that is "
14061 "modified is represented by one deletion and one insertion."
14062 msgstr ""
14064 #. type: Content of: <book><chapter><sect1><para>
14065 #: ../en/ch11-mq.xml:243
14066 msgid ""
14067 "We will return to some of the more subtle aspects of patches later (in <xref "
14068 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
14069 "to use MQ."
14070 msgstr ""
14072 #. type: Content of: <book><chapter><sect1><title>
14073 #: ../en/ch11-mq.xml:250
14074 msgid "Getting started with Mercurial Queues"
14075 msgstr "开始使用 MQ"
14077 #. type: Content of: <book><chapter><sect1><para>
14078 #: ../en/ch11-mq.xml:252
14079 msgid ""
14080 "Because MQ is implemented as an extension, you must explicitly enable before "
14081 "you can use it. (You don't need to download anything; MQ ships with the "
14082 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
14083 "\"home\">~/.hgrc</filename> file, and add the lines below."
14084 msgstr ""
14086 #. type: Content of: <book><chapter><sect1><para>
14087 #: ../en/ch11-mq.xml:262
14088 msgid ""
14089 "Once the extension is enabled, it will make a number of new commands "
14090 "available. To verify that the extension is working, you can use <command "
14091 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
14092 "\">qinit</command> command is now available."
14093 msgstr ""
14095 #. type: Content of: <book><chapter><sect1><para>
14096 #: ../en/ch11-mq.xml:270
14097 msgid ""
14098 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
14099 "commands only operate within that repository. To get started, simply prepare "
14100 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
14101 msgstr ""
14103 #. type: Content of: <book><chapter><sect1><para>
14104 #: ../en/ch11-mq.xml:277
14105 msgid ""
14106 "This command creates an empty directory called <filename role=\"special\" "
14107 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
14108 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
14109 "command> command prints nothing if it succeeds."
14110 msgstr ""
14112 #. type: Content of: <book><chapter><sect1><sect2><title>
14113 #: ../en/ch11-mq.xml:284
14114 msgid "Creating a new patch"
14115 msgstr "创建新补丁"
14117 #. type: Content of: <book><chapter><sect1><sect2><para>
14118 #: ../en/ch11-mq.xml:286
14119 msgid ""
14120 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
14121 "command> command. This command takes one argument, the name of the patch to "
14122 "create."
14123 msgstr ""
14125 #. type: Content of: <book><chapter><sect1><sect2><para>
14126 #: ../en/ch11-mq.xml:290
14127 msgid ""
14128 "MQ will use this as the name of an actual file in the <filename role=\"special"
14129 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
14130 msgstr ""
14132 #. type: Content of: <book><chapter><sect1><sect2><para>
14133 #: ../en/ch11-mq.xml:297
14134 msgid ""
14135 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
14136 "patches</filename> directory are two other files, <filename role=\"special"
14137 "\">series</filename> and <filename role=\"special\">status</filename>. The "
14138 "<filename role=\"special\">series</filename> file lists all of the patches "
14139 "that MQ knows about for this repository, with one patch per line. Mercurial "
14140 "uses the <filename role=\"special\">status</filename> file for internal book-"
14141 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
14142 "emphasis> in this repository."
14143 msgstr ""
14145 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14146 #: ../en/ch11-mq.xml:309
14147 msgid ""
14148 "You may sometimes want to edit the <filename role=\"special\">series</"
14149 "filename> file by hand; for example, to change the sequence in which some "
14150 "patches are applied. However, manually editing the <filename role=\"special"
14151 "\">status</filename> file is almost always a bad idea, as it's easy to "
14152 "corrupt MQ's idea of what is happening."
14153 msgstr ""
14155 #. type: Content of: <book><chapter><sect1><sect2><para>
14156 #: ../en/ch11-mq.xml:318
14157 msgid ""
14158 "Once you have created your new patch, you can edit files in the working "
14159 "directory as you usually would. All of the normal Mercurial commands, such "
14160 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
14161 "annotate</command>, work exactly as they did before."
14162 msgstr ""
14164 #. type: Content of: <book><chapter><sect1><sect2><title>
14165 #: ../en/ch11-mq.xml:326
14166 msgid "Refreshing a patch"
14167 msgstr "刷新补丁"
14169 #. type: Content of: <book><chapter><sect1><sect2><para>
14170 #: ../en/ch11-mq.xml:328
14171 msgid ""
14172 "When you reach a point where you want to save your work, use the <command "
14173 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
14174 "working on."
14175 msgstr ""
14177 #. type: Content of: <book><chapter><sect1><sect2><para>
14178 #: ../en/ch11-mq.xml:334
14179 msgid ""
14180 "This command folds the changes you have made in the working directory into "
14181 "your patch, and updates its corresponding changeset to contain those changes."
14182 msgstr ""
14184 #. type: Content of: <book><chapter><sect1><sect2><para>
14185 #: ../en/ch11-mq.xml:338
14186 msgid ""
14187 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
14188 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
14189 "your patch at an opportune time; try an experiment; and if the experiment "
14190 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
14191 "modifications back to the last time you refreshed."
14192 msgstr ""
14194 #. type: Content of: <book><chapter><sect1><sect2><title>
14195 #: ../en/ch11-mq.xml:349
14196 msgid "Stacking and tracking patches"
14197 msgstr "堆叠和跟踪补丁"
14199 #. type: Content of: <book><chapter><sect1><sect2><para>
14200 #: ../en/ch11-mq.xml:351
14201 msgid ""
14202 "Once you have finished working on a patch, or need to work on another, you "
14203 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
14204 "create a new patch. Mercurial will apply this patch on top of your existing "
14205 "patch."
14206 msgstr ""
14208 #. type: Content of: <book><chapter><sect1><sect2><para>
14209 #: ../en/ch11-mq.xml:358
14210 msgid ""
14211 "Notice that the patch contains the changes in our prior patch as part of its "
14212 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
14213 "\">hg annotate</command>)."
14214 msgstr ""
14216 #. type: Content of: <book><chapter><sect1><sect2><para>
14217 #: ../en/ch11-mq.xml:363
14218 msgid ""
14219 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
14220 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
14221 "use regular Mercurial commands. However, MQ provides many commands that are "
14222 "easier to use when you are thinking about patches, as illustrated below."
14223 msgstr ""
14225 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14226 #: ../en/ch11-mq.xml:373
14227 msgid ""
14228 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
14229 "that MQ knows about in this repository, from oldest to newest (most recently "
14230 "<emphasis>created</emphasis>)."
14231 msgstr ""
14233 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14234 #: ../en/ch11-mq.xml:379
14235 msgid ""
14236 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
14237 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
14238 "oldest to newest (most recently applied)."
14239 msgstr ""
14241 #. type: Content of: <book><chapter><sect1><sect2><title>
14242 #: ../en/ch11-mq.xml:388
14243 msgid "Manipulating the patch stack"
14244 msgstr "操作补丁堆栈"
14246 #. type: Content of: <book><chapter><sect1><sect2><para>
14247 #: ../en/ch11-mq.xml:390
14248 msgid ""
14249 "The previous discussion implied that there must be a difference between "
14250 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
14251 "can manage a patch without it being applied in the repository."
14252 msgstr ""
14254 #. type: Content of: <book><chapter><sect1><sect2><para>
14255 #: ../en/ch11-mq.xml:395
14256 msgid ""
14257 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
14258 "repository, and the effects of the patch and changeset are visible in the "
14259 "working directory. You can undo the application of a patch using the "
14260 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
14261 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
14262 "corresponding changeset in the repository, and the working directory does not "
14263 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
14264 "illustrates the difference between applied and tracked patches."
14265 msgstr ""
14267 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
14268 #: ../en/ch11-mq.xml:408
14269 msgid "Applied and unapplied patches in the MQ patch stack"
14270 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
14272 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
14273 #: ../en/ch11-mq.xml:411
14274 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
14275 msgstr ""
14277 #. type: Content of: <book><chapter><sect1><sect2><para>
14278 #: ../en/ch11-mq.xml:416
14279 msgid ""
14280 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
14281 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
14282 "to the patch, and the patch's changes once again become present in the "
14283 "working directory. See below for examples of <command role=\"hg-ext-mq"
14284 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
14285 msgstr ""
14287 #. type: Content of: <book><chapter><sect1><sect2><para>
14288 #: ../en/ch11-mq.xml:425
14289 msgid ""
14290 "Notice that once we have popped a patch or two patches, the output of "
14291 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
14292 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
14293 msgstr ""
14295 #. type: Content of: <book><chapter><sect1><sect2><title>
14296 #: ../en/ch11-mq.xml:433
14297 msgid "Pushing and popping many patches"
14298 msgstr "压入或弹出多个补丁"
14300 #. type: Content of: <book><chapter><sect1><sect2><para>
14301 #: ../en/ch11-mq.xml:435
14302 msgid ""
14303 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
14304 "mq\">qpop</command> each operate on a single patch at a time by default, you "
14305 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
14306 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
14307 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
14308 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
14309 "command> causes it to pop all applied patches. (For some more ways to push "
14310 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
14311 msgstr ""
14313 #. type: Content of: <book><chapter><sect1><sect2><title>
14314 #: ../en/ch11-mq.xml:451
14315 msgid "Safety checks, and overriding them"
14316 msgstr "安全的检查,然后覆盖它们"
14318 #. type: Content of: <book><chapter><sect1><sect2><para>
14319 #: ../en/ch11-mq.xml:453
14320 msgid ""
14321 "Several MQ commands check the working directory before they do anything, and "
14322 "fail if they find any modifications. They do this to ensure that you won't "
14323 "lose any changes that you have made, but not yet incorporated into a patch. "
14324 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
14325 "command> command will not create a new patch if there are outstanding "
14326 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
14327 "of <filename>file3</filename>."
14328 msgstr ""
14330 #. type: Content of: <book><chapter><sect1><sect2><para>
14331 #: ../en/ch11-mq.xml:465
14332 msgid ""
14333 "Commands that check the working directory all take an <quote>I know what I'm "
14334 "doing</quote> option, which is always named <option>-f</option>. The exact "
14335 "meaning of <option>-f</option> depends on the command. For example, <command "
14336 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
14337 "option></command> will incorporate any outstanding changes into the new patch "
14338 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
14339 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
14340 "affected by the patch that it is popping. Be sure to read the documentation "
14341 "for a command's <option>-f</option> option before you use it!"
14342 msgstr ""
14344 #. type: Content of: <book><chapter><sect1><sect2><title>
14345 #: ../en/ch11-mq.xml:480
14346 msgid "Working on several patches at once"
14347 msgstr "同时处理多个补丁"
14349 #. type: Content of: <book><chapter><sect1><sect2><para>
14350 #: ../en/ch11-mq.xml:482
14351 msgid ""
14352 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
14353 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
14354 "suspend work on one patch (by refreshing it), pop or push to make a different "
14355 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
14356 msgstr ""
14358 #. type: Content of: <book><chapter><sect1><sect2><para>
14359 #: ../en/ch11-mq.xml:489
14360 msgid ""
14361 "Here's an example that illustrates how you can use this ability. Let's say "
14362 "you're developing a new feature as two patches. The first is a change to the "
14363 "core of your software, and the second&emdash;layered on top of the "
14364 "first&emdash;changes the user interface to use the code you just added to the "
14365 "core. If you notice a bug in the core while you're working on the UI patch, "
14366 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
14367 "command> the UI patch to save your in-progress changes, and <command role="
14368 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
14369 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
14370 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
14371 "left off."
14372 msgstr ""
14374 #. type: Content of: <book><chapter><sect1><title>
14375 #: ../en/ch11-mq.xml:506
14376 msgid "More about patches"
14377 msgstr "关于补丁的更多信息"
14379 #. type: Content of: <book><chapter><sect1><para>
14380 #: ../en/ch11-mq.xml:508
14381 msgid ""
14382 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
14383 "helpful to know a few more detailed aspects of how <command>patch</command> "
14384 "works, and about patches themselves."
14385 msgstr ""
14387 #. type: Content of: <book><chapter><sect1><sect2><title>
14388 #: ../en/ch11-mq.xml:514
14389 msgid "The strip count"
14390 msgstr "修剪计数"
14392 #. type: Content of: <book><chapter><sect1><sect2><para>
14393 #: ../en/ch11-mq.xml:516
14394 msgid ""
14395 "If you look at the file headers in a patch, you will notice that the "
14396 "pathnames usually have an extra component on the front that isn't present in "
14397 "the actual path name. This is a holdover from the way that people used to "
14398 "generate patches (people still do this, but it's somewhat rare with modern "
14399 "revision control tools)."
14400 msgstr ""
14402 #. type: Content of: <book><chapter><sect1><sect2><para>
14403 #: ../en/ch11-mq.xml:523
14404 msgid ""
14405 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
14406 "create a patch. So she'd rename her working directory, unpack the tarball "
14407 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
14408 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
14409 "<command>diff</command> to recursively generate a patch between the "
14410 "unmodified directory and the modified one. The result would be that the name "
14411 "of the unmodified directory would be at the front of the left-hand path in "
14412 "every file header, and the name of the modified directory would be at the "
14413 "front of the right-hand path."
14414 msgstr ""
14416 #. type: Content of: <book><chapter><sect1><sect2><para>
14417 #: ../en/ch11-mq.xml:536
14418 msgid ""
14419 "Since someone receiving a patch from the Alices of the net would be unlikely "
14420 "to have unmodified and modified directories with exactly the same names, the "
14421 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
14422 "option> option that indicates the number of leading path name components to "
14423 "strip when trying to apply a patch. This number is called the "
14424 "<emphasis>strip count</emphasis>."
14425 msgstr ""
14427 #. type: Content of: <book><chapter><sect1><sect2><para>
14428 #: ../en/ch11-mq.xml:544
14429 msgid ""
14430 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
14431 "count of one</quote>. If <command>patch</command> sees a file name "
14432 "<filename>foo/bar/baz</filename> in a file header, it will strip "
14433 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
14434 "filename>. (Strictly speaking, the strip count refers to the number of "
14435 "<emphasis>path separators</emphasis> (and the components that go with them ) "
14436 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
14437 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
14438 "leading slash) into <filename>foo/bar</filename>.)"
14439 msgstr ""
14441 #. type: Content of: <book><chapter><sect1><sect2><para>
14442 #: ../en/ch11-mq.xml:557
14443 msgid ""
14444 "The <quote>standard</quote> strip count for patches is one; almost all "
14445 "patches contain one leading path name component that needs to be stripped. "
14446 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
14447 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
14448 "command and MQ expect patches to have a strip count of one."
14449 msgstr ""
14451 #. type: Content of: <book><chapter><sect1><sect2><para>
14452 #: ../en/ch11-mq.xml:565
14453 msgid ""
14454 "If you receive a patch from someone that you want to add to your patch queue, "
14455 "and the patch needs a strip count other than one, you cannot just <command "
14456 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
14457 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
14458 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
14459 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
14460 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
14461 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
14462 "command> to pick up any files added or removed by the patch, followed by "
14463 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
14464 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
14465 "mercurial/bts/issue311\">issue 311</ulink> for details."
14466 msgstr ""
14468 #. type: Content of: <book><chapter><sect1><sect2><title>
14469 #: ../en/ch11-mq.xml:584
14470 msgid "Strategies for applying a patch"
14471 msgstr "应用补丁的策略"
14473 #. type: Content of: <book><chapter><sect1><sect2><para>
14474 #: ../en/ch11-mq.xml:586
14475 msgid ""
14476 "When <command>patch</command> applies a hunk, it tries a handful of "
14477 "successively less accurate strategies to try to make the hunk apply. This "
14478 "falling-back technique often makes it possible to take a patch that was "
14479 "generated against an old version of a file, and apply it against a newer "
14480 "version of that file."
14481 msgstr ""
14483 #. type: Content of: <book><chapter><sect1><sect2><para>
14484 #: ../en/ch11-mq.xml:593
14485 msgid ""
14486 "First, <command>patch</command> tries an exact match, where the line numbers, "
14487 "the context, and the text to be modified must apply exactly. If it cannot "
14488 "make an exact match, it tries to find an exact match for the context, without "
14489 "honouring the line numbering information. If this succeeds, it prints a line "
14490 "of output saying that the hunk was applied, but at some <emphasis>offset</"
14491 "emphasis> from the original line number."
14492 msgstr ""
14494 #. type: Content of: <book><chapter><sect1><sect2><para>
14495 #: ../en/ch11-mq.xml:602
14496 msgid ""
14497 "If a context-only match fails, <command>patch</command> removes the first and "
14498 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
14499 "only match. If the hunk with reduced context succeeds, it prints a message "
14500 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
14501 "number after the fuzz factor indicates how many lines of context "
14502 "<command>patch</command> had to trim before the patch applied)."
14503 msgstr ""
14505 #. type: Content of: <book><chapter><sect1><sect2><para>
14506 #: ../en/ch11-mq.xml:611
14507 msgid ""
14508 "When neither of these techniques works, <command>patch</command> prints a "
14509 "message saying that the hunk in question was rejected. It saves rejected "
14510 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
14511 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
14512 "also saves an unmodified copy of the file with a <filename role=\"special\">."
14513 "orig</filename> extension; the copy of the file without any extensions will "
14514 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
14515 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
14516 "hunks, and one of them fails to apply, you will have: an unmodified "
14517 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
14518 "hunk, and <filename>foo</filename>, containing the changes made by the five "
14519 "successful hunks."
14520 msgstr ""
14522 #. type: Content of: <book><chapter><sect1><sect2><title>
14523 #: ../en/ch11-mq.xml:629
14524 msgid "Some quirks of patch representation"
14525 msgstr "补丁的一些特性"
14527 #. type: Content of: <book><chapter><sect1><sect2><para>
14528 #: ../en/ch11-mq.xml:631
14529 msgid ""
14530 "There are a few useful things to know about how <command>patch</command> "
14531 "works with files."
14532 msgstr ""
14534 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14535 #: ../en/ch11-mq.xml:634
14536 msgid ""
14537 "This should already be obvious, but <command>patch</command> cannot handle "
14538 "binary files."
14539 msgstr ""
14541 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14542 #: ../en/ch11-mq.xml:638
14543 msgid ""
14544 "Neither does it care about the executable bit; it creates new files as "
14545 "readable, but not executable."
14546 msgstr ""
14548 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14549 #: ../en/ch11-mq.xml:642
14550 msgid ""
14551 "<command>patch</command> treats the removal of a file as a diff between the "
14552 "file to be removed and the empty file. So your idea of <quote>I deleted this "
14553 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
14554 "a patch."
14555 msgstr ""
14557 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14558 #: ../en/ch11-mq.xml:648
14559 msgid ""
14560 "It treats the addition of a file as a diff between the empty file and the "
14561 "file to be added. So in a patch, your idea of <quote>I added this file</"
14562 "quote> looks like <quote>every line of this file was added</quote>."
14563 msgstr ""
14565 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14566 #: ../en/ch11-mq.xml:654
14567 msgid ""
14568 "It treats a renamed file as the removal of the old name, and the addition of "
14569 "the new name. This means that renamed files have a big footprint in "
14570 "patches. (Note also that Mercurial does not currently try to infer when "
14571 "files have been renamed or copied in a patch.)"
14572 msgstr ""
14574 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14575 #: ../en/ch11-mq.xml:660
14576 msgid ""
14577 "<command>patch</command> cannot represent empty files, so you cannot use a "
14578 "patch to represent the notion <quote>I added this empty file to the tree</"
14579 "quote>."
14580 msgstr ""
14582 #. type: Content of: <book><chapter><sect1><sect2><title>
14583 #: ../en/ch11-mq.xml:667
14584 msgid "Beware the fuzz"
14585 msgstr "当心毛刺"
14587 #. type: Content of: <book><chapter><sect1><sect2><para>
14588 #: ../en/ch11-mq.xml:669
14589 msgid ""
14590 "While applying a hunk at an offset, or with a fuzz factor, will often be "
14591 "completely successful, these inexact techniques naturally leave open the "
14592 "possibility of corrupting the patched file. The most common cases typically "
14593 "involve applying a patch twice, or at an incorrect location in the file. If "
14594 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
14595 "mentions an offset or fuzz factor, you should make sure that the modified "
14596 "files are correct afterwards."
14597 msgstr ""
14599 #. type: Content of: <book><chapter><sect1><sect2><para>
14600 #: ../en/ch11-mq.xml:679
14601 msgid ""
14602 "It's often a good idea to refresh a patch that has applied with an offset or "
14603 "fuzz factor; refreshing the patch generates new context information that will "
14604 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
14605 "quote> because sometimes refreshing a patch will make it fail to apply "
14606 "against a different revision of the underlying files. In some cases, such as "
14607 "when you're maintaining a patch that must sit on top of multiple versions of "
14608 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
14609 "you've verified the results of the patching process in such cases."
14610 msgstr ""
14612 #. type: Content of: <book><chapter><sect1><sect2><title>
14613 #: ../en/ch11-mq.xml:692
14614 msgid "Handling rejection"
14615 msgstr "处理拒绝"
14617 #. type: Content of: <book><chapter><sect1><sect2><para>
14618 #: ../en/ch11-mq.xml:694
14619 msgid ""
14620 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
14621 "will print an error message and exit. If it has left <filename role=\"special"
14622 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
14623 "hunks before you push more patches or do any further work."
14624 msgstr ""
14626 #. type: Content of: <book><chapter><sect1><sect2><para>
14627 #: ../en/ch11-mq.xml:700
14628 msgid ""
14629 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
14630 "because you've changed the underlying code that your patches are based on, "
14631 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
14632 msgstr ""
14634 #. type: Content of: <book><chapter><sect1><sect2><para>
14635 #: ../en/ch11-mq.xml:705
14636 msgid ""
14637 "Unfortunately, there aren't any great techniques for dealing with rejected "
14638 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
14639 "filename> file and edit the target file, applying the rejected hunks by hand."
14640 msgstr ""
14642 #. type: Content of: <book><chapter><sect1><sect2><para>
14643 #: ../en/ch11-mq.xml:710
14644 msgid ""
14645 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
14646 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
14647 "is more vigorous than <command>patch</command> in its attempts to make a "
14648 "patch apply."
14649 msgstr ""
14651 #. type: Content of: <book><chapter><sect1><sect2><para>
14652 #: ../en/ch11-mq.xml:716
14653 msgid ""
14654 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
14655 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
14656 "citation>, which takes a simple approach to automating the application of "
14657 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
14658 "command can help with four common reasons that a hunk may be rejected:"
14659 msgstr ""
14661 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14662 #: ../en/ch11-mq.xml:725
14663 msgid "The context in the middle of a hunk has changed."
14664 msgstr ""
14666 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14667 #: ../en/ch11-mq.xml:728
14668 msgid "A hunk is missing some context at the beginning or end."
14669 msgstr ""
14671 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14672 #: ../en/ch11-mq.xml:731
14673 msgid ""
14674 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
14675 "it was broken up into smaller hunks."
14676 msgstr ""
14678 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14679 #: ../en/ch11-mq.xml:735
14680 msgid ""
14681 "A hunk removes lines with slightly different content than those currently "
14682 "present in the file."
14683 msgstr ""
14685 #. type: Content of: <book><chapter><sect1><sect2><para>
14686 #: ../en/ch11-mq.xml:739
14687 msgid ""
14688 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
14689 "be doubly careful to check your results when you're done. In fact, "
14690 "<command>mpatch</command> enforces this method of double-checking the tool's "
14691 "output, by automatically dropping you into a merge program when it has done "
14692 "its job, so that you can verify its work and finish off any remaining merges."
14693 msgstr ""
14695 #. type: Content of: <book><chapter><sect1><title>
14696 #: ../en/ch11-mq.xml:751
14697 msgid "Getting the best performance out of MQ"
14698 msgstr "MQ 的性能"
14700 #. type: Content of: <book><chapter><sect1><para>
14701 #: ../en/ch11-mq.xml:753
14702 msgid ""
14703 "MQ is very efficient at handling a large number of patches. I ran some "
14704 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
14705 "EuroPython conference <citation>web:europython</citation>. I used as my data "
14706 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
14707 "applied these on top of a Linux kernel repository containing all 27,472 "
14708 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
14709 msgstr ""
14711 #. type: Content of: <book><chapter><sect1><para>
14712 #: ../en/ch11-mq.xml:762
14713 msgid ""
14714 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
14715 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
14716 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
14717 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
14718 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
14719 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
14720 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
14721 msgstr ""
14723 #. type: Content of: <book><chapter><sect1><para>
14724 #: ../en/ch11-mq.xml:773
14725 msgid ""
14726 "Clearly, MQ is well suited to working in large trees, but there are a few "
14727 "tricks you can use to get the best performance of it."
14728 msgstr ""
14730 #. type: Content of: <book><chapter><sect1><para>
14731 #: ../en/ch11-mq.xml:777
14732 msgid ""
14733 "First of all, try to <quote>batch</quote> operations together. Every time "
14734 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
14735 "mq\">qpop</command>, these commands scan the working directory once to make "
14736 "sure you haven't made some changes and then forgotten to run <command role="
14737 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
14738 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
14739 "thousands of files), it can take a second or more."
14740 msgstr ""
14742 #. type: Content of: <book><chapter><sect1><para>
14743 #: ../en/ch11-mq.xml:788
14744 msgid ""
14745 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
14746 "\">qpop</command> commands allow you to push and pop multiple patches at a "
14747 "time. You can identify the <quote>destination patch</quote> that you want to "
14748 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
14749 "destination specified, it will push patches until that patch is at the top of "
14750 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
14751 "destination, MQ will pop patches until the destination patch is at the top."
14752 msgstr ""
14754 #. type: Content of: <book><chapter><sect1><para>
14755 #: ../en/ch11-mq.xml:798
14756 msgid ""
14757 "You can identify a destination patch using either the name of the patch, or "
14758 "by number. If you use numeric addressing, patches are counted from zero; "
14759 "this means that the first patch is zero, the second is one, and so on."
14760 msgstr ""
14762 #. type: Content of: <book><chapter><sect1><title>
14763 #: ../en/ch11-mq.xml:805
14764 msgid "Updating your patches when the underlying code changes"
14765 msgstr "当基础代码改变时,更新补丁的方法"
14767 #. type: Content of: <book><chapter><sect1><para>
14768 #: ../en/ch11-mq.xml:808
14769 msgid ""
14770 "It's common to have a stack of patches on top of an underlying repository "
14771 "that you don't modify directly. If you're working on changes to third-party "
14772 "code, or on a feature that is taking longer to develop than the rate of "
14773 "change of the code beneath, you will often need to sync up with the "
14774 "underlying code, and fix up any hunks in your patches that no longer apply. "
14775 "This is called <emphasis>rebasing</emphasis> your patch series."
14776 msgstr ""
14778 #. type: Content of: <book><chapter><sect1><para>
14779 #: ../en/ch11-mq.xml:817
14780 msgid ""
14781 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
14782 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
14783 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
14784 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
14785 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
14786 "stop pushing any time it runs across a patch that fails to apply during "
14787 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
14788 "\">qrefresh</command> the affected patch, and continue pushing until you have "
14789 "fixed your entire stack."
14790 msgstr ""
14792 #. type: Content of: <book><chapter><sect1><para>
14793 #: ../en/ch11-mq.xml:829
14794 msgid ""
14795 "This approach is easy to use and works well if you don't expect changes to "
14796 "the underlying code to affect how well your patches apply. If your patch "
14797 "stack touches code that is modified frequently or invasively in the "
14798 "underlying repository, however, fixing up rejected hunks by hand quickly "
14799 "becomes tiresome."
14800 msgstr ""
14802 #. type: Content of: <book><chapter><sect1><para>
14803 #: ../en/ch11-mq.xml:836
14804 msgid ""
14805 "It's possible to partially automate the rebasing process. If your patches "
14806 "apply cleanly against some revision of the underlying repo, MQ can use this "
14807 "information to help you to resolve conflicts between your patches and a "
14808 "different revision."
14809 msgstr ""
14811 #. type: Content of: <book><chapter><sect1><para>
14812 #: ../en/ch11-mq.xml:842
14813 msgid "The process is a little involved."
14814 msgstr ""
14816 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14817 #: ../en/ch11-mq.xml:844
14818 msgid ""
14819 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
14820 "on top of the revision where you know that they apply cleanly."
14821 msgstr ""
14823 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14824 #: ../en/ch11-mq.xml:848
14825 msgid ""
14826 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
14827 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
14828 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
14829 "of the directory that it has saved the patches in. It will save the patches "
14830 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
14831 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
14832 "commits a <quote>save changeset</quote> on top of your applied patches; this "
14833 "is for internal book-keeping, and records the states of the <filename role="
14834 "\"special\">series</filename> and <filename role=\"special\">status</"
14835 "filename> files."
14836 msgstr ""
14838 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14839 #: ../en/ch11-mq.xml:862
14840 msgid ""
14841 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
14842 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
14843 "command>; see below for why.)"
14844 msgstr ""
14846 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14847 #: ../en/ch11-mq.xml:867
14848 msgid ""
14849 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
14850 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
14851 "you have pushed."
14852 msgstr ""
14854 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14855 #: ../en/ch11-mq.xml:872
14856 msgid ""
14857 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
14858 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
14859 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
14860 "to apply."
14861 msgstr ""
14863 #. type: Content of: <book><chapter><sect1><para>
14864 #: ../en/ch11-mq.xml:880
14865 msgid ""
14866 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
14867 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
14868 "\"special\">series</filename> file is applied normally. If a patch applies "
14869 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
14870 "\">qsave</command>d, and performs a three-way merge with the corresponding "
14871 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
14872 "up a GUI merge tool to help you to resolve problems."
14873 msgstr ""
14875 #. type: Content of: <book><chapter><sect1><para>
14876 #: ../en/ch11-mq.xml:890
14877 msgid ""
14878 "When you finish resolving the effects of a patch, MQ refreshes your patch "
14879 "based on the result of the merge."
14880 msgstr ""
14882 #. type: Content of: <book><chapter><sect1><para>
14883 #: ../en/ch11-mq.xml:893
14884 msgid ""
14885 "At the end of this process, your repository will have one extra head from the "
14886 "old patch queue, and a copy of the old patch queue will be in <filename role="
14887 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
14888 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
14889 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
14890 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
14891 "sure that you no longer need it as a backup."
14892 msgstr ""
14894 #. type: Content of: <book><chapter><sect1><title>
14895 #: ../en/ch11-mq.xml:905
14896 msgid "Identifying patches"
14897 msgstr "标识补丁"
14899 #. type: Content of: <book><chapter><sect1><para>
14900 #: ../en/ch11-mq.xml:907
14901 msgid ""
14902 "MQ commands that work with patches let you refer to a patch either by using "
14903 "its name or by a number. By name is obvious enough; pass the name "
14904 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
14905 "command>, for example, and it will push patches until <filename>foo.patch</"
14906 "filename> is applied."
14907 msgstr ""
14909 #. type: Content of: <book><chapter><sect1><para>
14910 #: ../en/ch11-mq.xml:914
14911 msgid ""
14912 "As a shortcut, you can refer to a patch using both a name and a numeric "
14913 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
14914 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
14915 "means <quote>four patches after <literal>bar.patch</literal></quote>."
14916 msgstr ""
14918 #. type: Content of: <book><chapter><sect1><para>
14919 #: ../en/ch11-mq.xml:920
14920 msgid ""
14921 "Referring to a patch by index isn't much different. The first patch printed "
14922 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
14923 "(yes, it's one of those start-at-zero counting systems); the second is patch "
14924 "one; and so on."
14925 msgstr ""
14927 #. type: Content of: <book><chapter><sect1><para>
14928 #: ../en/ch11-mq.xml:926
14929 msgid ""
14930 "MQ also makes it easy to work with patches when you are using normal "
14931 "Mercurial commands. Every command that accepts a changeset ID will also "
14932 "accept the name of an applied patch. MQ augments the tags normally in the "
14933 "repository with an eponymous one for each applied patch. In addition, the "
14934 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
14935 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
14936 "patches, respectively."
14937 msgstr ""
14939 #. type: Content of: <book><chapter><sect1><para>
14940 #: ../en/ch11-mq.xml:936
14941 msgid ""
14942 "These additions to Mercurial's normal tagging capabilities make dealing with "
14943 "patches even more of a breeze."
14944 msgstr ""
14946 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14947 #: ../en/ch11-mq.xml:939
14948 msgid "Want to patchbomb a mailing list with your latest series of changes?"
14949 msgstr ""
14951 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14952 #: ../en/ch11-mq.xml:942
14953 msgid ""
14954 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
14955 "hgext:patchbomb\"/>.)"
14956 msgstr ""
14958 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14959 #: ../en/ch11-mq.xml:945
14960 msgid ""
14961 "Need to see all of the patches since <literal>foo.patch</literal> that have "
14962 "touched files in a subdirectory of your tree?"
14963 msgstr ""
14965 #. type: Content of: <book><chapter><sect1><para>
14966 #: ../en/ch11-mq.xml:952
14967 msgid ""
14968 "Because MQ makes the names of patches available to the rest of Mercurial "
14969 "through its normal internal tag machinery, you don't need to type in the "
14970 "entire name of a patch when you want to identify it by name."
14971 msgstr ""
14973 #. type: Content of: <book><chapter><sect1><para>
14974 #: ../en/ch11-mq.xml:957
14975 msgid ""
14976 "Another nice consequence of representing patch names as tags is that when you "
14977 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
14978 "patch's name as a tag, simply as part of its normal output. This makes it "
14979 "easy to visually distinguish applied patches from underlying <quote>normal</"
14980 "quote> revisions. The following example shows a few normal Mercurial "
14981 "commands in use with applied patches."
14982 msgstr ""
14984 #. type: Content of: <book><chapter><sect1><title>
14985 #: ../en/ch11-mq.xml:970
14986 msgid "Useful things to know about"
14987 msgstr "其它需要了解的东西"
14989 #. type: Content of: <book><chapter><sect1><para>
14990 #: ../en/ch11-mq.xml:972
14991 msgid ""
14992 "There are a number of aspects of MQ usage that don't fit tidily into sections "
14993 "of their own, but that are good to know. Here they are, in one place."
14994 msgstr ""
14996 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14997 #: ../en/ch11-mq.xml:977
14998 msgid ""
14999 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
15000 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
15001 "represents the patch after the pop/push will have a <emphasis>different "
15002 "identity</emphasis> than the changeset that represented the hash beforehand. "
15003 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
15004 msgstr ""
15006 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15007 #: ../en/ch11-mq.xml:986
15008 msgid ""
15009 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
15010 "from another branch with a patch changeset, at least if you want to maintain "
15011 "the <quote>patchiness</quote> of that changeset and changesets below it on "
15012 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
15013 "will become confused."
15014 msgstr ""
15016 #. type: Content of: <book><chapter><sect1><title>
15017 #: ../en/ch11-mq.xml:997
15018 msgid "Managing patches in a repository"
15019 msgstr "在版本库管理补丁"
15021 #. type: Content of: <book><chapter><sect1><para>
15022 #: ../en/ch11-mq.xml:999
15023 msgid ""
15024 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
15025 "filename> directory resides outside a Mercurial repository's working "
15026 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
15027 "about the management or presence of patches."
15028 msgstr ""
15030 #. type: Content of: <book><chapter><sect1><para>
15031 #: ../en/ch11-mq.xml:1005
15032 msgid ""
15033 "This presents the interesting possibility of managing the contents of the "
15034 "patch directory as a Mercurial repository in its own right. This can be a "
15035 "useful way to work. For example, you can work on a patch for a while, "
15036 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
15037 "\">hg commit</command> the current state of the patch. This lets you "
15038 "<quote>roll back</quote> to that version of the patch later on."
15039 msgstr ""
15041 #. type: Content of: <book><chapter><sect1><para>
15042 #: ../en/ch11-mq.xml:1014
15043 msgid ""
15044 "You can then share different versions of the same patch stack among multiple "
15045 "underlying repositories. I use this when I am developing a Linux kernel "
15046 "feature. I have a pristine copy of my kernel sources for each of several CPU "
15047 "architectures, and a cloned repository under each that contains the patches I "
15048 "am working on. When I want to test a change on a different architecture, I "
15049 "push my current patches to the patch repository associated with that kernel "
15050 "tree, pop and push all of my patches, and build and test that kernel."
15051 msgstr ""
15053 #. type: Content of: <book><chapter><sect1><para>
15054 #: ../en/ch11-mq.xml:1024
15055 msgid ""
15056 "Managing patches in a repository makes it possible for multiple developers to "
15057 "work on the same patch series without colliding with each other, all on top "
15058 "of an underlying source base that they may or may not control."
15059 msgstr ""
15061 #. type: Content of: <book><chapter><sect1><sect2><title>
15062 #: ../en/ch11-mq.xml:1030
15063 msgid "MQ support for patch repositories"
15064 msgstr "MQ 支持补丁版本库"
15066 #. type: Content of: <book><chapter><sect1><sect2><para>
15067 #: ../en/ch11-mq.xml:1032
15068 msgid ""
15069 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
15070 "hg/patches</filename> directory as a repository; when you prepare a "
15071 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
15072 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
15073 "option> option to create the <filename role=\"special\" class=\"directory\">."
15074 "hg/patches</filename> directory as a Mercurial repository."
15075 msgstr ""
15077 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15078 #: ../en/ch11-mq.xml:1042
15079 msgid ""
15080 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
15081 "option> option, you can simply go into the <filename role=\"special\" class="
15082 "\"directory\">.hg/patches</filename> directory at any time and run <command "
15083 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
15084 "<filename role=\"special\">status</filename> file to the <filename role="
15085 "\"special\">.hgignore</filename> file, though"
15086 msgstr ""
15088 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15089 #: ../en/ch11-mq.xml:1051
15090 msgid ""
15091 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
15092 "\">hg -c</option></command> does this for you automatically); you "
15093 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
15094 "\">status</filename> file."
15095 msgstr ""
15097 #. type: Content of: <book><chapter><sect1><sect2><para>
15098 #: ../en/ch11-mq.xml:1058
15099 msgid ""
15100 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
15101 "patches</filename> directory is a repository, it will automatically <command "
15102 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
15103 msgstr ""
15105 #. type: Content of: <book><chapter><sect1><sect2><para>
15106 #: ../en/ch11-mq.xml:1063
15107 msgid ""
15108 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
15109 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
15110 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
15111 "directory. This saves some bothersome typing."
15112 msgstr ""
15114 #. type: Content of: <book><chapter><sect1><sect2><para>
15115 #: ../en/ch11-mq.xml:1069
15116 msgid ""
15117 "Finally, as a convenience to manage the patch directory, you can define the "
15118 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
15119 "using the <command>bash</command> shell, you can include the following "
15120 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
15121 msgstr ""
15123 #. type: Content of: <book><chapter><sect1><sect2><para>
15124 #: ../en/ch11-mq.xml:1078
15125 msgid ""
15126 "You can then issue commands of the form <command>mq pull</command> from the "
15127 "main repository."
15128 msgstr ""
15130 #. type: Content of: <book><chapter><sect1><sect2><title>
15131 #: ../en/ch11-mq.xml:1083
15132 msgid "A few things to watch out for"
15133 msgstr "需要注意的事情"
15135 #. type: Content of: <book><chapter><sect1><sect2><para>
15136 #: ../en/ch11-mq.xml:1085
15137 msgid ""
15138 "MQ's support for working with a repository full of patches is limited in a "
15139 "few small respects."
15140 msgstr ""
15142 #. type: Content of: <book><chapter><sect1><sect2><para>
15143 #: ../en/ch11-mq.xml:1088
15144 msgid ""
15145 "MQ cannot automatically detect changes that you make to the patch directory. "
15146 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
15147 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
15148 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
15149 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
15150 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
15151 "opt\">hg -a</option></command> in the underlying repository to see those "
15152 "changes show up there. If you forget to do this, you can confuse MQ's idea "
15153 "of which patches are applied."
15154 msgstr ""
15156 #. type: Content of: <book><chapter><sect1><title>
15157 #: ../en/ch11-mq.xml:1104
15158 msgid "Third party tools for working with patches"
15159 msgstr "操作补丁的第三方工具"
15161 #. type: Content of: <book><chapter><sect1><para>
15162 #: ../en/ch11-mq.xml:1106
15163 msgid ""
15164 "Once you've been working with patches for a while, you'll find yourself "
15165 "hungry for tools that will help you to understand and manipulate the patches "
15166 "you're dealing with."
15167 msgstr ""
15169 #. type: Content of: <book><chapter><sect1><para>
15170 #: ../en/ch11-mq.xml:1110
15171 msgid ""
15172 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
15173 "generates a histogram of the modifications made to each file in a patch. It "
15174 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
15175 "files it affects, and how much change it introduces to each file and as a "
15176 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
15177 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
15178 "as otherwise it will try to do clever things with prefixes of file names that "
15179 "inevitably confuse at least me.)"
15180 msgstr ""
15182 #. type: Content of: <book><chapter><sect1><para>
15183 #: ../en/ch11-mq.xml:1124
15184 msgid ""
15185 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
15186 "patchutils</citation> is invaluable. It provides a set of small utilities "
15187 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
15188 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
15189 "use most is <command>filterdiff</command>, which extracts subsets from a "
15190 "patch file. For example, given a patch that modifies hundreds of files "
15191 "across dozens of directories, a single invocation of <command>filterdiff</"
15192 "command> can generate a smaller patch that only touches files whose names "
15193 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
15194 "\"/> for another example."
15195 msgstr ""
15197 #. type: Content of: <book><chapter><sect1><title>
15198 #: ../en/ch11-mq.xml:1140
15199 msgid "Good ways to work with patches"
15200 msgstr "操作补丁的好习惯"
15202 #. type: Content of: <book><chapter><sect1><para>
15203 #: ../en/ch11-mq.xml:1142
15204 msgid ""
15205 "Whether you are working on a patch series to submit to a free software or "
15206 "open source project, or a series that you intend to treat as a sequence of "
15207 "regular changesets when you're done, you can use some simple techniques to "
15208 "keep your work well organized."
15209 msgstr ""
15211 #. type: Content of: <book><chapter><sect1><para>
15212 #: ../en/ch11-mq.xml:1148
15213 msgid ""
15214 "Give your patches descriptive names. A good name for a patch might be "
15215 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
15216 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
15217 "problem; you won't be typing the names often, but you <emphasis>will</"
15218 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
15219 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
15220 "naming becomes especially important when you have a number of patches to work "
15221 "with, or if you are juggling a number of different tasks and your patches "
15222 "only get a fraction of your attention."
15223 msgstr ""
15225 #. type: Content of: <book><chapter><sect1><para>
15226 #: ../en/ch11-mq.xml:1160
15227 msgid ""
15228 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
15229 "\">qtop</command> command and skim over the text of your patches "
15230 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
15231 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
15232 "stand. I have several times worked on and <command role=\"hg-ext-mq"
15233 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
15234 "tricky to migrate changes into the right patch after making them in the wrong "
15235 "one."
15236 msgstr ""
15238 #. type: Content of: <book><chapter><sect1><para>
15239 #: ../en/ch11-mq.xml:1170
15240 msgid ""
15241 "For this reason, it is very much worth investing a little time to learn how "
15242 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
15243 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
15244 "command>. The former will give you a quick idea of what changes your patch "
15245 "is making, while the latter makes it easy to splice hunks selectively out of "
15246 "one patch and into another."
15247 msgstr ""
15249 #. type: Content of: <book><chapter><sect1><title>
15250 #: ../en/ch11-mq.xml:1181
15251 msgid "MQ cookbook"
15252 msgstr "MQ 手册"
15254 #. type: Content of: <book><chapter><sect1><sect2><title>
15255 #: ../en/ch11-mq.xml:1184
15256 msgid "Manage <quote>trivial</quote> patches"
15257 msgstr "管理<quote>琐碎的</quote>补丁"
15259 #. type: Content of: <book><chapter><sect1><sect2><para>
15260 #: ../en/ch11-mq.xml:1186
15261 msgid ""
15262 "Because the overhead of dropping files into a new Mercurial repository is so "
15263 "low, it makes a lot of sense to manage patches this way even if you simply "
15264 "want to make a few changes to a source tarball that you downloaded."
15265 msgstr ""
15268 #. type: Content of: <book><chapter><sect1><sect2><para>
15269 #: ../en/ch11-mq.xml:1191
15270 msgid ""
15271 "Begin by downloading and unpacking the source tarball, and turning it into a "
15272 "Mercurial repository."
15273 msgstr ""
15275 #. type: Content of: <book><chapter><sect1><sect2><para>
15276 #: ../en/ch11-mq.xml:1196
15277 msgid "Continue by creating a patch stack and making your changes."
15278 msgstr ""
15280 #. type: Content of: <book><chapter><sect1><sect2><para>
15281 #: ../en/ch11-mq.xml:1201
15282 msgid ""
15283 "Let's say a few weeks or months pass, and your package author releases a new "
15284 "version. First, bring their changes into the repository."
15285 msgstr ""
15287 #. type: Content of: <book><chapter><sect1><sect2><para>
15288 #: ../en/ch11-mq.xml:1207
15289 msgid ""
15290 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
15291 "deletes all files in the working directory, so that <command role=\"hg-cmd"
15292 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
15293 "option can actually tell which files have really been removed in the newer "
15294 "version of the source."
15295 msgstr ""
15297 #. type: Content of: <book><chapter><sect1><sect2><para>
15298 #: ../en/ch11-mq.xml:1215
15299 msgid "Finally, you can apply your patches on top of the new tree."
15300 msgstr ""
15302 #. type: Content of: <book><chapter><sect1><sect2><title>
15303 #: ../en/ch11-mq.xml:1222
15304 msgid "Combining entire patches"
15305 msgstr "组合全部的补丁"
15307 #. type: Content of: <book><chapter><sect1><sect2><para>
15308 #: ../en/ch11-mq.xml:1224
15309 msgid ""
15310 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
15311 "you combine entire patches. This <quote>folds</quote> the patches you name, "
15312 "in the order you name them, into the topmost applied patch, and concatenates "
15313 "their descriptions onto the end of its description. The patches that you "
15314 "fold must be unapplied before you fold them."
15315 msgstr ""
15317 #. type: Content of: <book><chapter><sect1><sect2><para>
15318 #: ../en/ch11-mq.xml:1232
15319 msgid ""
15320 "The order in which you fold patches matters. If your topmost applied patch "
15321 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
15322 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
15323 "end up with a patch that has the same effect as if you applied first "
15324 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
15325 "<literal>quux</literal>."
15326 msgstr ""
15328 #. type: Content of: <book><chapter><sect1><sect2><title>
15329 #: ../en/ch11-mq.xml:1243
15330 msgid "Merging part of one patch into another"
15331 msgstr "合并补丁的部分内容到其它补丁"
15333 #. type: Content of: <book><chapter><sect1><sect2><para>
15334 #: ../en/ch11-mq.xml:1245
15335 msgid ""
15336 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
15337 "than combining entire patches."
15338 msgstr ""
15340 #. type: Content of: <book><chapter><sect1><sect2><para>
15341 #: ../en/ch11-mq.xml:1249
15342 msgid ""
15343 "If you want to move changes to entire files, you can use <command>filterdiff</"
15344 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
15345 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
15346 "snip out of one patch, concatenating its output onto the end of the patch you "
15347 "want to merge into. You usually won't need to modify the patch you've merged "
15348 "the changes from. Instead, MQ will report some rejected hunks when you "
15349 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
15350 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
15351 "command> the patch to drop the duplicate hunks."
15352 msgstr ""
15354 #. type: Content of: <book><chapter><sect1><sect2><para>
15355 #: ../en/ch11-mq.xml:1262
15356 msgid ""
15357 "If you have a patch that has multiple hunks modifying a file, and you only "
15358 "want to move a few of those hunks, the job becomes more messy, but you can "
15359 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
15360 "metadata about the patch."
15361 msgstr ""
15363 #. type: Content of: <book><chapter><sect1><sect2><para>
15364 #: ../en/ch11-mq.xml:1270
15365 msgid "This command prints three different kinds of number:"
15366 msgstr ""
15368 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15369 #: ../en/ch11-mq.xml:1273
15370 msgid ""
15371 "(in the first column) a <emphasis>file number</emphasis> to identify each "
15372 "file modified in the patch;"
15373 msgstr ""
15375 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15376 #: ../en/ch11-mq.xml:1277
15377 msgid ""
15378 "(on the next line, indented) the line number within a modified file where a "
15379 "hunk starts; and"
15380 msgstr ""
15382 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
15383 #: ../en/ch11-mq.xml:1280
15384 msgid ""
15385 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
15386 msgstr ""
15388 #. type: Content of: <book><chapter><sect1><sect2><para>
15389 #: ../en/ch11-mq.xml:1284
15390 msgid ""
15391 "You'll have to use some visual inspection, and reading of the patch, to "
15392 "identify the file and hunk numbers you'll want, but you can then pass them to "
15393 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
15394 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
15395 "options, to select exactly the file and hunk you want to extract."
15396 msgstr ""
15398 #. type: Content of: <book><chapter><sect1><sect2><para>
15399 #: ../en/ch11-mq.xml:1292
15400 msgid ""
15401 "Once you have this hunk, you can concatenate it onto the end of your "
15402 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
15403 "combine\"/>."
15404 msgstr ""
15406 #. type: Content of: <book><chapter><sect1><title>
15407 #: ../en/ch11-mq.xml:1299
15408 msgid "Differences between quilt and MQ"
15409 msgstr "MQ 与 quilt 的区别"
15411 #. type: Content of: <book><chapter><sect1><para>
15412 #: ../en/ch11-mq.xml:1301
15413 msgid ""
15414 "If you are already familiar with quilt, MQ provides a similar command set. "
15415 "There are a few differences in the way that it works."
15416 msgstr ""
15418 #. type: Content of: <book><chapter><sect1><para>
15419 #: ../en/ch11-mq.xml:1305
15420 msgid ""
15421 "You will already have noticed that most quilt commands have MQ counterparts "
15422 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
15423 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
15424 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
15425 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
15426 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
15427 "command."
15428 msgstr ""
15430 #. type: Content of: <book><chapter><title>
15431 #: ../en/ch12-mq-collab.xml:5
15432 msgid "Advanced uses of Mercurial Queues"
15433 msgstr "MQ 的高级用法"
15435 #. type: Content of: <book><chapter><para>
15436 #: ../en/ch12-mq-collab.xml:7
15437 msgid ""
15438 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
15439 "little discipline and some of MQ's less frequently used capabilities makes it "
15440 "possible to work in complicated development environments."
15441 msgstr ""
15443 #. type: Content of: <book><chapter><para>
15444 #: ../en/ch12-mq-collab.xml:12
15445 msgid ""
15446 "In this chapter, I will use as an example a technique I have used to manage "
15447 "the development of an Infiniband device driver for the Linux kernel. The "
15448 "driver in question is large (at least as drivers go), with 25,000 lines of "
15449 "code spread across 35 source files. It is maintained by a small team of "
15450 "developers."
15451 msgstr ""
15453 #. type: Content of: <book><chapter><para>
15454 #: ../en/ch12-mq-collab.xml:18
15455 msgid ""
15456 "While much of the material in this chapter is specific to Linux, the same "
15457 "principles apply to any code base for which you're not the primary owner, and "
15458 "upon which you need to do a lot of development."
15459 msgstr ""
15461 #. type: Content of: <book><chapter><sect1><title>
15462 #: ../en/ch12-mq-collab.xml:24
15463 msgid "The problem of many targets"
15464 msgstr "多个目标的问题"
15466 #. type: Content of: <book><chapter><sect1><para>
15467 #: ../en/ch12-mq-collab.xml:26
15468 msgid ""
15469 "The Linux kernel changes rapidly, and has never been internally stable; "
15470 "developers frequently make drastic changes between releases. This means that "
15471 "a version of the driver that works well with a particular released version of "
15472 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
15473 "typically, any other version."
15474 msgstr ""
15476 #. type: Content of: <book><chapter><sect1><para>
15477 #: ../en/ch12-mq-collab.xml:33
15478 msgid ""
15479 "To maintain a driver, we have to keep a number of distinct versions of Linux "
15480 "in mind."
15481 msgstr ""
15483 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15484 #: ../en/ch12-mq-collab.xml:36
15485 msgid ""
15486 "One target is the main Linux kernel development tree. Maintenance of the code "
15487 "is in this case partly shared by other developers in the kernel community, "
15488 "who make <quote>drive-by</quote> modifications to the driver as they develop "
15489 "and refine kernel subsystems."
15490 msgstr ""
15492 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15493 #: ../en/ch12-mq-collab.xml:42
15494 msgid ""
15495 "We also maintain a number of <quote>backports</quote> to older versions of "
15496 "the Linux kernel, to support the needs of customers who are running older "
15497 "Linux distributions that do not incorporate our drivers. (To "
15498 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
15499 "older version of its target environment than the version it was developed "
15500 "for.)"
15501 msgstr ""
15503 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15504 #: ../en/ch12-mq-collab.xml:50
15505 msgid ""
15506 "Finally, we make software releases on a schedule that is necessarily not "
15507 "aligned with those used by Linux distributors and kernel developers, so that "
15508 "we can deliver new features to customers without forcing them to upgrade "
15509 "their entire kernels or distributions."
15510 msgstr ""
15512 #. type: Content of: <book><chapter><sect1><sect2><title>
15513 #: ../en/ch12-mq-collab.xml:58
15514 msgid "Tempting approaches that don't work well"
15515 msgstr "工作不好的诱人方法"
15517 #. type: Content of: <book><chapter><sect1><sect2><para>
15518 #: ../en/ch12-mq-collab.xml:60
15519 msgid ""
15520 "There are two <quote>standard</quote> ways to maintain a piece of software "
15521 "that has to target many different environments."
15522 msgstr ""
15524 #. type: Content of: <book><chapter><sect1><sect2><para>
15525 #: ../en/ch12-mq-collab.xml:64
15526 msgid ""
15527 "The first is to maintain a number of branches, each intended for a single "
15528 "target. The trouble with this approach is that you must maintain iron "
15529 "discipline in the flow of changes between repositories. A new feature or bug "
15530 "fix must start life in a <quote>pristine</quote> repository, then percolate "
15531 "out to every backport repository. Backport changes are more limited in the "
15532 "branches they should propagate to; a backport change that is applied to a "
15533 "branch where it doesn't belong will probably stop the driver from compiling."
15534 msgstr ""
15536 #. type: Content of: <book><chapter><sect1><sect2><para>
15537 #: ../en/ch12-mq-collab.xml:74
15538 msgid ""
15539 "The second is to maintain a single source tree filled with conditional "
15540 "statements that turn chunks of code on or off depending on the intended "
15541 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
15542 "kernel tree, a manual or automatic process must be followed to strip them out "
15543 "and yield a clean tree. A code base maintained in this fashion rapidly "
15544 "becomes a rat's nest of conditional blocks that are difficult to understand "
15545 "and maintain."
15546 msgstr ""
15548 #. type: Content of: <book><chapter><sect1><sect2><para>
15549 #: ../en/ch12-mq-collab.xml:83
15550 msgid ""
15551 "Neither of these approaches is well suited to a situation where you don't "
15552 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
15553 "Linux driver that is distributed with the standard kernel, Linus's tree "
15554 "contains the copy of the code that will be treated by the world as "
15555 "canonical. The upstream version of <quote>my</quote> driver can be modified "
15556 "by people I don't know, without me even finding out about it until after the "
15557 "changes show up in Linus's tree."
15558 msgstr ""
15560 #. type: Content of: <book><chapter><sect1><sect2><para>
15561 #: ../en/ch12-mq-collab.xml:93
15562 msgid ""
15563 "These approaches have the added weakness of making it difficult to generate "
15564 "well-formed patches to submit upstream."
15565 msgstr ""
15567 #. type: Content of: <book><chapter><sect1><sect2><para>
15568 #: ../en/ch12-mq-collab.xml:97
15569 msgid ""
15570 "In principle, Mercurial Queues seems like a good candidate to manage a "
15571 "development scenario such as the above. While this is indeed the case, MQ "
15572 "contains a few added features that make the job more pleasant."
15573 msgstr ""
15575 #. type: Content of: <book><chapter><sect1><title>
15576 #: ../en/ch12-mq-collab.xml:105
15577 msgid "Conditionally applying patches with guards"
15578 msgstr "有条件的应用补丁"
15580 #. type: Content of: <book><chapter><sect1><para>
15581 #: ../en/ch12-mq-collab.xml:107
15582 msgid ""
15583 "Perhaps the best way to maintain sanity with so many targets is to be able to "
15584 "choose specific patches to apply for a given situation. MQ provides a "
15585 "feature called <quote>guards</quote> (which originates with quilt's "
15586 "<literal>guards</literal> command) that does just this. To start off, let's "
15587 "create a simple repository for experimenting in."
15588 msgstr ""
15590 #. type: Content of: <book><chapter><sect1><para>
15591 #: ../en/ch12-mq-collab.xml:116
15592 msgid ""
15593 "This gives us a tiny repository that contains two patches that don't have any "
15594 "dependencies on each other, because they touch different files."
15595 msgstr ""
15597 #. type: Content of: <book><chapter><sect1><para>
15598 #: ../en/ch12-mq-collab.xml:120
15599 msgid ""
15600 "The idea behind conditional application is that you can <quote>tag</quote> a "
15601 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
15602 "your choosing, then tell MQ to select specific guards to use when applying "
15603 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
15604 "on the guards that you have selected."
15605 msgstr ""
15607 #. type: Content of: <book><chapter><sect1><para>
15608 #: ../en/ch12-mq-collab.xml:127
15609 msgid ""
15610 "A patch can have an arbitrary number of guards; each one is "
15611 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
15612 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
15613 "this guard is selected</quote>). A patch with no guards is always applied."
15614 msgstr ""
15616 #. type: Content of: <book><chapter><sect1><title>
15617 #: ../en/ch12-mq-collab.xml:135
15618 msgid "Controlling the guards on a patch"
15619 msgstr "控制补丁的应用条件"
15621 #. type: Content of: <book><chapter><sect1><para>
15622 #: ../en/ch12-mq-collab.xml:137
15623 msgid ""
15624 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
15625 "which guards should apply to a patch, or display the guards that are already "
15626 "in effect. Without any arguments, it displays the guards on the current "
15627 "topmost patch."
15628 msgstr ""
15630 #. type: Content of: <book><chapter><sect1><para>
15631 #: ../en/ch12-mq-collab.xml:144
15632 msgid ""
15633 "To set a positive guard on a patch, prefix the name of the guard with a "
15634 "<quote><literal>+</literal></quote>."
15635 msgstr ""
15637 #. type: Content of: <book><chapter><sect1><para>
15638 #: ../en/ch12-mq-collab.xml:149
15639 msgid ""
15640 "To set a negative guard on a patch, prefix the name of the guard with a "
15641 "<quote><literal>-</literal></quote>."
15642 msgstr ""
15644 #. type: Content of: <book><chapter><sect1><note><para>
15645 #: ../en/ch12-mq-collab.xml:156
15646 msgid ""
15647 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
15648 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
15649 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
15650 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
15651 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
15652 "set on it afterwards is <literal>+c</literal>."
15653 msgstr ""
15656 #. type: Content of: <book><chapter><sect1><para>
15657 #: ../en/ch12-mq-collab.xml:165
15658 msgid ""
15659 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
15660 "file; the form in which they are stored is easy both to understand and to "
15661 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
15662 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
15663 "edit the <filename role=\"special\">series</filename> file.)"
15664 msgstr ""
15666 #. type: Content of: <book><chapter><sect1><title>
15667 #: ../en/ch12-mq-collab.xml:177
15668 msgid "Selecting the guards to use"
15669 msgstr "选择使用的条件"
15671 #. type: Content of: <book><chapter><sect1><para>
15672 #: ../en/ch12-mq-collab.xml:179
15673 msgid ""
15674 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
15675 "guards are active at a given time. The effect of this is to determine which "
15676 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
15677 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
15678 "anything to patches that are already applied."
15679 msgstr ""
15681 #. type: Content of: <book><chapter><sect1><para>
15682 #: ../en/ch12-mq-collab.xml:186
15683 msgid ""
15684 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
15685 "lists the guards currently in effect, one per line of output. Each argument "
15686 "is treated as the name of a guard to apply."
15687 msgstr ""
15689 #. type: Content of: <book><chapter><sect1><para>
15690 #: ../en/ch12-mq-collab.xml:193
15691 msgid ""
15692 "In case you're interested, the currently selected guards are stored in the "
15693 "<filename role=\"special\">guards</filename> file."
15694 msgstr ""
15696 #. type: Content of: <book><chapter><sect1><para>
15697 #: ../en/ch12-mq-collab.xml:198
15698 msgid ""
15699 "We can see the effect the selected guards have when we run <command role=\"hg-"
15700 "ext-mq\">qpush</command>."
15701 msgstr ""
15703 #. type: Content of: <book><chapter><sect1><para>
15704 #: ../en/ch12-mq-collab.xml:203
15705 msgid ""
15706 "A guard cannot start with a <quote><literal>+</literal></quote> or "
15707 "<quote><literal>-</literal></quote> character. The name of a guard must not "
15708 "contain white space, but most other characters are acceptable. If you try to "
15709 "use a guard with an invalid name, MQ will complain:"
15710 msgstr ""
15712 #. type: Content of: <book><chapter><sect1><para>
15713 #: ../en/ch12-mq-collab.xml:212
15714 msgid "Changing the selected guards changes the patches that are applied."
15715 msgstr ""
15717 #. type: Content of: <book><chapter><sect1><para>
15718 #: ../en/ch12-mq-collab.xml:217
15719 msgid ""
15720 "You can see in the example below that negative guards take precedence over "
15721 "positive guards."
15722 msgstr ""
15724 #. type: Content of: <book><chapter><sect1><title>
15725 #: ../en/ch12-mq-collab.xml:224
15726 msgid "MQ's rules for applying patches"
15727 msgstr "MQ 应用补丁的规则"
15729 #. type: Content of: <book><chapter><sect1><para>
15730 #: ../en/ch12-mq-collab.xml:226
15731 msgid ""
15732 "The rules that MQ uses when deciding whether to apply a patch are as follows."
15733 msgstr ""
15735 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15736 #: ../en/ch12-mq-collab.xml:229
15737 msgid "A patch that has no guards is always applied."
15738 msgstr ""
15740 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15741 #: ../en/ch12-mq-collab.xml:232
15742 msgid ""
15743 "If the patch has any negative guard that matches any currently selected "
15744 "guard, the patch is skipped."
15745 msgstr ""
15747 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15748 #: ../en/ch12-mq-collab.xml:235
15749 msgid ""
15750 "If the patch has any positive guard that matches any currently selected "
15751 "guard, the patch is applied."
15752 msgstr ""
15754 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15755 #: ../en/ch12-mq-collab.xml:238
15756 msgid ""
15757 "If the patch has positive or negative guards, but none matches any currently "
15758 "selected guard, the patch is skipped."
15759 msgstr ""
15761 #. type: Content of: <book><chapter><sect1><title>
15762 #: ../en/ch12-mq-collab.xml:245
15763 msgid "Trimming the work environment"
15764 msgstr "修剪工作环境"
15766 #. type: Content of: <book><chapter><sect1><para>
15767 #: ../en/ch12-mq-collab.xml:247
15768 msgid ""
15769 "In working on the device driver I mentioned earlier, I don't apply the "
15770 "patches to a normal Linux kernel tree. Instead, I use a repository that "
15771 "contains only a snapshot of the source files and headers that are relevant to "
15772 "Infiniband development. This repository is 1% the size of a kernel "
15773 "repository, so it's easier to work with."
15774 msgstr ""
15776 #. type: Content of: <book><chapter><sect1><para>
15777 #: ../en/ch12-mq-collab.xml:254
15778 msgid ""
15779 "I then choose a <quote>base</quote> version on top of which the patches are "
15780 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
15781 "choosing. When I take the snapshot, I record the changeset ID from the "
15782 "kernel repository in the commit message. Since the snapshot preserves the "
15783 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
15784 "can apply my patches on top of either my tiny repository or a normal kernel "
15785 "tree."
15786 msgstr ""
15788 #. type: Content of: <book><chapter><sect1><para>
15789 #: ../en/ch12-mq-collab.xml:263
15790 msgid ""
15791 "Normally, the base tree atop which the patches apply should be a snapshot of "
15792 "a very recent upstream tree. This best facilitates the development of "
15793 "patches that can easily be submitted upstream with few or no modifications."
15794 msgstr ""
15796 #. type: Content of: <book><chapter><sect1><title>
15797 #: ../en/ch12-mq-collab.xml:270
15798 msgid "Dividing up the <filename role=\"special\">series</filename> file"
15799 msgstr "分类补丁<filename role=\"special\">系列</filename>"
15801 #. type: Content of: <book><chapter><sect1><para>
15802 #: ../en/ch12-mq-collab.xml:273
15803 msgid ""
15804 "I categorise the patches in the <filename role=\"special\">series</filename> "
15805 "file into a number of logical groups. Each section of like patches begins "
15806 "with a block of comments that describes the purpose of the patches that "
15807 "follow."
15808 msgstr ""
15810 #. type: Content of: <book><chapter><sect1><para>
15811 #: ../en/ch12-mq-collab.xml:279
15812 msgid ""
15813 "The sequence of patch groups that I maintain follows. The ordering of these "
15814 "groups is important; I'll describe why after I introduce the groups."
15815 msgstr ""
15817 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15818 #: ../en/ch12-mq-collab.xml:283
15819 msgid ""
15820 "The <quote>accepted</quote> group. Patches that the development team has "
15821 "submitted to the maintainer of the Infiniband subsystem, and which he has "
15822 "accepted, but which are not present in the snapshot that the tiny repository "
15823 "is based on. These are <quote>read only</quote> patches, present only to "
15824 "transform the tree into a similar state as it is in the upstream maintainer's "
15825 "repository."
15826 msgstr ""
15828 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15829 #: ../en/ch12-mq-collab.xml:291
15830 msgid ""
15831 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
15832 "upstream maintainer has requested modifications to before he will accept them."
15833 msgstr ""
15835 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15836 #: ../en/ch12-mq-collab.xml:296
15837 msgid ""
15838 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
15839 "the upstream maintainer, but which we have finished working on. These will be "
15840 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
15841 "them upon submission, I'll move them to the end of the <quote>accepted</"
15842 "quote> group. If he requests that I modify any, I'll move them to the "
15843 "beginning of the <quote>rework</quote> group."
15844 msgstr ""
15846 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15847 #: ../en/ch12-mq-collab.xml:305
15848 msgid ""
15849 "The <quote>in progress</quote> group. Patches that are actively being "
15850 "developed, and should not be submitted anywhere yet."
15851 msgstr ""
15853 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15854 #: ../en/ch12-mq-collab.xml:309
15855 msgid ""
15856 "The <quote>backport</quote> group. Patches that adapt the source tree to "
15857 "older versions of the kernel tree."
15858 msgstr ""
15860 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15861 #: ../en/ch12-mq-collab.xml:313
15862 msgid ""
15863 "The <quote>do not ship</quote> group. Patches that for some reason should "
15864 "never be submitted upstream. For example, one such patch might change "
15865 "embedded driver identification strings to make it easier to distinguish, in "
15866 "the field, between an out-of-tree version of the driver and a version shipped "
15867 "by a distribution vendor."
15868 msgstr ""
15870 #. type: Content of: <book><chapter><sect1><para>
15871 #: ../en/ch12-mq-collab.xml:321
15872 msgid ""
15873 "Now to return to the reasons for ordering groups of patches in this way. We "
15874 "would like the lowest patches in the stack to be as stable as possible, so "
15875 "that we will not need to rework higher patches due to changes in context. "
15876 "Putting patches that will never be changed first in the <filename role="
15877 "\"special\">series</filename> file serves this purpose."
15878 msgstr ""
15880 #. type: Content of: <book><chapter><sect1><para>
15881 #: ../en/ch12-mq-collab.xml:329
15882 msgid ""
15883 "We would also like the patches that we know we'll need to modify to be "
15884 "applied on top of a source tree that resembles the upstream tree as closely "
15885 "as possible. This is why we keep accepted patches around for a while."
15886 msgstr ""
15888 #. type: Content of: <book><chapter><sect1><para>
15889 #: ../en/ch12-mq-collab.xml:334
15890 msgid ""
15891 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
15892 "the end of the <filename role=\"special\">series</filename> file. The "
15893 "backport patches must be applied on top of all other patches, and the "
15894 "<quote>do not ship</quote> patches might as well stay out of harm's way."
15895 msgstr ""
15897 #. type: Content of: <book><chapter><sect1><title>
15898 #: ../en/ch12-mq-collab.xml:343
15899 msgid "Maintaining the patch series"
15900 msgstr "维护补丁系列"
15902 #. type: Content of: <book><chapter><sect1><para>
15903 #: ../en/ch12-mq-collab.xml:345
15904 msgid ""
15905 "In my work, I use a number of guards to control which patches are to be "
15906 "applied."
15907 msgstr ""
15909 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15910 #: ../en/ch12-mq-collab.xml:349
15911 msgid ""
15912 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
15913 "literal>. I enable this guard most of the time. When I'm applying the "
15914 "patches on top of a tree where the patches are already present, I can turn "
15915 "this patch off, and the patches that follow it will apply cleanly."
15916 msgstr ""
15918 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15919 #: ../en/ch12-mq-collab.xml:356
15920 msgid ""
15921 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
15922 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
15923 "don't need to enable any guards in order to get a reasonably safe source tree."
15924 msgstr ""
15926 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15927 #: ../en/ch12-mq-collab.xml:362
15928 msgid ""
15929 "Those patches that need reworking before being resubmitted are guarded with "
15930 "<literal>rework</literal>."
15931 msgstr ""
15933 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15934 #: ../en/ch12-mq-collab.xml:366
15935 msgid ""
15936 "For those patches that are still under development, I use <literal>devel</"
15937 "literal>."
15938 msgstr ""
15940 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15941 #: ../en/ch12-mq-collab.xml:369
15942 msgid ""
15943 "A backport patch may have several guards, one for each version of the kernel "
15944 "to which it applies. For example, a patch that backports a piece of code to "
15945 "2.6.9 will have a <literal>2.6.9</literal> guard."
15946 msgstr ""
15948 #. type: Content of: <book><chapter><sect1><para>
15949 #: ../en/ch12-mq-collab.xml:374
15950 msgid ""
15951 "This variety of guards gives me considerable flexibility in determining what "
15952 "kind of source tree I want to end up with. For most situations, the "
15953 "selection of appropriate guards is automated during the build process, but I "
15954 "can manually tune the guards to use for less common circumstances."
15955 msgstr ""
15957 #. type: Content of: <book><chapter><sect1><sect2><title>
15958 #: ../en/ch12-mq-collab.xml:381
15959 msgid "The art of writing backport patches"
15960 msgstr "编写向后移植补丁的艺术"
15962 #. type: Content of: <book><chapter><sect1><sect2><para>
15963 #: ../en/ch12-mq-collab.xml:383
15964 msgid ""
15965 "Using MQ, writing a backport patch is a simple process. All such a patch has "
15966 "to do is modify a piece of code that uses a kernel feature not present in the "
15967 "older version of the kernel, so that the driver continues to work correctly "
15968 "under that older version."
15969 msgstr ""
15971 #. type: Content of: <book><chapter><sect1><sect2><para>
15972 #: ../en/ch12-mq-collab.xml:389
15973 msgid ""
15974 "A useful goal when writing a good backport patch is to make your code look as "
15975 "if it was written for the older version of the kernel you're targeting. The "
15976 "less obtrusive the patch, the easier it will be to understand and maintain. "
15977 "If you're writing a collection of backport patches to avoid the <quote>rat's "
15978 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
15979 "code that are only used conditionally) in your code, don't introduce version-"
15980 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
15981 "several patches, each of which makes unconditional changes, and control their "
15982 "application using guards."
15983 msgstr ""
15985 #. type: Content of: <book><chapter><sect1><sect2><para>
15986 #: ../en/ch12-mq-collab.xml:402
15987 msgid ""
15988 "There are two reasons to divide backport patches into a distinct group, away "
15989 "from the <quote>regular</quote> patches whose effects they modify. The first "
15990 "is that intermingling the two makes it more difficult to use a tool like the "
15991 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
15992 "process of submitting the patches to an upstream maintainer. The second is "
15993 "that a backport patch could perturb the context in which a subsequent regular "
15994 "patch is applied, making it impossible to apply the regular patch cleanly "
15995 "<emphasis>without</emphasis> the earlier backport patch already being applied."
15996 msgstr ""
15998 #. type: Content of: <book><chapter><sect1><title>
15999 #: ../en/ch12-mq-collab.xml:417
16000 msgid "Useful tips for developing with MQ"
16001 msgstr "使用 MQ 开发的技巧"
16003 #. type: Content of: <book><chapter><sect1><sect2><title>
16004 #: ../en/ch12-mq-collab.xml:420
16005 msgid "Organising patches in directories"
16006 msgstr "将补丁放到几个目录中"
16008 #. type: Content of: <book><chapter><sect1><sect2><para>
16009 #: ../en/ch12-mq-collab.xml:422
16010 msgid ""
16011 "If you're working on a substantial project with MQ, it's not difficult to "
16012 "accumulate a large number of patches. For example, I have one patch "
16013 "repository that contains over 250 patches."
16014 msgstr ""
16016 #. type: Content of: <book><chapter><sect1><sect2><para>
16017 #: ../en/ch12-mq-collab.xml:427
16018 msgid ""
16019 "If you can group these patches into separate logical categories, you can if "
16020 "you like store them in different directories; MQ has no problems with patch "
16021 "names that contain path separators."
16022 msgstr ""
16024 #. type: Content of: <book><chapter><sect1><sect2><title>
16025 #: ../en/ch12-mq-collab.xml:434
16026 msgid "Viewing the history of a patch"
16027 msgstr "察看补丁的历史"
16029 #. type: Content of: <book><chapter><sect1><sect2><para>
16030 #: ../en/ch12-mq-collab.xml:436
16031 msgid ""
16032 "If you're developing a set of patches over a long time, it's a good idea to "
16033 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
16034 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
16035 "cmd\">hg diff</command> command to look at the history of changes to a patch "
16036 "is unworkable. This is in part because you're looking at the second "
16037 "derivative of the real code (a diff of a diff), but also because MQ adds "
16038 "noise to the process by modifying time stamps and directory names when it "
16039 "updates a patch."
16040 msgstr ""
16042 #. type: Content of: <book><chapter><sect1><sect2><para>
16043 #: ../en/ch12-mq-collab.xml:448
16044 msgid ""
16045 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
16046 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
16047 "a patch into something readable. To do this, you will need a third-party "
16048 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
16049 "patchutils</citation>. This provides a command named <command>interdiff</"
16050 "command>, which shows the differences between two diffs as a diff. Used on "
16051 "two versions of the same diff, it generates a diff that represents the diff "
16052 "from the first to the second version."
16053 msgstr ""
16055 #. type: Content of: <book><chapter><sect1><sect2><para>
16056 #: ../en/ch12-mq-collab.xml:459
16057 msgid ""
16058 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
16059 "the usual way, by adding a line to the <literal role=\"rc-extensions"
16060 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
16061 "filename>."
16062 msgstr ""
16065 #. &example.hg-interdiff;
16066 #. type: Content of: <book><chapter><sect1><sect2><para>
16067 #: ../en/ch12-mq-collab.xml:466
16068 msgid ""
16069 "The <command>interdiff</command> command expects to be passed the names of "
16070 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
16071 "passes the program it runs a pair of directories, each of which can contain "
16072 "an arbitrary number of files. We thus need a small program that will run "
16073 "<command>interdiff</command> on each pair of files in these two directories. "
16074 "This program is available as <filename role=\"special\">hg-interdiff</"
16075 "filename> in the <filename class=\"directory\">examples</filename> directory "
16076 "of the source code repository that accompanies this book."
16077 msgstr ""
16079 #. type: Content of: <book><chapter><sect1><sect2><para>
16080 #: ../en/ch12-mq-collab.xml:478
16081 msgid ""
16082 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
16083 "shell's search path, you can run it as follows, from inside an MQ patch "
16084 "directory:"
16085 msgstr ""
16087 #. type: Content of: <book><chapter><sect1><sect2><para>
16088 #: ../en/ch12-mq-collab.xml:482
16089 msgid ""
16090 "Since you'll probably want to use this long-winded command a lot, you can get "
16091 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
16092 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
16093 "filename>."
16094 msgstr ""
16096 #. type: Content of: <book><chapter><sect1><sect2><para>
16097 #: ../en/ch12-mq-collab.xml:489
16098 msgid ""
16099 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
16100 "<literal>interdiff</literal> command available, so you can now shorten the "
16101 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
16102 "something a little more wieldy."
16103 msgstr ""
16105 #. type: Content of: <book><chapter><sect1><sect2><note><para>
16106 #: ../en/ch12-mq-collab.xml:497
16107 msgid ""
16108 "The <command>interdiff</command> command works well only if the underlying "
16109 "files against which versions of a patch are generated remain the same. If "
16110 "you create a patch, modify the underlying files, and then regenerate the "
16111 "patch, <command>interdiff</command> may not produce useful output."
16112 msgstr ""
16114 #. type: Content of: <book><chapter><sect1><sect2><para>
16115 #: ../en/ch12-mq-collab.xml:505
16116 msgid ""
16117 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
16118 "than merely improving the presentation of MQ patches. To read more about it, "
16119 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
16120 msgstr ""
16122 #. type: Content of: <book><chapter><title>
16123 #: ../en/ch13-hgext.xml:5
16124 msgid "Adding functionality with extensions"
16125 msgstr "使用扩展增加功能"
16127 #. type: Content of: <book><chapter><para>
16128 #: ../en/ch13-hgext.xml:7
16129 msgid ""
16130 "While the core of Mercurial is quite complete from a functionality "
16131 "standpoint, it's deliberately shorn of fancy features. This approach of "
16132 "preserving simplicity keeps the software easy to deal with for both "
16133 "maintainers and users."
16134 msgstr ""
16136 #. type: Content of: <book><chapter><para>
16137 #: ../en/ch13-hgext.xml:12
16138 msgid ""
16139 "However, Mercurial doesn't box you in with an inflexible command set: you can "
16140 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
16141 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
16142 "extensions in earlier chapters."
16143 msgstr ""
16145 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16146 #: ../en/ch13-hgext.xml:18
16147 msgid ""
16148 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
16149 "\">fetch</literal> extension; this combines pulling new changes and merging "
16150 "them with local changes into a single command, <command role=\"hg-ext-fetch"
16151 "\">fetch</command>."
16152 msgstr ""
16154 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16155 #: ../en/ch13-hgext.xml:24
16156 msgid ""
16157 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
16158 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
16159 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
16160 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
16161 "\">notify</literal> sends notification emails on new changes."
16162 msgstr ""
16164 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16165 #: ../en/ch13-hgext.xml:33
16166 msgid ""
16167 "The Mercurial Queues patch management extension is so invaluable that it "
16168 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
16169 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
16170 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
16171 msgstr ""
16173 #. type: Content of: <book><chapter><para>
16174 #: ../en/ch13-hgext.xml:43
16175 msgid ""
16176 "In this chapter, we'll cover some of the other extensions that are available "
16177 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
16178 "about if you want to write an extension of your own."
16179 msgstr ""
16181 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
16182 #: ../en/ch13-hgext.xml:48
16183 msgid ""
16184 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
16185 "<emphasis>huge</emphasis> performance improvements using the <literal role="
16186 "\"hg-ext\">inotify</literal> extension."
16187 msgstr ""
16189 #. type: Content of: <book><chapter><sect1><title>
16190 #: ../en/ch13-hgext.xml:55
16191 msgid ""
16192 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
16193 "extension"
16194 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
16196 #. type: Content of: <book><chapter><sect1><para>
16197 #: ../en/ch13-hgext.xml:58
16198 msgid ""
16199 "Are you interested in having some of the most common Mercurial operations run "
16200 "as much as a hundred times faster? Read on!"
16201 msgstr ""
16203 #. type: Content of: <book><chapter><sect1><para>
16204 #: ../en/ch13-hgext.xml:62
16205 msgid ""
16206 "Mercurial has great performance under normal circumstances. For example, "
16207 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
16208 "Mercurial has to scan almost every directory and file in your repository so "
16209 "that it can display file status. Many other Mercurial commands need to do "
16210 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
16211 "diff</command> command uses the status machinery to avoid doing an expensive "
16212 "comparison operation on files that obviously haven't changed."
16213 msgstr ""
16215 #. type: Content of: <book><chapter><sect1><para>
16216 #: ../en/ch13-hgext.xml:72
16217 msgid ""
16218 "Because obtaining file status is crucial to good performance, the authors of "
16219 "Mercurial have optimised this code to within an inch of its life. However, "
16220 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
16221 "status</command>, Mercurial is going to have to perform at least one "
16222 "expensive system call for each managed file to determine whether it's changed "
16223 "since the last time Mercurial checked. For a sufficiently large repository, "
16224 "this can take a long time."
16225 msgstr ""
16227 #. type: Content of: <book><chapter><sect1><para>
16228 #: ../en/ch13-hgext.xml:82
16229 msgid ""
16230 "To put a number on the magnitude of this effect, I created a repository "
16231 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
16232 "status</command> as taking ten seconds to run, even when <emphasis>none</"
16233 "emphasis> of those files had been modified."
16234 msgstr ""
16236 #. type: Content of: <book><chapter><sect1><para>
16237 #: ../en/ch13-hgext.xml:88
16238 msgid ""
16239 "Many modern operating systems contain a file notification facility. If a "
16240 "program signs up to an appropriate service, the operating system will notify "
16241 "it every time a file of interest is created, modified, or deleted. On Linux "
16242 "systems, the kernel component that does this is called <literal>inotify</"
16243 "literal>."
16244 msgstr ""
16246 #. type: Content of: <book><chapter><sect1><para>
16247 #: ../en/ch13-hgext.xml:95
16248 msgid ""
16249 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
16250 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
16251 "cmd\">hg status</command> commands. The extension has two components. A "
16252 "daemon sits in the background and receives notifications from the "
16253 "<literal>inotify</literal> subsystem. It also listens for connections from a "
16254 "regular Mercurial command. The extension modifies Mercurial's behavior so "
16255 "that instead of scanning the filesystem, it queries the daemon. Since the "
16256 "daemon has perfect information about the state of the repository, it can "
16257 "respond with a result instantaneously, avoiding the need to scan every "
16258 "directory and file in the repository."
16259 msgstr ""
16261 #. type: Content of: <book><chapter><sect1><para>
16262 #: ../en/ch13-hgext.xml:108
16263 msgid ""
16264 "Recall the ten seconds that I measured plain Mercurial as taking to run "
16265 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
16266 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
16267 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
16268 "faster."
16269 msgstr ""
16271 #. type: Content of: <book><chapter><sect1><para>
16272 #: ../en/ch13-hgext.xml:115
16273 msgid "Before we continue, please pay attention to some caveats."
16274 msgstr ""
16276 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16277 #: ../en/ch13-hgext.xml:118
16278 msgid ""
16279 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
16280 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
16281 "literal> subsystem, it does not work on other operating systems."
16282 msgstr ""
16284 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16285 #: ../en/ch13-hgext.xml:123
16286 msgid ""
16287 "It should work on any Linux distribution that was released after early 2005. "
16288 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
16289 "literal>, or a version of <literal>glibc</literal> that does not have the "
16290 "necessary interfacing support."
16291 msgstr ""
16293 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
16294 #: ../en/ch13-hgext.xml:130
16295 msgid ""
16296 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
16297 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
16298 "starter, for example, particularly if you're running Mercurial on several "
16299 "systems, all mounting the same network filesystem. The kernel's "
16300 "<literal>inotify</literal> system has no way of knowing about changes made on "
16301 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
16302 "work fine."
16303 msgstr ""
16305 #. type: Content of: <book><chapter><sect1><para>
16306 #: ../en/ch13-hgext.xml:141
16307 msgid ""
16308 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
16309 "with Mercurial as of May 2007, so it's a little more involved to set up than "
16310 "other extensions. But the performance improvement is worth it!"
16311 msgstr ""
16313 #. type: Content of: <book><chapter><sect1><para>
16314 #: ../en/ch13-hgext.xml:146
16315 msgid ""
16316 "The extension currently comes in two parts: a set of patches to the Mercurial "
16317 "source code, and a library of Python bindings to the <literal>inotify</"
16318 "literal> subsystem."
16319 msgstr ""
16321 #. type: Content of: <book><chapter><sect1><note><para>
16322 #: ../en/ch13-hgext.xml:150
16323 msgid ""
16324 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
16325 "libraries. One of them is called <literal>pyinotify</literal>, and is "
16326 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
16327 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
16328 "inefficient to be practical."
16329 msgstr ""
16331 #. type: Content of: <book><chapter><sect1><para>
16332 #: ../en/ch13-hgext.xml:157
16333 msgid ""
16334 "To get going, it's best to already have a functioning copy of Mercurial "
16335 "installed."
16336 msgstr ""
16338 #. type: Content of: <book><chapter><sect1><note><para>
16339 #: ../en/ch13-hgext.xml:160
16340 msgid ""
16341 "If you follow the instructions below, you'll be <emphasis>replacing</"
16342 "emphasis> and overwriting any existing installation of Mercurial that you "
16343 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
16344 "code. Don't say you weren't warned!"
16345 msgstr ""
16347 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16348 #: ../en/ch13-hgext.xml:167
16349 msgid ""
16350 "Clone the Python <literal>inotify</literal> binding repository. Build and "
16351 "install it."
16352 msgstr ""
16354 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16355 #: ../en/ch13-hgext.xml:174
16356 msgid ""
16357 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
16358 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
16359 "repository so that Mercurial Queues will be able to apply patches to your "
16360 "cope of the <filename class=\"directory\">crew</filename> repository."
16361 msgstr ""
16363 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16364 #: ../en/ch13-hgext.xml:184
16365 msgid ""
16366 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
16367 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
16368 "mq:start\"/> to get started quickly."
16369 msgstr ""
16371 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16372 #: ../en/ch13-hgext.xml:190
16373 msgid ""
16374 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
16375 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
16376 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
16377 "<command role=\"hg-ext-mq\">qpush</command> command."
16378 msgstr ""
16380 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16381 #: ../en/ch13-hgext.xml:199
16382 msgid ""
16383 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
16384 "you should not continue. Instead, ask for help."
16385 msgstr ""
16387 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
16388 #: ../en/ch13-hgext.xml:203
16389 msgid "Build and install the patched version of Mercurial."
16390 msgstr ""
16392 #. type: Content of: <book><chapter><sect1><para>
16393 #: ../en/ch13-hgext.xml:209
16394 msgid ""
16395 "Once you've build a suitably patched version of Mercurial, all you need to do "
16396 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
16397 "entry to your <filename role=\"special\">~/.hgrc</filename>."
16398 msgstr ""
16400 #. type: Content of: <book><chapter><sect1><para>
16401 #: ../en/ch13-hgext.xml:214
16402 msgid ""
16403 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
16404 "Mercurial will automatically and transparently start the status daemon the "
16405 "first time you run a command that needs status in a repository. It runs one "
16406 "status daemon per repository."
16407 msgstr ""
16409 #. type: Content of: <book><chapter><sect1><para>
16410 #: ../en/ch13-hgext.xml:220
16411 msgid ""
16412 "The status daemon is started silently, and runs in the background. If you "
16413 "look at a list of running processes after you've enabled the <literal role="
16414 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
16415 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
16416 "around, waiting for updates from the kernel and queries from Mercurial."
16417 msgstr ""
16419 #. type: Content of: <book><chapter><sect1><para>
16420 #: ../en/ch13-hgext.xml:228
16421 msgid ""
16422 "The first time you run a Mercurial command in a repository when you have the "
16423 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
16424 "with about the same performance as a normal Mercurial command. This is "
16425 "because the status daemon needs to perform a normal status scan so that it "
16426 "has a baseline against which to apply later updates from the kernel. "
16427 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
16428 "status check should be noticeably faster on repositories of even fairly "
16429 "modest size. Better yet, the bigger your repository is, the greater a "
16430 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
16431 "literal> daemon makes status operations almost instantaneous on repositories "
16432 "of all sizes!"
16433 msgstr ""
16435 #. type: Content of: <book><chapter><sect1><para>
16436 #: ../en/ch13-hgext.xml:242
16437 msgid ""
16438 "If you like, you can manually start a status daemon using the <command role="
16439 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
16440 "control over how the daemon ought to run. This command will of course only "
16441 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
16442 "enabled."
16443 msgstr ""
16445 #. type: Content of: <book><chapter><sect1><para>
16446 #: ../en/ch13-hgext.xml:249
16447 msgid ""
16448 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
16449 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
16450 "behavior, with the sole exception of status-related commands running a whole "
16451 "lot faster than they used to. You should specifically expect that commands "
16452 "will not print different output; neither should they give different results. "
16453 "If either of these situations occurs, please report a bug."
16454 msgstr ""
16456 #. type: Content of: <book><chapter><sect1><title>
16457 #: ../en/ch13-hgext.xml:260
16458 msgid ""
16459 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
16460 "extension"
16461 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
16463 #. type: Content of: <book><chapter><sect1><para>
16464 #: ../en/ch13-hgext.xml:263
16465 msgid ""
16466 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
16467 "outputs plaintext unified diffs."
16468 msgstr ""
16469 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
16470 "不同。"
16472 #. type: Content of: <book><chapter><sect1><para>
16473 #: ../en/ch13-hgext.xml:268
16474 msgid ""
16475 "If you would like to use an external tool to display modifications, you'll "
16476 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
16477 "will let you use, for example, a graphical diff tool."
16478 msgstr ""
16480 #. type: Content of: <book><chapter><sect1><para>
16481 #: ../en/ch13-hgext.xml:273
16482 msgid ""
16483 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
16484 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
16485 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
16486 "filename>, simply add a one-line entry to enable the extension."
16487 msgstr ""
16489 #. type: Content of: <book><chapter><sect1><para>
16490 #: ../en/ch13-hgext.xml:280
16491 msgid ""
16492 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
16493 "command>, which by default uses your system's <command>diff</command> command "
16494 "to generate a unified diff in the same form as the built-in <command role="
16495 "\"hg-cmd\">hg diff</command> command."
16496 msgstr ""
16498 #. type: Content of: <book><chapter><sect1><para>
16499 #: ../en/ch13-hgext.xml:288
16500 msgid ""
16501 "The result won't be exactly the same as with the built-in <command role=\"hg-"
16502 "cmd\">hg diff</command> variations, because the output of <command>diff</"
16503 "command> varies from one system to another, even when passed the same options."
16504 msgstr ""
16506 #. type: Content of: <book><chapter><sect1><para>
16507 #: ../en/ch13-hgext.xml:293
16508 msgid ""
16509 "As the <quote><literal>making snapshot</literal></quote> lines of output "
16510 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
16511 "works by creating two snapshots of your source tree. The first snapshot is "
16512 "of the source revision; the second, of the target revision or working "
16513 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
16514 "generates these snapshots in a temporary directory, passes the name of each "
16515 "directory to an external diff viewer, then deletes the temporary directory. "
16516 "For efficiency, it only snapshots the directories and files that have changed "
16517 "between the two revisions."
16518 msgstr ""
16520 #. type: Content of: <book><chapter><sect1><para>
16521 #: ../en/ch13-hgext.xml:306
16522 msgid ""
16523 "Snapshot directory names have the same base name as your repository. If your "
16524 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
16525 "then <filename class=\"directory\">foo</filename> will be the name of each "
16526 "snapshot directory. Each snapshot directory name has its changeset ID "
16527 "appended, if appropriate. If a snapshot is of revision "
16528 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
16529 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
16530 "directory won't have a changeset ID appended, so it would just be <filename "
16531 "class=\"directory\">foo</filename> in this example. To see what this looks "
16532 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
16533 "command> example above. Notice that the diff has the snapshot directory "
16534 "names embedded in its header."
16535 msgstr ""
16537 #. type: Content of: <book><chapter><sect1><para>
16538 #: ../en/ch13-hgext.xml:322
16539 msgid ""
16540 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
16541 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
16542 "option> option lets you choose a program to view differences with, instead of "
16543 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
16544 "opt\">hg -o</option> option, you can change the options that <command role="
16545 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
16546 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
16547 "you're running <command>diff</command>). In other respects, the <command "
16548 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
16549 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
16550 "option names, syntax, and arguments to specify the revisions you want, the "
16551 "files you want, and so on."
16552 msgstr ""
16555 #. type: Content of: <book><chapter><sect1><para>
16556 #: ../en/ch13-hgext.xml:339
16557 msgid ""
16558 "As an example, here's how to run the normal system <command>diff</command> "
16559 "command, getting it to generate context diffs (using the <option role=\"cmd-"
16560 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
16561 "context instead of the default three (passing <literal>5</literal> as the "
16562 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
16563 msgstr ""
16565 #. type: Content of: <book><chapter><sect1><para>
16566 #: ../en/ch13-hgext.xml:348
16567 msgid ""
16568 "Launching a visual diff tool is just as easy. Here's how to launch the "
16569 "<command>kdiff3</command> viewer."
16570 msgstr ""
16572 #. type: Content of: <book><chapter><sect1><para>
16573 #: ../en/ch13-hgext.xml:352
16574 msgid ""
16575 "If your diff viewing command can't deal with directories, you can easily work "
16576 "around this with a little scripting. For an example of such scripting in "
16577 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
16578 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
16579 "interdiff\"/>."
16580 msgstr ""
16582 #. type: Content of: <book><chapter><sect1><sect2><title>
16583 #: ../en/ch13-hgext.xml:360
16584 msgid "Defining command aliases"
16585 msgstr "定义命令的别名"
16587 #. type: Content of: <book><chapter><sect1><sect2><para>
16588 #: ../en/ch13-hgext.xml:362
16589 msgid ""
16590 "It can be cumbersome to remember the options to both the <command role=\"hg-"
16591 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
16592 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
16593 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
16594 "exactly the right options."
16595 msgstr ""
16597 #. type: Content of: <book><chapter><sect1><sect2><para>
16598 #: ../en/ch13-hgext.xml:369
16599 msgid ""
16600 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
16601 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
16602 "literal>. Inside this section, you can define multiple commands. Here's how "
16603 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
16604 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
16605 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
16606 "you."
16607 msgstr ""
16609 #. type: Content of: <book><chapter><sect1><sect2><para>
16610 #: ../en/ch13-hgext.xml:379
16611 msgid ""
16612 "If you leave the right hand side of the definition empty, as above, the "
16613 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
16614 "command you defined as the name of the external program to run. But these "
16615 "names don't have to be the same. Here, we define a command named "
16616 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
16617 "command>."
16618 msgstr ""
16620 #. type: Content of: <book><chapter><sect1><sect2><para>
16621 #: ../en/ch13-hgext.xml:389
16622 msgid ""
16623 "You can also specify the default options that you want to invoke your diff "
16624 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
16625 "quote>, followed by the name of the command to which the options apply. This "
16626 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
16627 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
16628 msgstr ""
16630 #. type: Content of: <book><chapter><sect1><title>
16631 #: ../en/ch13-hgext.xml:403
16632 msgid ""
16633 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
16634 "extension"
16635 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
16637 #. type: Content of: <book><chapter><sect1><para>
16638 #: ../en/ch13-hgext.xml:406
16639 msgid "Need to have a long chat with Brendan about this."
16640 msgstr ""
16642 #. type: Content of: <book><chapter><sect1><title>
16643 #: ../en/ch13-hgext.xml:410
16644 msgid ""
16645 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
16646 "extension"
16647 msgstr ""
16648 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
16650 #. type: Content of: <book><chapter><sect1><para>
16651 #: ../en/ch13-hgext.xml:413
16652 msgid ""
16653 "Many projects have a culture of <quote>change review</quote>, in which people "
16654 "send their modifications to a mailing list for others to read and comment on "
16655 "before they commit the final version to a shared repository. Some projects "
16656 "have people who act as gatekeepers; they apply changes from other people to a "
16657 "repository to which those others don't have access."
16658 msgstr ""
16660 #. type: Content of: <book><chapter><sect1><para>
16661 #: ../en/ch13-hgext.xml:421
16662 msgid ""
16663 "Mercurial makes it easy to send changes over email for review or application, "
16664 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
16665 "extension is so named because changes are formatted as patches, and it's "
16666 "usual to send one changeset per email message. Sending a long series of "
16667 "changes by email is thus much like <quote>bombing</quote> the recipient's "
16668 "inbox, hence <quote>patchbomb</quote>."
16669 msgstr ""
16671 #. type: Content of: <book><chapter><sect1><para>
16672 #: ../en/ch13-hgext.xml:429
16673 msgid ""
16674 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
16675 "literal> extension takes just one or two lines in your <filename role="
16676 "\"special\"> /.hgrc</filename>."
16677 msgstr ""
16679 #. type: Content of: <book><chapter><sect1><para>
16680 #: ../en/ch13-hgext.xml:435
16681 msgid ""
16682 "Once you've enabled the extension, you will have a new command available, "
16683 "named <command role=\"hg-ext-patchbomb\">email</command>."
16684 msgstr ""
16686 #. type: Content of: <book><chapter><sect1><para>
16687 #: ../en/ch13-hgext.xml:439
16688 msgid ""
16689 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
16690 "\">email</command> command is to <emphasis>always</emphasis> run it first "
16691 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
16692 "option. This will show you what the command <emphasis>would</emphasis> send, "
16693 "without actually sending anything. Once you've had a quick glance over the "
16694 "changes and verified that you are sending the right ones, you can rerun the "
16695 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
16696 "option> option removed."
16697 msgstr ""
16699 #. type: Content of: <book><chapter><sect1><para>
16700 #: ../en/ch13-hgext.xml:450
16701 msgid ""
16702 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
16703 "same kind of revision syntax as every other Mercurial command. For example, "
16704 "this command will send every revision between 7 and <literal>tip</literal>, "
16705 "inclusive."
16706 msgstr ""
16708 #. type: Content of: <book><chapter><sect1><para>
16709 #: ../en/ch13-hgext.xml:455
16710 msgid ""
16711 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
16712 "you provide a repository but no revisions, the <command role=\"hg-ext-"
16713 "patchbomb\">email</command> command will send all revisions in the local "
16714 "repository that are not present in the remote repository. If you "
16715 "additionally specify revisions or a branch name (the latter using the <option "
16716 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
16717 "constrain the revisions sent."
16718 msgstr ""
16720 #. type: Content of: <book><chapter><sect1><para>
16721 #: ../en/ch13-hgext.xml:464
16722 msgid ""
16723 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
16724 "command> command without the names of the people you want to send to: if you "
16725 "do this, it will just prompt you for those values interactively. (If you're "
16726 "using a Linux or Unix-like system, you should have enhanced "
16727 "<literal>readline</literal>-style editing capabilities when entering those "
16728 "headers, too, which is useful.)"
16729 msgstr ""
16731 #. type: Content of: <book><chapter><sect1><para>
16732 #: ../en/ch13-hgext.xml:472
16733 msgid ""
16734 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
16735 "\">email</command> command will by default use the first line of the "
16736 "changeset description as the subject of the single email message it sends."
16737 msgstr ""
16739 #. type: Content of: <book><chapter><sect1><para>
16740 #: ../en/ch13-hgext.xml:477
16741 msgid ""
16742 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
16743 "command> command will usually send one message per changeset. It will "
16744 "preface the series with an introductory message, in which you should describe "
16745 "the purpose of the series of changes you're sending."
16746 msgstr ""
16748 #. type: Content of: <book><chapter><sect1><sect2><title>
16749 #: ../en/ch13-hgext.xml:484
16750 msgid "Changing the behavior of patchbombs"
16751 msgstr "修改 patchbomb 的行为"
16753 #. type: Content of: <book><chapter><sect1><sect2><para>
16754 #: ../en/ch13-hgext.xml:486
16755 msgid ""
16756 "Not every project has exactly the same conventions for sending changes in "
16757 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
16758 "accommodate a number of variations through command line options."
16759 msgstr ""
16761 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16762 #: ../en/ch13-hgext.xml:492
16763 msgid ""
16764 "You can write a subject for the introductory message on the command line "
16765 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
16766 "option. This takes one argument, the text of the subject to use."
16767 msgstr ""
16769 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16770 #: ../en/ch13-hgext.xml:498
16771 msgid ""
16772 "To change the email address from which the messages originate, use the "
16773 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
16774 "takes one argument, the email address to use."
16775 msgstr ""
16777 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16778 #: ../en/ch13-hgext.xml:504
16779 msgid ""
16780 "The default behavior is to send unified diffs (see <xref linkend=\"sec:mq:"
16781 "patch\"/> for a description of the format), one per message. You can send a "
16782 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
16783 "\">hg -b</option> option."
16784 msgstr ""
16786 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16787 #: ../en/ch13-hgext.xml:512
16788 msgid ""
16789 "Unified diffs are normally prefaced with a metadata header. You can omit "
16790 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
16791 "email-opt\">hg --plain</option> option."
16792 msgstr ""
16794 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16795 #: ../en/ch13-hgext.xml:518
16796 msgid ""
16797 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
16798 "description of a patch. This makes it easiest for the largest number of "
16799 "readers to quote and respond to parts of a diff, as some mail clients will "
16800 "only quote the first MIME body part in a message. If you'd prefer to send the "
16801 "description and the diff in separate body parts, use the <option role=\"hg-"
16802 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
16803 msgstr ""
16805 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16806 #: ../en/ch13-hgext.xml:528
16807 msgid ""
16808 "Instead of sending mail messages, you can write them to an <literal>mbox</"
16809 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
16810 "email-opt\">hg -m</option> option. That option takes one argument, the name "
16811 "of the file to write to."
16812 msgstr ""
16814 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16815 #: ../en/ch13-hgext.xml:535
16816 msgid ""
16817 "If you would like to add a <command>diffstat</command>-format summary to each "
16818 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
16819 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
16820 "command> command displays a table containing the name of each file patched, "
16821 "the number of lines affected, and a histogram showing how much each file is "
16822 "modified. This gives readers a qualitative glance at how complex a patch is."
16823 msgstr ""