hgbook

view po/zh.po @ 679:06458701453c

Fix up some links to example URLs that aren't actually real.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Apr 21 21:07:20 2009 -0700 (2009-04-21)
parents 3b33dd6aba87
children 8613844dd2cf
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-05 11:48+0800\n"
45 "PO-Revision-Date: 2009-04-05 12:10+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 "behaviour 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 behaviour 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 ""
879 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
880 #: ../en/appC-srcinstall.xml:14
881 msgid ""
882 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
883 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
884 msgstr ""
886 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
887 #: ../en/appC-srcinstall.xml:17
888 msgid "Unpack the tarball:"
889 msgstr ""
891 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
892 #: ../en/appC-srcinstall.xml:20
893 msgid ""
894 "Go into the source directory and run the installer script. This will build "
895 "Mercurial and install it in your home directory."
896 msgstr ""
898 #. type: Content of: <book><appendix><sect1><para>
899 #: ../en/appC-srcinstall.xml:27
900 msgid ""
901 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
902 "subdirectory of your home directory. Don't forget to make sure that this "
903 "directory is present in your shell's search path."
904 msgstr ""
906 #. type: Content of: <book><appendix><sect1><para>
907 #: ../en/appC-srcinstall.xml:32
908 msgid ""
909 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
910 "variable so that the Mercurial executable can find the rest of the Mercurial "
911 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
912 "python</literal>. The exact path that you will need to use depends on how "
913 "Python was built for your system, but should be easy to figure out. If "
914 "you're uncertain, look through the output of the installer script above, and "
915 "see where the contents of the <literal>mercurial</literal> directory were "
916 "installed to."
917 msgstr ""
919 #. type: Content of: <book><appendix><sect1><title>
920 #: ../en/appC-srcinstall.xml:44
921 msgid "On Windows"
922 msgstr "Windows 系统"
924 #. type: Content of: <book><appendix><sect1><para>
925 #: ../en/appC-srcinstall.xml:46
926 msgid ""
927 "Building and installing Mercurial on Windows requires a variety of tools, a "
928 "fair amount of technical knowledge, and considerable patience. I very much "
929 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
930 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
931 "that you use a binary package instead."
932 msgstr ""
934 #. type: Content of: <book><appendix><sect1><para>
935 #: ../en/appC-srcinstall.xml:53
936 msgid ""
937 "If you are intent on building Mercurial from source on Windows, follow the "
938 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
939 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
940 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
941 "process to involve a lot of fiddly work."
942 msgstr ""
944 #. type: Content of: <book><appendix><title>
945 #: ../en/appD-license.xml:5
946 msgid "Open Publication License"
947 msgstr ""
949 #. type: Content of: <book><appendix><para>
950 #: ../en/appD-license.xml:7
951 msgid "Version 1.0, 8 June 1999"
952 msgstr ""
954 #. type: Content of: <book><appendix><sect1><title>
955 #: ../en/appD-license.xml:10
956 msgid "Requirements on both unmodified and modified versions"
957 msgstr ""
959 #. type: Content of: <book><appendix><sect1><para>
960 #: ../en/appD-license.xml:13
961 msgid ""
962 "The Open Publication works may be reproduced and distributed in whole or in "
963 "part, in any medium physical or electronic, provided that the terms of this "
964 "license are adhered to, and that this license or an incorporation of it by "
965 "reference (with any options elected by the author(s) and/or publisher) is "
966 "displayed in the reproduction."
967 msgstr ""
969 #. type: Content of: <book><appendix><sect1><para>
970 #: ../en/appD-license.xml:20
971 msgid "Proper form for an incorporation by reference is as follows:"
972 msgstr ""
974 #. type: Content of: <book><appendix><sect1><blockquote><para>
975 #: ../en/appD-license.xml:24
976 msgid ""
977 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
978 "designee</emphasis>. This material may be distributed only subject to the "
979 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
980 "y</emphasis> or later (the latest version is presently available at <ulink "
981 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
982 "openpub/</ulink>)."
983 msgstr ""
985 #. type: Content of: <book><appendix><sect1><para>
986 #: ../en/appD-license.xml:33
987 msgid ""
988 "The reference must be immediately followed with any options elected by the "
989 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
990 "options\"/>)."
991 msgstr ""
993 #. type: Content of: <book><appendix><sect1><para>
994 #: ../en/appD-license.xml:37
995 msgid ""
996 "Commercial redistribution of Open Publication-licensed material is permitted."
997 msgstr ""
999 #. type: Content of: <book><appendix><sect1><para>
1000 #: ../en/appD-license.xml:40
1001 msgid ""
1002 "Any publication in standard (paper) book form shall require the citation of "
1003 "the original publisher and author. The publisher and author's names shall "
1004 "appear on all outer surfaces of the book. On all outer surfaces of the book "
1005 "the original publisher's name shall be as large as the title of the work and "
1006 "cited as possessive with respect to the title."
1007 msgstr ""
1009 #. type: Content of: <book><appendix><sect1><title>
1010 #: ../en/appD-license.xml:49
1011 msgid "Copyright"
1012 msgstr ""
1014 #. type: Content of: <book><appendix><sect1><para>
1015 #: ../en/appD-license.xml:51
1016 msgid ""
1017 "The copyright to each Open Publication is owned by its author(s) or designee."
1018 msgstr ""
1020 #. type: Content of: <book><appendix><sect1><title>
1021 #: ../en/appD-license.xml:56
1022 msgid "Scope of license"
1023 msgstr ""
1025 #. type: Content of: <book><appendix><sect1><para>
1026 #: ../en/appD-license.xml:58
1027 msgid ""
1028 "The following license terms apply to all Open Publication works, unless "
1029 "otherwise explicitly stated in the document."
1030 msgstr ""
1032 #. type: Content of: <book><appendix><sect1><para>
1033 #: ../en/appD-license.xml:62
1034 msgid ""
1035 "Mere aggregation of Open Publication works or a portion of an Open "
1036 "Publication work with other works or programs on the same media shall not "
1037 "cause this license to apply to those other works. The aggregate work shall "
1038 "contain a notice specifying the inclusion of the Open Publication material "
1039 "and appropriate copyright notice."
1040 msgstr ""
1042 #. type: Content of: <book><appendix><sect1><para>
1043 #: ../en/appD-license.xml:69
1044 msgid ""
1045 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
1046 "is found to be unenforceable in any jurisdiction, the remaining portions of "
1047 "the license remain in force."
1048 msgstr ""
1050 #. type: Content of: <book><appendix><sect1><para>
1051 #: ../en/appD-license.xml:74
1052 msgid ""
1053 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
1054 "licensed and provided <quote>as is</quote> without warranty of any kind, "
1055 "express or implied, including, but not limited to, the implied warranties of "
1056 "merchantability and fitness for a particular purpose or a warranty of non-"
1057 "infringement."
1058 msgstr ""
1060 #. type: Content of: <book><appendix><sect1><title>
1061 #: ../en/appD-license.xml:83
1062 msgid "Requirements on modified works"
1063 msgstr ""
1065 #. type: Content of: <book><appendix><sect1><para>
1066 #: ../en/appD-license.xml:85
1067 msgid ""
1068 "All modified versions of documents covered by this license, including "
1069 "translations, anthologies, compilations and partial documents, must meet the "
1070 "following requirements:"
1071 msgstr ""
1073 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1074 #: ../en/appD-license.xml:90
1075 msgid "The modified version must be labeled as such."
1076 msgstr ""
1078 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1079 #: ../en/appD-license.xml:93
1080 msgid ""
1081 "The person making the modifications must be identified and the modifications "
1082 "dated."
1083 msgstr ""
1085 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1086 #: ../en/appD-license.xml:96
1087 msgid ""
1088 "Acknowledgement of the original author and publisher if applicable must be "
1089 "retained according to normal academic citation practices."
1090 msgstr ""
1092 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1093 #: ../en/appD-license.xml:100
1094 msgid "The location of the original unmodified document must be identified."
1095 msgstr ""
1097 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1098 #: ../en/appD-license.xml:103
1099 msgid ""
1100 "The original author's (or authors') name(s) may not be used to assert or "
1101 "imply endorsement of the resulting document without the original author's (or "
1102 "authors') permission."
1103 msgstr ""
1105 #. type: Content of: <book><appendix><sect1><title>
1106 #: ../en/appD-license.xml:111
1107 msgid "Good-practice recommendations"
1108 msgstr ""
1110 #. type: Content of: <book><appendix><sect1><para>
1111 #: ../en/appD-license.xml:113
1112 msgid ""
1113 "In addition to the requirements of this license, it is requested from and "
1114 "strongly recommended of redistributors that:"
1115 msgstr ""
1117 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1118 #: ../en/appD-license.xml:118
1119 msgid ""
1120 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
1121 "provide email notification to the authors of your intent to redistribute at "
1122 "least thirty days before your manuscript or media freeze, to give the authors "
1123 "time to provide updated documents. This notification should describe "
1124 "modifications, if any, made to the document."
1125 msgstr ""
1127 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1128 #: ../en/appD-license.xml:125
1129 msgid ""
1130 "All substantive modifications (including deletions) be either clearly marked "
1131 "up in the document or else described in an attachment to the document."
1132 msgstr ""
1134 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1135 #: ../en/appD-license.xml:129
1136 msgid ""
1137 "Finally, while it is not mandatory under this license, it is considered good "
1138 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
1139 "Publication-licensed work to its author(s)."
1140 msgstr ""
1142 #. type: Content of: <book><appendix><sect1><title>
1143 #: ../en/appD-license.xml:137
1144 msgid "License options"
1145 msgstr ""
1147 #. type: Content of: <book><appendix><sect1><para>
1148 #: ../en/appD-license.xml:139
1149 msgid ""
1150 "The author(s) and/or publisher of an Open Publication-licensed document may "
1151 "elect certain options by appending language to the reference to or copy of "
1152 "the license. These options are considered part of the license instance and "
1153 "must be included with the license (or its incorporation by reference) in "
1154 "derived works."
1155 msgstr ""
1157 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1158 #: ../en/appD-license.xml:147
1159 msgid ""
1160 "To prohibit distribution of substantively modified versions without the "
1161 "explicit permission of the author(s). <quote>Substantive modification</quote> "
1162 "is defined as a change to the semantic content of the document, and excludes "
1163 "mere changes in format or typographical corrections."
1164 msgstr ""
1166 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1167 #: ../en/appD-license.xml:154
1168 msgid ""
1169 "To accomplish this, add the phrase <quote>Distribution of substantively "
1170 "modified versions of this document is prohibited without the explicit "
1171 "permission of the copyright holder.</quote> to the license reference or copy."
1172 msgstr ""
1174 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1175 #: ../en/appD-license.xml:160
1176 msgid ""
1177 "To prohibit any publication of this work or derivative works in whole or in "
1178 "part in standard (paper) book form for commercial purposes is prohibited "
1179 "unless prior permission is obtained from the copyright holder."
1180 msgstr ""
1182 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
1183 #: ../en/appD-license.xml:165
1184 msgid ""
1185 "To accomplish this, add the phrase <quote>Distribution of the work or "
1186 "derivative of the work in any standard (paper) book form is prohibited unless "
1187 "prior permission is obtained from the copyright holder.</quote> to the "
1188 "license reference or copy."
1189 msgstr ""
1191 #. type: Content of: <book><preface><title>
1192 #: ../en/ch00-preface.xml:5
1193 msgid "Preface"
1194 msgstr "序言"
1196 #. type: Content of: <book><preface><sect1><title>
1197 #: ../en/ch00-preface.xml:8
1198 msgid "Why revision control? Why Mercurial?"
1199 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
1201 #. type: Content of: <book><preface><sect1><para>
1202 #: ../en/ch00-preface.xml:10
1203 msgid ""
1204 "Revision control is the process of managing multiple versions of a piece of "
1205 "information. In its simplest form, this is something that many people do by "
1206 "hand: every time you modify a file, save it under a new name that contains a "
1207 "number, each one higher than the number of the preceding version."
1208 msgstr ""
1210 #. type: Content of: <book><preface><sect1><para>
1211 #: ../en/ch00-preface.xml:16
1212 msgid ""
1213 "Manually managing multiple versions of even a single file is an error-prone "
1214 "task, though, so software tools to help automate this process have long been "
1215 "available. The earliest automated revision control tools were intended to "
1216 "help a single user to manage revisions of a single file. Over the past few "
1217 "decades, the scope of revision control tools has expanded greatly; they now "
1218 "manage multiple files, and help multiple people to work together. The best "
1219 "modern revision control tools have no problem coping with thousands of people "
1220 "working together on projects that consist of hundreds of thousands of files."
1221 msgstr ""
1223 #. type: Content of: <book><preface><sect1><para>
1224 #: ../en/ch00-preface.xml:27
1225 msgid ""
1226 "The arrival of distributed revision control is relatively recent, and so far "
1227 "this new field has grown due to people's willingness to explore ill-charted "
1228 "territory."
1229 msgstr ""
1231 #. type: Content of: <book><preface><sect1><para>
1232 #: ../en/ch00-preface.xml:31
1233 msgid ""
1234 "I am writing a book about distributed revision control because I believe that "
1235 "it is an important subject that deserves a field guide. I chose to write "
1236 "about Mercurial because it is the easiest tool to learn the terrain with, and "
1237 "yet it scales to the demands of real, challenging environments where many "
1238 "other revision control tools buckle."
1239 msgstr ""
1241 #. type: Content of: <book><preface><sect1><sect2><title>
1242 #: ../en/ch00-preface.xml:39
1243 msgid "Why use revision control?"
1244 msgstr "为什么使用版本控制?"
1246 #. type: Content of: <book><preface><sect1><sect2><para>
1247 #: ../en/ch00-preface.xml:41
1248 msgid ""
1249 "There are a number of reasons why you or your team might want to use an "
1250 "automated revision control tool for a project."
1251 msgstr ""
1253 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1254 #: ../en/ch00-preface.xml:46
1255 msgid ""
1256 "It will track the history and evolution of your project, so you don't have "
1257 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
1258 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
1259 "it; and <emphasis>what</emphasis> the change was."
1260 msgstr ""
1262 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1263 #: ../en/ch00-preface.xml:53
1264 msgid ""
1265 "When you're working with other people, revision control software makes it "
1266 "easier for you to collaborate. For example, when people more or less "
1267 "simultaneously make potentially incompatible changes, the software will help "
1268 "you to identify and resolve those conflicts."
1269 msgstr ""
1271 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1272 #: ../en/ch00-preface.xml:59
1273 msgid ""
1274 "It can help you to recover from mistakes. If you make a change that later "
1275 "turns out to be in error, you can revert to an earlier version of one or more "
1276 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
1277 "will even help you to efficiently figure out exactly when a problem was "
1278 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
1279 msgstr ""
1281 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1282 #: ../en/ch00-preface.xml:66
1283 msgid ""
1284 "It will help you to work simultaneously on, and manage the drift between, "
1285 "multiple versions of your project."
1286 msgstr ""
1288 #. type: Content of: <book><preface><sect1><sect2><para>
1289 #: ../en/ch00-preface.xml:71
1290 msgid ""
1291 "Most of these reasons are equally valid&emdash;at least in theory&emdash;"
1292 "whether you're working on a project by yourself, or with a hundred other "
1293 "people."
1294 msgstr ""
1296 #. type: Content of: <book><preface><sect1><sect2><para>
1297 #: ../en/ch00-preface.xml:76
1298 msgid ""
1299 "A key question about the practicality of revision control at these two "
1300 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
1301 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
1302 "emphasis>. A revision control tool that's difficult to understand or use is "
1303 "going to impose a high cost."
1304 msgstr ""
1306 #. type: Content of: <book><preface><sect1><sect2><para>
1307 #: ../en/ch00-preface.xml:84
1308 msgid ""
1309 "A five-hundred-person project is likely to collapse under its own weight "
1310 "almost immediately without a revision control tool and process. In this case, "
1311 "the cost of using revision control might hardly seem worth considering, since "
1312 "<emphasis>without</emphasis> it, failure is almost guaranteed."
1313 msgstr ""
1315 #. type: Content of: <book><preface><sect1><sect2><para>
1316 #: ../en/ch00-preface.xml:91
1317 msgid ""
1318 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
1319 "poor place to use a revision control tool, because surely the cost of using "
1320 "one must be close to the overall cost of the project. Right?"
1321 msgstr ""
1323 #. type: Content of: <book><preface><sect1><sect2><para>
1324 #: ../en/ch00-preface.xml:96
1325 msgid ""
1326 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
1327 "development. You can learn the basics in just a few minutes, and due to its "
1328 "low overhead, you can apply revision control to the smallest of projects with "
1329 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
1330 "command sequences competing for mental space with whatever you're "
1331 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
1332 "performance and peer-to-peer nature let you scale painlessly to handle large "
1333 "projects."
1334 msgstr ""
1336 #. type: Content of: <book><preface><sect1><sect2><para>
1337 #: ../en/ch00-preface.xml:106
1338 msgid ""
1339 "No revision control tool can rescue a poorly run project, but a good choice "
1340 "of tools can make a huge difference to the fluidity with which you can work "
1341 "on a project."
1342 msgstr ""
1344 #. type: Content of: <book><preface><sect1><sect2><title>
1345 #: ../en/ch00-preface.xml:113
1346 msgid "The many names of revision control"
1347 msgstr "版本控制的别名"
1349 #. type: Content of: <book><preface><sect1><sect2><para>
1350 #: ../en/ch00-preface.xml:115
1351 msgid ""
1352 "Revision control is a diverse field, so much so that it is referred to by "
1353 "many names and acronyms. Here are a few of the more common variations you'll "
1354 "encounter:"
1355 msgstr ""
1357 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1358 #: ../en/ch00-preface.xml:119
1359 msgid "Revision control (RCS)"
1360 msgstr "版本控制(RCS)"
1362 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1363 #: ../en/ch00-preface.xml:120
1364 msgid "Software configuration management (SCM), or configuration management"
1365 msgstr "软件配置管理(SCM),或配置管理"
1367 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1368 #: ../en/ch00-preface.xml:122
1369 msgid "Source code management"
1370 msgstr "源代码管理"
1372 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1373 #: ../en/ch00-preface.xml:123
1374 msgid "Source code control, or source control"
1375 msgstr "源代码控制,或源控制"
1377 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
1378 #: ../en/ch00-preface.xml:125
1379 msgid "Version control (VCS)"
1380 msgstr "版本控制(VCS)"
1382 #. type: Content of: <book><preface><sect1><sect2><para>
1383 #: ../en/ch00-preface.xml:127
1384 msgid ""
1385 "Some people claim that these terms actually have different meanings, but in "
1386 "practice they overlap so much that there's no agreed or even useful way to "
1387 "tease them apart."
1388 msgstr ""
1390 #. type: Content of: <book><preface><sect1><title>
1391 #: ../en/ch00-preface.xml:135
1392 msgid "This book is a work in progress"
1393 msgstr "本书正在编写中"
1395 #. type: Content of: <book><preface><sect1><para>
1396 #: ../en/ch00-preface.xml:137
1397 msgid ""
1398 "I am releasing this book while I am still writing it, in the hope that it "
1399 "will prove useful to others. I am writing under an open license in the hope "
1400 "that you, my readers, will contribute feedback and perhaps content of your "
1401 "own."
1402 msgstr ""
1404 #. type: Content of: <book><preface><sect1><title>
1405 #: ../en/ch00-preface.xml:144
1406 msgid "About the examples in this book"
1407 msgstr "本书的例子"
1409 #. type: Content of: <book><preface><sect1><para>
1410 #: ../en/ch00-preface.xml:146
1411 msgid ""
1412 "This book takes an unusual approach to code samples. Every example is "
1413 "<quote>live</quote>&emdash;each one is actually the result of a shell script "
1414 "that executes the Mercurial commands you see. Every time an image of the "
1415 "book is built from its sources, all the example scripts are automatically "
1416 "run, and their current results compared against their expected results."
1417 msgstr ""
1419 #. type: Content of: <book><preface><sect1><para>
1420 #: ../en/ch00-preface.xml:153
1421 msgid ""
1422 "The advantage of this approach is that the examples are always accurate; they "
1423 "describe <emphasis>exactly</emphasis> the behaviour of the version of "
1424 "Mercurial that's mentioned at the front of the book. If I update the version "
1425 "of Mercurial that I'm documenting, and the output of some command changes, "
1426 "the build fails."
1427 msgstr ""
1429 #. type: Content of: <book><preface><sect1><para>
1430 #: ../en/ch00-preface.xml:160
1431 msgid ""
1432 "There is a small disadvantage to this approach, which is that the dates and "
1433 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
1434 "way that they wouldn't be if the same commands were being typed by a human. "
1435 "Where a human can issue no more than one command every few seconds, with any "
1436 "resulting timestamps correspondingly spread out, my automated example scripts "
1437 "run many commands in one second."
1438 msgstr ""
1440 #. type: Content of: <book><preface><sect1><para>
1441 #: ../en/ch00-preface.xml:168
1442 msgid ""
1443 "As an instance of this, several consecutive commits in an example can show up "
1444 "as having occurred during the same second. You can see this occur in the "
1445 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
1446 "bisect\"/>, for instance."
1447 msgstr ""
1449 #. type: Content of: <book><preface><sect1><para>
1450 #: ../en/ch00-preface.xml:174
1451 msgid ""
1452 "So when you're reading examples, don't place too much weight on the dates or "
1453 "times you see in the output of commands. But <emphasis>do</emphasis> be "
1454 "confident that the behaviour you're seeing is consistent and reproducible."
1455 msgstr ""
1457 #. type: Content of: <book><preface><sect1><title>
1458 #: ../en/ch00-preface.xml:182
1459 msgid "Trends in the field"
1460 msgstr "版本控制的发展趋势"
1462 #. type: Content of: <book><preface><sect1><para>
1463 #: ../en/ch00-preface.xml:184
1464 msgid ""
1465 "There has been an unmistakable trend in the development and use of revision "
1466 "control tools over the past four decades, as people have become familiar with "
1467 "the capabilities of their tools and constrained by their limitations."
1468 msgstr ""
1470 #. type: Content of: <book><preface><sect1><para>
1471 #: ../en/ch00-preface.xml:189
1472 msgid ""
1473 "The first generation began by managing single files on individual computers. "
1474 "Although these tools represented a huge advance over ad-hoc manual revision "
1475 "control, their locking model and reliance on a single computer limited them "
1476 "to small, tightly-knit teams."
1477 msgstr ""
1479 #. type: Content of: <book><preface><sect1><para>
1480 #: ../en/ch00-preface.xml:195
1481 msgid ""
1482 "The second generation loosened these constraints by moving to network-"
1483 "centered architectures, and managing entire projects at a time. As projects "
1484 "grew larger, they ran into new problems. With clients needing to talk to "
1485 "servers very frequently, server scaling became an issue for large projects. "
1486 "An unreliable network connection could prevent remote users from being able "
1487 "to talk to the server at all. As open source projects started making read-"
1488 "only access available anonymously to anyone, people without commit privileges "
1489 "found that they could not use the tools to interact with a project in a "
1490 "natural way, as they could not record their changes."
1491 msgstr ""
1493 #. type: Content of: <book><preface><sect1><para>
1494 #: ../en/ch00-preface.xml:207
1495 msgid ""
1496 "The current generation of revision control tools is peer-to-peer in nature. "
1497 "All of these systems have dropped the dependency on a single central server, "
1498 "and allow people to distribute their revision control data to where it's "
1499 "actually needed. Collaboration over the Internet has moved from constrained "
1500 "by technology to a matter of choice and consensus. Modern tools can operate "
1501 "offline indefinitely and autonomously, with a network connection only needed "
1502 "when syncing changes with another repository."
1503 msgstr ""
1505 #. type: Content of: <book><preface><sect1><title>
1506 #: ../en/ch00-preface.xml:219
1507 msgid "A few of the advantages of distributed revision control"
1508 msgstr "分布版本控制的优点"
1510 #. type: Content of: <book><preface><sect1><para>
1511 #: ../en/ch00-preface.xml:222
1512 msgid ""
1513 "Even though distributed revision control tools have for several years been as "
1514 "robust and usable as their previous-generation counterparts, people using "
1515 "older tools have not yet necessarily woken up to their advantages. There are "
1516 "a number of ways in which distributed tools shine relative to centralised "
1517 "ones."
1518 msgstr ""
1520 #. type: Content of: <book><preface><sect1><para>
1521 #: ../en/ch00-preface.xml:229
1522 msgid ""
1523 "For an individual developer, distributed tools are almost always much faster "
1524 "than centralised tools. This is for a simple reason: a centralised tool "
1525 "needs to talk over the network for many common operations, because most "
1526 "metadata is stored in a single copy on the central server. A distributed "
1527 "tool stores all of its metadata locally. All else being equal, talking over "
1528 "the network adds overhead to a centralised tool. Don't underestimate the "
1529 "value of a snappy, responsive tool: you're going to spend a lot of time "
1530 "interacting with your revision control software."
1531 msgstr ""
1533 #. type: Content of: <book><preface><sect1><para>
1534 #: ../en/ch00-preface.xml:240
1535 msgid ""
1536 "Distributed tools are indifferent to the vagaries of your server "
1537 "infrastructure, again because they replicate metadata to so many locations. "
1538 "If you use a centralised system and your server catches fire, you'd better "
1539 "hope that your backup media are reliable, and that your last backup was "
1540 "recent and actually worked. With a distributed tool, you have many backups "
1541 "available on every contributor's computer."
1542 msgstr ""
1544 #. type: Content of: <book><preface><sect1><para>
1545 #: ../en/ch00-preface.xml:248
1546 msgid ""
1547 "The reliability of your network will affect distributed tools far less than "
1548 "it will centralised tools. You can't even use a centralised tool without a "
1549 "network connection, except for a few highly constrained commands. With a "
1550 "distributed tool, if your network connection goes down while you're working, "
1551 "you may not even notice. The only thing you won't be able to do is talk to "
1552 "repositories on other computers, something that is relatively rare compared "
1553 "with local operations. If you have a far-flung team of collaborators, this "
1554 "may be significant."
1555 msgstr ""
1557 #. type: Content of: <book><preface><sect1><sect2><title>
1558 #: ../en/ch00-preface.xml:259
1559 msgid "Advantages for open source projects"
1560 msgstr "开源项目的优点"
1562 #. type: Content of: <book><preface><sect1><sect2><para>
1563 #: ../en/ch00-preface.xml:261
1564 msgid ""
1565 "If you take a shine to an open source project and decide that you would like "
1566 "to start hacking on it, and that project uses a distributed revision control "
1567 "tool, you are at once a peer with the people who consider themselves the "
1568 "<quote>core</quote> of that project. If they publish their repositories, you "
1569 "can immediately copy their project history, start making changes, and record "
1570 "your work, using the same tools in the same ways as insiders. By contrast, "
1571 "with a centralised tool, you must use the software in a <quote>read only</"
1572 "quote> mode unless someone grants you permission to commit changes to their "
1573 "central server. Until then, you won't be able to record changes, and your "
1574 "local modifications will be at risk of corruption any time you try to update "
1575 "your client's view of the repository."
1576 msgstr ""
1578 #. type: Content of: <book><preface><sect1><sect2><sect3><title>
1579 #: ../en/ch00-preface.xml:277
1580 msgid "The forking non-problem"
1581 msgstr "分叉不是问题"
1583 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1584 #: ../en/ch00-preface.xml:279
1585 msgid ""
1586 "It has been suggested that distributed revision control tools pose some sort "
1587 "of risk to open source projects because they make it easy to <quote>fork</"
1588 "quote> the development of a project. A fork happens when there are "
1589 "differences in opinion or attitude between groups of developers that cause "
1590 "them to decide that they can't work together any longer. Each side takes a "
1591 "more or less complete copy of the project's source code, and goes off in its "
1592 "own direction."
1593 msgstr ""
1595 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1596 #: ../en/ch00-preface.xml:289
1597 msgid ""
1598 "Sometimes the camps in a fork decide to reconcile their differences. With a "
1599 "centralised revision control system, the <emphasis>technical</emphasis> "
1600 "process of reconciliation is painful, and has to be performed largely by "
1601 "hand. You have to decide whose revision history is going to <quote>win</"
1602 "quote>, and graft the other team's changes into the tree somehow. This "
1603 "usually loses some or all of one side's revision history."
1604 msgstr ""
1606 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1607 #: ../en/ch00-preface.xml:298
1608 msgid ""
1609 "What distributed tools do with respect to forking is they make forking the "
1610 "<emphasis>only</emphasis> way to develop a project. Every single change that "
1611 "you make is potentially a fork point. The great strength of this approach is "
1612 "that a distributed revision control tool has to be really good at "
1613 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
1614 "they happen all the time."
1615 msgstr ""
1617 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1618 #: ../en/ch00-preface.xml:307
1619 msgid ""
1620 "If every piece of work that everybody does, all the time, is framed in terms "
1621 "of forking and merging, then what the open source world refers to as a "
1622 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
1623 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
1624 "fork:"
1625 msgstr ""
1627 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1628 #: ../en/ch00-preface.xml:314
1629 msgid ""
1630 "They eliminate the social distinction that centralised tools impose: that "
1631 "between insiders (people with commit access) and outsiders (people without)."
1632 msgstr ""
1634 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
1635 #: ../en/ch00-preface.xml:318
1636 msgid ""
1637 "They make it easier to reconcile after a social fork, because all that's "
1638 "involved from the perspective of the revision control software is just "
1639 "another merge."
1640 msgstr ""
1642 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
1643 #: ../en/ch00-preface.xml:323
1644 msgid ""
1645 "Some people resist distributed tools because they want to retain tight "
1646 "control over their projects, and they believe that centralised tools give "
1647 "them this control. However, if you're of this belief, and you publish your "
1648 "CVS or Subversion repositories publicly, there are plenty of tools available "
1649 "that can pull out your entire project's history (albeit slowly) and recreate "
1650 "it somewhere that you don't control. So while your control in this case is "
1651 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
1652 "people feel compelled to mirror and fork your history."
1653 msgstr ""
1655 #. type: Content of: <book><preface><sect1><sect2><title>
1656 #: ../en/ch00-preface.xml:338
1657 msgid "Advantages for commercial projects"
1658 msgstr "商业项目的优点"
1660 #. type: Content of: <book><preface><sect1><sect2><para>
1661 #: ../en/ch00-preface.xml:340
1662 msgid ""
1663 "Many commercial projects are undertaken by teams that are scattered across "
1664 "the globe. Contributors who are far from a central server will see slower "
1665 "command execution and perhaps less reliability. Commercial revision control "
1666 "systems attempt to ameliorate these problems with remote-site replication add-"
1667 "ons that are typically expensive to buy and cantankerous to administer. A "
1668 "distributed system doesn't suffer from these problems in the first place. "
1669 "Better yet, you can easily set up multiple authoritative servers, say one per "
1670 "site, so that there's no redundant communication between repositories over "
1671 "expensive long-haul network links."
1672 msgstr ""
1674 #. type: Content of: <book><preface><sect1><sect2><para>
1675 #: ../en/ch00-preface.xml:352
1676 msgid ""
1677 "Centralised revision control systems tend to have relatively low "
1678 "scalability. It's not unusual for an expensive centralised system to fall "
1679 "over under the combined load of just a few dozen concurrent users. Once "
1680 "again, the typical response tends to be an expensive and clunky replication "
1681 "facility. Since the load on a central server&emdash;if you have one at "
1682 "all&emdash;is many times lower with a distributed tool (because all of the "
1683 "data is replicated everywhere), a single cheap server can handle the needs of "
1684 "a much larger team, and replication to balance load becomes a simple matter "
1685 "of scripting."
1686 msgstr ""
1688 #. type: Content of: <book><preface><sect1><sect2><para>
1689 #: ../en/ch00-preface.xml:364
1690 msgid ""
1691 "If you have an employee in the field, troubleshooting a problem at a "
1692 "customer's site, they'll benefit from distributed revision control. The tool "
1693 "will let them generate custom builds, try different fixes in isolation from "
1694 "each other, and search efficiently through history for the sources of bugs "
1695 "and regressions in the customer's environment, all without needing to connect "
1696 "to your company's network."
1697 msgstr ""
1699 #. type: Content of: <book><preface><sect1><title>
1700 #: ../en/ch00-preface.xml:375
1701 msgid "Why choose Mercurial?"
1702 msgstr "为什么选择 Mercurial?"
1704 #. type: Content of: <book><preface><sect1><para>
1705 #: ../en/ch00-preface.xml:377
1706 msgid ""
1707 "Mercurial has a unique set of properties that make it a particularly good "
1708 "choice as a revision control system."
1709 msgstr ""
1711 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1712 #: ../en/ch00-preface.xml:380
1713 msgid "It is easy to learn and use."
1714 msgstr ""
1716 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1717 #: ../en/ch00-preface.xml:381
1718 msgid "It is lightweight."
1719 msgstr ""
1721 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1722 #: ../en/ch00-preface.xml:382
1723 msgid "It scales excellently."
1724 msgstr ""
1726 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1727 #: ../en/ch00-preface.xml:383
1728 msgid "It is easy to customise."
1729 msgstr ""
1731 #. type: Content of: <book><preface><sect1><para>
1732 #: ../en/ch00-preface.xml:386
1733 msgid ""
1734 "If you are at all familiar with revision control systems, you should be able "
1735 "to get up and running with Mercurial in less than five minutes. Even if not, "
1736 "it will take no more than a few minutes longer. Mercurial's command and "
1737 "feature sets are generally uniform and consistent, so you can keep track of a "
1738 "few general rules instead of a host of exceptions."
1739 msgstr ""
1741 #. type: Content of: <book><preface><sect1><para>
1742 #: ../en/ch00-preface.xml:393
1743 msgid ""
1744 "On a small project, you can start working with Mercurial in moments. Creating "
1745 "new changes and branches; transferring changes around (whether locally or "
1746 "over a network); and history and status operations are all fast. Mercurial "
1747 "attempts to stay nimble and largely out of your way by combining low "
1748 "cognitive overhead with blazingly fast operations."
1749 msgstr ""
1751 #. type: Content of: <book><preface><sect1><para>
1752 #: ../en/ch00-preface.xml:400
1753 msgid ""
1754 "The usefulness of Mercurial is not limited to small projects: it is used by "
1755 "projects with hundreds to thousands of contributors, each containing tens of "
1756 "thousands of files and hundreds of megabytes of source code."
1757 msgstr ""
1759 #. type: Content of: <book><preface><sect1><para>
1760 #: ../en/ch00-preface.xml:405
1761 msgid ""
1762 "If the core functionality of Mercurial is not enough for you, it's easy to "
1763 "build on. Mercurial is well suited to scripting tasks, and its clean "
1764 "internals and implementation in Python make it easy to add features in the "
1765 "form of extensions. There are a number of popular and useful extensions "
1766 "already available, ranging from helping to identify bugs to improving "
1767 "performance."
1768 msgstr ""
1770 #. type: Content of: <book><preface><sect1><title>
1771 #: ../en/ch00-preface.xml:415
1772 msgid "Mercurial compared with other tools"
1773 msgstr "Mercurial 与其它工具的比较"
1775 #. type: Content of: <book><preface><sect1><para>
1776 #: ../en/ch00-preface.xml:417
1777 msgid ""
1778 "Before you read on, please understand that this section necessarily reflects "
1779 "my own experiences, interests, and (dare I say it) biases. I have used every "
1780 "one of the revision control tools listed below, in most cases for several "
1781 "years at a time."
1782 msgstr ""
1784 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1785 #: ../en/ch00-preface.xml:425 ../en/ch00-preface.xml:636
1786 msgid "Subversion"
1787 msgstr ""
1789 #. type: Content of: <book><preface><sect1><sect2><para>
1790 #: ../en/ch00-preface.xml:427
1791 msgid ""
1792 "Subversion is a popular revision control tool, developed to replace CVS. It "
1793 "has a centralised client/server architecture."
1794 msgstr ""
1796 #. type: Content of: <book><preface><sect1><sect2><para>
1797 #: ../en/ch00-preface.xml:431
1798 msgid ""
1799 "Subversion and Mercurial have similarly named commands for performing the "
1800 "same operations, so if you're familiar with one, it is easy to learn to use "
1801 "the other. Both tools are portable to all popular operating systems."
1802 msgstr ""
1804 #. type: Content of: <book><preface><sect1><sect2><para>
1805 #: ../en/ch00-preface.xml:436
1806 msgid ""
1807 "Prior to version 1.5, Subversion had no useful support for merges. At the "
1808 "time of writing, its merge tracking capability is new, and known to be <ulink "
1809 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
1810 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
1811 msgstr ""
1813 #. type: Content of: <book><preface><sect1><sect2><para>
1814 #: ../en/ch00-preface.xml:442
1815 msgid ""
1816 "Mercurial has a substantial performance advantage over Subversion on every "
1817 "revision control operation I have benchmarked. I have measured its advantage "
1818 "as ranging from a factor of two to a factor of six when compared with "
1819 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
1820 "fastest access method available. In more realistic deployments involving a "
1821 "network-based store, Subversion will be at a substantially larger "
1822 "disadvantage. Because many Subversion commands must talk to the server and "
1823 "Subversion does not have useful replication facilities, server capacity and "
1824 "network bandwidth become bottlenecks for modestly large projects."
1825 msgstr ""
1827 #. type: Content of: <book><preface><sect1><sect2><para>
1828 #: ../en/ch00-preface.xml:455
1829 msgid ""
1830 "Additionally, Subversion incurs substantial storage overhead to avoid network "
1831 "transactions for a few common operations, such as finding modified files "
1832 "(<literal>status</literal>) and displaying modifications against the current "
1833 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
1834 "is often the same size as, or larger than, a Mercurial repository and working "
1835 "directory, even though the Mercurial repository contains a complete history "
1836 "of the project."
1837 msgstr ""
1839 #. type: Content of: <book><preface><sect1><sect2><para>
1840 #: ../en/ch00-preface.xml:465
1841 msgid ""
1842 "Subversion is widely supported by third party tools. Mercurial currently "
1843 "lags considerably in this area. This gap is closing, however, and indeed "
1844 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
1845 "Like Mercurial, Subversion has an excellent user manual."
1846 msgstr ""
1848 #. type: Content of: <book><preface><sect1><sect2><para>
1849 #: ../en/ch00-preface.xml:471
1850 msgid ""
1851 "Because Subversion doesn't store revision history on the client, it is well "
1852 "suited to managing projects that deal with lots of large, opaque binary "
1853 "files. If you check in fifty revisions to an incompressible 10MB file, "
1854 "Subversion's client-side space usage stays constant The space used by any "
1855 "distributed SCM will grow rapidly in proportion to the number of revisions, "
1856 "because the differences between each revision are large."
1857 msgstr ""
1859 #. type: Content of: <book><preface><sect1><sect2><para>
1860 #: ../en/ch00-preface.xml:480
1861 msgid ""
1862 "In addition, it's often difficult or, more usually, impossible to merge "
1863 "different versions of a binary file. Subversion's ability to let a user lock "
1864 "a file, so that they temporarily have the exclusive right to commit changes "
1865 "to it, can be a significant advantage to a project where binary files are "
1866 "widely used."
1867 msgstr ""
1869 #. type: Content of: <book><preface><sect1><sect2><para>
1870 #: ../en/ch00-preface.xml:487
1871 msgid ""
1872 "Mercurial can import revision history from a Subversion repository. It can "
1873 "also export revision history to a Subversion repository. This makes it easy "
1874 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
1875 "parallel before deciding to switch. History conversion is incremental, so "
1876 "you can perform an initial conversion, then small additional conversions "
1877 "afterwards to bring in new changes."
1878 msgstr ""
1880 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1881 #: ../en/ch00-preface.xml:499 ../en/ch00-preface.xml:638
1882 msgid "Git"
1883 msgstr "Git"
1885 #. type: Content of: <book><preface><sect1><sect2><para>
1886 #: ../en/ch00-preface.xml:501
1887 msgid ""
1888 "Git is a distributed revision control tool that was developed for managing "
1889 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
1890 "influenced by Monotone."
1891 msgstr ""
1893 #. type: Content of: <book><preface><sect1><sect2><para>
1894 #: ../en/ch00-preface.xml:506
1895 msgid ""
1896 "Git has a very large command set, with version 1.5.0 providing 139 individual "
1897 "commands. It has something of a reputation for being difficult to learn. "
1898 "Compared to Git, Mercurial has a strong focus on simplicity."
1899 msgstr ""
1901 #. type: Content of: <book><preface><sect1><sect2><para>
1902 #: ../en/ch00-preface.xml:511
1903 msgid ""
1904 "In terms of performance, Git is extremely fast. In several cases, it is "
1905 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
1906 "other operations. However, on Windows, the performance and general level of "
1907 "support that Git provides is, at the time of writing, far behind that of "
1908 "Mercurial."
1909 msgstr ""
1911 #. type: Content of: <book><preface><sect1><sect2><para>
1912 #: ../en/ch00-preface.xml:518
1913 msgid ""
1914 "While a Mercurial repository needs no maintenance, a Git repository requires "
1915 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
1916 "performance degrades, while space usage grows rapidly. A server that "
1917 "contains many Git repositories that are not rigorously and frequently "
1918 "repacked will become heavily disk-bound during backups, and there have been "
1919 "instances of daily backups taking far longer than 24 hours as a result. A "
1920 "freshly packed Git repository is slightly smaller than a Mercurial "
1921 "repository, but an unpacked repository is several orders of magnitude larger."
1922 msgstr ""
1924 #. type: Content of: <book><preface><sect1><sect2><para>
1925 #: ../en/ch00-preface.xml:529
1926 msgid ""
1927 "The core of Git is written in C. Many Git commands are implemented as shell "
1928 "or Perl scripts, and the quality of these scripts varies widely. I have "
1929 "encountered several instances where scripts charged along blindly in the "
1930 "presence of errors that should have been fatal."
1931 msgstr ""
1933 #. type: Content of: <book><preface><sect1><sect2><para>
1934 #: ../en/ch00-preface.xml:535
1935 msgid "Mercurial can import revision history from a Git repository."
1936 msgstr ""
1938 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
1939 #: ../en/ch00-preface.xml:541 ../en/ch00-preface.xml:637
1940 msgid "CVS"
1941 msgstr "CVS"
1943 #. type: Content of: <book><preface><sect1><sect2><para>
1944 #: ../en/ch00-preface.xml:543
1945 msgid ""
1946 "CVS is probably the most widely used revision control tool in the world. Due "
1947 "to its age and internal untidiness, it has been only lightly maintained for "
1948 "many years."
1949 msgstr ""
1951 #. type: Content of: <book><preface><sect1><sect2><para>
1952 #: ../en/ch00-preface.xml:547
1953 msgid ""
1954 "It has a centralised client/server architecture. It does not group related "
1955 "file changes into atomic commits, making it easy for people to <quote>break "
1956 "the build</quote>: one person can successfully commit part of a change and "
1957 "then be blocked by the need for a merge, causing other people to see only a "
1958 "portion of the work they intended to do. This also affects how you work with "
1959 "project history. If you want to see all of the modifications someone made as "
1960 "part of a task, you will need to manually inspect the descriptions and "
1961 "timestamps of the changes made to each file involved (if you even know what "
1962 "those files were)."
1963 msgstr ""
1965 #. type: Content of: <book><preface><sect1><sect2><para>
1966 #: ../en/ch00-preface.xml:559
1967 msgid ""
1968 "CVS has a muddled notion of tags and branches that I will not attempt to even "
1969 "describe. It does not support renaming of files or directories well, making "
1970 "it easy to corrupt a repository. It has almost no internal consistency "
1971 "checking capabilities, so it is usually not even possible to tell whether or "
1972 "how a repository is corrupt. I would not recommend CVS for any project, "
1973 "existing or new."
1974 msgstr ""
1976 #. type: Content of: <book><preface><sect1><sect2><para>
1977 #: ../en/ch00-preface.xml:567
1978 msgid ""
1979 "Mercurial can import CVS revision history. However, there are a few caveats "
1980 "that apply; these are true of every other revision control tool's CVS "
1981 "importer, too. Due to CVS's lack of atomic changes and unversioned "
1982 "filesystem hierarchy, it is not possible to reconstruct CVS history "
1983 "completely accurately; some guesswork is involved, and renames will usually "
1984 "not show up. Because a lot of advanced CVS administration has to be done by "
1985 "hand and is hence error-prone, it's common for CVS importers to run into "
1986 "multiple problems with corrupted repositories (completely bogus revision "
1987 "timestamps and files that have remained locked for over a decade are just two "
1988 "of the less interesting problems I can recall from personal experience)."
1989 msgstr ""
1991 #. type: Content of: <book><preface><sect1><sect2><para>
1992 #: ../en/ch00-preface.xml:581
1993 msgid "Mercurial can import revision history from a CVS repository."
1994 msgstr ""
1996 #. type: Content of: <book><preface><sect1><sect2><title>
1997 #: ../en/ch00-preface.xml:587
1998 msgid "Commercial tools"
1999 msgstr "商业工具"
2001 #. type: Content of: <book><preface><sect1><sect2><para>
2002 #: ../en/ch00-preface.xml:589
2003 msgid ""
2004 "Perforce has a centralised client/server architecture, with no client-side "
2005 "caching of any data. Unlike modern revision control tools, Perforce requires "
2006 "that a user run a command to inform the server about every file they intend "
2007 "to edit."
2008 msgstr ""
2010 #. type: Content of: <book><preface><sect1><sect2><para>
2011 #: ../en/ch00-preface.xml:595
2012 msgid ""
2013 "The performance of Perforce is quite good for small teams, but it falls off "
2014 "rapidly as the number of users grows beyond a few dozen. Modestly large "
2015 "Perforce installations require the deployment of proxies to cope with the "
2016 "load their users generate."
2017 msgstr ""
2019 #. type: Content of: <book><preface><sect1><sect2><title>
2020 #: ../en/ch00-preface.xml:604
2021 msgid "Choosing a revision control tool"
2022 msgstr "选择版本控制工具"
2024 #. type: Content of: <book><preface><sect1><sect2><para>
2025 #: ../en/ch00-preface.xml:606
2026 msgid ""
2027 "With the exception of CVS, all of the tools listed above have unique "
2028 "strengths that suit them to particular styles of work. There is no single "
2029 "revision control tool that is best in all situations."
2030 msgstr ""
2032 #. type: Content of: <book><preface><sect1><sect2><para>
2033 #: ../en/ch00-preface.xml:611
2034 msgid ""
2035 "As an example, Subversion is a good choice for working with frequently edited "
2036 "binary files, due to its centralised nature and support for file locking."
2037 msgstr ""
2039 #. type: Content of: <book><preface><sect1><sect2><para>
2040 #: ../en/ch00-preface.xml:615
2041 msgid ""
2042 "I personally find Mercurial's properties of simplicity, performance, and good "
2043 "merge support to be a compelling combination that has served me well for "
2044 "several years."
2045 msgstr ""
2047 #. type: Content of: <book><preface><sect1><title>
2048 #: ../en/ch00-preface.xml:623
2049 msgid "Switching from another tool to Mercurial"
2050 msgstr "从其它工具切换到 Mercurial"
2052 #. type: Content of: <book><preface><sect1><para>
2053 #: ../en/ch00-preface.xml:625
2054 msgid ""
2055 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
2056 "\">convert</literal>, which can incrementally import revision history from "
2057 "several other revision control tools. By <quote>incremental</quote>, I mean "
2058 "that you can convert all of a project's history to date in one go, then rerun "
2059 "the conversion later to obtain new changes that happened after the initial "
2060 "conversion."
2061 msgstr ""
2063 #. type: Content of: <book><preface><sect1><para>
2064 #: ../en/ch00-preface.xml:633
2065 msgid ""
2066 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
2067 "literal> are as follows:"
2068 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
2070 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
2071 #: ../en/ch00-preface.xml:639
2072 msgid "Darcs"
2073 msgstr "Darcs"
2075 #. type: Content of: <book><preface><sect1><para>
2076 #: ../en/ch00-preface.xml:641
2077 msgid ""
2078 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
2079 "from Mercurial to Subversion. This makes it possible to try Subversion and "
2080 "Mercurial in parallel before committing to a switchover, without risking the "
2081 "loss of any work."
2082 msgstr ""
2084 #. type: Content of: <book><preface><sect1><para>
2085 #: ../en/ch00-preface.xml:647
2086 msgid ""
2087 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
2088 "use. Simply point it at the path or URL of the source repository, optionally "
2089 "give it the name of the destination repository, and it will start working. "
2090 "After the initial conversion, just run the same command again to import new "
2091 "changes."
2092 msgstr ""
2094 #. type: Content of: <book><preface><sect1><title>
2095 #: ../en/ch00-preface.xml:656
2096 msgid "A short history of revision control"
2097 msgstr "版本控制简史"
2099 #. type: Content of: <book><preface><sect1><para>
2100 #: ../en/ch00-preface.xml:658
2101 msgid ""
2102 "The best known of the old-time revision control tools is SCCS (Source Code "
2103 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
2104 "SCCS operated on individual files, and required every person working on a "
2105 "project to have access to a shared workspace on a single system. Only one "
2106 "person could modify a file at any time; arbitration for access to files was "
2107 "via locks. It was common for people to lock files, and later forget to "
2108 "unlock them, preventing anyone else from modifying those files without the "
2109 "help of an administrator."
2110 msgstr ""
2112 #. type: Content of: <book><preface><sect1><para>
2113 #: ../en/ch00-preface.xml:669
2114 msgid ""
2115 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
2116 "called his program RCS (Revision Control System). Like SCCS, RCS required "
2117 "developers to work in a single shared workspace, and to lock files to prevent "
2118 "multiple people from modifying them simultaneously."
2119 msgstr ""
2121 #. type: Content of: <book><preface><sect1><para>
2122 #: ../en/ch00-preface.xml:675
2123 msgid ""
2124 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
2125 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
2126 "Versions System). The big innovation of CVS was that it let developers work "
2127 "simultaneously and somewhat independently in their own personal workspaces. "
2128 "The personal workspaces prevented developers from stepping on each other's "
2129 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
2130 "of every project file, and could modify their copies independently. They had "
2131 "to merge their edits prior to committing changes to the central repository."
2132 msgstr ""
2134 #. type: Content of: <book><preface><sect1><para>
2135 #: ../en/ch00-preface.xml:686
2136 msgid ""
2137 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
2138 "in 1989 the code that has since developed into the modern version of CVS. "
2139 "CVS subsequently acquired the ability to operate over a network connection, "
2140 "giving it a client/server architecture. CVS's architecture is centralised; "
2141 "only the server has a copy of the history of the project. Client workspaces "
2142 "just contain copies of recent versions of the project's files, and a little "
2143 "metadata to tell them where the server is. CVS has been enormously "
2144 "successful; it is probably the world's most widely used revision control "
2145 "system."
2146 msgstr ""
2148 #. type: Content of: <book><preface><sect1><para>
2149 #: ../en/ch00-preface.xml:697
2150 msgid ""
2151 "In the early 1990s, Sun Microsystems developed an early distributed revision "
2152 "control system, called TeamWare. A TeamWare workspace contains a complete "
2153 "copy of the project's history. TeamWare has no notion of a central "
2154 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
2155 "SCCS.)"
2156 msgstr ""
2158 #. type: Content of: <book><preface><sect1><para>
2159 #: ../en/ch00-preface.xml:704
2160 msgid ""
2161 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
2162 "records simultaneous changes to multiple files individually, instead of "
2163 "grouping them together as a single logically atomic operation. It does not "
2164 "manage its file hierarchy well; it is easy to make a mess of a repository by "
2165 "renaming files and directories. Worse, its source code is difficult to read "
2166 "and maintain, which made the <quote>pain level</quote> of fixing these "
2167 "architectural problems prohibitive."
2168 msgstr ""
2170 #. type: Content of: <book><preface><sect1><para>
2171 #: ../en/ch00-preface.xml:714
2172 msgid ""
2173 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
2174 "started a project to replace it with a tool that would have a better "
2175 "architecture and cleaner code. The result, Subversion, does not stray from "
2176 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
2177 "better namespace management, and a number of other features that make it a "
2178 "generally better tool than CVS. Since its initial release, it has rapidly "
2179 "grown in popularity."
2180 msgstr ""
2182 #. type: Content of: <book><preface><sect1><para>
2183 #: ../en/ch00-preface.xml:723
2184 msgid ""
2185 "More or less simultaneously, Graydon Hoare began working on an ambitious "
2186 "distributed revision control system that he named Monotone. While Monotone "
2187 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
2188 "goes beyond earlier (and subsequent) revision control tools in a number of "
2189 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
2190 "integral notion of <quote>trust</quote> for code from different sources."
2191 msgstr ""
2193 #. type: Content of: <book><preface><sect1><para>
2194 #: ../en/ch00-preface.xml:732
2195 msgid ""
2196 "Mercurial began life in 2005. While a few aspects of its design are "
2197 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
2198 "and scalability to very large projects."
2199 msgstr ""
2201 #. type: Content of: <book><preface><sect1><title>
2202 #: ../en/ch00-preface.xml:740
2203 msgid "Colophon&emdash;this book is Free"
2204 msgstr "后记—本书是自由的!"
2206 #. type: Content of: <book><preface><sect1><para>
2207 #: ../en/ch00-preface.xml:742
2208 msgid ""
2209 "This book is licensed under the Open Publication License, and is produced "
2210 "entirely using Free Software tools. It is typeset with DocBook XML. "
2211 "Illustrations are drawn and rendered with <ulink url=\"http://www.inkscape."
2212 "org/\">Inkscape</ulink>."
2213 msgstr ""
2215 #. type: Content of: <book><preface><sect1><para>
2216 #: ../en/ch00-preface.xml:747
2217 msgid ""
2218 "The complete source code for this book is published as a Mercurial "
2219 "repository, at <ulink url=\"http://hg.serpentine.com/mercurial/book\">http://"
2220 "hg.serpentine.com/mercurial/book</ulink>."
2221 msgstr ""
2223 #. type: Content of: <book><chapter><title>
2224 #: ../en/ch01-tour-basic.xml:5
2225 msgid "A tour of Mercurial: the basics"
2226 msgstr "Mercurial 教程: 基础知识"
2228 #. type: Content of: <book><chapter><sect1><title>
2229 #: ../en/ch01-tour-basic.xml:8
2230 msgid "Installing Mercurial on your system"
2231 msgstr "安装 Mercurial"
2233 #. type: Content of: <book><chapter><sect1><para>
2234 #: ../en/ch01-tour-basic.xml:10
2235 msgid ""
2236 "Prebuilt binary packages of Mercurial are available for every popular "
2237 "operating system. These make it easy to start using Mercurial on your "
2238 "computer immediately."
2239 msgstr ""
2240 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
2241 "用 Mercurial 变得很容易。"
2243 #. type: Content of: <book><chapter><sect1><sect2><title>
2244 #: ../en/ch01-tour-basic.xml:15
2245 msgid "Windows"
2246 msgstr "Windows"
2248 #. type: Content of: <book><chapter><sect1><sect2><para>
2249 #: ../en/ch01-tour-basic.xml:17
2250 msgid ""
2251 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
2252 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
2253 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
2254 "external dependencies; it <quote>just works</quote>. It provides both "
2255 "command line and graphical user interfaces."
2256 msgstr ""
2258 #. type: Content of: <book><chapter><sect1><sect2><title>
2259 #: ../en/ch01-tour-basic.xml:27
2260 msgid "Mac OS X"
2261 msgstr "Mac OS X"
2263 #. type: Content of: <book><chapter><sect1><sect2><para>
2264 #: ../en/ch01-tour-basic.xml:29
2265 msgid ""
2266 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
2267 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
2268 msgstr ""
2270 #. type: Content of: <book><chapter><sect1><sect2><title>
2271 #: ../en/ch01-tour-basic.xml:35
2272 msgid "Linux"
2273 msgstr "Linux"
2275 #. type: Content of: <book><chapter><sect1><sect2><para>
2276 #: ../en/ch01-tour-basic.xml:37
2277 msgid ""
2278 "Because each Linux distribution has its own packaging tools, policies, and "
2279 "rate of development, it's difficult to give a comprehensive set of "
2280 "instructions on how to install Mercurial binaries. The version of Mercurial "
2281 "that you will end up with can vary depending on how active the person is who "
2282 "maintains the package for your distribution."
2283 msgstr ""
2284 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
2285 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
2286 "使用的发行版的 Mercurial 维护者的活跃程度。"
2288 #. type: Content of: <book><chapter><sect1><sect2><para>
2289 #: ../en/ch01-tour-basic.xml:44
2290 msgid ""
2291 "To keep things simple, I will focus on installing Mercurial from the command "
2292 "line under the most popular Linux distributions. Most of these distributions "
2293 "provide graphical package managers that will let you install Mercurial with a "
2294 "single click; the package name to look for is <literal>mercurial</literal>."
2295 msgstr ""
2296 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
2297 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
2298 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
2300 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2301 #: ../en/ch01-tour-basic.xml:52
2302 msgid "Ubuntu and Debian:"
2303 msgstr "Ubuntu 与 Debian:"
2305 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2306 #: ../en/ch01-tour-basic.xml:54
2307 msgid "Fedora and OpenSUSE:"
2308 msgstr "Fedora and OpenSUSE:"
2310 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2311 #: ../en/ch01-tour-basic.xml:56
2312 msgid "Gentoo:"
2313 msgstr "Gentoo:"
2315 #. type: Content of: <book><chapter><sect1><sect2><title>
2316 #: ../en/ch01-tour-basic.xml:62
2317 msgid "Solaris"
2318 msgstr "Solaris"
2320 #. type: Content of: <book><chapter><sect1><sect2><para>
2321 #: ../en/ch01-tour-basic.xml:64
2322 msgid ""
2323 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
2324 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
2325 msgstr ""
2326 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
2327 "ulink> 的 SunFreeWare 提供了 Mercurial 的二进制安装包。"
2329 #. type: Content of: <book><chapter><sect1><title>
2330 #: ../en/ch01-tour-basic.xml:73
2331 msgid "Getting started"
2332 msgstr "开始"
2334 #. type: Content of: <book><chapter><sect1><para>
2335 #: ../en/ch01-tour-basic.xml:75
2336 msgid ""
2337 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
2338 "to find out whether Mercurial is actually installed properly. The actual "
2339 "version information that it prints isn't so important; it's whether it prints "
2340 "anything at all that we care about."
2341 msgstr ""
2343 #. type: Content of: <book><chapter><sect1><sect2><title>
2344 #: ../en/ch01-tour-basic.xml:84
2345 msgid "Built-in help"
2346 msgstr "内置帮助"
2348 #. type: Content of: <book><chapter><sect1><sect2><para>
2349 #: ../en/ch01-tour-basic.xml:86
2350 msgid ""
2351 "Mercurial provides a built-in help system. This is invaluable for those "
2352 "times when you find yourself stuck trying to remember how to run a command. "
2353 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
2354 "command>; it will print a brief list of commands, along with a description of "
2355 "what each does. If you ask for help on a specific command (as below), it "
2356 "prints more detailed information."
2357 msgstr ""
2359 #. type: Content of: <book><chapter><sect1><sect2><para>
2360 #: ../en/ch01-tour-basic.xml:97
2361 msgid ""
2362 "For a more impressive level of detail (which you won't usually need) run "
2363 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
2364 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
2365 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
2366 "print more information than it usually would."
2367 msgstr ""
2369 #. type: Content of: <book><chapter><sect1><title>
2370 #: ../en/ch01-tour-basic.xml:108
2371 msgid "Working with a repository"
2372 msgstr "使用版本库"
2374 #. type: Content of: <book><chapter><sect1><para>
2375 #: ../en/ch01-tour-basic.xml:110
2376 msgid ""
2377 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
2378 "The repository for a project contains all of the files that <quote>belong to</"
2379 "quote> that project, along with a historical record of the project's files."
2380 msgstr ""
2382 #. type: Content of: <book><chapter><sect1><para>
2383 #: ../en/ch01-tour-basic.xml:116
2384 msgid ""
2385 "There's nothing particularly magical about a repository; it is simply a "
2386 "directory tree in your filesystem that Mercurial treats as special. You can "
2387 "rename or delete a repository any time you like, using either the command "
2388 "line or your file browser."
2389 msgstr ""
2391 #. type: Content of: <book><chapter><sect1><sect2><title>
2392 #: ../en/ch01-tour-basic.xml:123
2393 msgid "Making a local copy of a repository"
2394 msgstr "创建版本库的工作副本"
2396 #. type: Content of: <book><chapter><sect1><sect2><para>
2397 #: ../en/ch01-tour-basic.xml:125
2398 msgid ""
2399 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
2400 "While you could use a normal file copying command to make a copy of a "
2401 "repository, it's best to use a built-in command that Mercurial provides. "
2402 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
2403 "it makes an identical copy of an existing repository."
2404 msgstr ""
2406 #. type: Content of: <book><chapter><sect1><sect2><para>
2407 #: ../en/ch01-tour-basic.xml:134
2408 msgid ""
2409 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
2410 "as we can see above, it lets us clone repositories over the network. Another "
2411 "is that it remembers where we cloned from, which we'll find useful soon when "
2412 "we want to fetch new changes from another repository."
2413 msgstr ""
2415 #. type: Content of: <book><chapter><sect1><sect2><para>
2416 #: ../en/ch01-tour-basic.xml:140
2417 msgid ""
2418 "If our clone succeeded, we should now have a local directory called <filename "
2419 "class=\"directory\">hello</filename>. This directory will contain some files."
2420 msgstr ""
2422 #. type: Content of: <book><chapter><sect1><sect2><para>
2423 #: ../en/ch01-tour-basic.xml:146
2424 msgid ""
2425 "These files have the same contents and history in our repository as they do "
2426 "in the repository we cloned."
2427 msgstr ""
2429 #. type: Content of: <book><chapter><sect1><sect2><para>
2430 #: ../en/ch01-tour-basic.xml:149
2431 msgid ""
2432 "Every Mercurial repository is complete, self-contained, and independent. It "
2433 "contains its own private copy of a project's files and history. As we just "
2434 "mentioned, a cloned repository remembers the location of the repository it "
2435 "was cloned from, but Mercurial will not communicate with that repository, or "
2436 "any other, unless you tell it to."
2437 msgstr ""
2439 #. type: Content of: <book><chapter><sect1><sect2><para>
2440 #: ../en/ch01-tour-basic.xml:156
2441 msgid ""
2442 "What this means for now is that we're free to experiment with our repository, "
2443 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
2444 "affect anyone else."
2445 msgstr ""
2447 #. type: Content of: <book><chapter><sect1><sect2><title>
2448 #: ../en/ch01-tour-basic.xml:162
2449 msgid "What's in a repository?"
2450 msgstr "什么是版本库?"
2452 #. type: Content of: <book><chapter><sect1><sect2><para>
2453 #: ../en/ch01-tour-basic.xml:164
2454 msgid ""
2455 "When we take a more detailed look inside a repository, we can see that it "
2456 "contains a directory named <filename class=\"directory\">.hg</filename>. "
2457 "This is where Mercurial keeps all of its metadata for the repository."
2458 msgstr ""
2460 #. type: Content of: <book><chapter><sect1><sect2><para>
2461 #: ../en/ch01-tour-basic.xml:171
2462 msgid ""
2463 "The contents of the <filename class=\"directory\">.hg</filename> directory "
2464 "and its subdirectories are private to Mercurial. Every other file and "
2465 "directory in the repository is yours to do with as you please."
2466 msgstr ""
2468 #. type: Content of: <book><chapter><sect1><sect2><para>
2469 #: ../en/ch01-tour-basic.xml:177
2470 msgid ""
2471 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
2472 "filename> directory is the <quote>real</quote> repository, and all of the "
2473 "files and directories that coexist with it are said to live in the "
2474 "<emphasis>working directory</emphasis>. An easy way to remember the "
2475 "distinction is that the <emphasis>repository</emphasis> contains the "
2476 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
2477 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
2478 "at a particular point in history."
2479 msgstr ""
2481 #. type: Content of: <book><chapter><sect1><title>
2482 #: ../en/ch01-tour-basic.xml:192
2483 msgid "A tour through history"
2484 msgstr "回溯历史"
2486 #. type: Content of: <book><chapter><sect1><para>
2487 #: ../en/ch01-tour-basic.xml:194
2488 msgid ""
2489 "One of the first things we might want to do with a new, unfamiliar repository "
2490 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
2491 "command gives us a view of the history of changes in the repository."
2492 msgstr ""
2494 #. type: Content of: <book><chapter><sect1><para>
2495 #: ../en/ch01-tour-basic.xml:201
2496 msgid ""
2497 "By default, this command prints a brief paragraph of output for each change "
2498 "to the project that was recorded. In Mercurial terminology, we call each of "
2499 "these recorded events a <emphasis>changeset</emphasis>, because it can "
2500 "contain a record of changes to several files."
2501 msgstr ""
2503 #. type: Content of: <book><chapter><sect1><para>
2504 #: ../en/ch01-tour-basic.xml:207
2505 msgid ""
2506 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
2507 "command> are as follows."
2508 msgstr ""
2510 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2511 #: ../en/ch01-tour-basic.xml:211
2512 msgid ""
2513 "<literal>changeset</literal>: This field has the format of a number, followed "
2514 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
2515 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
2516 "is a unique identifier: the same hex string will always refer to the same "
2517 "changeset. The number is shorter and easier to type than the hex string, but "
2518 "it isn't unique: the same number in two different clones of a repository may "
2519 "identify different changesets. Why provide the number at all, then? For "
2520 "local convenience."
2521 msgstr ""
2523 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2524 #: ../en/ch01-tour-basic.xml:223
2525 msgid ""
2526 "<literal>user</literal>: The identity of the person who created the "
2527 "changeset. This is a free-form field, but it most often contains a person's "
2528 "name and email address."
2529 msgstr ""
2531 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2532 #: ../en/ch01-tour-basic.xml:227
2533 msgid ""
2534 "<literal>date</literal>: The date and time on which the changeset was "
2535 "created, and the timezone in which it was created. (The date and time are "
2536 "local to that timezone; they display what time and date it was for the person "
2537 "who created the changeset.)"
2538 msgstr ""
2540 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2541 #: ../en/ch01-tour-basic.xml:232
2542 msgid ""
2543 "<literal>summary</literal>: The first line of the text message that the "
2544 "creator of the changeset entered to describe the changeset."
2545 msgstr ""
2547 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2548 #: ../en/ch01-tour-basic.xml:236
2549 msgid ""
2550 "Some changesets, such as the first in the list above, have a <literal>tag</"
2551 "literal> field. A tag is another way to identify a changeset, by giving it "
2552 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
2553 "it always refers to the newest change in a repository.)"
2554 msgstr ""
2556 #. type: Content of: <book><chapter><sect1><para>
2557 #: ../en/ch01-tour-basic.xml:244
2558 msgid ""
2559 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
2560 "purely a summary; it is missing a lot of detail."
2561 msgstr ""
2563 #. type: Content of: <book><chapter><sect1><para>
2564 #: ../en/ch01-tour-basic.xml:248
2565 msgid ""
2566 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
2567 "representation of the history of the <filename class=\"directory\">hello</"
2568 "filename> repository, to make it a little easier to see which direction "
2569 "history is <quote>flowing</quote> in. We'll be returning to this figure "
2570 "several times in this chapter and the chapter that follows."
2571 msgstr ""
2573 #. type: Content of: <book><chapter><sect1><figure><title>
2574 #: ../en/ch01-tour-basic.xml:257
2575 msgid ""
2576 "Graphical history of the <filename class=\"directory\">hello</filename> "
2577 "repository"
2578 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
2580 #. type: Content of: <book><chapter><sect1><figure>
2581 #: ../en/ch01-tour-basic.xml:259 ../en/ch02-tour-merge.xml:50
2582 #: ../en/ch02-tour-merge.xml:181 ../en/ch03-concepts.xml:293
2583 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
2584 msgstr ""
2586 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
2587 #: ../en/ch01-tour-basic.xml:260
2588 msgid ""
2589 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
2590 msgstr ""
2592 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
2593 #: ../en/ch01-tour-basic.xml:261 ../en/ch02-tour-merge.xml:52
2594 #: ../en/ch02-tour-merge.xml:82 ../en/ch02-tour-merge.xml:129
2595 #: ../en/ch02-tour-merge.xml:183 ../en/ch02-tour-merge.xml:254
2596 #: ../en/ch03-concepts.xml:57 ../en/ch03-concepts.xml:106
2597 #: ../en/ch03-concepts.xml:191 ../en/ch03-concepts.xml:295
2598 #: ../en/ch03-concepts.xml:346 ../en/ch03-concepts.xml:361
2599 #: ../en/ch03-concepts.xml:402 ../en/ch03-concepts.xml:422
2600 #: ../en/ch03-concepts.xml:465 ../en/ch05-collab.xml:276
2601 #: ../en/ch08-undo.xml:365 ../en/ch08-undo.xml:412 ../en/ch08-undo.xml:477
2602 #: ../en/ch08-undo.xml:515 ../en/ch11-mq.xml:412
2603 msgid "XXX add text"
2604 msgstr ""
2606 #. type: Content of: <book><chapter><sect1><sect2><title>
2607 #: ../en/ch01-tour-basic.xml:266
2608 msgid "Changesets, revisions, and talking to other people"
2609 msgstr "修改集,版本,与其它用户交互"
2611 #. type: Content of: <book><chapter><sect1><sect2><para>
2612 #: ../en/ch01-tour-basic.xml:269
2613 msgid ""
2614 "As English is a notoriously sloppy language, and computer science has a "
2615 "hallowed history of terminological confusion (why use one term when four will "
2616 "do?), revision control has a variety of words and phrases that mean the same "
2617 "thing. If you are talking about Mercurial history with other people, you "
2618 "will find that the word <quote>changeset</quote> is often compressed to "
2619 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
2620 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
2621 msgstr ""
2623 #. type: Content of: <book><chapter><sect1><sect2><para>
2624 #: ../en/ch01-tour-basic.xml:279
2625 msgid ""
2626 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
2627 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
2628 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
2629 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
2630 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
2631 "identifies a changeset using both a number and a hexadecimal string."
2632 msgstr ""
2634 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2635 #: ../en/ch01-tour-basic.xml:288
2636 msgid ""
2637 "The revision number is a handy notation that is <emphasis>only valid in that "
2638 "repository</emphasis>."
2639 msgstr ""
2641 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
2642 #: ../en/ch01-tour-basic.xml:291
2643 msgid ""
2644 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
2645 "emphasis> that will always identify that exact changeset in <emphasis>every</"
2646 "emphasis> copy of the repository."
2647 msgstr ""
2649 #. type: Content of: <book><chapter><sect1><sect2><para>
2650 #: ../en/ch01-tour-basic.xml:297
2651 msgid ""
2652 "This distinction is important. If you send someone an email talking about "
2653 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
2654 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
2655 "that a revision number depends on the order in which changes arrived in a "
2656 "repository, and there is no guarantee that the same changes will happen in "
2657 "the same order in different repositories. Three changes <literal>a,b,c</"
2658 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
2659 "while in another as <literal>0,2,1</literal>."
2660 msgstr ""
2662 #. type: Content of: <book><chapter><sect1><sect2><para>
2663 #: ../en/ch01-tour-basic.xml:309
2664 msgid ""
2665 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
2666 "need to discuss a changeset with someone, or make a record of a changeset for "
2667 "some other reason (for example, in a bug report), use the hexadecimal "
2668 "identifier."
2669 msgstr ""
2671 #. type: Content of: <book><chapter><sect1><sect2><title>
2672 #: ../en/ch01-tour-basic.xml:317
2673 msgid "Viewing specific revisions"
2674 msgstr "察看指定版本"
2676 #. type: Content of: <book><chapter><sect1><sect2><para>
2677 #: ../en/ch01-tour-basic.xml:319
2678 msgid ""
2679 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
2680 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
2681 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
2682 "number or a hexadecimal identifier, and you can provide as many revisions as "
2683 "you want."
2684 msgstr ""
2686 #. type: Content of: <book><chapter><sect1><sect2><para>
2687 #: ../en/ch01-tour-basic.xml:328
2688 msgid ""
2689 "If you want to see the history of several revisions without having to list "
2690 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
2691 "express the idea <quote>I want all revisions between <literal>abc</literal> "
2692 "and <literal>def</literal>, inclusive</quote>."
2693 msgstr ""
2695 #. type: Content of: <book><chapter><sect1><sect2><para>
2696 #: ../en/ch01-tour-basic.xml:336
2697 msgid ""
2698 "Mercurial also honours the order in which you specify revisions, so <command "
2699 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
2700 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
2701 msgstr ""
2703 #. type: Content of: <book><chapter><sect1><sect2><title>
2704 #: ../en/ch01-tour-basic.xml:343
2705 msgid "More detailed information"
2706 msgstr "更详细的信息"
2708 #. type: Content of: <book><chapter><sect1><sect2><para>
2709 #: ../en/ch01-tour-basic.xml:345
2710 msgid ""
2711 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
2712 "command> is useful if you already know what you're looking for, you may need "
2713 "to see a complete description of the change, or a list of the files changed, "
2714 "if you're trying to decide whether a changeset is the one you're looking for. "
2715 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
2716 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
2717 "option gives you this extra detail."
2718 msgstr ""
2720 #. type: Content of: <book><chapter><sect1><sect2><para>
2721 #: ../en/ch01-tour-basic.xml:357
2722 msgid ""
2723 "If you want to see both the description and content of a change, add the "
2724 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
2725 "patch</option>) option. This displays the content of a change as a "
2726 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
2727 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
2728 msgstr ""
2730 #. type: Content of: <book><chapter><sect1><sect2><para>
2731 #: ../en/ch01-tour-basic.xml:367
2732 msgid ""
2733 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
2734 "it's well worth remembering."
2735 msgstr ""
2737 #. type: Content of: <book><chapter><sect1><title>
2738 #: ../en/ch01-tour-basic.xml:374
2739 msgid "All about command options"
2740 msgstr "命令选项"
2742 #. type: Content of: <book><chapter><sect1><para>
2743 #: ../en/ch01-tour-basic.xml:376
2744 msgid ""
2745 "Let's take a brief break from exploring Mercurial commands to discuss a "
2746 "pattern in the way that they work; you may find this useful to keep in mind "
2747 "as we continue our tour."
2748 msgstr ""
2750 #. type: Content of: <book><chapter><sect1><para>
2751 #: ../en/ch01-tour-basic.xml:380
2752 msgid ""
2753 "Mercurial has a consistent and straightforward approach to dealing with the "
2754 "options that you can pass to commands. It follows the conventions for "
2755 "options that are common to modern Linux and Unix systems."
2756 msgstr ""
2758 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2759 #: ../en/ch01-tour-basic.xml:387
2760 msgid ""
2761 "Every option has a long name. For example, as we've already seen, the "
2762 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
2763 "opt-log\">--rev</option> option."
2764 msgstr ""
2766 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2767 #: ../en/ch01-tour-basic.xml:393
2768 msgid ""
2769 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
2770 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
2771 "reason that some options don't have short names is that the options in "
2772 "question are rarely used.)"
2773 msgstr ""
2775 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2776 #: ../en/ch01-tour-basic.xml:400
2777 msgid ""
2778 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
2779 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
2780 "\">-r</option>)."
2781 msgstr ""
2783 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2784 #: ../en/ch01-tour-basic.xml:406
2785 msgid ""
2786 "Option naming and usage is consistent across commands. For example, every "
2787 "command that lets you specify a changeset ID or revision number accepts both "
2788 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
2789 "rev</option> arguments."
2790 msgstr ""
2792 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
2793 #: ../en/ch01-tour-basic.xml:413
2794 msgid ""
2795 "If you are using short options, you can save typing by running them together. "
2796 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
2797 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
2798 msgstr ""
2800 #. type: Content of: <book><chapter><sect1><para>
2801 #: ../en/ch01-tour-basic.xml:420
2802 msgid ""
2803 "In the examples throughout this book, I use short options instead of long. "
2804 "This just reflects my own preference, so don't read anything significant into "
2805 "it."
2806 msgstr ""
2808 #. type: Content of: <book><chapter><sect1><para>
2809 #: ../en/ch01-tour-basic.xml:424
2810 msgid ""
2811 "Most commands that print output of some kind will print more output when "
2812 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
2813 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
2814 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
2815 msgstr ""
2817 #. type: Content of: <book><chapter><sect1><note><title>
2818 #: ../en/ch01-tour-basic.xml:431
2819 msgid "Option naming consistency"
2820 msgstr ""
2822 #. type: Content of: <book><chapter><sect1><note><para>
2823 #: ../en/ch01-tour-basic.xml:433
2824 msgid ""
2825 "Almost always, Mercurial commands use consistent option names to refer to the "
2826 "same concepts. For instance, if a command deals with changesets, you'll "
2827 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
2828 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
2829 "makes it easier to remember what options a particular command takes."
2830 msgstr ""
2832 #. type: Content of: <book><chapter><sect1><title>
2833 #: ../en/ch01-tour-basic.xml:444
2834 msgid "Making and reviewing changes"
2835 msgstr "创建和复审修改"
2837 #. type: Content of: <book><chapter><sect1><para>
2838 #: ../en/ch01-tour-basic.xml:446
2839 msgid ""
2840 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
2841 "at making some changes and examining them."
2842 msgstr ""
2844 #. type: Content of: <book><chapter><sect1><para>
2845 #: ../en/ch01-tour-basic.xml:450
2846 msgid ""
2847 "The first thing we'll do is isolate our experiment in a repository of its "
2848 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
2849 "don't need to clone a copy of the remote repository. Since we already have a "
2850 "copy of it locally, we can just clone that instead. This is much faster than "
2851 "cloning over the network, and cloning a local repository uses less disk space "
2852 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
2853 msgstr ""
2855 #. type: Content of: <book><chapter><sect1><para><footnote><para>
2856 #: ../en/ch01-tour-basic.xml:457
2857 msgid ""
2858 "The saving of space arises when source and destination repositories are on "
2859 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
2860 "write sharing of its internal metadata. If that explanation meant nothing to "
2861 "you, don't worry: everything happens transparently and automatically, and you "
2862 "don't need to understand it."
2863 msgstr ""
2865 #. type: Content of: <book><chapter><sect1><para>
2866 #: ../en/ch01-tour-basic.xml:467
2867 msgid ""
2868 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
2869 "of a remote repository around, which you can then make temporary clones of to "
2870 "create sandboxes for each task you want to work on. This lets you work on "
2871 "multiple tasks in parallel, each isolated from the others until it's complete "
2872 "and you're ready to integrate it back. Because local clones are so cheap, "
2873 "there's almost no overhead to cloning and destroying repositories whenever "
2874 "you want."
2875 msgstr ""
2877 #. type: Content of: <book><chapter><sect1><para>
2878 #: ../en/ch01-tour-basic.xml:476
2879 msgid ""
2880 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
2881 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
2882 "world</quote> program."
2883 msgstr ""
2885 #. type: Content of: <book><chapter><sect1><para>
2886 #: ../en/ch01-tour-basic.xml:482
2887 msgid "Let's edit this file so that it prints a second line of output."
2888 msgstr ""
2890 #. type: Content of: <book><chapter><sect1><para>
2891 #: ../en/ch01-tour-basic.xml:487
2892 msgid ""
2893 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
2894 "what Mercurial knows about the files in the repository."
2895 msgstr ""
2897 #. type: Content of: <book><chapter><sect1><para>
2898 #: ../en/ch01-tour-basic.xml:493
2899 msgid ""
2900 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
2901 "some files, but a line starting with <quote><literal>M</literal></quote> for "
2902 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
2903 "\">hg status</command> will not print any output for files that have not been "
2904 "modified."
2905 msgstr ""
2907 #. type: Content of: <book><chapter><sect1><para>
2908 #: ../en/ch01-tour-basic.xml:500
2909 msgid ""
2910 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
2911 "that we modified <filename>hello.c</filename>. We didn't need to "
2912 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
2913 "before we started, or that we had modified the file after we were done; it "
2914 "was able to figure this out itself."
2915 msgstr ""
2917 #. type: Content of: <book><chapter><sect1><para>
2918 #: ../en/ch01-tour-basic.xml:508
2919 msgid ""
2920 "It's somewhat helpful to know that we've modified <filename>hello.c</"
2921 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
2922 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
2923 "diff</command> command."
2924 msgstr ""
2926 #. type: Content of: <book><chapter><sect1><title>
2927 #: ../en/ch01-tour-basic.xml:517 ../en/ch11-mq.xml:187
2928 msgid "Understanding patches"
2929 msgstr "理解补丁"
2931 #. type: Content of: <book><chapter><sect1><tip><para>
2932 #: ../en/ch01-tour-basic.xml:519
2933 msgid ""
2934 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
2935 "how to read output above."
2936 msgstr ""
2938 #. type: Content of: <book><chapter><sect1><title>
2939 #: ../en/ch01-tour-basic.xml:525
2940 msgid "Recording changes in a new changeset"
2941 msgstr "在新修改集中记录修改"
2943 #. type: Content of: <book><chapter><sect1><para>
2944 #: ../en/ch01-tour-basic.xml:527
2945 msgid ""
2946 "We can modify files, build and test our changes, and use <command role=\"hg-"
2947 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
2948 "review our changes, until we're satisfied with what we've done and arrive at "
2949 "a natural stopping point where we want to record our work in a new changeset."
2950 msgstr ""
2952 #. type: Content of: <book><chapter><sect1><para>
2953 #: ../en/ch01-tour-basic.xml:534
2954 msgid ""
2955 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
2956 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
2957 "<quote>committing</quote>."
2958 msgstr ""
2960 #. type: Content of: <book><chapter><sect1><sect2><title>
2961 #: ../en/ch01-tour-basic.xml:540
2962 msgid "Setting up a username"
2963 msgstr "配置用户名称"
2965 #. type: Content of: <book><chapter><sect1><sect2><para>
2966 #: ../en/ch01-tour-basic.xml:542
2967 msgid ""
2968 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
2969 "first time, it is not guaranteed to succeed. Mercurial records your name and "
2970 "address with each change that you commit, so that you and others will later "
2971 "be able to tell who made each change. Mercurial tries to automatically "
2972 "figure out a sensible username to commit the change with. It will attempt "
2973 "each of the following methods, in order:"
2974 msgstr ""
2976 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2977 #: ../en/ch01-tour-basic.xml:551
2978 msgid ""
2979 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
2980 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
2981 "followed by a username, this is always given the highest precedence."
2982 msgstr ""
2984 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2985 #: ../en/ch01-tour-basic.xml:556
2986 msgid ""
2987 "If you have set the <envar>HGUSER</envar> environment variable, this is "
2988 "checked next."
2989 msgstr ""
2991 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
2992 #: ../en/ch01-tour-basic.xml:559
2993 msgid ""
2994 "If you create a file in your home directory called <filename role=\"special"
2995 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
2996 "entry, that will be used next. To see what the contents of this file should "
2997 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
2998 msgstr ""
3000 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3001 #: ../en/ch01-tour-basic.xml:567
3002 msgid ""
3003 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
3004 "used next."
3005 msgstr ""
3007 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
3008 #: ../en/ch01-tour-basic.xml:570
3009 msgid ""
3010 "Mercurial will query your system to find out your local user name and host "
3011 "name, and construct a username from these components. Since this often "
3012 "results in a username that is not very useful, it will print a warning if it "
3013 "has to do this."
3014 msgstr ""
3016 #. type: Content of: <book><chapter><sect1><sect2><para>
3017 #: ../en/ch01-tour-basic.xml:577
3018 msgid ""
3019 "If all of these mechanisms fail, Mercurial will fail, printing an error "
3020 "message. In this case, it will not let you commit until you set up a "
3021 "username."
3022 msgstr ""
3024 #. type: Content of: <book><chapter><sect1><sect2><para>
3025 #: ../en/ch01-tour-basic.xml:581
3026 msgid ""
3027 "You should think of the <envar>HGUSER</envar> environment variable and the "
3028 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
3029 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
3030 "Mercurial's default selection of username. For normal use, the simplest and "
3031 "most robust way to set a username for yourself is by creating a <filename "
3032 "role=\"special\">.hgrc</filename> file; see below for details."
3033 msgstr ""
3035 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3036 #: ../en/ch01-tour-basic.xml:590
3037 msgid "Creating a Mercurial configuration file"
3038 msgstr "创建 Mercurial 的配置文件"
3040 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3041 #: ../en/ch01-tour-basic.xml:592
3042 msgid ""
3043 "To set a user name, use your favourite editor to create a file called "
3044 "<filename role=\"special\">.hgrc</filename> in your home directory. "
3045 "Mercurial will use this file to look up your personalised configuration "
3046 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
3047 "filename> should look like this."
3048 msgstr ""
3050 #. type: Content of: <book><chapter><sect1><sect2><sect3><remark>
3051 #: ../en/ch01-tour-basic.xml:600
3052 msgid "Figure out what the appropriate directory is on Windows."
3053 msgstr ""
3055 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3056 #: ../en/ch01-tour-basic.xml:607
3057 msgid ""
3058 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
3059 "emphasis> of the config file, so you can read the <quote><literal>username "
3060 "= ...</literal></quote> line as meaning <quote>set the value of the "
3061 "<literal>username</literal> item in the <literal>ui</literal> section</"
3062 "quote>. A section continues until a new section begins, or the end of the "
3063 "file. Mercurial ignores empty lines and treats any text from "
3064 "<quote><literal>#</literal></quote> to the end of a line as a comment."
3065 msgstr ""
3067 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
3068 #: ../en/ch01-tour-basic.xml:620
3069 msgid "Choosing a user name"
3070 msgstr "选择用户名称"
3072 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
3073 #: ../en/ch01-tour-basic.xml:622
3074 msgid ""
3075 "You can use any text you like as the value of the <literal>username</literal> "
3076 "config item, since this information is for reading by other people, but will "
3077 "not be interpreted by Mercurial. The convention that most people follow is "
3078 "to use their name and email address, as in the example above."
3079 msgstr ""
3081 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
3082 #: ../en/ch01-tour-basic.xml:629
3083 msgid ""
3084 "Mercurial's built-in web server obfuscates email addresses, to make it more "
3085 "difficult for the email harvesting tools that spammers use. This reduces the "
3086 "likelihood that you'll start receiving more junk email if you publish a "
3087 "Mercurial repository on the web."
3088 msgstr ""
3090 #. type: Content of: <book><chapter><sect1><sect2><title>
3091 #: ../en/ch01-tour-basic.xml:639
3092 msgid "Writing a commit message"
3093 msgstr "写提交日志"
3095 #. type: Content of: <book><chapter><sect1><sect2><para>
3096 #: ../en/ch01-tour-basic.xml:641
3097 msgid ""
3098 "When we commit a change, Mercurial drops us into a text editor, to enter a "
3099 "message that will describe the modifications we've made in this changeset. "
3100 "This is called the <emphasis>commit message</emphasis>. It will be a record "
3101 "for readers of what we did and why, and it will be printed by <command role="
3102 "\"hg-cmd\">hg log</command> after we've finished committing."
3103 msgstr ""
3105 #. type: Content of: <book><chapter><sect1><sect2><para>
3106 #: ../en/ch01-tour-basic.xml:651
3107 msgid ""
3108 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
3109 "drops us into will contain an empty line or two, followed by a number of "
3110 "lines starting with <quote><literal>HG:</literal></quote>."
3111 msgstr ""
3113 #. type: Content of: <book><chapter><sect1><sect2><para>
3114 #: ../en/ch01-tour-basic.xml:665
3115 msgid ""
3116 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
3117 "quote>; it uses them only to tell us which files it's recording changes to. "
3118 "Modifying or deleting these lines has no effect."
3119 msgstr ""
3121 #. type: Content of: <book><chapter><sect1><sect2><title>
3122 #: ../en/ch01-tour-basic.xml:671
3123 msgid "Writing a good commit message"
3124 msgstr "写好提交日志"
3126 #. type: Content of: <book><chapter><sect1><sect2><para>
3127 #: ../en/ch01-tour-basic.xml:673
3128 msgid ""
3129 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
3130 "a commit message by default, it's best to write a commit message whose first "
3131 "line stands alone. Here's a real example of a commit message that "
3132 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
3133 "that is not readable."
3134 msgstr ""
3136 #. type: Content of: <book><chapter><sect1><sect2><para>
3137 #: ../en/ch01-tour-basic.xml:687
3138 msgid ""
3139 "As far as the remainder of the contents of the commit message are concerned, "
3140 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
3141 "about the contents of the commit message, though your project may have "
3142 "policies that dictate a certain kind of formatting."
3143 msgstr ""
3145 #. type: Content of: <book><chapter><sect1><sect2><para>
3146 #: ../en/ch01-tour-basic.xml:693
3147 msgid ""
3148 "My personal preference is for short, but informative, commit messages that "
3149 "tell me something that I can't figure out with a quick glance at the output "
3150 "of <command role=\"hg-cmd\">hg log --patch</command>."
3151 msgstr ""
3153 #. type: Content of: <book><chapter><sect1><sect2><title>
3154 #: ../en/ch01-tour-basic.xml:700
3155 msgid "Aborting a commit"
3156 msgstr "终止提交"
3158 #. type: Content of: <book><chapter><sect1><sect2><para>
3159 #: ../en/ch01-tour-basic.xml:702
3160 msgid ""
3161 "If you decide that you don't want to commit while in the middle of editing a "
3162 "commit message, simply exit from your editor without saving the file that "
3163 "it's editing. This will cause nothing to happen to either the repository or "
3164 "the working directory."
3165 msgstr ""
3167 #. type: Content of: <book><chapter><sect1><sect2><para>
3168 #: ../en/ch01-tour-basic.xml:707
3169 msgid ""
3170 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
3171 "any arguments, it records all of the changes we've made, as reported by "
3172 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
3173 "diff</command>."
3174 msgstr ""
3176 #. type: Content of: <book><chapter><sect1><sect2><title>
3177 #: ../en/ch01-tour-basic.xml:714
3178 msgid "Admiring our new handiwork"
3179 msgstr "欣赏我们的成果"
3181 #. type: Content of: <book><chapter><sect1><sect2><para>
3182 #: ../en/ch01-tour-basic.xml:716
3183 msgid ""
3184 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
3185 "tip</command> command to display the changeset we just created. This command "
3186 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
3187 "command>, but it only displays the newest revision in the repository."
3188 msgstr ""
3190 #. type: Content of: <book><chapter><sect1><sect2><para>
3191 #: ../en/ch01-tour-basic.xml:725
3192 msgid ""
3193 "We refer to the newest revision in the repository as the <emphasis>tip "
3194 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
3195 msgstr ""
3197 #. type: Content of: <book><chapter><sect1><sect2><para>
3198 #: ../en/ch01-tour-basic.xml:729
3199 msgid ""
3200 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
3201 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
3202 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
3203 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
3204 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
3205 "patches is another example of the consistent naming we mentioned earlier."
3206 msgstr ""
3208 #. type: Content of: <book><chapter><sect1><title>
3209 #: ../en/ch01-tour-basic.xml:741
3210 msgid "Sharing changes"
3211 msgstr "共享修改"
3213 #. type: Content of: <book><chapter><sect1><para>
3214 #: ../en/ch01-tour-basic.xml:743
3215 msgid ""
3216 "We mentioned earlier that repositories in Mercurial are self-contained. This "
3217 "means that the changeset we just created exists only in our <filename class="
3218 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
3219 "we can propagate this change into other repositories."
3220 msgstr ""
3222 #. type: Content of: <book><chapter><sect1><sect2><title>
3223 #: ../en/ch01-tour-basic.xml:751
3224 msgid "Pulling changes from another repository"
3225 msgstr "从其它版本库取得修改"
3227 #. type: Content of: <book><chapter><sect1><sect2><para>
3228 #: ../en/ch01-tour-basic.xml:752
3229 msgid ""
3230 "To get started, let's clone our original <filename class=\"directory\">hello</"
3231 "filename> repository, which does not contain the change we just committed. "
3232 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
3233 "filename>."
3234 msgstr ""
3236 #. type: Content of: <book><chapter><sect1><sect2><para>
3237 #: ../en/ch01-tour-basic.xml:760
3238 msgid ""
3239 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
3240 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
3241 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
3242 "changes into a repository is a somewhat scary prospect. Mercurial provides "
3243 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
3244 "changes the <command role=\"hg-cmd\">hg pull</command> command "
3245 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
3246 "the changes in."
3247 msgstr ""
3249 #. type: Content of: <book><chapter><sect1><sect2><para>
3250 #: ../en/ch01-tour-basic.xml:773
3251 msgid ""
3252 "Suppose you're pulling changes from a repository on the network somewhere. "
3253 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
3254 "output, and before you pull those changes, someone might have committed "
3255 "something in the remote repository. This means that it's possible to pull "
3256 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
3257 "command>."
3258 msgstr ""
3260 #. type: Content of: <book><chapter><sect1><sect2><para>
3261 #: ../en/ch01-tour-basic.xml:781
3262 msgid ""
3263 "Bringing changes into a repository is a simple matter of running the <command "
3264 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
3265 "pull from."
3266 msgstr ""
3268 #. type: Content of: <book><chapter><sect1><sect2><para>
3269 #: ../en/ch01-tour-basic.xml:788
3270 msgid ""
3271 "As you can see from the before-and-after output of <command role=\"hg-cmd"
3272 "\">hg tip</command>, we have successfully pulled changes into our "
3273 "repository. There remains one step before we can see these changes in the "
3274 "working directory."
3275 msgstr ""
3277 #. type: Content of: <book><chapter><sect1><sect2><title>
3278 #: ../en/ch01-tour-basic.xml:796
3279 msgid "Updating the working directory"
3280 msgstr "更新工作目录"
3282 #. type: Content of: <book><chapter><sect1><sect2><para>
3283 #: ../en/ch01-tour-basic.xml:798
3284 msgid ""
3285 "We have so far glossed over the relationship between a repository and its "
3286 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
3287 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
3288 "repository, but if we check, there's no sign of those changes in the working "
3289 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
3290 "not (by default) touch the working directory. Instead, we use the <command "
3291 "role=\"hg-cmd\">hg update</command> command to do this."
3292 msgstr ""
3294 #. type: Content of: <book><chapter><sect1><sect2><para>
3295 #: ../en/ch01-tour-basic.xml:810
3296 msgid ""
3297 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
3298 "doesn't update the working directory automatically. There's actually a good "
3299 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
3300 "update the working directory to the state it was in at <emphasis>any "
3301 "revision</emphasis> in the history of the repository. If you had the working "
3302 "directory updated to an old revision&emdash;to hunt down the origin of a bug, "
3303 "say&emdash;and ran a <command role=\"hg-cmd\">hg pull</command> which "
3304 "automatically updated the working directory to a new revision, you might not "
3305 "be terribly happy."
3306 msgstr ""
3308 #. type: Content of: <book><chapter><sect1><sect2><para>
3309 #: ../en/ch01-tour-basic.xml:821
3310 msgid ""
3311 "However, since pull-then-update is such a common thing to do, Mercurial lets "
3312 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
3313 "option to <command role=\"hg-cmd\">hg pull</command>."
3314 msgstr ""
3316 #. type: Content of: <book><chapter><sect1><sect2><para>
3317 #: ../en/ch01-tour-basic.xml:826
3318 msgid ""
3319 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
3320 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
3321 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
3322 "we'd have to take an explicit step to update the working directory:"
3323 msgstr ""
3325 #. type: Content of: <book><chapter><sect1><sect2><para>
3326 #: ../en/ch01-tour-basic.xml:835
3327 msgid ""
3328 "To find out what revision the working directory is at, use the <command role="
3329 "\"hg-cmd\">hg parents</command> command."
3330 msgstr ""
3332 #. type: Content of: <book><chapter><sect1><sect2><para>
3333 #: ../en/ch01-tour-basic.xml:841
3334 msgid ""
3335 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
3336 "arrows connecting each changeset. The node that the arrow leads "
3337 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
3338 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
3339 "a parent in just the same way; this is the changeset that the working "
3340 "directory currently contains."
3341 msgstr ""
3343 #. type: Content of: <book><chapter><sect1><sect2><para>
3344 #: ../en/ch01-tour-basic.xml:850
3345 msgid ""
3346 "To update the working directory to a particular revision, give a revision "
3347 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
3348 "command."
3349 msgstr ""
3351 #. type: Content of: <book><chapter><sect1><sect2><para>
3352 #: ../en/ch01-tour-basic.xml:857
3353 msgid ""
3354 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
3355 "command> will update to the tip revision, as shown by the second call to "
3356 "<command role=\"hg-cmd\">hg update</command> in the example above."
3357 msgstr ""
3359 #. type: Content of: <book><chapter><sect1><sect2><title>
3360 #: ../en/ch01-tour-basic.xml:865
3361 msgid "Pushing changes to another repository"
3362 msgstr "发布修改到其它版本库"
3364 #. type: Content of: <book><chapter><sect1><sect2><para>
3365 #: ../en/ch01-tour-basic.xml:867
3366 msgid ""
3367 "Mercurial lets us push changes to another repository, from the repository "
3368 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
3369 "pull</command> above, we'll create a temporary repository to push our changes "
3370 "into."
3371 msgstr ""
3373 #. type: Content of: <book><chapter><sect1><sect2><para>
3374 #: ../en/ch01-tour-basic.xml:875
3375 msgid ""
3376 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
3377 "changes would be pushed into another repository."
3378 msgstr ""
3380 #. type: Content of: <book><chapter><sect1><sect2><para>
3381 #: ../en/ch01-tour-basic.xml:881
3382 msgid ""
3383 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
3384 "push."
3385 msgstr ""
3387 #. type: Content of: <book><chapter><sect1><sect2><para>
3388 #: ../en/ch01-tour-basic.xml:887
3389 msgid ""
3390 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
3391 "\">hg push</command> command does not update the working directory in the "
3392 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
3393 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
3394 "<literal>-u</literal> option that updates the other repository's working "
3395 "directory. This asymmetry is deliberate: the repository we're pushing to "
3396 "might be on a remote server and shared between several people. If we were to "
3397 "update its working directory while someone was working in it, their work "
3398 "would be disrupted."
3399 msgstr ""
3401 #. type: Content of: <book><chapter><sect1><sect2><para>
3402 #: ../en/ch01-tour-basic.xml:899
3403 msgid ""
3404 "What happens if we try to pull or push changes and the receiving repository "
3405 "already has those changes? Nothing too exciting."
3406 msgstr ""
3408 #. type: Content of: <book><chapter><sect1><sect2><title>
3409 #: ../en/ch01-tour-basic.xml:906
3410 msgid "Sharing changes over a network"
3411 msgstr "通过网络共享修改"
3413 #. type: Content of: <book><chapter><sect1><sect2><para>
3414 #: ../en/ch01-tour-basic.xml:908
3415 msgid ""
3416 "The commands we have covered in the previous few sections are not limited to "
3417 "working with local repositories. Each works in exactly the same fashion over "
3418 "a network connection; simply pass in a URL instead of a local path."
3419 msgstr ""
3421 #. type: Content of: <book><chapter><sect1><sect2><para>
3422 #: ../en/ch01-tour-basic.xml:916
3423 msgid ""
3424 "In this example, we can see what changes we could push to the remote "
3425 "repository, but the repository is understandably not set up to let anonymous "
3426 "users push to it."
3427 msgstr ""
3429 #. type: Content of: <book><chapter><title>
3430 #: ../en/ch02-tour-merge.xml:5
3431 msgid "A tour of Mercurial: merging work"
3432 msgstr "Mercurial 教程: 合并工作"
3434 #. type: Content of: <book><chapter><para>
3435 #: ../en/ch02-tour-merge.xml:7
3436 msgid ""
3437 "We've now covered cloning a repository, making changes in a repository, and "
3438 "pulling or pushing changes from one repository into another. Our next step "
3439 "is <emphasis>merging</emphasis> changes from separate repositories."
3440 msgstr ""
3442 #. type: Content of: <book><chapter><sect1><title>
3443 #: ../en/ch02-tour-merge.xml:13
3444 msgid "Merging streams of work"
3445 msgstr "合并的流程"
3447 #. type: Content of: <book><chapter><sect1><para>
3448 #: ../en/ch02-tour-merge.xml:15
3449 msgid ""
3450 "Merging is a fundamental part of working with a distributed revision control "
3451 "tool."
3452 msgstr ""
3454 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3455 #: ../en/ch02-tour-merge.xml:18
3456 msgid ""
3457 "Alice and Bob each have a personal copy of a repository for a project they're "
3458 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
3459 "feature in his. They want the shared repository to contain both the bug fix "
3460 "and the new feature."
3461 msgstr ""
3463 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
3464 #: ../en/ch02-tour-merge.xml:24
3465 msgid ""
3466 "I frequently work on several different tasks for a single project at once, "
3467 "each safely isolated in its own repository. Working this way means that I "
3468 "often need to merge one piece of my own work with another."
3469 msgstr ""
3471 #. type: Content of: <book><chapter><sect1><para>
3472 #: ../en/ch02-tour-merge.xml:30
3473 msgid ""
3474 "Because merging is such a common thing to need to do, Mercurial makes it "
3475 "easy. Let's walk through the process. We'll begin by cloning yet another "
3476 "repository (see how often they spring up?) and making a change in it."
3477 msgstr ""
3479 #. type: Content of: <book><chapter><sect1><para>
3480 #: ../en/ch02-tour-merge.xml:37
3481 msgid ""
3482 "We should now have two copies of <filename>hello.c</filename> with different "
3483 "contents. The histories of the two repositories have also diverged, as "
3484 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>."
3485 msgstr ""
3487 #. type: Content of: <book><chapter><sect1><figure><title>
3488 #: ../en/ch02-tour-merge.xml:46
3489 msgid ""
3490 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
3491 "filename> and <filename class=\"directory\">my-new-hello</filename> "
3492 "repositories"
3493 msgstr ""
3494 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
3495 "\"directory\">my-new-hello</filename> 最新的历史分叉"
3497 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3498 #: ../en/ch02-tour-merge.xml:51
3499 msgid ""
3500 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
3501 "imageobject>"
3502 msgstr ""
3504 #. type: Content of: <book><chapter><sect1><para>
3505 #: ../en/ch02-tour-merge.xml:56
3506 msgid ""
3507 "We already know that pulling changes from our <filename class=\"directory"
3508 "\">my-hello</filename> repository will have no effect on the working "
3509 "directory."
3510 msgstr ""
3512 #. type: Content of: <book><chapter><sect1><para>
3513 #: ../en/ch02-tour-merge.xml:62
3514 msgid ""
3515 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
3516 "something about <quote>heads</quote>."
3517 msgstr ""
3519 #. type: Content of: <book><chapter><sect1><sect2><title>
3520 #: ../en/ch02-tour-merge.xml:66
3521 msgid "Head changesets"
3522 msgstr "顶点修改集"
3524 #. type: Content of: <book><chapter><sect1><sect2><para>
3525 #: ../en/ch02-tour-merge.xml:68
3526 msgid ""
3527 "A head is a change that has no descendants, or children, as they're also "
3528 "known. The tip revision is thus a head, because the newest revision in a "
3529 "repository doesn't have any children, but a repository can contain more than "
3530 "one head."
3531 msgstr ""
3533 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3534 #: ../en/ch02-tour-merge.xml:75
3535 msgid ""
3536 "Repository contents after pulling from <filename class=\"directory\">my-"
3537 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
3538 msgstr ""
3539 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
3540 "\"directory\">my-new-hello</filename> 之后版本库的内容"
3542 #. type: Content of: <book><chapter><sect1><sect2><figure>
3543 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:125
3544 #: ../en/ch02-tour-merge.xml:250 ../en/ch03-concepts.xml:55
3545 #: ../en/ch03-concepts.xml:104 ../en/ch03-concepts.xml:189
3546 #: ../en/ch03-concepts.xml:344 ../en/ch03-concepts.xml:359
3547 #: ../en/ch03-concepts.xml:400 ../en/ch03-concepts.xml:420
3548 #: ../en/ch03-concepts.xml:461 ../en/ch05-collab.xml:274
3549 #: ../en/ch08-undo.xml:363 ../en/ch08-undo.xml:410 ../en/ch08-undo.xml:475
3550 #: ../en/ch08-undo.xml:513 ../en/ch11-mq.xml:410
3551 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
3552 msgstr ""
3554 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3555 #: ../en/ch02-tour-merge.xml:79
3556 msgid ""
3557 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
3558 msgstr ""
3560 #. type: Content of: <book><chapter><sect1><sect2><para>
3561 #: ../en/ch02-tour-merge.xml:86
3562 msgid ""
3563 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
3564 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
3565 "class=\"directory\">my-new-hello</filename>. The history that was already "
3566 "present in <filename class=\"directory\">my-new-hello</filename> is "
3567 "untouched, but a new revision has been added. By referring to <xref linkend="
3568 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
3569 "emphasis> remains the same in the new repository, but the <emphasis>revision "
3570 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
3571 "it's not safe to use revision numbers when discussing changesets.) We can "
3572 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
3573 "command> command."
3574 msgstr ""
3576 #. type: Content of: <book><chapter><sect1><sect2><title>
3577 #: ../en/ch02-tour-merge.xml:105
3578 msgid "Performing the merge"
3579 msgstr "执行合并"
3581 #. type: Content of: <book><chapter><sect1><sect2><para>
3582 #: ../en/ch02-tour-merge.xml:107
3583 msgid ""
3584 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
3585 "command> command to update to the new tip?"
3586 msgstr ""
3588 #. type: Content of: <book><chapter><sect1><sect2><para>
3589 #: ../en/ch02-tour-merge.xml:113
3590 msgid ""
3591 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
3592 "command won't do a merge; it won't update the working directory when it "
3593 "thinks we might be wanting to do a merge, unless we force it to do so. "
3594 "Instead, we use the <command role=\"hg-cmd\">hg merge</command> command to "
3595 "merge the two heads."
3596 msgstr ""
3598 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3599 #: ../en/ch02-tour-merge.xml:123
3600 msgid "Working directory and repository during merge, and following commit"
3601 msgstr "在合并期间,以及提交之后的工作目录与版本库"
3603 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3604 #: ../en/ch02-tour-merge.xml:126
3605 msgid ""
3606 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
3607 "imageobject>"
3608 msgstr ""
3610 #. type: Content of: <book><chapter><sect1><sect2><para>
3611 #: ../en/ch02-tour-merge.xml:133
3612 msgid ""
3613 "This updates the working directory so that it contains changes from "
3614 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
3615 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
3616 "<filename>hello.c</filename>."
3617 msgstr ""
3619 #. type: Content of: <book><chapter><sect1><sect2><title>
3620 #: ../en/ch02-tour-merge.xml:143
3621 msgid "Committing the results of the merge"
3622 msgstr "提交合并结果"
3624 #. type: Content of: <book><chapter><sect1><sect2><para>
3625 #: ../en/ch02-tour-merge.xml:145
3626 msgid ""
3627 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
3628 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
3629 "command> the results of the merge."
3630 msgstr ""
3632 #. type: Content of: <book><chapter><sect1><sect2><para>
3633 #: ../en/ch02-tour-merge.xml:152
3634 msgid ""
3635 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
3636 "of our former heads as its parents. These are the same revisions that were "
3637 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
3638 msgstr ""
3640 #. type: Content of: <book><chapter><sect1><sect2><para>
3641 #: ../en/ch02-tour-merge.xml:159
3642 msgid ""
3643 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
3644 "what happens to the working directory during the merge, and how this affects "
3645 "the repository when the commit happens. During the merge, the working "
3646 "directory has two parent changesets, and these become the parents of the new "
3647 "changeset."
3648 msgstr ""
3650 #. type: Content of: <book><chapter><sect1><title>
3651 #: ../en/ch02-tour-merge.xml:170
3652 msgid "Merging conflicting changes"
3653 msgstr "合并有冲突的改变"
3655 #. type: Content of: <book><chapter><sect1><para>
3656 #: ../en/ch02-tour-merge.xml:172
3657 msgid ""
3658 "Most merges are simple affairs, but sometimes you'll find yourself merging "
3659 "changes where each modifies the same portions of the same files. Unless both "
3660 "modifications are identical, this results in a <emphasis>conflict</emphasis>, "
3661 "where you have to decide how to reconcile the different changes into "
3662 "something coherent."
3663 msgstr ""
3665 #. type: Content of: <book><chapter><sect1><figure><title>
3666 #: ../en/ch02-tour-merge.xml:180
3667 msgid "Conflicting changes to a document"
3668 msgstr "冲突的修改"
3670 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
3671 #: ../en/ch02-tour-merge.xml:182
3672 msgid ""
3673 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
3674 "imageobject>"
3675 msgstr ""
3677 #. type: Content of: <book><chapter><sect1><para>
3678 #: ../en/ch02-tour-merge.xml:187
3679 msgid ""
3680 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
3681 "conflicting changes to a document. We started with a single version of the "
3682 "file; then we made some changes; while someone else made different changes to "
3683 "the same text. Our task in resolving the conflicting changes is to decide "
3684 "what the file should look like."
3685 msgstr ""
3687 #. type: Content of: <book><chapter><sect1><para>
3688 #: ../en/ch02-tour-merge.xml:194
3689 msgid ""
3690 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
3691 "it runs an external program called <command>hgmerge</command>. This is a "
3692 "shell script that is bundled with Mercurial; you can change it to behave "
3693 "however you please. What it does by default is try to find one of several "
3694 "different merging tools that are likely to be installed on your system. It "
3695 "first tries a few fully automatic merging tools; if these don't succeed "
3696 "(because the resolution process requires human guidance) or aren't present, "
3697 "the script tries a few different graphical merging tools."
3698 msgstr ""
3700 #. type: Content of: <book><chapter><sect1><para>
3701 #: ../en/ch02-tour-merge.xml:205
3702 msgid ""
3703 "It's also possible to get Mercurial to run another program or script instead "
3704 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
3705 "environment variable to the name of your preferred program."
3706 msgstr ""
3708 #. type: Content of: <book><chapter><sect1><sect2><title>
3709 #: ../en/ch02-tour-merge.xml:211
3710 msgid "Using a graphical merge tool"
3711 msgstr "使用图形合并工具"
3713 #. type: Content of: <book><chapter><sect1><sect2><para>
3714 #: ../en/ch02-tour-merge.xml:213
3715 msgid ""
3716 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
3717 "use to describe the features that are common to graphical file merging "
3718 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
3719 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
3720 "performing is called a <emphasis>three-way merge</emphasis>, because there "
3721 "are three different versions of the file of interest to us. The tool thus "
3722 "splits the upper portion of the window into three panes:"
3723 msgstr ""
3725 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3726 #: ../en/ch02-tour-merge.xml:223
3727 msgid ""
3728 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
3729 "most recent version from which the two versions we're trying to merge are "
3730 "descended."
3731 msgstr ""
3733 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3734 #: ../en/ch02-tour-merge.xml:228
3735 msgid ""
3736 "In the middle is <quote>our</quote> version of the file, with the contents "
3737 "that we modified."
3738 msgstr ""
3740 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
3741 #: ../en/ch02-tour-merge.xml:231
3742 msgid ""
3743 "On the right is <quote>their</quote> version of the file, the one that from "
3744 "the changeset that we're trying to merge with."
3745 msgstr ""
3747 #. type: Content of: <book><chapter><sect1><sect2><para>
3748 #: ../en/ch02-tour-merge.xml:235
3749 msgid ""
3750 "In the pane below these is the current <emphasis>result</emphasis> of the "
3751 "merge. Our task is to replace all of the red text, which indicates unresolved "
3752 "conflicts, with some sensible merger of the <quote>ours</quote> and "
3753 "<quote>theirs</quote> versions of the file."
3754 msgstr ""
3756 #. type: Content of: <book><chapter><sect1><sect2><para>
3757 #: ../en/ch02-tour-merge.xml:242
3758 msgid ""
3759 "All four of these panes are <emphasis>locked together</emphasis>; if we "
3760 "scroll vertically or horizontally in any of them, the others are updated to "
3761 "display the corresponding sections of their respective files."
3762 msgstr ""
3764 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
3765 #: ../en/ch02-tour-merge.xml:248
3766 msgid "Using <command>kdiff3</command> to merge versions of a file"
3767 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
3769 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
3770 #: ../en/ch02-tour-merge.xml:251
3771 msgid ""
3772 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
3773 "imageobject>"
3774 msgstr ""
3776 #. type: Content of: <book><chapter><sect1><sect2><para>
3777 #: ../en/ch02-tour-merge.xml:259
3778 msgid ""
3779 "For each conflicting portion of the file, we can choose to resolve the "
3780 "conflict using some combination of text from the base version, ours, or "
3781 "theirs. We can also manually edit the merged file at any time, in case we "
3782 "need to make further modifications."
3783 msgstr ""
3785 #. type: Content of: <book><chapter><sect1><sect2><para>
3786 #: ../en/ch02-tour-merge.xml:265
3787 msgid ""
3788 "There are <emphasis>many</emphasis> file merging tools available, too many to "
3789 "cover here. They vary in which platforms they are available for, and in "
3790 "their particular strengths and weaknesses. Most are tuned for merging files "
3791 "containing plain text, while a few are aimed at specialised file formats "
3792 "(generally XML)."
3793 msgstr ""
3795 #. type: Content of: <book><chapter><sect1><sect2><title>
3796 #: ../en/ch02-tour-merge.xml:274
3797 msgid "A worked example"
3798 msgstr "合并实例"
3800 #. type: Content of: <book><chapter><sect1><sect2><para>
3801 #: ../en/ch02-tour-merge.xml:276
3802 msgid ""
3803 "In this example, we will reproduce the file modification history of <xref "
3804 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
3805 "repository with a base version of our document."
3806 msgstr ""
3808 #. type: Content of: <book><chapter><sect1><sect2><para>
3809 #: ../en/ch02-tour-merge.xml:283
3810 msgid "We'll clone the repository and make a change to the file."
3811 msgstr ""
3813 #. type: Content of: <book><chapter><sect1><sect2><para>
3814 #: ../en/ch02-tour-merge.xml:288
3815 msgid ""
3816 "And another clone, to simulate someone else making a change to the file. "
3817 "(This hints at the idea that it's not all that unusual to merge with yourself "
3818 "when you isolate tasks in separate repositories, and indeed to find and "
3819 "resolve conflicts while doing so.)"
3820 msgstr ""
3822 #. type: Content of: <book><chapter><sect1><sect2><para>
3823 #: ../en/ch02-tour-merge.xml:296
3824 msgid ""
3825 "Having created two different versions of the file, we'll set up an "
3826 "environment suitable for running our merge."
3827 msgstr ""
3829 #. type: Content of: <book><chapter><sect1><sect2><para>
3830 #: ../en/ch02-tour-merge.xml:302
3831 msgid ""
3832 "In this example, I won't use Mercurial's normal <command>hgmerge</command> "
3833 "program to do the merge, because it would drop my nice automated example-"
3834 "running tool into a graphical user interface. Instead, I'll set "
3835 "<envar>HGMERGE</envar> to tell Mercurial to use the non-interactive "
3836 "<command>merge</command> command. This is bundled with many Unix-like "
3837 "systems. If you're following this example on your computer, don't bother "
3838 "setting <envar>HGMERGE</envar>."
3839 msgstr ""
3841 #. type: Content of: <book><chapter><sect1><sect2><para>
3842 #: ../en/ch02-tour-merge.xml:312
3843 msgid "<emphasis role=\"bold\">XXX FIX THIS EXAMPLE.</emphasis>"
3844 msgstr ""
3846 #. type: Content of: <book><chapter><sect1><sect2><para>
3847 #: ../en/ch02-tour-merge.xml:317
3848 msgid ""
3849 "Because <command>merge</command> can't resolve the conflicting changes, it "
3850 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
3851 "indicating which lines have conflicts, and whether they came from our version "
3852 "of the file or theirs."
3853 msgstr ""
3855 #. type: Content of: <book><chapter><sect1><sect2><para>
3856 #: ../en/ch02-tour-merge.xml:323
3857 msgid ""
3858 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
3859 "able to merge successfully, so it tells us what commands we'll need to run if "
3860 "we want to redo the merging operation. This could be useful if, for example, "
3861 "we were running a graphical merge tool and quit because we were confused or "
3862 "realised we had made a mistake."
3863 msgstr ""
3865 #. type: Content of: <book><chapter><sect1><sect2><para>
3866 #: ../en/ch02-tour-merge.xml:330
3867 msgid ""
3868 "If automatic or manual merges fail, there's nothing to prevent us from "
3869 "<quote>fixing up</quote> the affected files ourselves, and committing the "
3870 "results of our merge:"
3871 msgstr ""
3873 #. type: Content of: <book><chapter><sect1><title>
3874 #: ../en/ch02-tour-merge.xml:339
3875 msgid "Simplifying the pull-merge-commit sequence"
3876 msgstr "简化拉-合并-提交程序"
3878 #. type: Content of: <book><chapter><sect1><para>
3879 #: ../en/ch02-tour-merge.xml:341
3880 msgid ""
3881 "The process of merging changes as outlined above is straightforward, but "
3882 "requires running three commands in sequence."
3883 msgstr ""
3885 #. type: Content of: <book><chapter><sect1><para>
3886 #: ../en/ch02-tour-merge.xml:347
3887 msgid ""
3888 "In the case of the final commit, you also need to enter a commit message, "
3889 "which is almost always going to be a piece of uninteresting "
3890 "<quote>boilerplate</quote> text."
3891 msgstr ""
3893 #. type: Content of: <book><chapter><sect1><para>
3894 #: ../en/ch02-tour-merge.xml:351
3895 msgid ""
3896 "It would be nice to reduce the number of steps needed, if this were "
3897 "possible. Indeed, Mercurial is distributed with an extension called <literal "
3898 "role=\"hg-ext\">fetch</literal> that does just this."
3899 msgstr ""
3901 #. type: Content of: <book><chapter><sect1><para>
3902 #: ../en/ch02-tour-merge.xml:356
3903 msgid ""
3904 "Mercurial provides a flexible extension mechanism that lets people extend its "
3905 "functionality, while keeping the core of Mercurial small and easy to deal "
3906 "with. Some extensions add new commands that you can use from the command "
3907 "line, while others work <quote>behind the scenes,</quote> for example adding "
3908 "capabilities to the server."
3909 msgstr ""
3911 #. type: Content of: <book><chapter><sect1><para>
3912 #: ../en/ch02-tour-merge.xml:363
3913 msgid ""
3914 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
3915 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
3916 "extension acts as a combination of <command role=\"hg-cmd\">hg pull</"
3917 "command>, <command role=\"hg-cmd\">hg update</command> and <command role=\"hg-"
3918 "cmd\">hg merge</command>. It begins by pulling changes from another "
3919 "repository into the current repository. If it finds that the changes added a "
3920 "new head to the repository, it begins a merge, then commits the result of the "
3921 "merge with an automatically-generated commit message. If no new heads were "
3922 "added, it updates the working directory to the new tip changeset."
3923 msgstr ""
3925 #. type: Content of: <book><chapter><sect1><para>
3926 #: ../en/ch02-tour-merge.xml:376
3927 msgid ""
3928 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
3929 "Edit your <filename role=\"special\">.hgrc</filename>, and either go to the "
3930 "<literal role=\"rc-extensions\">extensions</literal> section or create an "
3931 "<literal role=\"rc-extensions\">extensions</literal> section. Then add a line "
3932 "that simply reads <quote><literal>fetch </literal></quote>."
3933 msgstr ""
3935 #. type: Content of: <book><chapter><sect1><para>
3936 #: ../en/ch02-tour-merge.xml:385
3937 msgid ""
3938 "(Normally, on the right-hand side of the <quote><literal>=</literal></quote> "
3939 "would appear the location of the extension, but since the <literal role=\"hg-"
3940 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
3941 "knows where to search for it.)"
3942 msgstr ""
3944 #. type: Content of: <book><chapter><title>
3945 #: ../en/ch03-concepts.xml:5
3946 msgid "Behind the scenes"
3947 msgstr "Mercurial 内幕"
3949 #. type: Content of: <book><chapter><para>
3950 #: ../en/ch03-concepts.xml:7
3951 msgid ""
3952 "Unlike many revision control systems, the concepts upon which Mercurial is "
3953 "built are simple enough that it's easy to understand how the software really "
3954 "works. Knowing this certainly isn't necessary, but I find it useful to have "
3955 "a <quote>mental model</quote> of what's going on."
3956 msgstr ""
3958 #. type: Content of: <book><chapter><para>
3959 #: ../en/ch03-concepts.xml:13
3960 msgid ""
3961 "This understanding gives me confidence that Mercurial has been carefully "
3962 "designed to be both <emphasis>safe</emphasis> and <emphasis>efficient</"
3963 "emphasis>. And just as importantly, if it's easy for me to retain a good "
3964 "idea of what the software is doing when I perform a revision control task, "
3965 "I'm less likely to be surprised by its behaviour."
3966 msgstr ""
3968 #. type: Content of: <book><chapter><para>
3969 #: ../en/ch03-concepts.xml:20
3970 msgid ""
3971 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
3972 "design, then continue to discuss some of the interesting details of its "
3973 "implementation."
3974 msgstr ""
3976 #. type: Content of: <book><chapter><sect1><title>
3977 #: ../en/ch03-concepts.xml:25
3978 msgid "Mercurial's historical record"
3979 msgstr "Mercurial 的历史记录"
3981 #. type: Content of: <book><chapter><sect1><sect2><title>
3982 #: ../en/ch03-concepts.xml:28
3983 msgid "Tracking the history of a single file"
3984 msgstr "跟踪单一文件的历史"
3986 #. type: Content of: <book><chapter><sect1><sect2><para>
3987 #: ../en/ch03-concepts.xml:30
3988 msgid ""
3989 "When Mercurial tracks modifications to a file, it stores the history of that "
3990 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
3991 "in the filelog contains enough information to reconstruct one revision of the "
3992 "file that is being tracked. Filelogs are stored as files in the <filename "
3993 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
3994 "filelog contains two kinds of information: revision data, and an index to "
3995 "help Mercurial to find a revision efficiently."
3996 msgstr ""
3998 #. type: Content of: <book><chapter><sect1><sect2><para>
3999 #: ../en/ch03-concepts.xml:41
4000 msgid ""
4001 "A file that is large, or has a lot of history, has its filelog stored in "
4002 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
4003 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
4004 "much history, the revision data and index are combined in a single "
4005 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
4006 "in the working directory and the filelog that tracks its history in the "
4007 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
4008 msgstr ""
4010 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4011 #: ../en/ch03-concepts.xml:53
4012 msgid ""
4013 "Relationships between files in working directory and filelogs in repository"
4014 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
4016 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4017 #: ../en/ch03-concepts.xml:56
4018 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
4019 msgstr ""
4021 #. type: Content of: <book><chapter><sect1><sect2><title>
4022 #: ../en/ch03-concepts.xml:63
4023 msgid "Managing tracked files"
4024 msgstr "管理跟踪的文件"
4026 #. type: Content of: <book><chapter><sect1><sect2><para>
4027 #: ../en/ch03-concepts.xml:65
4028 msgid ""
4029 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
4030 "together information about the files that it tracks. Each entry in the "
4031 "manifest contains information about the files present in a single changeset. "
4032 "An entry records which files are present in the changeset, the revision of "
4033 "each file, and a few other pieces of file metadata."
4034 msgstr ""
4036 #. type: Content of: <book><chapter><sect1><sect2><title>
4037 #: ../en/ch03-concepts.xml:75
4038 msgid "Recording changeset information"
4039 msgstr "记录修改集信息"
4041 #. type: Content of: <book><chapter><sect1><sect2><para>
4042 #: ../en/ch03-concepts.xml:77
4043 msgid ""
4044 "The <emphasis>changelog</emphasis> contains information about each "
4045 "changeset. Each revision records who committed a change, the changeset "
4046 "comment, other pieces of changeset-related information, and the revision of "
4047 "the manifest to use."
4048 msgstr ""
4050 #. type: Content of: <book><chapter><sect1><sect2><title>
4051 #: ../en/ch03-concepts.xml:85
4052 msgid "Relationships between revisions"
4053 msgstr "版本之间的关系"
4055 #. type: Content of: <book><chapter><sect1><sect2><para>
4056 #: ../en/ch03-concepts.xml:87
4057 msgid ""
4058 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
4059 "to its immediate parent (or to its two parents, if it's a merge revision). "
4060 "As I mentioned above, there are also relationships between revisions "
4061 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
4062 "nature."
4063 msgstr ""
4065 #. type: Content of: <book><chapter><sect1><sect2><para>
4066 #: ../en/ch03-concepts.xml:94
4067 msgid ""
4068 "For every changeset in a repository, there is exactly one revision stored in "
4069 "the changelog. Each revision of the changelog contains a pointer to a single "
4070 "revision of the manifest. A revision of the manifest stores a pointer to a "
4071 "single revision of each filelog tracked when that changeset was created. "
4072 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
4073 "\"/>."
4074 msgstr ""
4076 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4077 #: ../en/ch03-concepts.xml:103
4078 msgid "Metadata relationships"
4079 msgstr "元数据之间的关系"
4081 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4082 #: ../en/ch03-concepts.xml:105
4083 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
4084 msgstr ""
4086 #. type: Content of: <book><chapter><sect1><sect2><para>
4087 #: ../en/ch03-concepts.xml:110
4088 msgid ""
4089 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
4090 "one</quote> relationship between revisions in the changelog, manifest, or "
4091 "filelog. If the manifest hasn't changed between two changesets, the changelog "
4092 "entries for those changesets will point to the same revision of the "
4093 "manifest. If a file that Mercurial tracks hasn't changed between two "
4094 "changesets, the entry for that file in the two revisions of the manifest will "
4095 "point to the same revision of its filelog."
4096 msgstr ""
4098 #. type: Content of: <book><chapter><sect1><title>
4099 #: ../en/ch03-concepts.xml:123
4100 msgid "Safe, efficient storage"
4101 msgstr "安全,高效的存储"
4103 #. type: Content of: <book><chapter><sect1><para>
4104 #: ../en/ch03-concepts.xml:125
4105 msgid ""
4106 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
4107 "single structure called the <emphasis>revlog</emphasis>."
4108 msgstr ""
4110 #. type: Content of: <book><chapter><sect1><sect2><title>
4111 #: ../en/ch03-concepts.xml:130
4112 msgid "Efficient storage"
4113 msgstr "高效存储"
4115 #. type: Content of: <book><chapter><sect1><sect2><para>
4116 #: ../en/ch03-concepts.xml:132
4117 msgid ""
4118 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
4119 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
4120 "revision, it stores the changes needed to transform an older revision into "
4121 "the new revision. For many kinds of file data, these deltas are typically a "
4122 "fraction of a percent of the size of a full copy of a file."
4123 msgstr ""
4125 #. type: Content of: <book><chapter><sect1><sect2><para>
4126 #: ../en/ch03-concepts.xml:140
4127 msgid ""
4128 "Some obsolete revision control systems can only work with deltas of text "
4129 "files. They must either store binary files as complete snapshots or encoded "
4130 "into a text representation, both of which are wasteful approaches. Mercurial "
4131 "can efficiently handle deltas of files with arbitrary binary contents; it "
4132 "doesn't need to treat text as special."
4133 msgstr ""
4135 #. type: Content of: <book><chapter><sect1><sect2><title>
4136 #: ../en/ch03-concepts.xml:149
4137 msgid "Safe operation"
4138 msgstr "安全操作"
4140 #. type: Content of: <book><chapter><sect1><sect2><para>
4141 #: ../en/ch03-concepts.xml:151
4142 msgid ""
4143 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
4144 "file. It never modifies a section of a file after it has written it. This is "
4145 "both more robust and efficient than schemes that need to modify or rewrite "
4146 "data."
4147 msgstr ""
4149 #. type: Content of: <book><chapter><sect1><sect2><para>
4150 #: ../en/ch03-concepts.xml:157
4151 msgid ""
4152 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
4153 "emphasis> that can span a number of files. A transaction is "
4154 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
4155 "effects are all visible to readers in one go, or the whole thing is undone. "
4156 "This guarantee of atomicity means that if you're running two copies of "
4157 "Mercurial, where one is reading data and one is writing it, the reader will "
4158 "never see a partially written result that might confuse it."
4159 msgstr ""
4161 #. type: Content of: <book><chapter><sect1><sect2><para>
4162 #: ../en/ch03-concepts.xml:167
4163 msgid ""
4164 "The fact that Mercurial only appends to files makes it easier to provide this "
4165 "transactional guarantee. The easier it is to do stuff like this, the more "
4166 "confident you should be that it's done correctly."
4167 msgstr ""
4169 #. type: Content of: <book><chapter><sect1><sect2><title>
4170 #: ../en/ch03-concepts.xml:174
4171 msgid "Fast retrieval"
4172 msgstr "快速检索"
4174 #. type: Content of: <book><chapter><sect1><sect2><para>
4175 #: ../en/ch03-concepts.xml:176
4176 msgid ""
4177 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
4178 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
4179 "revision control systems store the contents of a revision as an incremental "
4180 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
4181 "specific revision, you must first read the snapshot, and then every one of "
4182 "the revisions between the snapshot and your target revision. The more "
4183 "history that a file accumulates, the more revisions you must read, hence the "
4184 "longer it takes to reconstruct a particular revision."
4185 msgstr ""
4187 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4188 #: ../en/ch03-concepts.xml:188
4189 msgid "Snapshot of a revlog, with incremental deltas"
4190 msgstr "版本日志的快照,以及增量差异"
4192 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4193 #: ../en/ch03-concepts.xml:190
4194 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
4195 msgstr ""
4197 #. type: Content of: <book><chapter><sect1><sect2><para>
4198 #: ../en/ch03-concepts.xml:195
4199 msgid ""
4200 "The innovation that Mercurial applies to this problem is simple but "
4201 "effective. Once the cumulative amount of delta information stored since the "
4202 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
4203 "(compressed, of course), instead of another delta. This makes it possible to "
4204 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
4205 "approach works so well that it has since been copied by several other "
4206 "revision control systems."
4207 msgstr ""
4209 #. type: Content of: <book><chapter><sect1><sect2><para>
4210 #: ../en/ch03-concepts.xml:204
4211 msgid ""
4212 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
4213 "in a revlog's index file, Mercurial stores the range of entries from the data "
4214 "file that it must read to reconstruct a particular revision."
4215 msgstr ""
4217 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4218 #: ../en/ch03-concepts.xml:210
4219 msgid "Aside: the influence of video compression"
4220 msgstr "旁白: 视频压缩的影响"
4222 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4223 #: ../en/ch03-concepts.xml:212
4224 msgid ""
4225 "If you're familiar with video compression or have ever watched a TV feed "
4226 "through a digital cable or satellite service, you may know that most video "
4227 "compression schemes store each frame of video as a delta against its "
4228 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
4229 "compression techniques to increase the compression ratio, so visual errors "
4230 "accumulate over the course of a number of inter-frame deltas."
4231 msgstr ""
4233 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4234 #: ../en/ch03-concepts.xml:221
4235 msgid ""
4236 "Because it's possible for a video stream to <quote>drop out</quote> "
4237 "occasionally due to signal glitches, and to limit the accumulation of "
4238 "artefacts introduced by the lossy compression process, video encoders "
4239 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
4240 "the video stream; the next delta is generated against that frame. This means "
4241 "that if the video signal gets interrupted, it will resume once the next key "
4242 "frame is received. Also, the accumulation of encoding errors restarts anew "
4243 "with each key frame."
4244 msgstr ""
4246 #. type: Content of: <book><chapter><sect1><sect2><title>
4247 #: ../en/ch03-concepts.xml:235
4248 msgid "Identification and strong integrity"
4249 msgstr "鉴别和强完整性"
4251 #. type: Content of: <book><chapter><sect1><sect2><para>
4252 #: ../en/ch03-concepts.xml:237
4253 msgid ""
4254 "Along with delta or snapshot information, a revlog entry contains a "
4255 "cryptographic hash of the data that it represents. This makes it difficult "
4256 "to forge the contents of a revision, and easy to detect accidental corruption."
4257 msgstr ""
4259 #. type: Content of: <book><chapter><sect1><sect2><para>
4260 #: ../en/ch03-concepts.xml:242
4261 msgid ""
4262 "Hashes provide more than a mere check against corruption; they are used as "
4263 "the identifiers for revisions. The changeset identification hashes that you "
4264 "see as an end user are from revisions of the changelog. Although filelogs "
4265 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
4266 msgstr ""
4268 #. type: Content of: <book><chapter><sect1><sect2><para>
4269 #: ../en/ch03-concepts.xml:249
4270 msgid ""
4271 "Mercurial verifies that hashes are correct when it retrieves file revisions "
4272 "and when it pulls changes from another repository. If it encounters an "
4273 "integrity problem, it will complain and stop whatever it's doing."
4274 msgstr ""
4276 #. type: Content of: <book><chapter><sect1><sect2><para>
4277 #: ../en/ch03-concepts.xml:254
4278 msgid ""
4279 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
4280 "periodic snapshots makes it more robust against partial data corruption. If "
4281 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
4282 "often possible to reconstruct some or most revisions from the uncorrupted "
4283 "sections of the revlog, both before and after the corrupted section. This "
4284 "would not be possible with a delta-only storage model."
4285 msgstr ""
4287 #. type: Content of: <book><chapter><sect1><title>
4288 #: ../en/ch03-concepts.xml:266
4289 msgid "Revision history, branching, and merging"
4290 msgstr "修订历史,分支与合并"
4292 #. type: Content of: <book><chapter><sect1><para>
4293 #: ../en/ch03-concepts.xml:268
4294 msgid ""
4295 "Every entry in a Mercurial revlog knows the identity of its immediate "
4296 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
4297 "In fact, a revision contains room for not one parent, but two. Mercurial "
4298 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
4299 "<quote>there is no parent here</quote>. This hash is simply a string of "
4300 "zeroes."
4301 msgstr ""
4303 #. type: Content of: <book><chapter><sect1><para>
4304 #: ../en/ch03-concepts.xml:276
4305 msgid ""
4306 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
4307 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
4308 "have this same structure; they differ only in the kind of data stored in each "
4309 "delta or snapshot."
4310 msgstr ""
4312 #. type: Content of: <book><chapter><sect1><para>
4313 #: ../en/ch03-concepts.xml:282
4314 msgid ""
4315 "The first revision in a revlog (at the bottom of the image) has the null ID "
4316 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
4317 "parent slot contains the ID of its parent revision, and its second contains "
4318 "the null ID, indicating that the revision has only one real parent. Any two "
4319 "revisions that have the same parent ID are branches. A revision that "
4320 "represents a merge between branches has two normal revision IDs in its parent "
4321 "slots."
4322 msgstr ""
4324 #. type: Content of: <book><chapter><sect1><figure><title>
4325 #: ../en/ch03-concepts.xml:292
4326 msgid "The conceptual structure of a revlog"
4327 msgstr "版本日志的设计结构"
4329 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
4330 #: ../en/ch03-concepts.xml:294
4331 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
4332 msgstr ""
4334 #. type: Content of: <book><chapter><sect1><title>
4335 #: ../en/ch03-concepts.xml:301
4336 msgid "The working directory"
4337 msgstr "工作目录"
4339 #. type: Content of: <book><chapter><sect1><para>
4340 #: ../en/ch03-concepts.xml:303
4341 msgid ""
4342 "In the working directory, Mercurial stores a snapshot of the files from the "
4343 "repository as of a particular changeset."
4344 msgstr ""
4346 #. type: Content of: <book><chapter><sect1><para>
4347 #: ../en/ch03-concepts.xml:306
4348 msgid ""
4349 "The working directory <quote>knows</quote> which changeset it contains. When "
4350 "you update the working directory to contain a particular changeset, Mercurial "
4351 "looks up the appropriate revision of the manifest to find out which files it "
4352 "was tracking at the time that changeset was committed, and which revision of "
4353 "each file was then current. It then recreates a copy of each of those files, "
4354 "with the same contents it had when the changeset was committed."
4355 msgstr ""
4357 #. type: Content of: <book><chapter><sect1><para>
4358 #: ../en/ch03-concepts.xml:315
4359 msgid ""
4360 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
4361 "working directory. This details which changeset the working directory is "
4362 "updated to, and all of the files that Mercurial is tracking in the working "
4363 "directory."
4364 msgstr ""
4366 #. type: Content of: <book><chapter><sect1><para>
4367 #: ../en/ch03-concepts.xml:321
4368 msgid ""
4369 "Just as a revision of a revlog has room for two parents, so that it can "
4370 "represent either a normal revision (with one parent) or a merge of two "
4371 "earlier revisions, the dirstate has slots for two parents. When you use the "
4372 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
4373 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
4374 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
4375 "another changeset, the first parent remains unchanged, and the second parent "
4376 "is filled in with the changeset you're merging with. The <command role=\"hg-"
4377 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
4378 "are."
4379 msgstr ""
4381 #. type: Content of: <book><chapter><sect1><sect2><title>
4382 #: ../en/ch03-concepts.xml:335
4383 msgid "What happens when you commit"
4384 msgstr "当你提交时发生的事情"
4386 #. type: Content of: <book><chapter><sect1><sect2><para>
4387 #: ../en/ch03-concepts.xml:337
4388 msgid ""
4389 "The dirstate stores parent information for more than just book-keeping "
4390 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
4391 "parents of a new changeset</emphasis> when you perform a commit."
4392 msgstr ""
4394 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4395 #: ../en/ch03-concepts.xml:343
4396 msgid "The working directory can have two parents"
4397 msgstr "工作目录可以有两个父亲"
4399 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4400 #: ../en/ch03-concepts.xml:345
4401 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
4402 msgstr ""
4404 #. type: Content of: <book><chapter><sect1><sect2><para>
4405 #: ../en/ch03-concepts.xml:350
4406 msgid ""
4407 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
4408 "directory, where it has a single changeset as parent. That changeset is the "
4409 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
4410 "children."
4411 msgstr ""
4413 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4414 #: ../en/ch03-concepts.xml:357
4415 msgid "The working directory gains new parents after a commit"
4416 msgstr "提交之后,工作目录的父亲就改变了"
4418 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4419 #: ../en/ch03-concepts.xml:360
4420 msgid ""
4421 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
4422 msgstr ""
4424 #. type: Content of: <book><chapter><sect1><sect2><para>
4425 #: ../en/ch03-concepts.xml:365
4426 msgid ""
4427 "It's useful to think of the working directory as <quote>the changeset I'm "
4428 "about to commit</quote>. Any files that you tell Mercurial that you've "
4429 "added, removed, renamed, or copied will be reflected in that changeset, as "
4430 "will modifications to any files that Mercurial is already tracking; the new "
4431 "changeset will have the parents of the working directory as its parents."
4432 msgstr ""
4434 #. type: Content of: <book><chapter><sect1><sect2><para>
4435 #: ../en/ch03-concepts.xml:373
4436 msgid ""
4437 "After a commit, Mercurial will update the parents of the working directory, "
4438 "so that the first parent is the ID of the new changeset, and the second is "
4439 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
4440 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
4441 "you commit; it just modifies the dirstate to note its new parents."
4442 msgstr ""
4444 #. type: Content of: <book><chapter><sect1><sect2><title>
4445 #: ../en/ch03-concepts.xml:384
4446 msgid "Creating a new head"
4447 msgstr "创建新顶点"
4449 #. type: Content of: <book><chapter><sect1><sect2><para>
4450 #: ../en/ch03-concepts.xml:386
4451 msgid ""
4452 "It's perfectly normal to update the working directory to a changeset other "
4453 "than the current tip. For example, you might want to know what your project "
4454 "looked like last Tuesday, or you could be looking through changesets to see "
4455 "which one introduced a bug. In cases like this, the natural thing to do is "
4456 "update the working directory to the changeset you're interested in, and then "
4457 "examine the files in the working directory directly to see their contents as "
4458 "they were when you committed that changeset. The effect of this is shown in "
4459 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
4460 msgstr ""
4462 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4463 #: ../en/ch03-concepts.xml:398
4464 msgid "The working directory, updated to an older changeset"
4465 msgstr "同步到旧修改集的工作目录"
4467 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4468 #: ../en/ch03-concepts.xml:401
4469 msgid ""
4470 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
4471 msgstr ""
4473 #. type: Content of: <book><chapter><sect1><sect2><para>
4474 #: ../en/ch03-concepts.xml:406
4475 msgid ""
4476 "Having updated the working directory to an older changeset, what happens if "
4477 "you make some changes, and then commit? Mercurial behaves in the same way as "
4478 "I outlined above. The parents of the working directory become the parents of "
4479 "the new changeset. This new changeset has no children, so it becomes the new "
4480 "tip. And the repository now contains two changesets that have no children; "
4481 "we call these <emphasis>heads</emphasis>. You can see the structure that "
4482 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
4483 msgstr ""
4485 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4486 #: ../en/ch03-concepts.xml:418
4487 msgid "After a commit made while synced to an older changeset"
4488 msgstr "对同步到旧修改集的工作目录提交之后"
4490 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4491 #: ../en/ch03-concepts.xml:421
4492 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
4493 msgstr ""
4495 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4496 #: ../en/ch03-concepts.xml:427
4497 msgid ""
4498 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
4499 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
4500 "command without any options. By default, the <command role=\"hg-cmd\">hg "
4501 "pull</command> command <emphasis>does not</emphasis> update the working "
4502 "directory, so you'll bring new changesets into your repository, but the "
4503 "working directory will stay synced at the same changeset as before the pull. "
4504 "If you make some changes and commit afterwards, you'll thus create a new "
4505 "head, because your working directory isn't synced to whatever the current tip "
4506 "is."
4507 msgstr ""
4509 #. type: Content of: <book><chapter><sect1><sect2><note><para>
4510 #: ../en/ch03-concepts.xml:439
4511 msgid ""
4512 "I put the word <quote>error</quote> in quotes because all that you need to do "
4513 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
4514 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
4515 "almost never has negative consequences; it just surprises people. I'll "
4516 "discuss other ways to avoid this behaviour, and why Mercurial behaves in this "
4517 "initially surprising way, later on."
4518 msgstr ""
4520 #. type: Content of: <book><chapter><sect1><sect2><title>
4521 #: ../en/ch03-concepts.xml:451
4522 msgid "Merging heads"
4523 msgstr "合并顶点"
4525 #. type: Content of: <book><chapter><sect1><sect2><para>
4526 #: ../en/ch03-concepts.xml:453
4527 msgid ""
4528 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
4529 "Mercurial leaves the first parent of the working directory unchanged, and "
4530 "sets the second parent to the changeset you're merging with, as shown in "
4531 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
4532 msgstr ""
4534 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
4535 #: ../en/ch03-concepts.xml:460
4536 msgid "Merging two heads"
4537 msgstr "合并两个顶点"
4539 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
4540 #: ../en/ch03-concepts.xml:462
4541 msgid ""
4542 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
4543 msgstr ""
4545 #. type: Content of: <book><chapter><sect1><sect2><para>
4546 #: ../en/ch03-concepts.xml:469
4547 msgid ""
4548 "Mercurial also has to modify the working directory, to merge the files "
4549 "managed in the two changesets. Simplified a little, the merging process goes "
4550 "like this, for every file in the manifests of both changesets."
4551 msgstr ""
4553 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4554 #: ../en/ch03-concepts.xml:474
4555 msgid "If neither changeset has modified a file, do nothing with that file."
4556 msgstr ""
4558 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4559 #: ../en/ch03-concepts.xml:477
4560 msgid ""
4561 "If one changeset has modified a file, and the other hasn't, create the "
4562 "modified copy of the file in the working directory."
4563 msgstr ""
4565 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4566 #: ../en/ch03-concepts.xml:481
4567 msgid ""
4568 "If one changeset has removed a file, and the other hasn't (or has also "
4569 "deleted it), delete the file from the working directory."
4570 msgstr ""
4572 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4573 #: ../en/ch03-concepts.xml:485
4574 msgid ""
4575 "If one changeset has removed a file, but the other has modified the file, ask "
4576 "the user what to do: keep the modified file, or remove it?"
4577 msgstr ""
4579 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4580 #: ../en/ch03-concepts.xml:489
4581 msgid ""
4582 "If both changesets have modified a file, invoke an external merge program to "
4583 "choose the new contents for the merged file. This may require input from the "
4584 "user."
4585 msgstr ""
4587 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
4588 #: ../en/ch03-concepts.xml:494
4589 msgid ""
4590 "If one changeset has modified a file, and the other has renamed or copied the "
4591 "file, make sure that the changes follow the new name of the file."
4592 msgstr ""
4594 #. type: Content of: <book><chapter><sect1><sect2><para>
4595 #: ../en/ch03-concepts.xml:498
4596 msgid ""
4597 "There are more details&emdash;merging has plenty of corner cases&emdash;but "
4598 "these are the most common choices that are involved in a merge. As you can "
4599 "see, most cases are completely automatic, and indeed most merges finish "
4600 "automatically, without requiring your input to resolve any conflicts."
4601 msgstr ""
4603 #. type: Content of: <book><chapter><sect1><sect2><para>
4604 #: ../en/ch03-concepts.xml:505
4605 msgid ""
4606 "When you're thinking about what happens when you commit after a merge, once "
4607 "again the working directory is <quote>the changeset I'm about to commit</"
4608 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
4609 "completes, the working directory has two parents; these will become the "
4610 "parents of the new changeset."
4611 msgstr ""
4613 #. type: Content of: <book><chapter><sect1><sect2><para>
4614 #: ../en/ch03-concepts.xml:512
4615 msgid ""
4616 "Mercurial lets you perform multiple merges, but you must commit the results "
4617 "of each individual merge as you go. This is necessary because Mercurial only "
4618 "tracks two parents for both revisions and the working directory. While it "
4619 "would be technically possible to merge multiple changesets at once, the "
4620 "prospect of user confusion and making a terrible mess of a merge immediately "
4621 "becomes overwhelming."
4622 msgstr ""
4624 #. type: Content of: <book><chapter><sect1><title>
4625 #: ../en/ch03-concepts.xml:523
4626 msgid "Other interesting design features"
4627 msgstr "其它有趣的设计特性"
4629 #. type: Content of: <book><chapter><sect1><para>
4630 #: ../en/ch03-concepts.xml:525
4631 msgid ""
4632 "In the sections above, I've tried to highlight some of the most important "
4633 "aspects of Mercurial's design, to illustrate that it pays careful attention "
4634 "to reliability and performance. However, the attention to detail doesn't "
4635 "stop there. There are a number of other aspects of Mercurial's construction "
4636 "that I personally find interesting. I'll detail a few of them here, separate "
4637 "from the <quote>big ticket</quote> items above, so that if you're interested, "
4638 "you can gain a better idea of the amount of thinking that goes into a well-"
4639 "designed system."
4640 msgstr ""
4642 #. type: Content of: <book><chapter><sect1><sect2><title>
4643 #: ../en/ch03-concepts.xml:536
4644 msgid "Clever compression"
4645 msgstr "智能压缩"
4647 #. type: Content of: <book><chapter><sect1><sect2><para>
4648 #: ../en/ch03-concepts.xml:538
4649 msgid ""
4650 "When appropriate, Mercurial will store both snapshots and deltas in "
4651 "compressed form. It does this by always <emphasis>trying to</emphasis> "
4652 "compress a snapshot or delta, but only storing the compressed version if it's "
4653 "smaller than the uncompressed version."
4654 msgstr ""
4656 #. type: Content of: <book><chapter><sect1><sect2><para>
4657 #: ../en/ch03-concepts.xml:544
4658 msgid ""
4659 "This means that Mercurial does <quote>the right thing</quote> when storing a "
4660 "file whose native form is compressed, such as a <literal>zip</literal> "
4661 "archive or a JPEG image. When these types of files are compressed a second "
4662 "time, the resulting file is usually bigger than the once-compressed form, and "
4663 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
4664 msgstr ""
4666 #. type: Content of: <book><chapter><sect1><sect2><para>
4667 #: ../en/ch03-concepts.xml:552
4668 msgid ""
4669 "Deltas between revisions of a compressed file are usually larger than "
4670 "snapshots of the file, and Mercurial again does <quote>the right thing</"
4671 "quote> in these cases. It finds that such a delta exceeds the threshold at "
4672 "which it should store a complete snapshot of the file, so it stores the "
4673 "snapshot, again saving space compared to a naive delta-only approach."
4674 msgstr ""
4676 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4677 #: ../en/ch03-concepts.xml:561
4678 msgid "Network recompression"
4679 msgstr "网络重新压缩"
4681 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4682 #: ../en/ch03-concepts.xml:563
4683 msgid ""
4684 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
4685 "compression algorithm (the same one used by the popular <literal>zip</"
4686 "literal> archive format), which balances good speed with a respectable "
4687 "compression ratio. However, when transmitting revision data over a network "
4688 "connection, Mercurial uncompresses the compressed revision data."
4689 msgstr ""
4691 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4692 #: ../en/ch03-concepts.xml:571
4693 msgid ""
4694 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
4695 "data using a compression algorithm that gives a better compression ratio (the "
4696 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
4697 "compression package). This combination of algorithm and compression of the "
4698 "entire stream (instead of a revision at a time) substantially reduces the "
4699 "number of bytes to be transferred, yielding better network performance over "
4700 "almost all kinds of network."
4701 msgstr ""
4703 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4704 #: ../en/ch03-concepts.xml:581
4705 msgid ""
4706 "(If the connection is over <command>ssh</command>, Mercurial "
4707 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
4708 "command> can already do this itself.)"
4709 msgstr ""
4711 #. type: Content of: <book><chapter><sect1><sect2><title>
4712 #: ../en/ch03-concepts.xml:589
4713 msgid "Read/write ordering and atomicity"
4714 msgstr "读写顺序与原子性"
4716 #. type: Content of: <book><chapter><sect1><sect2><para>
4717 #: ../en/ch03-concepts.xml:591
4718 msgid ""
4719 "Appending to files isn't the whole story when it comes to guaranteeing that a "
4720 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
4721 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
4722 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
4723 "is deliberate."
4724 msgstr ""
4726 #. type: Content of: <book><chapter><sect1><sect2><para>
4727 #: ../en/ch03-concepts.xml:599
4728 msgid ""
4729 "A writer starts a transaction by writing filelog and manifest data, and "
4730 "doesn't write any changelog data until those are finished. A reader starts "
4731 "by reading changelog data, then manifest data, followed by filelog data."
4732 msgstr ""
4734 #. type: Content of: <book><chapter><sect1><sect2><para>
4735 #: ../en/ch03-concepts.xml:604
4736 msgid ""
4737 "Since the writer has always finished writing filelog and manifest data before "
4738 "it writes to the changelog, a reader will never read a pointer to a partially "
4739 "written manifest revision from the changelog, and it will never read a "
4740 "pointer to a partially written filelog revision from the manifest."
4741 msgstr ""
4743 #. type: Content of: <book><chapter><sect1><sect2><title>
4744 #: ../en/ch03-concepts.xml:612
4745 msgid "Concurrent access"
4746 msgstr "并发访问"
4748 #. type: Content of: <book><chapter><sect1><sect2><para>
4749 #: ../en/ch03-concepts.xml:614
4750 msgid ""
4751 "The read/write ordering and atomicity guarantees mean that Mercurial never "
4752 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
4753 "if the repository is being written to while the read is occurring. This has a "
4754 "big effect on scalability; you can have an arbitrary number of Mercurial "
4755 "processes safely reading data from a repository safely all at once, no matter "
4756 "whether it's being written to or not."
4757 msgstr ""
4759 #. type: Content of: <book><chapter><sect1><sect2><para>
4760 #: ../en/ch03-concepts.xml:623
4761 msgid ""
4762 "The lockless nature of reading means that if you're sharing a repository on a "
4763 "multi-user system, you don't need to grant other local users permission to "
4764 "<emphasis>write</emphasis> to your repository in order for them to be able to "
4765 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
4766 "permission. (This is <emphasis>not</emphasis> a common feature among "
4767 "revision control systems, so don't take it for granted! Most require readers "
4768 "to be able to lock a repository to access it safely, and this requires write "
4769 "permission on at least one directory, which of course makes for all kinds of "
4770 "nasty and annoying security and administrative problems.)"
4771 msgstr ""
4773 #. type: Content of: <book><chapter><sect1><sect2><para>
4774 #: ../en/ch03-concepts.xml:636
4775 msgid ""
4776 "Mercurial uses locks to ensure that only one process can write to a "
4777 "repository at a time (the locking mechanism is safe even over filesystems "
4778 "that are notoriously hostile to locking, such as NFS). If a repository is "
4779 "locked, a writer will wait for a while to retry if the repository becomes "
4780 "unlocked, but if the repository remains locked for too long, the process "
4781 "attempting to write will time out after a while. This means that your daily "
4782 "automated scripts won't get stuck forever and pile up if a system crashes "
4783 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
4784 "infinity.)"
4785 msgstr ""
4787 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
4788 #: ../en/ch03-concepts.xml:648
4789 msgid "Safe dirstate access"
4790 msgstr "安全的目录状态访问"
4792 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
4793 #: ../en/ch03-concepts.xml:650
4794 msgid ""
4795 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
4796 "file; it does acquire a lock to write it. To avoid the possibility of "
4797 "reading a partially written copy of the dirstate file, Mercurial writes to a "
4798 "file with a unique name in the same directory as the dirstate file, then "
4799 "renames the temporary file atomically to <filename>dirstate</filename>. The "
4800 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
4801 "not partially written."
4802 msgstr ""
4804 #. type: Content of: <book><chapter><sect1><sect2><title>
4805 #: ../en/ch03-concepts.xml:663
4806 msgid "Avoiding seeks"
4807 msgstr "避免查找"
4809 #. type: Content of: <book><chapter><sect1><sect2><para>
4810 #: ../en/ch03-concepts.xml:665
4811 msgid ""
4812 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
4813 "head, since any seek is far more expensive than even a comparatively large "
4814 "read operation."
4815 msgstr ""
4817 #. type: Content of: <book><chapter><sect1><sect2><para>
4818 #: ../en/ch03-concepts.xml:669
4819 msgid ""
4820 "This is why, for example, the dirstate is stored in a single file. If there "
4821 "were a dirstate file per directory that Mercurial tracked, the disk would "
4822 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
4823 "file in one step."
4824 msgstr ""
4826 #. type: Content of: <book><chapter><sect1><sect2><para>
4827 #: ../en/ch03-concepts.xml:675
4828 msgid ""
4829 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
4830 "repository on local storage. Instead of copying every revlog file from the "
4831 "old repository into the new repository, it makes a <quote>hard link</quote>, "
4832 "which is a shorthand way to say <quote>these two names point to the same "
4833 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
4834 "it checks to see if the number of names pointing at the file is greater than "
4835 "one. If it is, more than one repository is using the file, so Mercurial "
4836 "makes a new copy of the file that is private to this repository."
4837 msgstr ""
4839 #. type: Content of: <book><chapter><sect1><sect2><para>
4840 #: ../en/ch03-concepts.xml:686
4841 msgid ""
4842 "A few revision control developers have pointed out that this idea of making a "
4843 "complete private copy of a file is not very efficient in its use of storage. "
4844 "While this is true, storage is cheap, and this method gives the highest "
4845 "performance while deferring most book-keeping to the operating system. An "
4846 "alternative scheme would most likely reduce performance and increase the "
4847 "complexity of the software, each of which is much more important to the "
4848 "<quote>feel</quote> of day-to-day use."
4849 msgstr ""
4851 #. type: Content of: <book><chapter><sect1><sect2><title>
4852 #: ../en/ch03-concepts.xml:698
4853 msgid "Other contents of the dirstate"
4854 msgstr "目录状态的其它内容"
4856 #. type: Content of: <book><chapter><sect1><sect2><para>
4857 #: ../en/ch03-concepts.xml:700
4858 msgid ""
4859 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
4860 "it uses the dirstate to store some extra information so it can determine "
4861 "efficiently whether you have modified a file. For each file in the working "
4862 "directory, it stores the time that it last modified the file itself, and the "
4863 "size of the file at that time."
4864 msgstr ""
4866 #. type: Content of: <book><chapter><sect1><sect2><para>
4867 #: ../en/ch03-concepts.xml:707
4868 msgid ""
4869 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
4870 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
4871 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
4872 "dirstate so that it knows what to do with those files when you commit."
4873 msgstr ""
4875 #. type: Content of: <book><chapter><sect1><sect2><para>
4876 #: ../en/ch03-concepts.xml:714
4877 msgid ""
4878 "When Mercurial is checking the states of files in the working directory, it "
4879 "first checks a file's modification time. If that has not changed, the file "
4880 "must not have been modified. If the file's size has changed, the file must "
4881 "have been modified. If the modification time has changed, but the size has "
4882 "not, only then does Mercurial need to read the actual contents of the file to "
4883 "see if they've changed. Storing these few extra pieces of information "
4884 "dramatically reduces the amount of data that Mercurial needs to read, which "
4885 "yields large performance improvements compared to other revision control "
4886 "systems."
4887 msgstr ""
4889 #. type: Content of: <book><chapter><title>
4890 #: ../en/ch04-daily.xml:5
4891 msgid "Mercurial in daily use"
4892 msgstr "Mercurial 的日常使用"
4894 #. type: Content of: <book><chapter><sect1><title>
4895 #: ../en/ch04-daily.xml:8
4896 msgid "Telling Mercurial which files to track"
4897 msgstr "告诉 Mercurial 要跟踪哪些文件"
4899 #. type: Content of: <book><chapter><sect1><para>
4900 #: ../en/ch04-daily.xml:10
4901 msgid ""
4902 "Mercurial does not work with files in your repository unless you tell it to "
4903 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
4904 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
4905 "</literal></quote> to display such files."
4906 msgstr ""
4909 #. type: Content of: <book><chapter><sect1><para>
4910 #: ../en/ch04-daily.xml:17
4911 msgid ""
4912 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
4913 "command> command. Once you have added a file, the entry in the output of "
4914 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
4915 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
4916 msgstr ""
4918 #. type: Content of: <book><chapter><sect1><para>
4919 #: ../en/ch04-daily.xml:26
4920 msgid ""
4921 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
4922 "you added before the commit will no longer be listed in the output of "
4923 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that "
4924 "<command role=\"hg-cmd\">hg status</command> only tells you about "
4925 "<quote>interesting</quote> files&emdash;those that you have modified or told "
4926 "Mercurial to do something with&emdash;by default. If you have a repository "
4927 "that contains thousands of files, you will rarely want to know about files "
4928 "that Mercurial is tracking, but that have not changed. (You can still get "
4929 "this information; we'll return to this later.)"
4930 msgstr ""
4932 #. type: Content of: <book><chapter><sect1><para>
4933 #: ../en/ch04-daily.xml:38
4934 msgid ""
4935 "Once you add a file, Mercurial doesn't do anything with it immediately. "
4936 "Instead, it will take a snapshot of the file's state the next time you "
4937 "perform a commit. It will then continue to track the changes you make to the "
4938 "file every time you commit, until you remove the file."
4939 msgstr ""
4941 #. type: Content of: <book><chapter><sect1><sect2><title>
4942 #: ../en/ch04-daily.xml:45
4943 msgid "Explicit versus implicit file naming"
4944 msgstr "明确与隐含文件命名"
4946 #. type: Content of: <book><chapter><sect1><sect2><para>
4947 #: ../en/ch04-daily.xml:47
4948 msgid ""
4949 "A useful behaviour that Mercurial has is that if you pass the name of a "
4950 "directory to a command, every Mercurial command will treat this as <quote>I "
4951 "want to operate on every file in this directory and its subdirectories</"
4952 "quote>."
4953 msgstr ""
4955 #. type: Content of: <book><chapter><sect1><sect2><para>
4956 #: ../en/ch04-daily.xml:54
4957 msgid ""
4958 "Notice in this example that Mercurial printed the names of the files it "
4959 "added, whereas it didn't do so when we added the file named <filename>a</"
4960 "filename> in the earlier example."
4961 msgstr ""
4963 #. type: Content of: <book><chapter><sect1><sect2><para>
4964 #: ../en/ch04-daily.xml:59
4965 msgid ""
4966 "What's going on is that in the former case, we explicitly named the file to "
4967 "add on the command line, so the assumption that Mercurial makes in such cases "
4968 "is that you know what you were doing, and it doesn't print any output."
4969 msgstr ""
4971 #. type: Content of: <book><chapter><sect1><sect2><para>
4972 #: ../en/ch04-daily.xml:64
4973 msgid ""
4974 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
4975 "name of a directory, Mercurial takes the extra step of printing the name of "
4976 "each file that it does something with. This makes it more clear what is "
4977 "happening, and reduces the likelihood of a silent and nasty surprise. This "
4978 "behaviour is common to most Mercurial commands."
4979 msgstr ""
4981 #. type: Content of: <book><chapter><sect1><sect2><title>
4982 #: ../en/ch04-daily.xml:73
4983 msgid "Aside: Mercurial tracks files, not directories"
4984 msgstr "旁白: Mercurial 只跟踪文件,不跟踪目录"
4986 #. type: Content of: <book><chapter><sect1><sect2><para>
4987 #: ../en/ch04-daily.xml:75
4988 msgid ""
4989 "Mercurial does not track directory information. Instead, it tracks the path "
4990 "to a file. Before creating a file, it first creates any missing directory "
4991 "components of the path. After it deletes a file, it then deletes any empty "
4992 "directories that were in the deleted file's path. This sounds like a trivial "
4993 "distinction, but it has one minor practical consequence: it is not possible "
4994 "to represent a completely empty directory in Mercurial."
4995 msgstr ""
4997 #. type: Content of: <book><chapter><sect1><sect2><para>
4998 #: ../en/ch04-daily.xml:84
4999 msgid ""
5000 "Empty directories are rarely useful, and there are unintrusive workarounds "
5001 "that you can use to achieve an appropriate effect. The developers of "
5002 "Mercurial thus felt that the complexity that would be required to manage "
5003 "empty directories was not worth the limited benefit this feature would bring."
5004 msgstr ""
5006 #. type: Content of: <book><chapter><sect1><sect2><para>
5007 #: ../en/ch04-daily.xml:91
5008 msgid ""
5009 "If you need an empty directory in your repository, there are a few ways to "
5010 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
5011 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
5012 "systems, any file name that begins with a period (<quote><literal>.</"
5013 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
5014 "approach is illustrated below."
5015 msgstr ""
5017 #. type: Content of: <book><chapter><sect1><sect2><para>
5018 #: ../en/ch04-daily.xml:102
5019 msgid ""
5020 "Another way to tackle a need for an empty directory is to simply create one "
5021 "in your automated build scripts before they will need it."
5022 msgstr ""
5024 #. type: Content of: <book><chapter><sect1><title>
5025 #: ../en/ch04-daily.xml:109
5026 msgid "How to stop tracking a file"
5027 msgstr "如何停止跟踪文件"
5030 #. type: Content of: <book><chapter><sect1><para>
5031 #: ../en/ch04-daily.xml:111
5032 msgid ""
5033 "Once you decide that a file no longer belongs in your repository, use the "
5034 "<command role=\"hg-cmd\">hg remove</command> command; this deletes the file, "
5035 "and tells Mercurial to stop tracking it. A removed file is represented in "
5036 "the output of <command role=\"hg-cmd\">hg status</command> with a "
5037 "<quote><literal>R</literal></quote>."
5038 msgstr ""
5040 #. type: Content of: <book><chapter><sect1><para>
5041 #: ../en/ch04-daily.xml:120
5042 msgid ""
5043 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
5044 "no longer track changes to that file, even if you recreate a file with the "
5045 "same name in your working directory. If you do recreate a file with the same "
5046 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
5047 "\">hg add</command> it. Mercurial will know that the newly added file is not "
5048 "related to the old file of the same name."
5049 msgstr ""
5051 #. type: Content of: <book><chapter><sect1><sect2><title>
5052 #: ../en/ch04-daily.xml:129
5053 msgid "Removing a file does not affect its history"
5054 msgstr "删除文件不影响历史"
5056 #. type: Content of: <book><chapter><sect1><sect2><para>
5057 #: ../en/ch04-daily.xml:131
5058 msgid "It is important to understand that removing a file has only two effects."
5059 msgstr ""
5061 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5062 #: ../en/ch04-daily.xml:134
5063 msgid "It removes the current version of the file from the working directory."
5064 msgstr ""
5066 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
5067 #: ../en/ch04-daily.xml:137
5068 msgid ""
5069 "It stops Mercurial from tracking changes to the file, from the time of the "
5070 "next commit."
5071 msgstr ""
5073 #. type: Content of: <book><chapter><sect1><sect2><para>
5074 #: ../en/ch04-daily.xml:140
5075 msgid ""
5076 "Removing a file <emphasis>does not</emphasis> in any way alter the "
5077 "<emphasis>history</emphasis> of the file."
5078 msgstr ""
5080 #. type: Content of: <book><chapter><sect1><sect2><para>
5081 #: ../en/ch04-daily.xml:143
5082 msgid ""
5083 "If you update the working directory to a changeset in which a file that you "
5084 "have removed was still tracked, it will reappear in the working directory, "
5085 "with the contents it had when you committed that changeset. If you then "
5086 "update the working directory to a later changeset, in which the file had been "
5087 "removed, Mercurial will once again remove the file from the working directory."
5088 msgstr ""
5090 #. type: Content of: <book><chapter><sect1><sect2><title>
5091 #: ../en/ch04-daily.xml:153
5092 msgid "Missing files"
5093 msgstr "丢失的文件"
5095 #. type: Content of: <book><chapter><sect1><sect2><para>
5096 #: ../en/ch04-daily.xml:155
5097 msgid ""
5098 "Mercurial considers a file that you have deleted, but not used <command role="
5099 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
5100 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
5101 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
5102 "Mercurial commands will not generally do anything with missing files."
5103 msgstr ""
5105 #. type: Content of: <book><chapter><sect1><sect2><para>
5106 #: ../en/ch04-daily.xml:165
5107 msgid ""
5108 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
5109 "command> reports as missing, and you want the file to stay gone, you can run "
5110 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
5111 "option></command> at any time later on, to tell Mercurial that you really did "
5112 "mean to remove the file."
5113 msgstr ""
5115 #. type: Content of: <book><chapter><sect1><sect2><para>
5116 #: ../en/ch04-daily.xml:175
5117 msgid ""
5118 "On the other hand, if you deleted the missing file by accident, give <command "
5119 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
5120 "reappear, in unmodified form."
5121 msgstr ""
5123 #. type: Content of: <book><chapter><sect1><sect2><title>
5124 #: ../en/ch04-daily.xml:184
5125 msgid "Aside: why tell Mercurial explicitly to remove a file?"
5126 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
5128 #. type: Content of: <book><chapter><sect1><sect2><para>
5129 #: ../en/ch04-daily.xml:187
5130 msgid ""
5131 "You might wonder why Mercurial requires you to explicitly tell it that you "
5132 "are deleting a file. Early during the development of Mercurial, it let you "
5133 "delete a file however you pleased; Mercurial would notice the absence of the "
5134 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
5135 "command>, and stop tracking the file. In practice, this made it too easy to "
5136 "accidentally remove a file without noticing."
5137 msgstr ""
5139 #. type: Content of: <book><chapter><sect1><sect2><title>
5140 #: ../en/ch04-daily.xml:198
5141 msgid "Useful shorthand&emdash;adding and removing files in one step"
5142 msgstr "有用的速记—一个步骤添加和删除文件"
5144 #. type: Content of: <book><chapter><sect1><sect2><para>
5145 #: ../en/ch04-daily.xml:201
5146 msgid ""
5147 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
5148 "addremove</command>, that adds untracked files and marks missing files as "
5149 "removed."
5150 msgstr ""
5152 #. type: Content of: <book><chapter><sect1><sect2><para>
5153 #: ../en/ch04-daily.xml:207
5154 msgid ""
5155 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
5156 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
5157 "and-remove, immediately followed by a commit."
5158 msgstr ""
5160 #. type: Content of: <book><chapter><sect1><title>
5161 #: ../en/ch04-daily.xml:217
5162 msgid "Copying files"
5163 msgstr "复制文件"
5165 #. type: Content of: <book><chapter><sect1><para>
5166 #: ../en/ch04-daily.xml:219
5167 msgid ""
5168 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
5169 "lets you make a new copy of a file. When you copy a file using this command, "
5170 "Mercurial makes a record of the fact that the new file is a copy of the "
5171 "original file. It treats these copied files specially when you merge your "
5172 "work with someone else's."
5173 msgstr ""
5175 #. type: Content of: <book><chapter><sect1><sect2><title>
5176 #: ../en/ch04-daily.xml:227
5177 msgid "The results of copying during a merge"
5178 msgstr "合并期间的复制结果"
5180 #. type: Content of: <book><chapter><sect1><sect2><para>
5181 #: ../en/ch04-daily.xml:229
5182 msgid ""
5183 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
5184 "best illustrate what this means, let's create an example. We'll start with "
5185 "the usual tiny repository that contains a single file."
5186 msgstr ""
5188 #. type: Content of: <book><chapter><sect1><sect2><para>
5189 #: ../en/ch04-daily.xml:236
5190 msgid ""
5191 "We need to do some work in parallel, so that we'll have something to merge. "
5192 "So let's clone our repository."
5193 msgstr ""
5195 #. type: Content of: <book><chapter><sect1><sect2><para>
5196 #: ../en/ch04-daily.xml:242
5197 msgid ""
5198 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
5199 "copy</command> command to make a copy of the first file we created."
5200 msgstr ""
5202 #. type: Content of: <book><chapter><sect1><sect2><para>
5203 #: ../en/ch04-daily.xml:248
5204 msgid ""
5205 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
5206 "command afterwards, the copied file looks just like a normal added file."
5207 msgstr ""
5209 #. type: Content of: <book><chapter><sect1><sect2><para>
5210 #: ../en/ch04-daily.xml:254
5211 msgid ""
5212 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
5213 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
5214 "output: this is the file that our newly-added file was copied <emphasis>from</"
5215 "emphasis>."
5216 msgstr ""
5218 #. type: Content of: <book><chapter><sect1><sect2><para>
5219 #: ../en/ch04-daily.xml:262
5220 msgid ""
5221 "Now, back in the repository we cloned, let's make a change in parallel. "
5222 "We'll add a line of content to the original file that we created."
5223 msgstr ""
5225 #. type: Content of: <book><chapter><sect1><sect2><para>
5226 #: ../en/ch04-daily.xml:268
5227 msgid ""
5228 "Now we have a modified <filename>file</filename> in this repository. When we "
5229 "pull the changes from the first repository, and merge the two heads, "
5230 "Mercurial will propagate the changes that we made locally to <filename>file</"
5231 "filename> into its copy, <filename>new-file</filename>."
5232 msgstr ""
5234 #. type: Content of: <book><chapter><sect1><sect2><title>
5235 #: ../en/ch04-daily.xml:278
5236 msgid "Why should changes follow copies?"
5237 msgstr "为什么复制后需要后续修改?"
5239 #. type: Content of: <book><chapter><sect1><sect2><para>
5240 #: ../en/ch04-daily.xml:280
5241 msgid ""
5242 "This behaviour, of changes to a file propagating out to copies of the file, "
5243 "might seem esoteric, but in most cases it's highly desirable."
5244 msgstr ""
5246 #. type: Content of: <book><chapter><sect1><sect2><para>
5247 #: ../en/ch04-daily.xml:284
5248 msgid ""
5249 "First of all, remember that this propagation <emphasis>only</emphasis> "
5250 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
5251 "a file, and subsequently modify the original file during the normal course of "
5252 "your work, nothing will happen."
5253 msgstr ""
5255 #. type: Content of: <book><chapter><sect1><sect2><para>
5256 #: ../en/ch04-daily.xml:290
5257 msgid ""
5258 "The second thing to know is that modifications will only propagate across a "
5259 "copy as long as the repository that you're pulling changes from "
5260 "<emphasis>doesn't know</emphasis> about the copy."
5261 msgstr ""
5263 #. type: Content of: <book><chapter><sect1><sect2><para>
5264 #: ../en/ch04-daily.xml:295
5265 msgid ""
5266 "The reason that Mercurial does this is as follows. Let's say I make an "
5267 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
5268 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
5269 "repository, without knowing about the bug or having seen the fix, and you "
5270 "have started hacking on your copy of the file."
5271 msgstr ""
5273 #. type: Content of: <book><chapter><sect1><sect2><para>
5274 #: ../en/ch04-daily.xml:302
5275 msgid ""
5276 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
5277 "emphasis> propagate changes across copies, your source file would now contain "
5278 "the bug, and unless you remembered to propagate the bug fix by hand, the bug "
5279 "would <emphasis>remain</emphasis> in your copy of the file."
5280 msgstr ""
5282 #. type: Content of: <book><chapter><sect1><sect2><para>
5283 #: ../en/ch04-daily.xml:308
5284 msgid ""
5285 "By automatically propagating the change that fixed the bug from the original "
5286 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
5287 "Mercurial is the <emphasis>only</emphasis> revision control system that "
5288 "propagates changes across copies like this."
5289 msgstr ""
5291 #. type: Content of: <book><chapter><sect1><sect2><para>
5292 #: ../en/ch04-daily.xml:314
5293 msgid ""
5294 "Once your change history has a record that the copy and subsequent merge "
5295 "occurred, there's usually no further need to propagate changes from the "
5296 "original file to the copied file, and that's why Mercurial only propagates "
5297 "changes across copies until this point, and no further."
5298 msgstr ""
5300 #. type: Content of: <book><chapter><sect1><sect2><title>
5301 #: ../en/ch04-daily.xml:322
5302 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
5303 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
5305 #. type: Content of: <book><chapter><sect1><sect2><para>
5306 #: ../en/ch04-daily.xml:325
5307 msgid ""
5308 "If, for some reason, you decide that this business of automatically "
5309 "propagating changes across copies is not for you, simply use your system's "
5310 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
5311 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
5312 "new copy by hand. Before you do so, though, please do reread <xref linkend="
5313 "\"sec:daily:why-copy\"/>, and make an informed decision that this behaviour "
5314 "is not appropriate to your specific case."
5315 msgstr ""
5317 #. type: Content of: <book><chapter><sect1><sect2><title>
5318 #: ../en/ch04-daily.xml:338
5319 msgid "Behaviour of the <command role=\"hg-cmd\">hg copy</command> command"
5320 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
5322 #. type: Content of: <book><chapter><sect1><sect2><para>
5323 #: ../en/ch04-daily.xml:341
5324 msgid ""
5325 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
5326 "Mercurial makes a copy of each source file as it currently stands in the "
5327 "working directory. This means that if you make some modifications to a file, "
5328 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
5329 "committed those changes, the new copy will also contain the modifications you "
5330 "have made up until that point. (I find this behaviour a little "
5331 "counterintuitive, which is why I mention it here.)"
5332 msgstr ""
5334 #. type: Content of: <book><chapter><sect1><sect2><para>
5335 #: ../en/ch04-daily.xml:351
5336 msgid ""
5337 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
5338 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
5339 "\">hg cp</command> alias if you prefer). The last argument is the "
5340 "<emphasis>destination</emphasis>, and all prior arguments are "
5341 "<emphasis>sources</emphasis>. If you pass it a single file as the source, "
5342 "and the destination does not exist, it creates a new file with that name."
5343 msgstr ""
5345 #. type: Content of: <book><chapter><sect1><sect2><para>
5346 #: ../en/ch04-daily.xml:362
5347 msgid ""
5348 "If the destination is a directory, Mercurial copies its sources into that "
5349 "directory."
5350 msgstr ""
5352 #. type: Content of: <book><chapter><sect1><sect2><para>
5353 #: ../en/ch04-daily.xml:367
5354 msgid ""
5355 "Copying a directory is recursive, and preserves the directory structure of "
5356 "the source."
5357 msgstr ""
5359 #. type: Content of: <book><chapter><sect1><sect2><para>
5360 #: ../en/ch04-daily.xml:373
5361 msgid ""
5362 "If the source and destination are both directories, the source tree is "
5363 "recreated in the destination directory."
5364 msgstr ""
5367 #. type: Content of: <book><chapter><sect1><sect2><para>
5368 #: ../en/ch04-daily.xml:378
5369 msgid ""
5370 "As with the <command role=\"hg-cmd\">hg rename</command> command, if you copy "
5371 "a file manually and then want Mercurial to know that you've copied the file, "
5372 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
5373 "<command role=\"hg-cmd\">hg copy</command>."
5374 msgstr ""
5376 #. type: Content of: <book><chapter><sect1><title>
5377 #: ../en/ch04-daily.xml:389
5378 msgid "Renaming files"
5379 msgstr "改名文件"
5381 #. type: Content of: <book><chapter><sect1><para>
5382 #: ../en/ch04-daily.xml:391
5383 msgid ""
5384 "It's rather more common to need to rename a file than to make a copy of it. "
5385 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
5386 "before talking about renaming files is that Mercurial treats a rename in "
5387 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
5388 "when you copy a file tells you what to expect when you rename a file."
5389 msgstr ""
5391 #. type: Content of: <book><chapter><sect1><para>
5392 #: ../en/ch04-daily.xml:399
5393 msgid ""
5394 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
5395 "Mercurial makes a copy of each source file, then deletes it and marks the "
5396 "file as removed."
5397 msgstr ""
5399 #. type: Content of: <book><chapter><sect1><para>
5400 #: ../en/ch04-daily.xml:405
5401 msgid ""
5402 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
5403 "copied file as added, and the copied-from file as removed."
5404 msgstr ""
5406 #. type: Content of: <book><chapter><sect1><para>
5407 #: ../en/ch04-daily.xml:411
5408 msgid ""
5409 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
5410 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
5411 "\"hg-cmd\">hg status</command> to see that the added file is really being "
5412 "tracked by Mercurial as a copy of the original, now removed, file."
5413 msgstr ""
5415 #. type: Content of: <book><chapter><sect1><para>
5416 #: ../en/ch04-daily.xml:420
5417 msgid ""
5418 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
5419 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
5420 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
5421 "other respects, the behaviour of the <command role=\"hg-cmd\">hg rename</"
5422 "command> command, and the options it accepts, are similar to the <command "
5423 "role=\"hg-cmd\">hg copy</command> command."
5424 msgstr ""
5426 #. type: Content of: <book><chapter><sect1><sect2><title>
5427 #: ../en/ch04-daily.xml:430
5428 msgid "Renaming files and merging changes"
5429 msgstr "改名文件与合并修改"
5431 #. type: Content of: <book><chapter><sect1><sect2><para>
5432 #: ../en/ch04-daily.xml:432
5433 msgid ""
5434 "Since Mercurial's rename is implemented as copy-and-remove, the same "
5435 "propagation of changes happens when you merge after a rename as after a copy."
5436 msgstr ""
5438 #. type: Content of: <book><chapter><sect1><sect2><para>
5439 #: ../en/ch04-daily.xml:436
5440 msgid ""
5441 "If I modify a file, and you rename it to a new name, and then we merge our "
5442 "respective changes, my modifications to the file under its original name will "
5443 "be propagated into the file under its new name. (This is something you might "
5444 "expect to <quote>simply work,</quote> but not all revision control systems "
5445 "actually do this.)"
5446 msgstr ""
5448 #. type: Content of: <book><chapter><sect1><sect2><para>
5449 #: ../en/ch04-daily.xml:443
5450 msgid ""
5451 "Whereas having changes follow a copy is a feature where you can perhaps nod "
5452 "and say <quote>yes, that might be useful,</quote> it should be clear that "
5453 "having them follow a rename is definitely important. Without this facility, "
5454 "it would simply be too easy for changes to become orphaned when files are "
5455 "renamed."
5456 msgstr ""
5458 #. type: Content of: <book><chapter><sect1><sect2><title>
5459 #: ../en/ch04-daily.xml:452
5460 msgid "Divergent renames and merging"
5461 msgstr "改名与合并的分歧"
5463 #. type: Content of: <book><chapter><sect1><sect2><para>
5464 #: ../en/ch04-daily.xml:454
5465 msgid ""
5466 "The case of diverging names occurs when two developers start with a "
5467 "file&emdash;let's call it <filename>foo</filename>&emdash;in their respective "
5468 "repositories."
5469 msgstr ""
5471 #. type: Content of: <book><chapter><sect1><sect2><para>
5472 #: ../en/ch04-daily.xml:461
5473 msgid "Anne renames the file to <filename>bar</filename>."
5474 msgstr ""
5476 #. type: Content of: <book><chapter><sect1><sect2><para>
5477 #: ../en/ch04-daily.xml:465
5478 msgid "Meanwhile, Bob renames it to <filename>quux</filename>."
5479 msgstr ""
5481 #. type: Content of: <book><chapter><sect1><sect2><para>
5482 #: ../en/ch04-daily.xml:470
5483 msgid ""
5484 "I like to think of this as a conflict because each developer has expressed "
5485 "different intentions about what the file ought to be named."
5486 msgstr ""
5489 #. type: Content of: <book><chapter><sect1><sect2><para>
5490 #: ../en/ch04-daily.xml:474
5491 msgid ""
5492 "What do you think should happen when they merge their work? Mercurial's "
5493 "actual behaviour is that it always preserves <emphasis>both</emphasis> names "
5494 "when it merges changesets that contain divergent renames."
5495 msgstr ""
5497 #. type: Content of: <book><chapter><sect1><sect2><para>
5498 #: ../en/ch04-daily.xml:481
5499 msgid ""
5500 "Notice that Mercurial does warn about the divergent renames, but it leaves it "
5501 "up to you to do something about the divergence after the merge."
5502 msgstr ""
5504 #. type: Content of: <book><chapter><sect1><sect2><title>
5505 #: ../en/ch04-daily.xml:487
5506 msgid "Convergent renames and merging"
5507 msgstr "收敛改名与合并"
5509 #. type: Content of: <book><chapter><sect1><sect2><para>
5510 #: ../en/ch04-daily.xml:489
5511 msgid ""
5512 "Another kind of rename conflict occurs when two people choose to rename "
5513 "different <emphasis>source</emphasis> files to the same "
5514 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
5515 "merge machinery, and lets you guide it to a suitable resolution."
5516 msgstr ""
5518 #. type: Content of: <book><chapter><sect1><sect2><title>
5519 #: ../en/ch04-daily.xml:497
5520 msgid "Other name-related corner cases"
5521 msgstr "其它名称相关的角落"
5523 #. type: Content of: <book><chapter><sect1><sect2><para>
5524 #: ../en/ch04-daily.xml:499
5525 msgid ""
5526 "Mercurial has a longstanding bug in which it fails to handle a merge where "
5527 "one side has a file with a given name, while another has a directory with the "
5528 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
5529 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
5530 msgstr ""
5532 #. type: Content of: <book><chapter><sect1><title>
5533 #: ../en/ch04-daily.xml:511
5534 msgid "Recovering from mistakes"
5535 msgstr "从错误恢复"
5537 #. type: Content of: <book><chapter><sect1><para>
5538 #: ../en/ch04-daily.xml:513
5539 msgid ""
5540 "Mercurial has some useful commands that will help you to recover from some "
5541 "common mistakes."
5542 msgstr ""
5544 #. type: Content of: <book><chapter><sect1><para>
5545 #: ../en/ch04-daily.xml:516
5546 msgid ""
5547 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
5548 "changes that you have made to your working directory. For example, if you "
5549 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
5550 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
5551 "added, and while the file won't be touched in any way, it won't be tracked "
5552 "for adding by Mercurial any longer, either. You can also use <command role="
5553 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
5554 msgstr ""
5556 #. type: Content of: <book><chapter><sect1><para>
5557 #: ../en/ch04-daily.xml:526
5558 msgid ""
5559 "It's useful to remember that the <command role=\"hg-cmd\">hg revert</command> "
5560 "command is useful for changes that you have not yet committed. Once you've "
5561 "committed a change, if you decide it was a mistake, you can still do "
5562 "something about it, though your options may be more limited."
5563 msgstr ""
5565 #. type: Content of: <book><chapter><sect1><para>
5566 #: ../en/ch04-daily.xml:532
5567 msgid ""
5568 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
5569 "command, and details about how to deal with changes you have already "
5570 "committed, see <xref linkend=\"chap:undo\"/>."
5571 msgstr ""
5573 #. type: Content of: <book><chapter><title>
5574 #: ../en/ch05-collab.xml:5
5575 msgid "Collaborating with other people"
5576 msgstr "团体协作"
5578 #. type: Content of: <book><chapter><para>
5579 #: ../en/ch05-collab.xml:7
5580 msgid ""
5581 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
5582 "how people ought to work with each other. However, if you're new to "
5583 "distributed revision control, it helps to have some tools and examples in "
5584 "mind when you're thinking about possible workflow models."
5585 msgstr ""
5587 #. type: Content of: <book><chapter><sect1><title>
5588 #: ../en/ch05-collab.xml:14
5589 msgid "Mercurial's web interface"
5590 msgstr "Mercurial 的 web 接口"
5592 #. type: Content of: <book><chapter><sect1><para>
5593 #: ../en/ch05-collab.xml:16
5594 msgid ""
5595 "Mercurial has a powerful web interface that provides several useful "
5596 "capabilities."
5597 msgstr ""
5599 #. type: Content of: <book><chapter><sect1><para>
5600 #: ../en/ch05-collab.xml:19
5601 msgid ""
5602 "For interactive use, the web interface lets you browse a single repository or "
5603 "a collection of repositories. You can view the history of a repository, "
5604 "examine each change (comments and diffs), and view the contents of each "
5605 "directory and file."
5606 msgstr ""
5608 #. type: Content of: <book><chapter><sect1><para>
5609 #: ../en/ch05-collab.xml:24
5610 msgid ""
5611 "Also for human consumption, the web interface provides an RSS feed of the "
5612 "changes in a repository. This lets you <quote>subscribe</quote> to a "
5613 "repository using your favourite feed reader, and be automatically notified of "
5614 "activity in that repository as soon as it happens. I find this capability "
5615 "much more convenient than the model of subscribing to a mailing list to which "
5616 "notifications are sent, as it requires no additional configuration on the "
5617 "part of whoever is serving the repository."
5618 msgstr ""
5620 #. type: Content of: <book><chapter><sect1><para>
5621 #: ../en/ch05-collab.xml:34
5622 msgid ""
5623 "The web interface also lets remote users clone a repository, pull changes "
5624 "from it, and (when the server is configured to permit it) push changes back "
5625 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
5626 "that it works efficiently even over low-bandwidth network connections."
5627 msgstr ""
5629 #. type: Content of: <book><chapter><sect1><para>
5630 #: ../en/ch05-collab.xml:40
5631 msgid ""
5632 "The easiest way to get started with the web interface is to use your web "
5633 "browser to visit an existing repository, such as the master Mercurial "
5634 "repository at <ulink url=\"http://www.selenic.com/repo/hg?style=gitweb"
5635 "\">http://www.selenic.com/repo/hg?style=gitweb</ulink>."
5636 msgstr ""
5638 #. type: Content of: <book><chapter><sect1><para>
5639 #: ../en/ch05-collab.xml:45
5640 msgid ""
5641 "If you're interested in providing a web interface to your own repositories, "
5642 "Mercurial provides two ways to do this. The first is using the <command role="
5643 "\"hg-cmd\">hg serve</command> command, which is best suited to short-term "
5644 "<quote>lightweight</quote> serving. See <xref linkend=\"sec:collab:serve\"/> "
5645 "below for details of how to use this command. If you have a long-lived "
5646 "repository that you'd like to make permanently available, Mercurial has built-"
5647 "in support for the CGI (Common Gateway Interface) standard, which all common "
5648 "web servers support. See <xref linkend=\"sec:collab:cgi\"/> for details of "
5649 "CGI configuration."
5650 msgstr ""
5652 #. type: Content of: <book><chapter><sect1><title>
5653 #: ../en/ch05-collab.xml:60
5654 msgid "Collaboration models"
5655 msgstr "协作模型"
5657 #. type: Content of: <book><chapter><sect1><para>
5658 #: ../en/ch05-collab.xml:62
5659 msgid ""
5660 "With a suitably flexible tool, making decisions about workflow is much more "
5661 "of a social engineering challenge than a technical one. Mercurial imposes few "
5662 "limitations on how you can structure the flow of work in a project, so it's "
5663 "up to you and your group to set up and live with a model that matches your "
5664 "own particular needs."
5665 msgstr ""
5667 #. type: Content of: <book><chapter><sect1><sect2><title>
5668 #: ../en/ch05-collab.xml:70
5669 msgid "Factors to keep in mind"
5670 msgstr "要牢记的因素"
5672 #. type: Content of: <book><chapter><sect1><sect2><para>
5673 #: ../en/ch05-collab.xml:72
5674 msgid ""
5675 "The most important aspect of any model that you must keep in mind is how well "
5676 "it matches the needs and capabilities of the people who will be using it. "
5677 "This might seem self-evident; even so, you still can't afford to forget it "
5678 "for a moment."
5679 msgstr ""
5681 #. type: Content of: <book><chapter><sect1><sect2><para>
5682 #: ../en/ch05-collab.xml:78
5683 msgid ""
5684 "I once put together a workflow model that seemed to make perfect sense to me, "
5685 "but that caused a considerable amount of consternation and strife within my "
5686 "development team. In spite of my attempts to explain why we needed a complex "
5687 "set of branches, and how changes ought to flow between them, a few team "
5688 "members revolted. Even though they were smart people, they didn't want to "
5689 "pay attention to the constraints we were operating under, or face the "
5690 "consequences of those constraints in the details of the model that I was "
5691 "advocating."
5692 msgstr ""
5694 #. type: Content of: <book><chapter><sect1><sect2><para>
5695 #: ../en/ch05-collab.xml:88
5696 msgid ""
5697 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
5698 "scheme you put into effect, you should plan for mistakes and problem "
5699 "scenarios. Consider adding automated machinery to prevent, or quickly "
5700 "recover from, trouble that you can anticipate. As an example, if you intend "
5701 "to have a branch with not-for-release changes in it, you'd do well to think "
5702 "early about the possibility that someone might accidentally merge those "
5703 "changes into a release branch. You could avoid this particular problem by "
5704 "writing a hook that prevents changes from being merged from an inappropriate "
5705 "branch."
5706 msgstr ""
5708 #. type: Content of: <book><chapter><sect1><sect2><title>
5709 #: ../en/ch05-collab.xml:102
5710 msgid "Informal anarchy"
5711 msgstr "无政府状态"
5713 #. type: Content of: <book><chapter><sect1><sect2><para>
5714 #: ../en/ch05-collab.xml:104
5715 msgid ""
5716 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
5717 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
5718 "well in a few unusual situations."
5719 msgstr ""
5721 #. type: Content of: <book><chapter><sect1><sect2><para>
5722 #: ../en/ch05-collab.xml:109
5723 msgid ""
5724 "As one example, many projects have a loose-knit group of collaborators who "
5725 "rarely physically meet each other. Some groups like to overcome the "
5726 "isolation of working at a distance by organising occasional <quote>sprints</"
5727 "quote>. In a sprint, a number of people get together in a single location (a "
5728 "company's conference room, a hotel meeting room, that kind of place) and "
5729 "spend several days more or less locked in there, hacking intensely on a "
5730 "handful of projects."
5731 msgstr ""
5733 #. type: Content of: <book><chapter><sect1><sect2><para>
5734 #: ../en/ch05-collab.xml:118
5735 msgid ""
5736 "A sprint is the perfect place to use the <command role=\"hg-cmd\">hg serve</"
5737 "command> command, since <command role=\"hg-cmd\">hg serve</command> does not "
5738 "require any fancy server infrastructure. You can get started with <command "
5739 "role=\"hg-cmd\">hg serve</command> in moments, by reading <xref linkend=\"sec:"
5740 "collab:serve\"/> below. Then simply tell the person next to you that you're "
5741 "running a server, send the URL to them in an instant message, and you "
5742 "immediately have a quick-turnaround way to work together. They can type your "
5743 "URL into their web browser and quickly review your changes; or they can pull "
5744 "a bugfix from you and verify it; or they can clone a branch containing a new "
5745 "feature and try it out."
5746 msgstr ""
5748 #. type: Content of: <book><chapter><sect1><sect2><para>
5749 #: ../en/ch05-collab.xml:132
5750 msgid ""
5751 "The charm, and the problem, with doing things in an ad hoc fashion like this "
5752 "is that only people who know about your changes, and where they are, can see "
5753 "them. Such an informal approach simply doesn't scale beyond a handful "
5754 "people, because each individual needs to know about $n$ different "
5755 "repositories to pull from."
5756 msgstr ""
5758 #. type: Content of: <book><chapter><sect1><sect2><title>
5759 #: ../en/ch05-collab.xml:141
5760 msgid "A single central repository"
5761 msgstr "单一中央版本库"
5763 #. type: Content of: <book><chapter><sect1><sect2><para>
5764 #: ../en/ch05-collab.xml:143
5765 msgid ""
5766 "For smaller projects migrating from a centralised revision control tool, "
5767 "perhaps the easiest way to get started is to have changes flow through a "
5768 "single shared central repository. This is also the most common "
5769 "<quote>building block</quote> for more ambitious workflow schemes."
5770 msgstr ""
5772 #. type: Content of: <book><chapter><sect1><sect2><para>
5773 #: ../en/ch05-collab.xml:149
5774 msgid ""
5775 "Contributors start by cloning a copy of this repository. They can pull "
5776 "changes from it whenever they need to, and some (perhaps all) developers have "
5777 "permission to push a change back when they're ready for other people to see "
5778 "it."
5779 msgstr ""
5781 #. type: Content of: <book><chapter><sect1><sect2><para>
5782 #: ../en/ch05-collab.xml:154
5783 msgid ""
5784 "Under this model, it can still often make sense for people to pull changes "
5785 "directly from each other, without going through the central repository. "
5786 "Consider a case in which I have a tentative bug fix, but I am worried that if "
5787 "I were to publish it to the central repository, it might subsequently break "
5788 "everyone else's trees as they pull it. To reduce the potential for damage, I "
5789 "can ask you to clone my repository into a temporary repository of your own "
5790 "and test it. This lets us put off publishing the potentially unsafe change "
5791 "until it has had a little testing."
5792 msgstr ""
5794 #. type: Content of: <book><chapter><sect1><sect2><para>
5795 #: ../en/ch05-collab.xml:165
5796 msgid ""
5797 "In this kind of scenario, people usually use the <command>ssh</command> "
5798 "protocol to securely push changes to the central repository, as documented in "
5799 "<xref linkend=\"sec:collab:ssh\"/>. It's also usual to publish a read-only "
5800 "copy of the repository over HTTP using CGI, as in <xref linkend=\"sec:collab:"
5801 "cgi\"/>. Publishing over HTTP satisfies the needs of people who don't have "
5802 "push access, and those who want to use web browsers to browse the "
5803 "repository's history."
5804 msgstr ""
5806 #. type: Content of: <book><chapter><sect1><sect2><title>
5807 #: ../en/ch05-collab.xml:177
5808 msgid "Working with multiple branches"
5809 msgstr "使用多个分支工作"
5811 #. type: Content of: <book><chapter><sect1><sect2><para>
5812 #: ../en/ch05-collab.xml:179
5813 msgid ""
5814 "Projects of any significant size naturally tend to make progress on several "
5815 "fronts simultaneously. In the case of software, it's common for a project to "
5816 "go through periodic official releases. A release might then go into "
5817 "<quote>maintenance mode</quote> for a while after its first publication; "
5818 "maintenance releases tend to contain only bug fixes, not new features. In "
5819 "parallel with these maintenance releases, one or more future releases may be "
5820 "under development. People normally use the word <quote>branch</quote> to "
5821 "refer to one of these many slightly different directions in which development "
5822 "is proceeding."
5823 msgstr ""
5825 #. type: Content of: <book><chapter><sect1><sect2><para>
5826 #: ../en/ch05-collab.xml:192
5827 msgid ""
5828 "Mercurial is particularly well suited to managing a number of simultaneous, "
5829 "but not identical, branches. Each <quote>development direction</quote> can "
5830 "live in its own central repository, and you can merge changes from one to "
5831 "another as the need arises. Because repositories are independent of each "
5832 "other, unstable changes in a development branch will never affect a stable "
5833 "branch unless someone explicitly merges those changes in."
5834 msgstr ""
5836 #. type: Content of: <book><chapter><sect1><sect2><para>
5837 #: ../en/ch05-collab.xml:201
5838 msgid ""
5839 "Here's an example of how this can work in practice. Let's say you have one "
5840 "<quote>main branch</quote> on a central server."
5841 msgstr ""
5843 #. type: Content of: <book><chapter><sect1><sect2><para>
5844 #: ../en/ch05-collab.xml:207
5845 msgid "People clone it, make changes locally, test them, and push them back."
5846 msgstr ""
5848 #. type: Content of: <book><chapter><sect1><sect2><para>
5849 #: ../en/ch05-collab.xml:210
5850 msgid ""
5851 "Once the main branch reaches a release milestone, you can use the <command "
5852 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
5853 "milestone revision."
5854 msgstr ""
5856 #. type: Content of: <book><chapter><sect1><sect2><para>
5857 #: ../en/ch05-collab.xml:216
5858 msgid "Let's say some ongoing development occurs on the main branch."
5859 msgstr ""
5861 #. type: Content of: <book><chapter><sect1><sect2><para>
5862 #: ../en/ch05-collab.xml:221
5863 msgid ""
5864 "Using the tag that was recorded at the milestone, people who clone that "
5865 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
5866 "update</command> to get a copy of the working directory exactly as it was "
5867 "when that tagged revision was committed."
5868 msgstr ""
5871 #. type: Content of: <book><chapter><sect1><sect2><para>
5872 #: ../en/ch05-collab.xml:229
5873 msgid ""
5874 "In addition, immediately after the main branch is tagged, someone can then "
5875 "clone the main branch on the server to a new <quote>stable</quote> branch, "
5876 "also on the server."
5877 msgstr ""
5879 #. type: Content of: <book><chapter><sect1><sect2><para>
5880 #: ../en/ch05-collab.xml:235
5881 msgid ""
5882 "Someone who needs to make a change to the stable branch can then clone "
5883 "<emphasis>that</emphasis> repository, make their changes, commit, and push "
5884 "their changes back there."
5885 msgstr ""
5887 #. type: Content of: <book><chapter><sect1><sect2><para>
5888 #: ../en/ch05-collab.xml:241
5889 msgid ""
5890 "Because Mercurial repositories are independent, and Mercurial doesn't move "
5891 "changes around automatically, the stable and main branches are "
5892 "<emphasis>isolated</emphasis> from each other. The changes that you made on "
5893 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
5894 "versa."
5895 msgstr ""
5897 #. type: Content of: <book><chapter><sect1><sect2><para>
5898 #: ../en/ch05-collab.xml:248
5899 msgid ""
5900 "You'll often want all of your bugfixes on the stable branch to show up on the "
5901 "main branch, too. Rather than rewrite a bugfix on the main branch, you can "
5902 "simply pull and merge changes from the stable to the main branch, and "
5903 "Mercurial will bring those bugfixes in for you."
5904 msgstr ""
5906 #. type: Content of: <book><chapter><sect1><sect2><para>
5907 #: ../en/ch05-collab.xml:256
5908 msgid ""
5909 "The main branch will still contain changes that are not on the stable branch, "
5910 "but it will also contain all of the bugfixes from the stable branch. The "
5911 "stable branch remains unaffected by these changes."
5912 msgstr ""
5914 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
5915 #: ../en/ch05-collab.xml:263 ../en/ch05-collab.xml:273
5916 msgid "Feature branches"
5917 msgstr "特性分支"
5919 #. type: Content of: <book><chapter><sect1><sect2><para>
5920 #: ../en/ch05-collab.xml:265
5921 msgid ""
5922 "For larger projects, an effective way to manage change is to break up a team "
5923 "into smaller groups. Each group has a shared branch of its own, cloned from "
5924 "a single <quote>master</quote> branch used by the entire project. People "
5925 "working on an individual branch are typically quite isolated from "
5926 "developments on other branches."
5927 msgstr ""
5929 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
5930 #: ../en/ch05-collab.xml:275
5931 msgid ""
5932 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
5933 "></imageobject>"
5934 msgstr ""
5936 #. type: Content of: <book><chapter><sect1><sect2><para>
5937 #: ../en/ch05-collab.xml:280
5938 msgid ""
5939 "When a particular feature is deemed to be in suitable shape, someone on that "
5940 "feature team pulls and merges from the master branch into the feature branch, "
5941 "then pushes back up to the master branch."
5942 msgstr ""
5944 #. type: Content of: <book><chapter><sect1><sect2><title>
5945 #: ../en/ch05-collab.xml:287
5946 msgid "The release train"
5947 msgstr "发布列车"
5949 #. type: Content of: <book><chapter><sect1><sect2><para>
5950 #: ../en/ch05-collab.xml:289
5951 msgid ""
5952 "Some projects are organised on a <quote>train</quote> basis: a release is "
5953 "scheduled to happen every few months, and whatever features are ready when "
5954 "the <quote>train</quote> is ready to leave are allowed in."
5955 msgstr ""
5957 #. type: Content of: <book><chapter><sect1><sect2><para>
5958 #: ../en/ch05-collab.xml:294
5959 msgid ""
5960 "This model resembles working with feature branches. The difference is that "
5961 "when a feature branch misses a train, someone on the feature team pulls and "
5962 "merges the changes that went out on that train release into the feature "
5963 "branch, and the team continues its work on top of that release so that their "
5964 "feature can make the next release."
5965 msgstr ""
5967 #. type: Content of: <book><chapter><sect1><sect2><title>
5968 #: ../en/ch05-collab.xml:303
5969 msgid "The Linux kernel model"
5970 msgstr "Linux 内核模型"
5972 #. type: Content of: <book><chapter><sect1><sect2><para>
5973 #: ../en/ch05-collab.xml:305
5974 msgid ""
5975 "The development of the Linux kernel has a shallow hierarchical structure, "
5976 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
5977 "<command>git</command>, a distributed revision control tool with capabilities "
5978 "similar to Mercurial, it's useful to describe the way work flows in that "
5979 "environment; if you like the ideas, the approach translates well across tools."
5980 msgstr ""
5982 #. type: Content of: <book><chapter><sect1><sect2><para>
5983 #: ../en/ch05-collab.xml:313
5984 msgid ""
5985 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
5986 "publishes a single source repository that is considered the "
5987 "<quote>authoritative</quote> current tree by the entire developer community. "
5988 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
5989 "pulls from."
5990 msgstr ""
5992 #. type: Content of: <book><chapter><sect1><sect2><para>
5993 #: ../en/ch05-collab.xml:320
5994 msgid ""
5995 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
5996 "he pulls whatever changes they publish, in most cases without even reviewing "
5997 "those changes. Some of those lieutenants are generally agreed to be "
5998 "<quote>maintainers</quote>, responsible for specific subsystems within the "
5999 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
6000 "they want to end up in Linus's tree, they must find out who the subsystem's "
6001 "maintainer is, and ask that maintainer to take their change. If the "
6002 "maintainer reviews their changes and agrees to take them, they'll pass them "
6003 "along to Linus in due course."
6004 msgstr ""
6006 #. type: Content of: <book><chapter><sect1><sect2><para>
6007 #: ../en/ch05-collab.xml:332
6008 msgid ""
6009 "Individual lieutenants have their own approaches to reviewing, accepting, and "
6010 "publishing changes; and for deciding when to feed them to Linus. In "
6011 "addition, there are several well known branches that people use for different "
6012 "purposes. For example, a few people maintain <quote>stable</quote> "
6013 "repositories of older versions of the kernel, to which they apply critical "
6014 "fixes as needed. Some maintainers publish multiple trees: one for "
6015 "experimental changes; one for changes that they are about to feed upstream; "
6016 "and so on. Others just publish a single tree."
6017 msgstr ""
6019 #. type: Content of: <book><chapter><sect1><sect2><para>
6020 #: ../en/ch05-collab.xml:343
6021 msgid ""
6022 "This model has two notable features. The first is that it's <quote>pull "
6023 "only</quote>. You have to ask, convince, or beg another developer to take a "
6024 "change from you, because there are almost no trees to which more than one "
6025 "person can push, and there's no way to push changes into a tree that someone "
6026 "else controls."
6027 msgstr ""
6029 #. type: Content of: <book><chapter><sect1><sect2><para>
6030 #: ../en/ch05-collab.xml:350
6031 msgid ""
6032 "The second is that it's based on reputation and acclaim. If you're an "
6033 "unknown, Linus will probably ignore changes from you without even "
6034 "responding. But a subsystem maintainer will probably review them, and will "
6035 "likely take them if they pass their criteria for suitability. The more "
6036 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
6037 "they are to trust your judgment and accept your changes. If you're well-"
6038 "known and maintain a long-lived branch for something Linus hasn't yet "
6039 "accepted, people with similar interests may pull your changes regularly to "
6040 "keep up with your work."
6041 msgstr ""
6043 #. type: Content of: <book><chapter><sect1><sect2><para>
6044 #: ../en/ch05-collab.xml:361
6045 msgid ""
6046 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
6047 "quote> boundaries. If you're a respected but specialised storage hacker, and "
6048 "you try to fix a networking bug, that change will receive a level of scrutiny "
6049 "from a network maintainer comparable to a change from a complete stranger."
6050 msgstr ""
6052 #. type: Content of: <book><chapter><sect1><sect2><para>
6053 #: ../en/ch05-collab.xml:368
6054 msgid ""
6055 "To people who come from more orderly project backgrounds, the comparatively "
6056 "chaotic Linux kernel development process often seems completely insane. It's "
6057 "subject to the whims of individuals; people make sweeping changes whenever "
6058 "they deem it appropriate; and the pace of development is astounding. And yet "
6059 "Linux is a highly successful, well-regarded piece of software."
6060 msgstr ""
6062 #. type: Content of: <book><chapter><sect1><sect2><title>
6063 #: ../en/ch05-collab.xml:378
6064 msgid "Pull-only versus shared-push collaboration"
6065 msgstr "只读与共享写协作"
6067 #. type: Content of: <book><chapter><sect1><sect2><para>
6068 #: ../en/ch05-collab.xml:380
6069 msgid ""
6070 "A perpetual source of heat in the open source community is whether a "
6071 "development model in which people only ever pull changes from others is "
6072 "<quote>better than</quote> one in which multiple people can push changes to a "
6073 "shared repository."
6074 msgstr ""
6076 #. type: Content of: <book><chapter><sect1><sect2><para>
6077 #: ../en/ch05-collab.xml:386
6078 msgid ""
6079 "Typically, the backers of the shared-push model use tools that actively "
6080 "enforce this approach. If you're using a centralised revision control tool "
6081 "such as Subversion, there's no way to make a choice over which model you'll "
6082 "use: the tool gives you shared-push, and if you want to do anything else, "
6083 "you'll have to roll your own approach on top (such as applying a patch by "
6084 "hand)."
6085 msgstr ""
6087 #. type: Content of: <book><chapter><sect1><sect2><para>
6088 #: ../en/ch05-collab.xml:394
6089 msgid ""
6090 "A good distributed revision control tool, such as Mercurial, will support "
6091 "both models. You and your collaborators can then structure how you work "
6092 "together based on your own needs and preferences, not on what contortions "
6093 "your tools force you into."
6094 msgstr ""
6096 #. type: Content of: <book><chapter><sect1><sect2><title>
6097 #: ../en/ch05-collab.xml:402
6098 msgid "Where collaboration meets branch management"
6099 msgstr "协作与分支管理"
6101 #. type: Content of: <book><chapter><sect1><sect2><para>
6102 #: ../en/ch05-collab.xml:404
6103 msgid ""
6104 "Once you and your team set up some shared repositories and start propagating "
6105 "changes back and forth between local and shared repos, you begin to face a "
6106 "related, but slightly different challenge: that of managing the multiple "
6107 "directions in which your team may be moving at once. Even though this "
6108 "subject is intimately related to how your team collaborates, it's dense "
6109 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
6110 msgstr ""
6112 #. type: Content of: <book><chapter><sect1><title>
6113 #: ../en/ch05-collab.xml:416
6114 msgid "The technical side of sharing"
6115 msgstr "共享的技术因素"
6117 #. type: Content of: <book><chapter><sect1><para>
6118 #: ../en/ch05-collab.xml:418
6119 msgid ""
6120 "The remainder of this chapter is devoted to the question of serving data to "
6121 "your collaborators."
6122 msgstr ""
6124 #. type: Content of: <book><chapter><sect1><title>
6125 #: ../en/ch05-collab.xml:423
6126 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
6127 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
6129 #. type: Content of: <book><chapter><sect1><para>
6130 #: ../en/ch05-collab.xml:426
6131 msgid ""
6132 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
6133 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
6134 "It also provides a great way to get a feel for using Mercurial commands over "
6135 "a network."
6136 msgstr ""
6138 #. type: Content of: <book><chapter><sect1><para>
6139 #: ../en/ch05-collab.xml:431
6140 msgid ""
6141 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
6142 "under a second it will bring up a specialised HTTP server; this will accept "
6143 "connections from any client, and serve up data for that repository until you "
6144 "terminate it. Anyone who knows the URL of the server you just started, and "
6145 "can talk to your computer over the network, can then use a web browser or "
6146 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
6147 "cmd\">hg serve</command> instance running on a laptop is likely to look "
6148 "something like <literal>http://my-laptop.local:8000/</literal>."
6149 msgstr ""
6151 #. type: Content of: <book><chapter><sect1><para>
6152 #: ../en/ch05-collab.xml:442
6153 msgid ""
6154 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
6155 "emphasis> a general-purpose web server. It can do only two things:"
6156 msgstr ""
6158 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6159 #: ../en/ch05-collab.xml:446
6160 msgid ""
6161 "Allow people to browse the history of the repository it's serving, from their "
6162 "normal web browsers."
6163 msgstr ""
6165 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
6166 #: ../en/ch05-collab.xml:450
6167 msgid ""
6168 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
6169 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
6170 "from that repository."
6171 msgstr ""
6173 #. type: Content of: <book><chapter><sect1><para>
6174 #: ../en/ch05-collab.xml:455
6175 msgid ""
6176 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
6177 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
6178 "only use."
6179 msgstr ""
6181 #. type: Content of: <book><chapter><sect1><para>
6182 #: ../en/ch05-collab.xml:459
6183 msgid ""
6184 "If you're getting started with Mercurial, there's nothing to prevent you from "
6185 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
6186 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
6187 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
6188 "to that server as if the repository was hosted remotely. This can help you to "
6189 "quickly get acquainted with using commands on network-hosted repositories."
6190 msgstr ""
6192 #. type: Content of: <book><chapter><sect1><sect2><title>
6193 #: ../en/ch05-collab.xml:469
6194 msgid "A few things to keep in mind"
6195 msgstr "要牢记的几件事"
6197 #. type: Content of: <book><chapter><sect1><sect2><para>
6198 #: ../en/ch05-collab.xml:471
6199 msgid ""
6200 "Because it provides unauthenticated read access to all clients, you should "
6201 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
6202 "you either don't care, or have complete control over, who can access your "
6203 "network and pull data from your repository."
6204 msgstr ""
6206 #. type: Content of: <book><chapter><sect1><sect2><para>
6207 #: ../en/ch05-collab.xml:477
6208 msgid ""
6209 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
6210 "any firewall software you might have installed on your system or network. It "
6211 "cannot detect or control your firewall software. If other people are unable "
6212 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
6213 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
6214 "they're using the correct URL) is check your firewall configuration."
6215 msgstr ""
6217 #. type: Content of: <book><chapter><sect1><sect2><para>
6218 #: ../en/ch05-collab.xml:486
6219 msgid ""
6220 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
6221 "connections on port 8000. If another process is already listening on the "
6222 "port you want to use, you can specify a different port to listen on using the "
6223 "<option role=\"hg-opt-serve\">-p</option> option."
6224 msgstr ""
6226 #. type: Content of: <book><chapter><sect1><sect2><para>
6227 #: ../en/ch05-collab.xml:492
6228 msgid ""
6229 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
6230 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
6231 "indeed running correctly, and find out what URL you should send to your "
6232 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
6233 "option."
6234 msgstr ""
6236 #. type: Content of: <book><chapter><sect1><title>
6237 #: ../en/ch05-collab.xml:502
6238 msgid "Using the Secure Shell (ssh) protocol"
6239 msgstr "使用 ssh 协议"
6241 #. type: Content of: <book><chapter><sect1><para>
6242 #: ../en/ch05-collab.xml:504
6243 msgid ""
6244 "You can pull and push changes securely over a network connection using the "
6245 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
6246 "you may have to do a little bit of configuration on the client or server "
6247 "sides."
6248 msgstr ""
6250 #. type: Content of: <book><chapter><sect1><para>
6251 #: ../en/ch05-collab.xml:509
6252 msgid ""
6253 "If you're not familiar with ssh, it's a network protocol that lets you "
6254 "securely communicate with another computer. To use it with Mercurial, you'll "
6255 "be setting up one or more user accounts on a server so that remote users can "
6256 "log in and execute commands."
6257 msgstr ""
6259 #. type: Content of: <book><chapter><sect1><para>
6260 #: ../en/ch05-collab.xml:515
6261 msgid ""
6262 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
6263 "of the material that follows to be elementary in nature.)"
6264 msgstr ""
6266 #. type: Content of: <book><chapter><sect1><sect2><title>
6267 #: ../en/ch05-collab.xml:520
6268 msgid "How to read and write ssh URLs"
6269 msgstr "如何读写 ssh 路径"
6271 #. type: Content of: <book><chapter><sect1><sect2><para>
6272 #: ../en/ch05-collab.xml:522
6273 msgid "An ssh URL tends to look like this:"
6274 msgstr ""
6276 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6277 #: ../en/ch05-collab.xml:525
6278 msgid ""
6279 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
6280 "ssh protocol."
6281 msgstr ""
6283 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6284 #: ../en/ch05-collab.xml:528
6285 msgid ""
6286 "The <quote><literal>bos@</literal></quote> component indicates what username "
6287 "to log into the server as. You can leave this out if the remote username is "
6288 "the same as your local username."
6289 msgstr ""
6291 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6292 #: ../en/ch05-collab.xml:533
6293 msgid ""
6294 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
6295 "the server to log into."
6296 msgstr ""
6298 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6299 #: ../en/ch05-collab.xml:537
6300 msgid ""
6301 "The <quote>:22</quote> identifies the port number to connect to the server "
6302 "on. The default port is 22, so you only need to specify a colon and port "
6303 "number if you're <emphasis>not</emphasis> using port 22."
6304 msgstr ""
6306 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6307 #: ../en/ch05-collab.xml:542
6308 msgid ""
6309 "The remainder of the URL is the local path to the repository on the server."
6310 msgstr ""
6312 #. type: Content of: <book><chapter><sect1><sect2><para>
6313 #: ../en/ch05-collab.xml:546
6314 msgid ""
6315 "There's plenty of scope for confusion with the path component of ssh URLs, as "
6316 "there is no standard way for tools to interpret it. Some programs behave "
6317 "differently than others when dealing with these paths. This isn't an ideal "
6318 "situation, but it's unlikely to change. Please read the following paragraphs "
6319 "carefully."
6320 msgstr ""
6322 #. type: Content of: <book><chapter><sect1><sect2><para>
6323 #: ../en/ch05-collab.xml:553
6324 msgid ""
6325 "Mercurial treats the path to a repository on the server as relative to the "
6326 "remote user's home directory. For example, if user <literal>foo</literal> on "
6327 "the server has a home directory of <filename class=\"directory\">/home/foo</"
6328 "filename>, then an ssh URL that contains a path component of <filename class="
6329 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
6330 "directory <filename class=\"directory\">/home/foo/bar</filename>."
6331 msgstr ""
6333 #. type: Content of: <book><chapter><sect1><sect2><para>
6334 #: ../en/ch05-collab.xml:562
6335 msgid ""
6336 "If you want to specify a path relative to another user's home directory, you "
6337 "can use a path that starts with a tilde character followed by the user's name "
6338 "(let's call them <literal>otheruser</literal>), like this."
6339 msgstr ""
6341 #. type: Content of: <book><chapter><sect1><sect2><para>
6342 #: ../en/ch05-collab.xml:568
6343 msgid ""
6344 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
6345 "the server, begin the path component with two slashes, as in this example."
6346 msgstr ""
6348 #. type: Content of: <book><chapter><sect1><sect2><title>
6349 #: ../en/ch05-collab.xml:575
6350 msgid "Finding an ssh client for your system"
6351 msgstr "为你的系统寻找 ssh 客户端"
6353 #. type: Content of: <book><chapter><sect1><sect2><para>
6354 #: ../en/ch05-collab.xml:577
6355 msgid ""
6356 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
6357 "using such a system, run <literal>which ssh</literal> to find out if the "
6358 "<command>ssh</command> command is installed (it's usually in <filename class="
6359 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
6360 "present, take a look at your system documentation to figure out how to "
6361 "install it."
6362 msgstr ""
6364 #. type: Content of: <book><chapter><sect1><sect2><para>
6365 #: ../en/ch05-collab.xml:585
6366 msgid ""
6367 "On Windows, you'll first need to download a suitable ssh client. There are "
6368 "two alternatives."
6369 msgstr ""
6371 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6372 #: ../en/ch05-collab.xml:588
6373 msgid ""
6374 "Simon Tatham's excellent PuTTY package <citation>web:putty</citation> "
6375 "provides a complete suite of ssh client commands."
6376 msgstr ""
6378 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6379 #: ../en/ch05-collab.xml:592
6380 msgid ""
6381 "If you have a high tolerance for pain, you can use the Cygwin port of OpenSSH."
6382 msgstr ""
6384 #. type: Content of: <book><chapter><sect1><sect2><para>
6385 #: ../en/ch05-collab.xml:595
6386 msgid ""
6387 "In either case, you'll need to edit your <filename role=\"special\">hg.ini</"
6388 "filename> file to tell Mercurial where to find the actual client command. "
6389 "For example, if you're using PuTTY, you'll need to use the <command>plink</"
6390 "command> command as a command-line ssh client."
6391 msgstr ""
6393 #. type: Content of: <book><chapter><sect1><sect2><note><para>
6394 #: ../en/ch05-collab.xml:605
6395 msgid ""
6396 "The path to <command>plink</command> shouldn't contain any whitespace "
6397 "characters, or Mercurial may not be able to run it correctly (so putting it "
6398 "in <filename class=\"directory\">C:\\Program Files</filename> is probably not "
6399 "a good idea)."
6400 msgstr ""
6402 #. type: Content of: <book><chapter><sect1><sect2><title>
6403 #: ../en/ch05-collab.xml:614
6404 msgid "Generating a key pair"
6405 msgstr "产生密钥对"
6407 #. type: Content of: <book><chapter><sect1><sect2><para>
6408 #: ../en/ch05-collab.xml:616
6409 msgid ""
6410 "To avoid the need to repetitively type a password every time you need to use "
6411 "your ssh client, I recommend generating a key pair. On a Unix-like system, "
6412 "the <command>ssh-keygen</command> command will do the trick. On Windows, if "
6413 "you're using PuTTY, the <command>puttygen</command> command is what you'll "
6414 "need."
6415 msgstr ""
6417 #. type: Content of: <book><chapter><sect1><sect2><para>
6418 #: ../en/ch05-collab.xml:624
6419 msgid ""
6420 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
6421 "advisable to protect it with a passphrase. (The only time that you might not "
6422 "want to do this is when you're using the ssh protocol for automated tasks on "
6423 "a secure network.)"
6424 msgstr ""
6426 #. type: Content of: <book><chapter><sect1><sect2><para>
6427 #: ../en/ch05-collab.xml:630
6428 msgid ""
6429 "Simply generating a key pair isn't enough, however. You'll need to add the "
6430 "public key to the set of authorised keys for whatever user you're logging in "
6431 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
6432 "adding the public key to a list in a file called <filename role=\"special"
6433 "\">authorized_keys</filename> in their <filename role=\"special\" class="
6434 "\"directory\">.ssh</filename> directory."
6435 msgstr ""
6437 #. type: Content of: <book><chapter><sect1><sect2><para>
6438 #: ../en/ch05-collab.xml:639
6439 msgid ""
6440 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
6441 "extension. If you're using <command>puttygen</command> on Windows, you can "
6442 "save the public key to a file of your choosing, or paste it from the window "
6443 "it's displayed in straight into the <filename role=\"special"
6444 "\">authorized_keys</filename> file."
6445 msgstr ""
6447 #. type: Content of: <book><chapter><sect1><sect2><title>
6448 #: ../en/ch05-collab.xml:648
6449 msgid "Using an authentication agent"
6450 msgstr "使用认证代理"
6452 #. type: Content of: <book><chapter><sect1><sect2><para>
6453 #: ../en/ch05-collab.xml:650
6454 msgid ""
6455 "An authentication agent is a daemon that stores passphrases in memory (so it "
6456 "will forget passphrases if you log out and log back in again). An ssh client "
6457 "will notice if it's running, and query it for a passphrase. If there's no "
6458 "authentication agent running, or the agent doesn't store the necessary "
6459 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
6460 "communicate with a server on your behalf (e.g. whenever you pull or push "
6461 "changes)."
6462 msgstr ""
6464 #. type: Content of: <book><chapter><sect1><sect2><para>
6465 #: ../en/ch05-collab.xml:659
6466 msgid ""
6467 "The downside of storing passphrases in an agent is that it's possible for a "
6468 "well-prepared attacker to recover the plain text of your passphrases, in some "
6469 "cases even if your system has been power-cycled. You should make your own "
6470 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
6471 "of repeated typing."
6472 msgstr ""
6474 #. type: Content of: <book><chapter><sect1><sect2><para>
6475 #: ../en/ch05-collab.xml:666
6476 msgid ""
6477 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
6478 "it's often run automatically for you when you log in. You'll need to use the "
6479 "<command>ssh-add</command> command to add passphrases to the agent's store. "
6480 "On Windows, if you're using PuTTY, the <command>pageant</command> command "
6481 "acts as the agent. It adds an icon to your system tray that will let you "
6482 "manage stored passphrases."
6483 msgstr ""
6485 #. type: Content of: <book><chapter><sect1><sect2><title>
6486 #: ../en/ch05-collab.xml:677
6487 msgid "Configuring the server side properly"
6488 msgstr "正确配置服务器端"
6490 #. type: Content of: <book><chapter><sect1><sect2><para>
6491 #: ../en/ch05-collab.xml:679
6492 msgid ""
6493 "Because ssh can be fiddly to set up if you're new to it, there's a variety of "
6494 "things that can go wrong. Add Mercurial on top, and there's plenty more "
6495 "scope for head-scratching. Most of these potential problems occur on the "
6496 "server side, not the client side. The good news is that once you've gotten a "
6497 "configuration working, it will usually continue to work indefinitely."
6498 msgstr ""
6500 #. type: Content of: <book><chapter><sect1><sect2><para>
6501 #: ../en/ch05-collab.xml:687
6502 msgid ""
6503 "Before you try using Mercurial to talk to an ssh server, it's best to make "
6504 "sure that you can use the normal <command>ssh</command> or <command>putty</"
6505 "command> command to talk to the server first. If you run into problems with "
6506 "using these commands directly, Mercurial surely won't work. Worse, it will "
6507 "obscure the underlying problem. Any time you want to debug ssh-related "
6508 "Mercurial problems, you should drop back to making sure that plain ssh client "
6509 "commands work first, <emphasis>before</emphasis> you worry about whether "
6510 "there's a problem with Mercurial."
6511 msgstr ""
6513 #. type: Content of: <book><chapter><sect1><sect2><para>
6514 #: ../en/ch05-collab.xml:698
6515 msgid ""
6516 "The first thing to be sure of on the server side is that you can actually log "
6517 "in from another machine at all. If you can't use <command>ssh</command> or "
6518 "<command>putty</command> to log in, the error message you get may give you a "
6519 "few hints as to what's wrong. The most common problems are as follows."
6520 msgstr ""
6522 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6523 #: ../en/ch05-collab.xml:705
6524 msgid ""
6525 "If you get a <quote>connection refused</quote> error, either there isn't an "
6526 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
6527 "configuration."
6528 msgstr ""
6530 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6531 #: ../en/ch05-collab.xml:710
6532 msgid ""
6533 "If you get a <quote>no route to host</quote> error, you either have an "
6534 "incorrect address for the server or a seriously locked down firewall that "
6535 "won't admit its existence at all."
6536 msgstr ""
6538 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6539 #: ../en/ch05-collab.xml:715
6540 msgid ""
6541 "If you get a <quote>permission denied</quote> error, you may have mistyped "
6542 "the username on the server, or you could have mistyped your key's passphrase "
6543 "or the remote user's password."
6544 msgstr ""
6546 #. type: Content of: <book><chapter><sect1><sect2><para>
6547 #: ../en/ch05-collab.xml:720
6548 msgid ""
6549 "In summary, if you're having trouble talking to the server's ssh daemon, "
6550 "first make sure that one is running at all. On many systems it will be "
6551 "installed, but disabled, by default. Once you're done with this step, you "
6552 "should then check that the server's firewall is configured to allow incoming "
6553 "connections on the port the ssh daemon is listening on (usually 22). Don't "
6554 "worry about more exotic possibilities for misconfiguration until you've "
6555 "checked these two first."
6556 msgstr ""
6558 #. type: Content of: <book><chapter><sect1><sect2><para>
6559 #: ../en/ch05-collab.xml:730
6560 msgid ""
6561 "If you're using an authentication agent on the client side to store "
6562 "passphrases for your keys, you ought to be able to log into the server "
6563 "without being prompted for a passphrase or a password. If you're prompted "
6564 "for a passphrase, there are a few possible culprits."
6565 msgstr ""
6567 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6568 #: ../en/ch05-collab.xml:736
6569 msgid ""
6570 "You might have forgotten to use <command>ssh-add</command> or "
6571 "<command>pageant</command> to store the passphrase."
6572 msgstr ""
6574 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6575 #: ../en/ch05-collab.xml:740
6576 msgid "You might have stored the passphrase for the wrong key."
6577 msgstr ""
6579 #. type: Content of: <book><chapter><sect1><sect2><para>
6580 #: ../en/ch05-collab.xml:743
6581 msgid ""
6582 "If you're being prompted for the remote user's password, there are another "
6583 "few possible problems to check."
6584 msgstr ""
6586 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6587 #: ../en/ch05-collab.xml:746
6588 msgid ""
6589 "Either the user's home directory or their <filename role=\"special\" class="
6590 "\"directory\">.ssh</filename> directory might have excessively liberal "
6591 "permissions. As a result, the ssh daemon will not trust or read their "
6592 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
6593 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
6594 "filename> directory will often cause this symptom."
6595 msgstr ""
6597 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6598 #: ../en/ch05-collab.xml:755
6599 msgid ""
6600 "The user's <filename role=\"special\">authorized_keys</filename> file may "
6601 "have a problem. If anyone other than the user owns or can write to that file, "
6602 "the ssh daemon will not trust or read it."
6603 msgstr ""
6605 #. type: Content of: <book><chapter><sect1><sect2><para>
6606 #: ../en/ch05-collab.xml:762
6607 msgid ""
6608 "In the ideal world, you should be able to run the following command "
6609 "successfully, and it should print exactly one line of output, the current "
6610 "date and time."
6611 msgstr ""
6613 #. type: Content of: <book><chapter><sect1><sect2><para>
6614 #: ../en/ch05-collab.xml:767
6615 msgid ""
6616 "If, on your server, you have login scripts that print banners or other junk "
6617 "even when running non-interactive commands like this, you should fix them "
6618 "before you continue, so that they only print output if they're run "
6619 "interactively. Otherwise these banners will at least clutter up Mercurial's "
6620 "output. Worse, they could potentially cause problems with running Mercurial "
6621 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
6622 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
6623 "you're editing your login scripts on your server, the usual way to see if a "
6624 "login script is running in an interactive shell is to check the return code "
6625 "from the command <literal>tty -s</literal>.)"
6626 msgstr ""
6628 #. type: Content of: <book><chapter><sect1><sect2><para>
6629 #: ../en/ch05-collab.xml:781
6630 msgid ""
6631 "Once you've verified that plain old ssh is working with your server, the next "
6632 "step is to ensure that Mercurial runs on the server. The following command "
6633 "should run successfully:"
6634 msgstr ""
6636 #. type: Content of: <book><chapter><sect1><sect2><para>
6637 #: ../en/ch05-collab.xml:788
6638 msgid ""
6639 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
6640 "version</command> output, this is usually because you haven't installed "
6641 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
6642 "if this is the case; you don't need to do that. But you should check for a "
6643 "few possible problems."
6644 msgstr ""
6646 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6647 #: ../en/ch05-collab.xml:795
6648 msgid ""
6649 "Is Mercurial really installed on the server at all? I know this sounds "
6650 "trivial, but it's worth checking!"
6651 msgstr ""
6653 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6654 #: ../en/ch05-collab.xml:799
6655 msgid ""
6656 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
6657 "environment variable) is simply misconfigured."
6658 msgstr ""
6660 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6661 #: ../en/ch05-collab.xml:803
6662 msgid ""
6663 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
6664 "point to the location of the <command>hg</command> executable if the login "
6665 "session is interactive. This can happen if you're setting the path in the "
6666 "wrong shell login script. See your shell's documentation for details."
6667 msgstr ""
6669 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
6670 #: ../en/ch05-collab.xml:810
6671 msgid ""
6672 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
6673 "path to the Mercurial Python modules. It might not be set at all; it could "
6674 "be incorrect; or it may be set only if the login is interactive."
6675 msgstr ""
6677 #. type: Content of: <book><chapter><sect1><sect2><para>
6678 #: ../en/ch05-collab.xml:817
6679 msgid ""
6680 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
6681 "connection, well done! You've got the server and client sorted out. You "
6682 "should now be able to use Mercurial to access repositories hosted by that "
6683 "username on that server. If you run into problems with Mercurial and ssh at "
6684 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
6685 "option to get a clearer picture of what's going on."
6686 msgstr ""
6688 #. type: Content of: <book><chapter><sect1><sect2><title>
6689 #: ../en/ch05-collab.xml:827
6690 msgid "Using compression with ssh"
6691 msgstr "通过 ssh 使用压缩"
6693 #. type: Content of: <book><chapter><sect1><sect2><para>
6694 #: ../en/ch05-collab.xml:829
6695 msgid ""
6696 "Mercurial does not compress data when it uses the ssh protocol, because the "
6697 "ssh protocol can transparently compress data. However, the default behaviour "
6698 "of ssh clients is <emphasis>not</emphasis> to request compression."
6699 msgstr ""
6701 #. type: Content of: <book><chapter><sect1><sect2><para>
6702 #: ../en/ch05-collab.xml:834
6703 msgid ""
6704 "Over any network other than a fast LAN (even a wireless network), using "
6705 "compression is likely to significantly speed up Mercurial's network "
6706 "operations. For example, over a WAN, someone measured compression as "
6707 "reducing the amount of time required to clone a particularly large repository "
6708 "from 51 minutes to 17 minutes."
6709 msgstr ""
6711 #. type: Content of: <book><chapter><sect1><sect2><para>
6712 #: ../en/ch05-collab.xml:841
6713 msgid ""
6714 "Both <command>ssh</command> and <command>plink</command> accept a <option "
6715 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
6716 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
6717 "compression for all of Mercurial's uses of the ssh protocol."
6718 msgstr ""
6720 #. type: Content of: <book><chapter><sect1><sect2><para>
6721 #: ../en/ch05-collab.xml:849
6722 msgid ""
6723 "If you use <command>ssh</command>, you can configure it to always use "
6724 "compression when talking to your server. To do this, edit your <filename "
6725 "role=\"special\">.ssh/config</filename> file (which may not yet exist), as "
6726 "follows."
6727 msgstr ""
6729 #. type: Content of: <book><chapter><sect1><sect2><para>
6730 #: ../en/ch05-collab.xml:857
6731 msgid ""
6732 "This defines an alias, <literal>hg</literal>. When you use it on the "
6733 "<command>ssh</command> command line or in a Mercurial <literal>ssh</literal>-"
6734 "protocol URL, it will cause <command>ssh</command> to connect to <literal>hg."
6735 "example.com</literal> and use compression. This gives you both a shorter "
6736 "name to type and compression, each of which is a good thing in its own right."
6737 msgstr ""
6739 #. type: Content of: <book><chapter><sect1><title>
6740 #: ../en/ch05-collab.xml:868
6741 msgid "Serving over HTTP using CGI"
6742 msgstr "使用 CGI 通过 HTTP 提供服务"
6744 #. type: Content of: <book><chapter><sect1><para>
6745 #: ../en/ch05-collab.xml:870
6746 msgid ""
6747 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
6748 "take anything from a few moments to several hours."
6749 msgstr ""
6751 #. type: Content of: <book><chapter><sect1><para>
6752 #: ../en/ch05-collab.xml:874
6753 msgid ""
6754 "We'll begin with the simplest of examples, and work our way towards a more "
6755 "complex configuration. Even for the most basic case, you're almost certainly "
6756 "going to need to read and modify your web server's configuration."
6757 msgstr ""
6759 #. type: Content of: <book><chapter><sect1><note><para>
6760 #: ../en/ch05-collab.xml:880
6761 msgid ""
6762 "Configuring a web server is a complex, fiddly, and highly system-dependent "
6763 "activity. I can't possibly give you instructions that will cover anything "
6764 "like all of the cases you will encounter. Please use your discretion and "
6765 "judgment in following the sections below. Be prepared to make plenty of "
6766 "mistakes, and to spend a lot of time reading your server's error logs."
6767 msgstr ""
6769 #. type: Content of: <book><chapter><sect1><sect2><title>
6770 #: ../en/ch05-collab.xml:890
6771 msgid "Web server configuration checklist"
6772 msgstr "Web 服务器配置检查表"
6774 #. type: Content of: <book><chapter><sect1><sect2><para>
6775 #: ../en/ch05-collab.xml:892
6776 msgid ""
6777 "Before you continue, do take a few moments to check a few aspects of your "
6778 "system's setup."
6779 msgstr ""
6781 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6782 #: ../en/ch05-collab.xml:896
6783 msgid ""
6784 "Do you have a web server installed at all? Mac OS X ships with Apache, but "
6785 "many other systems may not have a web server installed."
6786 msgstr ""
6788 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6789 #: ../en/ch05-collab.xml:900
6790 msgid ""
6791 "If you have a web server installed, is it actually running? On most systems, "
6792 "even if one is present, it will be disabled by default."
6793 msgstr ""
6795 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
6796 #: ../en/ch05-collab.xml:904
6797 msgid ""
6798 "Is your server configured to allow you to run CGI programs in the directory "
6799 "where you plan to do so? Most servers default to explicitly disabling the "
6800 "ability to run CGI programs."
6801 msgstr ""
6803 #. type: Content of: <book><chapter><sect1><sect2><para>
6804 #: ../en/ch05-collab.xml:910
6805 msgid ""
6806 "If you don't have a web server installed, and don't have substantial "
6807 "experience configuring Apache, you should consider using the "
6808 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
6809 "deserved reputation for baroque and confusing configuration. While "
6810 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
6811 "these capabilities are not relevant to serving Mercurial repositories. And "
6812 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
6813 "get started with than Apache."
6814 msgstr ""
6816 #. type: Content of: <book><chapter><sect1><sect2><title>
6817 #: ../en/ch05-collab.xml:923
6818 msgid "Basic CGI configuration"
6819 msgstr "基本 CGI 配置"
6821 #. type: Content of: <book><chapter><sect1><sect2><para>
6822 #: ../en/ch05-collab.xml:925
6823 msgid ""
6824 "On Unix-like systems, it's common for users to have a subdirectory named "
6825 "something like <filename class=\"directory\">public_html</filename> in their "
6826 "home directory, from which they can serve up web pages. A file named "
6827 "<filename>foo</filename> in this directory will be accessible at a URL of the "
6828 "form <literal>http://www.example.com/username/foo</literal>."
6829 msgstr ""
6831 #. type: Content of: <book><chapter><sect1><sect2><para>
6832 #: ../en/ch05-collab.xml:933
6833 msgid ""
6834 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
6835 "script that should be present in your Mercurial installation. If you can't "
6836 "quickly find a local copy on your system, simply download one from the master "
6837 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
6838 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
6839 msgstr ""
6841 #. type: Content of: <book><chapter><sect1><sect2><para>
6842 #: ../en/ch05-collab.xml:940 ../en/ch05-collab.xml:1109
6843 msgid ""
6844 "You'll need to copy this script into your <filename class=\"directory"
6845 "\">public_html</filename> directory, and ensure that it's executable."
6846 msgstr ""
6848 #. type: Content of: <book><chapter><sect1><sect2><para>
6849 #: ../en/ch05-collab.xml:945
6850 msgid ""
6851 "The <literal>755</literal> argument to <command>chmod</command> is a little "
6852 "more general than just making the script executable: it ensures that the "
6853 "script is executable by anyone, and that <quote>group</quote> and "
6854 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
6855 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
6856 "literal> subsystem would likely refuse to execute the script. In fact, "
6857 "<literal>suexec</literal> also insists that the <emphasis>directory</"
6858 "emphasis> in which the script resides must not be writable by others."
6859 msgstr ""
6861 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6862 #: ../en/ch05-collab.xml:959
6863 msgid "What could <emphasis>possibly</emphasis> go wrong?"
6864 msgstr "什么<emphasis>可能</emphasis>会出错?"
6866 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6867 #: ../en/ch05-collab.xml:962
6868 msgid ""
6869 "Once you've copied the CGI script into place, go into a web browser, and try "
6870 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
6871 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
6872 "for instant failure. There's a high probability that trying to visit this "
6873 "URL will fail, and there are many possible reasons for this. In fact, you're "
6874 "likely to stumble over almost every one of the possible errors below, so "
6875 "please read carefully. The following are all of the problems I ran into on a "
6876 "system running Fedora 7, with a fresh installation of Apache, and a user "
6877 "account that I created specially to perform this exercise."
6878 msgstr ""
6880 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6881 #: ../en/ch05-collab.xml:976
6882 msgid ""
6883 "Your web server may have per-user directories disabled. If you're using "
6884 "Apache, search your config file for a <literal>UserDir</literal> directive. "
6885 "If there's none present, per-user directories will be disabled. If one "
6886 "exists, but its value is <literal>disabled</literal>, then per-user "
6887 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
6888 "literal> gives the name of the subdirectory that Apache will look in under "
6889 "your home directory, for example <filename class=\"directory\">public_html</"
6890 "filename>."
6891 msgstr ""
6893 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6894 #: ../en/ch05-collab.xml:987
6895 msgid ""
6896 "Your file access permissions may be too restrictive. The web server must be "
6897 "able to traverse your home directory and directories under your <filename "
6898 "class=\"directory\">public_html</filename> directory, and read files under "
6899 "the latter too. Here's a quick recipe to help you to make your permissions "
6900 "more appropriate."
6901 msgstr ""
6903 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6904 #: ../en/ch05-collab.xml:997
6905 msgid ""
6906 "The other possibility with permissions is that you might get a completely "
6907 "empty window when you try to load the script. In this case, it's likely that "
6908 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
6909 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
6910 "world-writable, for example."
6911 msgstr ""
6913 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6914 #: ../en/ch05-collab.xml:1004
6915 msgid ""
6916 "Your web server may be configured to disallow execution of CGI programs in "
6917 "your per-user web directory. Here's Apache's default per-user configuration "
6918 "from my Fedora system."
6919 msgstr ""
6921 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6922 #: ../en/ch05-collab.xml:1011
6923 msgid ""
6924 "If you find a similar-looking <literal>Directory</literal> group in your "
6925 "Apache configuration, the directive to look at inside it is <literal>Options</"
6926 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
6927 "missing, and restart the web server."
6928 msgstr ""
6930 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6931 #: ../en/ch05-collab.xml:1018
6932 msgid ""
6933 "If you find that Apache serves you the text of the CGI script instead of "
6934 "executing it, you may need to either uncomment (if already present) or add a "
6935 "directive like this."
6936 msgstr ""
6938 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6939 #: ../en/ch05-collab.xml:1024
6940 msgid ""
6941 "The next possibility is that you might be served with a colourful Python "
6942 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
6943 "related module. This is actually progress! The server is now capable of "
6944 "executing your CGI script. This error is only likely to occur if you're "
6945 "running a private installation of Mercurial, instead of a system-wide "
6946 "version. Remember that the web server runs the CGI program without any of "
6947 "the environment variables that you take for granted in an interactive "
6948 "session. If this error happens to you, edit your copy of <filename role="
6949 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
6950 "correctly set your <envar>PYTHONPATH</envar> environment variable."
6951 msgstr ""
6953 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6954 #: ../en/ch05-collab.xml:1038
6955 msgid ""
6956 "Finally, you are <emphasis>certain</emphasis> to by served with another "
6957 "colourful Python backtrace: this one will complain that it can't find "
6958 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
6959 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
6960 "<filename class=\"directory\">/path/to/repository</filename> string with the "
6961 "complete path to the repository you want to serve up."
6962 msgstr ""
6964 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6965 #: ../en/ch05-collab.xml:1048
6966 msgid ""
6967 "At this point, when you try to reload the page, you should be presented with "
6968 "a nice HTML view of your repository's history. Whew!"
6969 msgstr ""
6971 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
6972 #: ../en/ch05-collab.xml:1054
6973 msgid "Configuring lighttpd"
6974 msgstr "配置 lighttpd"
6976 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6977 #: ../en/ch05-collab.xml:1056
6978 msgid ""
6979 "To be exhaustive in my experiments, I tried configuring the increasingly "
6980 "popular <literal>lighttpd</literal> web server to serve the same repository "
6981 "as I described with Apache above. I had already overcome all of the problems "
6982 "I outlined with Apache, many of which are not server-specific. As a result, "
6983 "I was fairly sure that my file and directory permissions were good, and that "
6984 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
6985 msgstr ""
6987 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
6988 #: ../en/ch05-collab.xml:1066
6989 msgid ""
6990 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
6991 "repository was a snap (in other words, even if you're trying to use "
6992 "<literal>lighttpd</literal>, you should read the Apache section). I first "
6993 "had to edit the <literal>mod_access</literal> section of its config file to "
6994 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
6995 "which were disabled by default on my system. I then added a few lines to the "
6996 "end of the config file, to configure these modules."
6997 msgstr ""
6999 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7000 #: ../en/ch05-collab.xml:1078
7001 msgid ""
7002 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
7003 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
7004 "have run into many of the same system-level configuration problems as I did "
7005 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
7006 "easier to configure than Apache, even though I've used Apache for over a "
7007 "decade, and this was my first exposure to <literal>lighttpd</literal>."
7008 msgstr ""
7010 #. type: Content of: <book><chapter><sect1><sect2><title>
7011 #: ../en/ch05-collab.xml:1091
7012 msgid "Sharing multiple repositories with one CGI script"
7013 msgstr "使用一个 CGI 脚本共享多个版本库"
7015 #. type: Content of: <book><chapter><sect1><sect2><para>
7016 #: ../en/ch05-collab.xml:1093
7017 msgid ""
7018 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
7019 "publish a single repository, which is an annoying restriction. If you want "
7020 "to publish more than one without wracking yourself with multiple copies of "
7021 "the same script, each with different names, a better choice is to use the "
7022 "<filename role=\"special\">hgwebdir.cgi</filename> script."
7023 msgstr ""
7025 #. type: Content of: <book><chapter><sect1><sect2><para>
7026 #: ../en/ch05-collab.xml:1101
7027 msgid ""
7028 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
7029 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
7030 "filename>. First, you must obtain a copy of the script. If you don't have "
7031 "one handy, you can download a copy from the master Mercurial repository at "
7032 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
7033 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
7034 msgstr ""
7036 #. type: Content of: <book><chapter><sect1><sect2><para>
7037 #: ../en/ch05-collab.xml:1116
7038 msgid ""
7039 "With basic configuration out of the way, try to visit <ulink url=\"http://"
7040 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
7041 "ulink> in your browser. It should display an empty list of repositories. If "
7042 "you get a blank window or error message, try walking through the list of "
7043 "potential problems in <xref linkend=\"sec:collab:wtf\"/>."
7044 msgstr ""
7046 #. type: Content of: <book><chapter><sect1><sect2><para>
7047 #: ../en/ch05-collab.xml:1125
7048 msgid ""
7049 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
7050 "external configuration file. By default, it searches for a file named "
7051 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
7052 "itself. You'll need to create this file, and make it world-readable. The "
7053 "format of the file is similar to a Windows <quote>ini</quote> file, as "
7054 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
7055 "configparser</citation> module."
7056 msgstr ""
7058 #. type: Content of: <book><chapter><sect1><sect2><para>
7059 #: ../en/ch05-collab.xml:1135
7060 msgid ""
7061 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
7062 "filename> is with a section named <literal>collections</literal>. This will "
7063 "automatically publish <emphasis>every</emphasis> repository under the "
7064 "directories you name. The section should look like this:"
7065 msgstr ""
7067 #. type: Content of: <book><chapter><sect1><sect2><para>
7068 #: ../en/ch05-collab.xml:1143
7069 msgid ""
7070 "Mercurial interprets this by looking at the directory name on the "
7071 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
7072 "quote> sign; finding repositories in that directory hierarchy; and using the "
7073 "text on the <emphasis>left</emphasis> to strip off matching text from the "
7074 "names it will actually list in the web interface. The remaining component of "
7075 "a path after this stripping has occurred is called a <quote>virtual path</"
7076 "quote>."
7077 msgstr ""
7079 #. type: Content of: <book><chapter><sect1><sect2><para>
7080 #: ../en/ch05-collab.xml:1152
7081 msgid ""
7082 "Given the example above, if we have a repository whose local path is "
7083 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
7084 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
7085 "the name, and publish the repository with a virtual path of <filename class="
7086 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
7087 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
7088 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
7089 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
7090 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
7091 msgstr ""
7093 #. type: Content of: <book><chapter><sect1><sect2><para>
7094 #: ../en/ch05-collab.xml:1166
7095 msgid ""
7096 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
7097 "hand side of this example with <filename class=\"directory\">/my</filename>, "
7098 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
7099 "<filename class=\"directory\">/my</filename> from the repository name, and "
7100 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
7101 "filename> instead of <filename class=\"directory\">this/repo</filename>."
7102 msgstr ""
7104 #. type: Content of: <book><chapter><sect1><sect2><para>
7105 #: ../en/ch05-collab.xml:1176
7106 msgid ""
7107 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
7108 "recursively search each directory listed in the <literal>collections</"
7109 "literal> section of its configuration file, but it will <literal>not</"
7110 "literal> recurse into the repositories it finds."
7111 msgstr ""
7113 #. type: Content of: <book><chapter><sect1><sect2><para>
7114 #: ../en/ch05-collab.xml:1182
7115 msgid ""
7116 "The <literal>collections</literal> mechanism makes it easy to publish many "
7117 "repositories in a <quote>fire and forget</quote> manner. You only need to "
7118 "set up the CGI script and configuration file one time. Afterwards, you can "
7119 "publish or unpublish a repository at any time by simply moving it into, or "
7120 "out of, the directory hierarchy in which you've configured <filename role="
7121 "\"special\">hgwebdir.cgi</filename> to look."
7122 msgstr ""
7124 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7125 #: ../en/ch05-collab.xml:1192
7126 msgid "Explicitly specifying which repositories to publish"
7127 msgstr "明确指出要发布的版本库"
7129 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7130 #: ../en/ch05-collab.xml:1195
7131 msgid ""
7132 "In addition to the <literal>collections</literal> mechanism, the <filename "
7133 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
7134 "specific list of repositories. To do so, create a <literal>paths</literal> "
7135 "section, with contents of the following form."
7136 msgstr ""
7138 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7139 #: ../en/ch05-collab.xml:1204
7140 msgid ""
7141 "In this case, the virtual path (the component that will appear in a URL) is "
7142 "on the left hand side of each definition, while the path to the repository is "
7143 "on the right. Notice that there does not need to be any relationship between "
7144 "the virtual path you choose and the location of a repository in your "
7145 "filesystem."
7146 msgstr ""
7148 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7149 #: ../en/ch05-collab.xml:1211
7150 msgid ""
7151 "If you wish, you can use both the <literal>collections</literal> and "
7152 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
7153 "file."
7154 msgstr ""
7156 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
7157 #: ../en/ch05-collab.xml:1217
7158 msgid ""
7159 "If multiple repositories have the same virtual path, <filename role=\"special"
7160 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
7161 "unpredictably."
7162 msgstr ""
7164 #. type: Content of: <book><chapter><sect1><sect2><title>
7165 #: ../en/ch05-collab.xml:1226
7166 msgid "Downloading source archives"
7167 msgstr "下载源代码档案包"
7169 #. type: Content of: <book><chapter><sect1><sect2><para>
7170 #: ../en/ch05-collab.xml:1228
7171 msgid ""
7172 "Mercurial's web interface lets users download an archive of any revision. "
7173 "This archive will contain a snapshot of the working directory as of that "
7174 "revision, but it will not contain a copy of the repository data."
7175 msgstr ""
7177 #. type: Content of: <book><chapter><sect1><sect2><para>
7178 #: ../en/ch05-collab.xml:1233
7179 msgid ""
7180 "By default, this feature is not enabled. To enable it, you'll need to add an "
7181 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
7182 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
7183 "filename>."
7184 msgstr ""
7186 #. type: Content of: <book><chapter><sect1><sect2><title>
7187 #: ../en/ch05-collab.xml:1241
7188 msgid "Web configuration options"
7189 msgstr "Web 配置选项"
7191 #. type: Content of: <book><chapter><sect1><sect2><para>
7192 #: ../en/ch05-collab.xml:1243
7193 msgid ""
7194 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
7195 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
7196 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
7197 "configuration options that you can set. These belong in a section named "
7198 "<literal role=\"rc-web\">web</literal>."
7199 msgstr ""
7201 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7202 #: ../en/ch05-collab.xml:1251
7203 msgid ""
7204 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
7205 "archive download mechanisms Mercurial supports. If you enable this feature, "
7206 "users of the web interface will be able to download an archive of whatever "
7207 "revision of a repository they are viewing. To enable the archive feature, "
7208 "this item must take the form of a sequence of words drawn from the list below."
7209 msgstr ""
7211 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7212 #: ../en/ch05-collab.xml:1260
7213 msgid ""
7214 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
7215 "<literal>bzip2</literal> compression. This has the best compression ratio, "
7216 "but uses the most CPU time on the server."
7217 msgstr ""
7219 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7220 #: ../en/ch05-collab.xml:1266
7221 msgid ""
7222 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
7223 "<literal>gzip</literal> compression."
7224 msgstr ""
7226 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
7227 #: ../en/ch05-collab.xml:1270
7228 msgid ""
7229 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
7230 "LZW compression. This format has the worst compression ratio, but is widely "
7231 "used in the Windows world."
7232 msgstr ""
7234 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7235 #: ../en/ch05-collab.xml:1276
7236 msgid ""
7237 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
7238 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
7239 "is an example of how to enable all three supported formats."
7240 msgstr ""
7242 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7243 #: ../en/ch05-collab.xml:1283
7244 msgid ""
7245 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
7246 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
7247 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
7248 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
7249 "<quote>human-oriented</quote> portion of the web interface is available."
7250 msgstr ""
7252 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7253 #: ../en/ch05-collab.xml:1292
7254 msgid ""
7255 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
7256 "preferably brief) string identifying the person or group in charge of the "
7257 "repository. This often contains the name and email address of a person or "
7258 "mailing list. It often makes sense to place this entry in a repository's own "
7259 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
7260 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
7261 "repository has a single maintainer."
7262 msgstr ""
7264 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7265 #: ../en/ch05-collab.xml:1303
7266 msgid ""
7267 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
7268 "number of changesets to display in a single page of output."
7269 msgstr ""
7271 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7272 #: ../en/ch05-collab.xml:1307
7273 msgid ""
7274 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
7275 "number of modified files to display in a single page of output."
7276 msgstr ""
7278 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7279 #: ../en/ch05-collab.xml:1311
7280 msgid ""
7281 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
7282 "displays alternating <quote>stripes</quote> to make it easier to visually "
7283 "align rows when you are looking at a table, this number controls the number "
7284 "of rows in each stripe."
7285 msgstr ""
7287 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7288 #: ../en/ch05-collab.xml:1317
7289 msgid ""
7290 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
7291 "uses to display the web interface. Mercurial ships with two web templates, "
7292 "named <literal>default</literal> and <literal>gitweb</literal> (the latter is "
7293 "much more visually attractive). You can also specify a custom template of "
7294 "your own; see <xref linkend=\"chap:template\"/> for details. Here, you can "
7295 "see how to enable the <literal>gitweb</literal> style."
7296 msgstr ""
7298 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
7299 #: ../en/ch05-collab.xml:1330
7300 msgid ""
7301 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
7302 "to search for template files. By default, Mercurial searches in the "
7303 "directory in which it was installed."
7304 msgstr ""
7306 #. type: Content of: <book><chapter><sect1><sect2><para>
7307 #: ../en/ch05-collab.xml:1335
7308 msgid ""
7309 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
7310 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
7311 "section of the <filename role=\"special\">hgweb.config</filename> file "
7312 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
7313 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
7314 "<envar role=\"rc-item-web\">style</envar>."
7315 msgstr ""
7317 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7318 #: ../en/ch05-collab.xml:1346
7319 msgid "Options specific to an individual repository"
7320 msgstr "针对单个版本库的选项"
7322 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7323 #: ../en/ch05-collab.xml:1348
7324 msgid ""
7325 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
7326 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
7327 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
7328 "filename>."
7329 msgstr ""
7331 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7332 #: ../en/ch05-collab.xml:1353
7333 msgid ""
7334 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
7335 "preferably brief) string that describes the contents or purpose of the "
7336 "repository."
7337 msgstr ""
7339 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7340 #: ../en/ch05-collab.xml:1358
7341 msgid ""
7342 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
7343 "repository in the web interface. This overrides the default name, which is "
7344 "the last component of the repository's path."
7345 msgstr ""
7347 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7348 #: ../en/ch05-collab.xml:1366
7349 msgid ""
7350 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
7351 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
7353 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7354 #: ../en/ch05-collab.xml:1369
7355 msgid ""
7356 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
7357 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
7358 "<command role=\"hg-cmd\">hg serve</command> command."
7359 msgstr ""
7361 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7362 #: ../en/ch05-collab.xml:1375
7363 msgid ""
7364 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
7365 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
7366 "serve</command> command writes this information to standard output, not to a "
7367 "file. Log entries are written in the standard <quote>combined</quote> file "
7368 "format used by almost all web servers."
7369 msgstr ""
7371 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7372 #: ../en/ch05-collab.xml:1383
7373 msgid ""
7374 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
7375 "which the server should listen for incoming connections. By default, the "
7376 "server listens on all addresses."
7377 msgstr ""
7379 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7380 #: ../en/ch05-collab.xml:1388
7381 msgid ""
7382 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
7383 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
7384 "serve</command> command writes this information to standard error, not to a "
7385 "file."
7386 msgstr ""
7388 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7389 #: ../en/ch05-collab.xml:1394
7390 msgid ""
7391 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
7392 "protocol. By default, IPv6 is not used."
7393 msgstr ""
7395 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
7396 #: ../en/ch05-collab.xml:1398
7397 msgid ""
7398 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
7399 "which the server should listen. The default port number used is 8000."
7400 msgstr ""
7402 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7403 #: ../en/ch05-collab.xml:1405
7404 msgid ""
7405 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
7406 "<literal role=\"rc-web\">web</literal> items to"
7407 msgstr ""
7408 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
7409 "role=\"rc-web\">web</literal> 条目"
7411 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7412 #: ../en/ch05-collab.xml:1409
7413 msgid ""
7414 "It is important to remember that a web server like Apache or "
7415 "<literal>lighttpd</literal> will run under a user ID that is different to "
7416 "yours. CGI scripts run by your server, such as <filename role=\"special"
7417 "\">hgweb.cgi</filename>, will usually also run under that user ID."
7418 msgstr ""
7420 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7421 #: ../en/ch05-collab.xml:1416
7422 msgid ""
7423 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
7424 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
7425 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
7426 "thus only affect the behaviour of the <command role=\"hg-cmd\">hg serve</"
7427 "command> command when you run it. To cause CGI scripts to see your settings, "
7428 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
7429 "home directory of the user ID that runs your web server, or add those "
7430 "settings to a system-wide <filename role=\"special\">~/.hgrc</filename> file."
7431 msgstr ""
7433 #. type: Content of: <book><chapter><title>
7434 #: ../en/ch06-filenames.xml:5
7435 msgid "File names and pattern matching"
7436 msgstr "文件名称与模式匹配"
7438 #. type: Content of: <book><chapter><para>
7439 #: ../en/ch06-filenames.xml:7
7440 msgid ""
7441 "Mercurial provides mechanisms that let you work with file names in a "
7442 "consistent and expressive way."
7443 msgstr ""
7445 #. type: Content of: <book><chapter><sect1><title>
7446 #: ../en/ch06-filenames.xml:11
7447 msgid "Simple file naming"
7448 msgstr "简单文件名称"
7450 #. type: Content of: <book><chapter><sect1><para>
7451 #: ../en/ch06-filenames.xml:13
7452 msgid ""
7453 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
7454 "handle file names. Every command behaves uniformly with respect to file "
7455 "names. The way in which commands work with file names is as follows."
7456 msgstr ""
7458 #. type: Content of: <book><chapter><sect1><para>
7459 #: ../en/ch06-filenames.xml:18
7460 msgid ""
7461 "If you explicitly name real files on the command line, Mercurial works with "
7462 "exactly those files, as you would expect. &interaction.filenames.files;"
7463 msgstr ""
7466 #. type: Content of: <book><chapter><sect1><para>
7467 #: ../en/ch06-filenames.xml:22
7468 msgid ""
7469 "When you provide a directory name, Mercurial will interpret this as "
7470 "<quote>operate on every file in this directory and its subdirectories</"
7471 "quote>. Mercurial traverses the files and subdirectories in a directory in "
7472 "alphabetical order. When it encounters a subdirectory, it will traverse that "
7473 "subdirectory before continuing with the current directory."
7474 msgstr ""
7476 #. type: Content of: <book><chapter><sect1><title>
7477 #: ../en/ch06-filenames.xml:33
7478 msgid "Running commands without any file names"
7479 msgstr "不提供文件名称的执行命令"
7481 #. type: Content of: <book><chapter><sect1><para>
7482 #: ../en/ch06-filenames.xml:35
7483 msgid ""
7484 "Mercurial's commands that work with file names have useful default behaviours "
7485 "when you invoke them without providing any file names or patterns. What kind "
7486 "of behaviour you should expect depends on what the command does. Here are a "
7487 "few rules of thumb you can use to predict what a command is likely to do if "
7488 "you don't give it any names to work with."
7489 msgstr ""
7491 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7492 #: ../en/ch06-filenames.xml:42
7493 msgid ""
7494 "Most commands will operate on the entire working directory. This is what the "
7495 "<command role=\"hg-cmd\">hg add</command> command does, for example."
7496 msgstr ""
7498 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7499 #: ../en/ch06-filenames.xml:46
7500 msgid ""
7501 "If the command has effects that are difficult or impossible to reverse, it "
7502 "will force you to explicitly provide at least one name or pattern (see "
7503 "below). This protects you from accidentally deleting files by running "
7504 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
7505 msgstr ""
7508 #. type: Content of: <book><chapter><sect1><para>
7509 #: ../en/ch06-filenames.xml:54
7510 msgid ""
7511 "It's easy to work around these default behaviours if they don't suit you. If "
7512 "a command normally operates on the whole working directory, you can invoke it "
7513 "on just the current directory and its subdirectories by giving it the name "
7514 "<quote><filename class=\"directory\">.</filename></quote>."
7515 msgstr ""
7518 #. type: Content of: <book><chapter><sect1><para>
7519 #: ../en/ch06-filenames.xml:62
7520 msgid ""
7521 "Along the same lines, some commands normally print file names relative to the "
7522 "root of the repository, even if you're invoking them from a subdirectory. "
7523 "Such a command will print file names relative to your subdirectory if you "
7524 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
7525 "status</command> from a subdirectory, and get it to operate on the entire "
7526 "working directory while printing file names relative to our subdirectory, by "
7527 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
7528 "command."
7529 msgstr ""
7531 #. type: Content of: <book><chapter><sect1><title>
7532 #: ../en/ch06-filenames.xml:76
7533 msgid "Telling you what's going on"
7534 msgstr "告诉你正在做什么"
7536 #. type: Content of: <book><chapter><sect1><para>
7537 #: ../en/ch06-filenames.xml:78
7538 msgid ""
7539 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
7540 "section illustrates something else that's helpful about Mercurial commands. "
7541 "If a command operates on a file that you didn't name explicitly on the "
7542 "command line, it will usually print the name of the file, so that you will "
7543 "not be surprised what's going on."
7544 msgstr ""
7546 #. type: Content of: <book><chapter><sect1><para>
7547 #: ../en/ch06-filenames.xml:85
7548 msgid ""
7549 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
7550 "exactly named a file on the command line, there's no point in repeating it "
7551 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
7552 "emphasis>, because you provided no names, or a directory, or a pattern (see "
7553 "below), it's safest to tell you what it's doing."
7554 msgstr ""
7556 #. type: Content of: <book><chapter><sect1><para>
7557 #: ../en/ch06-filenames.xml:92
7558 msgid ""
7559 "For commands that behave this way, you can silence them using the <option "
7560 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
7561 "the name of every file, even those you've named explicitly, using the <option "
7562 "role=\"hg-opt-global\">-v</option> option."
7563 msgstr ""
7565 #. type: Content of: <book><chapter><sect1><title>
7566 #: ../en/ch06-filenames.xml:100
7567 msgid "Using patterns to identify files"
7568 msgstr "使用模式标识文件"
7570 #. type: Content of: <book><chapter><sect1><para>
7571 #: ../en/ch06-filenames.xml:102
7572 msgid ""
7573 "In addition to working with file and directory names, Mercurial lets you use "
7574 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
7575 "handling is expressive."
7576 msgstr ""
7578 #. type: Content of: <book><chapter><sect1><para>
7579 #: ../en/ch06-filenames.xml:106
7580 msgid ""
7581 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
7582 "patterns normally falls to the shell. On these systems, you must explicitly "
7583 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
7584 "expand patterns, so Mercurial will automatically identify names that are "
7585 "patterns, and expand them for you."
7586 msgstr ""
7588 #. type: Content of: <book><chapter><sect1><para>
7589 #: ../en/ch06-filenames.xml:113
7590 msgid ""
7591 "To provide a pattern in place of a regular name on the command line, the "
7592 "mechanism is simple:"
7593 msgstr ""
7595 #. type: Content of: <book><chapter><sect1><para>
7596 #: ../en/ch06-filenames.xml:116
7597 msgid ""
7598 "That is, a pattern is identified by a short text string that says what kind "
7599 "of pattern this is, followed by a colon, followed by the actual pattern."
7600 msgstr ""
7602 #. type: Content of: <book><chapter><sect1><para>
7603 #: ../en/ch06-filenames.xml:120
7604 msgid ""
7605 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
7606 "called <literal>glob</literal>; this is the same kind of pattern matching "
7607 "used by the Unix shell, and should be familiar to Windows command prompt "
7608 "users, too."
7609 msgstr ""
7611 #. type: Content of: <book><chapter><sect1><para>
7612 #: ../en/ch06-filenames.xml:125
7613 msgid ""
7614 "When Mercurial does automatic pattern matching on Windows, it uses "
7615 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
7616 "literal></quote> prefix on Windows, but it's safe to use it, too."
7617 msgstr ""
7619 #. type: Content of: <book><chapter><sect1><para>
7620 #: ../en/ch06-filenames.xml:130
7621 msgid ""
7622 "The <literal>re</literal> syntax is more powerful; it lets you specify "
7623 "patterns using regular expressions, also known as regexps."
7624 msgstr ""
7626 #. type: Content of: <book><chapter><sect1><para>
7627 #: ../en/ch06-filenames.xml:134
7628 msgid ""
7629 "By the way, in the examples that follow, notice that I'm careful to wrap all "
7630 "of my patterns in quote characters, so that they won't get expanded by the "
7631 "shell before Mercurial sees them."
7632 msgstr ""
7634 #. type: Content of: <book><chapter><sect1><sect2><title>
7635 #: ../en/ch06-filenames.xml:140
7636 msgid "Shell-style <literal>glob</literal> patterns"
7637 msgstr "外壳风格的 <literal>glob</literal> 模式"
7639 #. type: Content of: <book><chapter><sect1><sect2><para>
7640 #: ../en/ch06-filenames.xml:142
7641 msgid ""
7642 "This is an overview of the kinds of patterns you can use when you're matching "
7643 "on glob patterns."
7644 msgstr ""
7647 #. type: Content of: <book><chapter><sect1><sect2><para>
7648 #: ../en/ch06-filenames.xml:145
7649 msgid ""
7650 "The <quote><literal>*</literal></quote> character matches any string, within "
7651 "a single directory."
7652 msgstr ""
7655 #. type: Content of: <book><chapter><sect1><sect2><para>
7656 #: ../en/ch06-filenames.xml:150
7657 msgid ""
7658 "The <quote><literal>**</literal></quote> pattern matches any string, and "
7659 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
7660 "accepted by several popular Unix shells, and is very useful."
7661 msgstr ""
7664 #. type: Content of: <book><chapter><sect1><sect2><para>
7665 #: ../en/ch06-filenames.xml:157
7666 msgid ""
7667 "The <quote><literal>?</literal></quote> pattern matches any single character."
7668 msgstr ""
7670 #. type: Content of: <book><chapter><sect1><sect2><para>
7671 #: ../en/ch06-filenames.xml:162
7672 msgid ""
7673 "The <quote><literal>[</literal></quote> character begins a "
7674 "<emphasis>character class</emphasis>. This matches any single character "
7675 "within the class. The class ends with a <quote><literal>]</literal></quote> "
7676 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
7677 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
7678 "<quote><literal>abcdef</literal></quote>."
7679 msgstr ""
7681 #. type: Content of: <book><chapter><sect1><sect2><para>
7682 #: ../en/ch06-filenames.xml:172
7683 msgid ""
7684 "If the first character after the <quote><literal>[</literal></quote> in a "
7685 "character class is a <quote><literal>!</literal></quote>, it "
7686 "<emphasis>negates</emphasis> the class, making it match any single character "
7687 "not in the class."
7688 msgstr ""
7690 #. type: Content of: <book><chapter><sect1><sect2><para>
7691 #: ../en/ch06-filenames.xml:178
7692 msgid ""
7693 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
7694 "the whole group matches if any subpattern in the group matches. The "
7695 "<quote><literal>,</literal></quote> character separates subpatterns, and "
7696 "<quote><literal>}</literal></quote> ends the group."
7697 msgstr ""
7699 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
7700 #: ../en/ch06-filenames.xml:187
7701 msgid "Watch out!"
7702 msgstr "千万小心!"
7705 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
7706 #: ../en/ch06-filenames.xml:189
7707 msgid ""
7708 "Don't forget that if you want to match a pattern in any directory, you should "
7709 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
7710 "will only match within one directory. Instead, use the <quote><literal>**</"
7711 "literal></quote> token. This small example illustrates the difference "
7712 "between the two."
7713 msgstr ""
7715 #. type: Content of: <book><chapter><sect1><sect2><title>
7716 #: ../en/ch06-filenames.xml:201
7717 msgid "Regular expression matching with <literal>re</literal> patterns"
7718 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
7720 #. type: Content of: <book><chapter><sect1><sect2><para>
7721 #: ../en/ch06-filenames.xml:204
7722 msgid ""
7723 "Mercurial accepts the same regular expression syntax as the Python "
7724 "programming language (it uses Python's regexp engine internally). This is "
7725 "based on the Perl language's regexp syntax, which is the most popular dialect "
7726 "in use (it's also used in Java, for example)."
7727 msgstr ""
7729 #. type: Content of: <book><chapter><sect1><sect2><para>
7730 #: ../en/ch06-filenames.xml:210
7731 msgid ""
7732 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
7733 "not often used. Perl-style regexps are in any case already exhaustively "
7734 "documented on a multitude of web sites, and in many books. Instead, I will "
7735 "focus here on a few things you should know if you find yourself needing to "
7736 "use regexps with Mercurial."
7737 msgstr ""
7739 #. type: Content of: <book><chapter><sect1><sect2><para>
7740 #: ../en/ch06-filenames.xml:217
7741 msgid ""
7742 "A regexp is matched against an entire file name, relative to the root of the "
7743 "repository. In other words, even if you're already in subbdirectory "
7744 "<filename class=\"directory\">foo</filename>, if you want to match files "
7745 "under this directory, your pattern must start with <quote><literal>foo/</"
7746 "literal></quote>."
7747 msgstr ""
7749 #. type: Content of: <book><chapter><sect1><sect2><para>
7750 #: ../en/ch06-filenames.xml:224
7751 msgid ""
7752 "One thing to note, if you're familiar with Perl-style regexps, is that "
7753 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
7754 "matching against the beginning of a string; it doesn't look for a match "
7755 "anywhere within the string. To match anywhere in a string, start your "
7756 "pattern with <quote><literal>.*</literal></quote>."
7757 msgstr ""
7759 #. type: Content of: <book><chapter><sect1><title>
7760 #: ../en/ch06-filenames.xml:234
7761 msgid "Filtering files"
7762 msgstr "过滤文件"
7764 #. type: Content of: <book><chapter><sect1><para>
7765 #: ../en/ch06-filenames.xml:236
7766 msgid ""
7767 "Not only does Mercurial give you a variety of ways to specify files; it lets "
7768 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
7769 "that work with file names accept two filtering options."
7770 msgstr ""
7772 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7773 #: ../en/ch06-filenames.xml:241
7774 msgid ""
7775 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
7776 "\">--include</option>, lets you specify a pattern that file names must match "
7777 "in order to be processed."
7778 msgstr ""
7780 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7781 #: ../en/ch06-filenames.xml:246
7782 msgid ""
7783 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
7784 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
7785 "processing files, if they match this pattern."
7786 msgstr ""
7788 #. type: Content of: <book><chapter><sect1><para>
7789 #: ../en/ch06-filenames.xml:251
7790 msgid ""
7791 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
7792 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
7793 "intermix them as you please. Mercurial interprets the patterns you provide "
7794 "using glob syntax by default (but you can use regexps if you need to)."
7795 msgstr ""
7797 #. type: Content of: <book><chapter><sect1><para>
7798 #: ../en/ch06-filenames.xml:258
7799 msgid ""
7800 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
7801 "<quote>process only the files that match this filter</quote>."
7802 msgstr ""
7804 #. type: Content of: <book><chapter><sect1><para>
7805 #: ../en/ch06-filenames.xml:264
7806 msgid ""
7807 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
7808 "<quote>process only the files that don't match this pattern</quote>."
7809 msgstr ""
7811 #. type: Content of: <book><chapter><sect1><title>
7812 #: ../en/ch06-filenames.xml:272
7813 msgid "Ignoring unwanted files and directories"
7814 msgstr "忽略不需要的文件和目录"
7816 #. type: Content of: <book><chapter><sect1><para>
7817 #: ../en/ch06-filenames.xml:274
7818 msgid "XXX."
7819 msgstr ""
7821 #. type: Content of: <book><chapter><sect1><title>
7822 #: ../en/ch06-filenames.xml:278
7823 msgid "Case sensitivity"
7824 msgstr "大小写敏感性"
7826 #. type: Content of: <book><chapter><sect1><para>
7827 #: ../en/ch06-filenames.xml:280
7828 msgid ""
7829 "If you're working in a mixed development environment that contains both Linux "
7830 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
7831 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
7832 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
7833 "very likely to affect you, and it's easy to deal with if it does, but it "
7834 "could surprise you if you don't know about it."
7835 msgstr ""
7837 #. type: Content of: <book><chapter><sect1><para>
7838 #: ../en/ch06-filenames.xml:289
7839 msgid ""
7840 "Operating systems and filesystems differ in the way they handle the "
7841 "<emphasis>case</emphasis> of characters in file and directory names. There "
7842 "are three common ways to handle case in names."
7843 msgstr ""
7845 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7846 #: ../en/ch06-filenames.xml:294
7847 msgid ""
7848 "Completely case insensitive. Uppercase and lowercase versions of a letter "
7849 "are treated as identical, both when creating a file and during subsequent "
7850 "accesses. This is common on older DOS-based systems."
7851 msgstr ""
7853 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7854 #: ../en/ch06-filenames.xml:299
7855 msgid ""
7856 "Case preserving, but insensitive. When a file or directory is created, the "
7857 "case of its name is stored, and can be retrieved and displayed by the "
7858 "operating system. When an existing file is being looked up, its case is "
7859 "ignored. This is the standard arrangement on Windows and MacOS. The names "
7860 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
7861 "file. This treatment of uppercase and lowercase letters as interchangeable "
7862 "is also referred to as <emphasis>case folding</emphasis>."
7863 msgstr ""
7865 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
7866 #: ../en/ch06-filenames.xml:310
7867 msgid ""
7868 "Case sensitive. The case of a name is significant at all times. The names "
7869 "<filename>foo</filename> and {FoO} identify different files. This is the way "
7870 "Linux and Unix systems normally work."
7871 msgstr ""
7873 #. type: Content of: <book><chapter><sect1><para>
7874 #: ../en/ch06-filenames.xml:316
7875 msgid ""
7876 "On Unix-like systems, it is possible to have any or all of the above ways of "
7877 "handling case in action at once. For example, if you use a USB thumb drive "
7878 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
7879 "on that filesystem in a case preserving, but insensitive, way."
7880 msgstr ""
7882 #. type: Content of: <book><chapter><sect1><sect2><title>
7883 #: ../en/ch06-filenames.xml:323
7884 msgid "Safe, portable repository storage"
7885 msgstr "安全,可移植的版本库存储"
7887 #. type: Content of: <book><chapter><sect1><sect2><para>
7888 #: ../en/ch06-filenames.xml:325
7889 msgid ""
7890 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
7891 "It translates file names so that they can be safely stored on both case "
7892 "sensitive and case insensitive filesystems. This means that you can use "
7893 "normal file copying tools to transfer a Mercurial repository onto, for "
7894 "example, a USB thumb drive, and safely move that drive and repository back "
7895 "and forth between a Mac, a PC running Windows, and a Linux box."
7896 msgstr ""
7898 #. type: Content of: <book><chapter><sect1><sect2><title>
7899 #: ../en/ch06-filenames.xml:336
7900 msgid "Detecting case conflicts"
7901 msgstr "检测大小写冲突"
7903 #. type: Content of: <book><chapter><sect1><sect2><para>
7904 #: ../en/ch06-filenames.xml:338
7905 msgid ""
7906 "When operating in the working directory, Mercurial honours the naming policy "
7907 "of the filesystem where the working directory is located. If the filesystem "
7908 "is case preserving, but insensitive, Mercurial will treat names that differ "
7909 "only in case as the same."
7910 msgstr ""
7912 #. type: Content of: <book><chapter><sect1><sect2><para>
7913 #: ../en/ch06-filenames.xml:344
7914 msgid ""
7915 "An important aspect of this approach is that it is possible to commit a "
7916 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
7917 "cause trouble for users on case insensitive (usually Windows and MacOS) "
7918 "users. If a Linux user commits changes to two files, one named "
7919 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
7920 "filename>, they will be stored correctly in the repository. And in the "
7921 "working directories of other Linux users, they will be correctly represented "
7922 "as separate files."
7923 msgstr ""
7925 #. type: Content of: <book><chapter><sect1><sect2><para>
7926 #: ../en/ch06-filenames.xml:355
7927 msgid ""
7928 "If a Windows or Mac user pulls this change, they will not initially have a "
7929 "problem, because Mercurial's repository storage mechanism is case safe. "
7930 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
7931 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
7932 "command> with that changeset, Mercurial will spot the conflict between the "
7933 "two file names that the filesystem would treat as the same, and forbid the "
7934 "update or merge from occurring."
7935 msgstr ""
7937 #. type: Content of: <book><chapter><sect1><sect2><title>
7938 #: ../en/ch06-filenames.xml:367
7939 msgid "Fixing a case conflict"
7940 msgstr "修正大小写冲突"
7942 #. type: Content of: <book><chapter><sect1><sect2><para>
7943 #: ../en/ch06-filenames.xml:369
7944 msgid ""
7945 "If you are using Windows or a Mac in a mixed environment where some of your "
7946 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
7947 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
7948 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
7949 "is simple."
7950 msgstr ""
7952 #. type: Content of: <book><chapter><sect1><sect2><para>
7953 #: ../en/ch06-filenames.xml:376
7954 msgid ""
7955 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
7956 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
7957 "change the names of any offending files or directories so that they will no "
7958 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
7959 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
7960 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
7961 "update</command> to the revision with the non-conflicting names."
7962 msgstr ""
7964 #. type: Content of: <book><chapter><sect1><sect2><para>
7965 #: ../en/ch06-filenames.xml:386
7966 msgid ""
7967 "The changeset with case-conflicting names will remain in your project's "
7968 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
7969 "command> your working directory to that changeset on a Windows or MacOS "
7970 "system, but you can continue development unimpeded."
7971 msgstr ""
7973 #. type: Content of: <book><chapter><sect1><sect2><note><para>
7974 #: ../en/ch06-filenames.xml:393
7975 msgid ""
7976 "Prior to version 0.9.3, Mercurial did not use a case safe repository storage "
7977 "mechanism, and did not detect case folding conflicts. If you are using an "
7978 "older version of Mercurial on Windows or MacOS, I strongly recommend that you "
7979 "upgrade."
7980 msgstr ""
7982 #. type: Content of: <book><chapter><title>
7983 #: ../en/ch07-branch.xml:5
7984 msgid "Managing releases and branchy development"
7985 msgstr "发布管理与分支开发"
7987 #. type: Content of: <book><chapter><para>
7988 #: ../en/ch07-branch.xml:7
7989 msgid ""
7990 "Mercurial provides several mechanisms for you to manage a project that is "
7991 "making progress on multiple fronts at once. To understand these mechanisms, "
7992 "let's first take a brief look at a fairly normal software project structure."
7993 msgstr ""
7995 #. type: Content of: <book><chapter><para>
7996 #: ../en/ch07-branch.xml:12
7997 msgid ""
7998 "Many software projects issue periodic <quote>major</quote> releases that "
7999 "contain substantial new features. In parallel, they may issue <quote>minor</"
8000 "quote> releases. These are usually identical to the major releases off which "
8001 "they're based, but with a few bugs fixed."
8002 msgstr ""
8004 #. type: Content of: <book><chapter><para>
8005 #: ../en/ch07-branch.xml:18
8006 msgid ""
8007 "In this chapter, we'll start by talking about how to keep records of project "
8008 "milestones such as releases. We'll then continue on to talk about the flow "
8009 "of work between different phases of a project, and how Mercurial can help you "
8010 "to isolate and manage this work."
8011 msgstr ""
8013 #. type: Content of: <book><chapter><sect1><title>
8014 #: ../en/ch07-branch.xml:25
8015 msgid "Giving a persistent name to a revision"
8016 msgstr "给版本指定一个永久的名称"
8018 #. type: Content of: <book><chapter><sect1><para>
8019 #: ../en/ch07-branch.xml:27
8020 msgid ""
8021 "Once you decide that you'd like to call a particular revision a "
8022 "<quote>release</quote>, it's a good idea to record the identity of that "
8023 "revision. This will let you reproduce that release at a later date, for "
8024 "whatever purpose you might need at the time (reproducing a bug, porting to a "
8025 "new platform, etc). &interaction.tag.init;"
8026 msgstr ""
8029 #. type: Content of: <book><chapter><sect1><para>
8030 #: ../en/ch07-branch.xml:34
8031 msgid ""
8032 "Mercurial lets you give a permanent name to any revision using the <command "
8033 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
8034 "called <quote>tags</quote>."
8035 msgstr ""
8037 #. type: Content of: <book><chapter><sect1><para>
8038 #: ../en/ch07-branch.xml:40
8039 msgid ""
8040 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
8041 "Tags exist purely for your convenience, so that you have a handy permanent "
8042 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
8043 "in any way. Neither does Mercurial place any restrictions on the name of a "
8044 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
8045 "unambiguously. A tag name cannot contain any of the following characters:"
8046 msgstr ""
8048 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8049 #: ../en/ch07-branch.xml:49
8050 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
8051 msgstr ""
8053 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8054 #: ../en/ch07-branch.xml:52
8055 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
8056 msgstr ""
8058 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8059 #: ../en/ch07-branch.xml:55
8060 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
8061 msgstr ""
8063 #. type: Content of: <book><chapter><sect1><para>
8064 #: ../en/ch07-branch.xml:59
8065 msgid ""
8066 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
8067 "the tags present in your repository. In the output, each tagged revision is "
8068 "identified first by its name, then by revision number, and finally by the "
8069 "unique hash of the revision."
8070 msgstr ""
8072 #. type: Content of: <book><chapter><sect1><para>
8073 #: ../en/ch07-branch.xml:67
8074 msgid ""
8075 "Notice that <literal>tip</literal> is listed in the output of <command role="
8076 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
8077 "<quote>floating</quote> tag, which always identifies the newest revision in "
8078 "the repository."
8079 msgstr ""
8081 #. type: Content of: <book><chapter><sect1><para>
8082 #: ../en/ch07-branch.xml:73
8083 msgid ""
8084 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
8085 "are listed in reverse order, by revision number. This usually means that "
8086 "recent tags are listed before older tags. It also means that <literal>tip</"
8087 "literal> is always going to be the first tag listed in the output of <command "
8088 "role=\"hg-cmd\">hg tags</command>."
8089 msgstr ""
8091 #. type: Content of: <book><chapter><sect1><para>
8092 #: ../en/ch07-branch.xml:80
8093 msgid ""
8094 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
8095 "revision that has tags associated with it, it will print those tags."
8096 msgstr ""
8099 #. type: Content of: <book><chapter><sect1><para>
8100 #: ../en/ch07-branch.xml:86
8101 msgid ""
8102 "Any time you need to provide a revision ID to a Mercurial command, the "
8103 "command will accept a tag name in its place. Internally, Mercurial will "
8104 "translate your tag name into the corresponding revision ID, then use that."
8105 msgstr ""
8107 #. type: Content of: <book><chapter><sect1><para>
8108 #: ../en/ch07-branch.xml:93
8109 msgid ""
8110 "There's no limit on the number of tags you can have in a repository, or on "
8111 "the number of tags that a single revision can have. As a practical matter, "
8112 "it's not a great idea to have <quote>too many</quote> (a number which will "
8113 "vary from project to project), simply because tags are supposed to help you "
8114 "to find revisions. If you have lots of tags, the ease of using them to "
8115 "identify revisions diminishes rapidly."
8116 msgstr ""
8118 #. type: Content of: <book><chapter><sect1><para>
8119 #: ../en/ch07-branch.xml:101
8120 msgid ""
8121 "For example, if your project has milestones as frequent as every few days, "
8122 "it's perfectly reasonable to tag each one of those. But if you have a "
8123 "continuous build system that makes sure every revision can be built cleanly, "
8124 "you'd be introducing a lot of noise if you were to tag every clean build. "
8125 "Instead, you could tag failed builds (on the assumption that they're rare!), "
8126 "or simply not use tags to track buildability."
8127 msgstr ""
8129 #. type: Content of: <book><chapter><sect1><para>
8130 #: ../en/ch07-branch.xml:109
8131 msgid ""
8132 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
8133 "cmd\">hg tag --remove</command>."
8134 msgstr ""
8136 #. type: Content of: <book><chapter><sect1><para>
8137 #: ../en/ch07-branch.xml:114
8138 msgid ""
8139 "You can also modify a tag at any time, so that it identifies a different "
8140 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
8141 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
8142 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
8143 "the tag."
8144 msgstr ""
8146 #. type: Content of: <book><chapter><sect1><para>
8147 #: ../en/ch07-branch.xml:123
8148 msgid ""
8149 "There will still be a permanent record of the previous identity of the tag, "
8150 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
8151 "wrong revision; all you have to do is turn around and tag the correct "
8152 "revision once you discover your error."
8153 msgstr ""
8156 #. type: Content of: <book><chapter><sect1><para>
8157 #: ../en/ch07-branch.xml:129
8158 msgid ""
8159 "Mercurial stores tags in a normal revision-controlled file in your "
8160 "repository. If you've created any tags, you'll find them in a file named "
8161 "<filename role=\"special\">.hgtags</filename>. When you run the <command "
8162 "role=\"hg-cmd\">hg tag</command> command, Mercurial modifies this file, then "
8163 "automatically commits the change to it. This means that every time you run "
8164 "<command role=\"hg-cmd\">hg tag</command>, you'll see a corresponding "
8165 "changeset in the output of <command role=\"hg-cmd\">hg log</command>."
8166 msgstr ""
8168 #. type: Content of: <book><chapter><sect1><sect2><title>
8169 #: ../en/ch07-branch.xml:142
8170 msgid "Handling tag conflicts during a merge"
8171 msgstr "在合并期间处理标签冲突"
8173 #. type: Content of: <book><chapter><sect1><sect2><para>
8174 #: ../en/ch07-branch.xml:144
8175 msgid ""
8176 "You won't often need to care about the <filename role=\"special\">.hgtags</"
8177 "filename> file, but it sometimes makes its presence known during a merge. "
8178 "The format of the file is simple: it consists of a series of lines. Each "
8179 "line starts with a changeset hash, followed by a space, followed by the name "
8180 "of a tag."
8181 msgstr ""
8183 #. type: Content of: <book><chapter><sect1><sect2><para>
8184 #: ../en/ch07-branch.xml:151
8185 msgid ""
8186 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
8187 "filename> file during a merge, there's one twist to modifying the <filename "
8188 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
8189 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
8190 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
8191 "<emphasis>most recently committed</emphasis> revision of the file."
8192 msgstr ""
8194 #. type: Content of: <book><chapter><sect1><sect2><para>
8195 #: ../en/ch07-branch.xml:161
8196 msgid ""
8197 "An unfortunate consequence of this design is that you can't actually verify "
8198 "that your merged <filename role=\"special\">.hgtags</filename> file is "
8199 "correct until <emphasis>after</emphasis> you've committed a change. So if "
8200 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
8201 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
8202 "command> after you commit. If it finds an error in the <filename role="
8203 "\"special\">.hgtags</filename> file, it will report the location of the "
8204 "error, which you can then fix and commit. You should then run <command role="
8205 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
8206 msgstr ""
8208 #. type: Content of: <book><chapter><sect1><sect2><title>
8209 #: ../en/ch07-branch.xml:176
8210 msgid "Tags and cloning"
8211 msgstr "标签与克隆"
8213 #. type: Content of: <book><chapter><sect1><sect2><para>
8214 #: ../en/ch07-branch.xml:178
8215 msgid ""
8216 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
8217 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
8218 "clone an exact copy of the repository as of a particular changeset. The new "
8219 "clone will not contain any project history that comes after the revision you "
8220 "specified. This has an interaction with tags that can surprise the unwary."
8221 msgstr ""
8223 #. type: Content of: <book><chapter><sect1><sect2><para>
8224 #: ../en/ch07-branch.xml:186
8225 msgid ""
8226 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
8227 "hgtags</filename> file, so that when you create a tag, the changeset in which "
8228 "it's recorded necessarily refers to an older changeset. When you run "
8229 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
8230 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
8231 "history that created the tag</emphasis> that you used to clone the "
8232 "repository. The result is that you'll get exactly the right subset of the "
8233 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
8234 "you might have expected."
8235 msgstr ""
8237 #. type: Content of: <book><chapter><sect1><sect2><title>
8238 #: ../en/ch07-branch.xml:201
8239 msgid "When permanent tags are too much"
8240 msgstr "当永久标签太多的时候"
8242 #. type: Content of: <book><chapter><sect1><sect2><para>
8243 #: ../en/ch07-branch.xml:203
8244 msgid ""
8245 "Since Mercurial's tags are revision controlled and carried around with a "
8246 "project's history, everyone you work with will see the tags you create. But "
8247 "giving names to revisions has uses beyond simply noting that revision "
8248 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
8249 "you're trying to track down a subtle bug, you might want a tag to remind you "
8250 "of something like <quote>Anne saw the symptoms with this revision</quote>."
8251 msgstr ""
8253 #. type: Content of: <book><chapter><sect1><sect2><para>
8254 #: ../en/ch07-branch.xml:213
8255 msgid ""
8256 "For cases like this, what you might want to use are <emphasis>local</"
8257 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
8258 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
8259 "command. This will store the tag in a file called <filename role=\"special"
8260 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
8261 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
8262 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
8263 "l</option> remain strictly local to the repository you're currently working "
8264 "in."
8265 msgstr ""
8267 #. type: Content of: <book><chapter><sect1><title>
8268 #: ../en/ch07-branch.xml:228
8269 msgid "The flow of changes&emdash;big picture vs. little"
8270 msgstr "修改流程—宏观与微观"
8272 #. type: Content of: <book><chapter><sect1><para>
8273 #: ../en/ch07-branch.xml:230
8274 msgid ""
8275 "To return to the outline I sketched at the beginning of a chapter, let's "
8276 "think about a project that has multiple concurrent pieces of work under "
8277 "development at once."
8278 msgstr ""
8280 #. type: Content of: <book><chapter><sect1><para>
8281 #: ../en/ch07-branch.xml:234
8282 msgid ""
8283 "There might be a push for a new <quote>main</quote> release; a new minor "
8284 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
8285 "quote> to an old release that is now in maintenance mode."
8286 msgstr ""
8288 #. type: Content of: <book><chapter><sect1><para>
8289 #: ../en/ch07-branch.xml:239
8290 msgid ""
8291 "The usual way people refer to these different concurrent directions of "
8292 "development is as <quote>branches</quote>. However, we've already seen "
8293 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
8294 "series of branches and merges. Really, what we have here is two ideas that "
8295 "are peripherally related, but which happen to share a name."
8296 msgstr ""
8298 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8299 #: ../en/ch07-branch.xml:246
8300 msgid ""
8301 "<quote>Big picture</quote> branches represent the sweep of a project's "
8302 "evolution; people give them names, and talk about them in conversation."
8303 msgstr ""
8305 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8306 #: ../en/ch07-branch.xml:250
8307 msgid ""
8308 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
8309 "activity of developing and merging changes. They expose the narrative of how "
8310 "the code was developed."
8311 msgstr ""
8313 #. type: Content of: <book><chapter><sect1><title>
8314 #: ../en/ch07-branch.xml:258
8315 msgid "Managing big-picture branches in repositories"
8316 msgstr "在版本库中管理分支"
8318 #. type: Content of: <book><chapter><sect1><para>
8319 #: ../en/ch07-branch.xml:260
8320 msgid ""
8321 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
8322 "is in a dedicated repository. If you have an existing shared "
8323 "repository&emdash;let's call it <literal>myproject</literal>&emdash;that "
8324 "reaches a <quote>1.0</quote> milestone, you can start to prepare for future "
8325 "maintenance releases on top of version 1.0 by tagging the revision from which "
8326 "you prepared the 1.0 release."
8327 msgstr ""
8329 #. type: Content of: <book><chapter><sect1><para>
8330 #: ../en/ch07-branch.xml:270
8331 msgid ""
8332 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
8333 "as of that tag."
8334 msgstr ""
8336 #. type: Content of: <book><chapter><sect1><para>
8337 #: ../en/ch07-branch.xml:276
8338 msgid ""
8339 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
8340 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
8341 "literal> repository, make their changes, and push them back."
8342 msgstr ""
8344 #. type: Content of: <book><chapter><sect1><para>
8345 #: ../en/ch07-branch.xml:283
8346 msgid ""
8347 "Meanwhile, development for the next major release can continue, isolated and "
8348 "unabated, in the <literal>myproject</literal> repository."
8349 msgstr ""
8351 #. type: Content of: <book><chapter><sect1><title>
8352 #: ../en/ch07-branch.xml:291
8353 msgid "Don't repeat yourself: merging across branches"
8354 msgstr "不要重复劳动:在分支间合并"
8356 #. type: Content of: <book><chapter><sect1><para>
8357 #: ../en/ch07-branch.xml:293
8358 msgid ""
8359 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
8360 "are good that the bug exists on your project's main branch (and possibly "
8361 "other maintenance branches, too). It's a rare developer who wants to fix the "
8362 "same bug multiple times, so let's look at a few ways that Mercurial can help "
8363 "you to manage these bugfixes without duplicating your work."
8364 msgstr ""
8366 #. type: Content of: <book><chapter><sect1><para>
8367 #: ../en/ch07-branch.xml:301
8368 msgid ""
8369 "In the simplest instance, all you need to do is pull changes from your "
8370 "maintenance branch into your local clone of the target branch."
8371 msgstr ""
8373 #. type: Content of: <book><chapter><sect1><para>
8374 #: ../en/ch07-branch.xml:307
8375 msgid ""
8376 "You'll then need to merge the heads of the two branches, and push back to the "
8377 "main branch."
8378 msgstr ""
8380 #. type: Content of: <book><chapter><sect1><title>
8381 #: ../en/ch07-branch.xml:314
8382 msgid "Naming branches within one repository"
8383 msgstr "版本库中的命名分支"
8385 #. type: Content of: <book><chapter><sect1><para>
8386 #: ../en/ch07-branch.xml:316
8387 msgid ""
8388 "In most instances, isolating branches in repositories is the right approach. "
8389 "Its simplicity makes it easy to understand; and so it's hard to make "
8390 "mistakes. There's a one-to-one relationship between branches you're working "
8391 "in and directories on your system. This lets you use normal (non-Mercurial-"
8392 "aware) tools to work on files within a branch/repository."
8393 msgstr ""
8395 #. type: Content of: <book><chapter><sect1><para>
8396 #: ../en/ch07-branch.xml:323
8397 msgid ""
8398 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
8399 "emphasis> your collaborators are too), there is an alternative way of "
8400 "handling branches that you can consider. I've already mentioned the human-"
8401 "level distinction between <quote>small picture</quote> and <quote>big "
8402 "picture</quote> branches. While Mercurial works with multiple <quote>small "
8403 "picture</quote> branches in a repository all the time (for example after you "
8404 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
8405 "work with multiple <quote>big picture</quote> branches."
8406 msgstr ""
8408 #. type: Content of: <book><chapter><sect1><para>
8409 #: ../en/ch07-branch.xml:334
8410 msgid ""
8411 "The key to working this way is that Mercurial lets you assign a persistent "
8412 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
8413 "<literal>default</literal>. Even before you start naming branches yourself, "
8414 "you can find traces of the <literal>default</literal> branch if you look for "
8415 "them."
8416 msgstr ""
8418 #. type: Content of: <book><chapter><sect1><para>
8419 #: ../en/ch07-branch.xml:341
8420 msgid ""
8421 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
8422 "command, and it pops up your editor so that you can enter a commit message, "
8423 "look for a line that contains the text <quote><literal>HG: branch default</"
8424 "literal></quote> at the bottom. This is telling you that your commit will "
8425 "occur on the branch named <literal>default</literal>."
8426 msgstr ""
8428 #. type: Content of: <book><chapter><sect1><para>
8429 #: ../en/ch07-branch.xml:348
8430 msgid ""
8431 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
8432 "branches</command> command. This command lists the named branches already "
8433 "present in your repository, telling you which changeset is the tip of each."
8434 msgstr ""
8436 #. type: Content of: <book><chapter><sect1><para>
8437 #: ../en/ch07-branch.xml:355
8438 msgid ""
8439 "Since you haven't created any named branches yet, the only one that exists is "
8440 "<literal>default</literal>."
8441 msgstr ""
8443 #. type: Content of: <book><chapter><sect1><para>
8444 #: ../en/ch07-branch.xml:358
8445 msgid ""
8446 "To find out what the <quote>current</quote> branch is, run the <command role="
8447 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
8448 "you what branch the parent of the current changeset is on."
8449 msgstr ""
8452 #. type: Content of: <book><chapter><sect1><para>
8453 #: ../en/ch07-branch.xml:365
8454 msgid ""
8455 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
8456 "command again. This time, give it one argument: the name of the branch you "
8457 "want to create."
8458 msgstr ""
8460 #. type: Content of: <book><chapter><sect1><para>
8461 #: ../en/ch07-branch.xml:371
8462 msgid ""
8463 "After you've created a branch, you might wonder what effect the <command role="
8464 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
8465 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
8466 "commands report?"
8467 msgstr ""
8469 #. type: Content of: <book><chapter><sect1><para>
8470 #: ../en/ch07-branch.xml:378
8471 msgid ""
8472 "Nothing has changed in the working directory, and there's been no new history "
8473 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
8474 "command> command has no permanent effect; it only tells Mercurial what branch "
8475 "name to use the <emphasis>next</emphasis> time you commit a changeset."
8476 msgstr ""
8478 #. type: Content of: <book><chapter><sect1><para>
8479 #: ../en/ch07-branch.xml:385
8480 msgid ""
8481 "When you commit a change, Mercurial records the name of the branch on which "
8482 "you committed. Once you've switched from the <literal>default</literal> "
8483 "branch to another and committed, you'll see the name of the new branch show "
8484 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
8485 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
8486 "output."
8487 msgstr ""
8489 #. type: Content of: <book><chapter><sect1><para>
8490 #: ../en/ch07-branch.xml:395
8491 msgid ""
8492 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
8493 "branch name of every changeset that's not on the <literal>default</literal> "
8494 "branch. As a result, if you never use named branches, you'll never see this "
8495 "information."
8496 msgstr ""
8498 #. type: Content of: <book><chapter><sect1><para>
8499 #: ../en/ch07-branch.xml:400
8500 msgid ""
8501 "Once you've named a branch and committed a change with that name, every "
8502 "subsequent commit that descends from that change will inherit the same branch "
8503 "name. You can change the name of a branch at any time, using the <command "
8504 "role=\"hg-cmd\">hg branch</command> command."
8505 msgstr ""
8507 #. type: Content of: <book><chapter><sect1><para>
8508 #: ../en/ch07-branch.xml:408
8509 msgid ""
8510 "In practice, this is something you won't do very often, as branch names tend "
8511 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
8512 msgstr ""
8514 #. type: Content of: <book><chapter><sect1><title>
8515 #: ../en/ch07-branch.xml:414
8516 msgid "Dealing with multiple named branches in a repository"
8517 msgstr "在版本库中处理多个命名分支"
8519 #. type: Content of: <book><chapter><sect1><para>
8520 #: ../en/ch07-branch.xml:417
8521 msgid ""
8522 "If you have more than one named branch in a repository, Mercurial will "
8523 "remember the branch that your working directory on when you start a command "
8524 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
8525 "\">hg pull -u</command>. It will update the working directory to the tip of "
8526 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
8527 "to a revision that's on a different named branch, you may need to use the "
8528 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
8529 "\">hg update</command>."
8530 msgstr ""
8532 #. type: Content of: <book><chapter><sect1><para>
8533 #: ../en/ch07-branch.xml:427
8534 msgid ""
8535 "This behaviour is a little subtle, so let's see it in action. First, let's "
8536 "remind ourselves what branch we're currently on, and what branches are in our "
8537 "repository."
8538 msgstr ""
8540 #. type: Content of: <book><chapter><sect1><para>
8541 #: ../en/ch07-branch.xml:433
8542 msgid ""
8543 "We're on the <literal>bar</literal> branch, but there also exists an older "
8544 "<command role=\"hg-cmd\">hg foo</command> branch."
8545 msgstr ""
8547 #. type: Content of: <book><chapter><sect1><para>
8548 #: ../en/ch07-branch.xml:437
8549 msgid ""
8550 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
8551 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
8552 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
8553 "because this only involves going backwards and forwards linearly through our "
8554 "change history."
8555 msgstr ""
8558 #. type: Content of: <book><chapter><sect1><para>
8559 #: ../en/ch07-branch.xml:446
8560 msgid ""
8561 "If we go back to the <literal>foo</literal> branch and then run <command role="
8562 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
8563 "not move us to the tip of <literal>bar</literal>."
8564 msgstr ""
8567 #. type: Content of: <book><chapter><sect1><para>
8568 #: ../en/ch07-branch.xml:453
8569 msgid ""
8570 "Committing a new change on the <literal>foo</literal> branch introduces a new "
8571 "head."
8572 msgstr ""
8574 #. type: Content of: <book><chapter><sect1><title>
8575 #: ../en/ch07-branch.xml:460
8576 msgid "Branch names and merging"
8577 msgstr "分支名称与合并"
8579 #. type: Content of: <book><chapter><sect1><para>
8580 #: ../en/ch07-branch.xml:462
8581 msgid ""
8582 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
8583 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
8584 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
8585 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
8586 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
8587 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
8588 "records 23 as the first parent, and 17 as the second."
8589 msgstr ""
8591 #. type: Content of: <book><chapter><sect1><para>
8592 #: ../en/ch07-branch.xml:472
8593 msgid ""
8594 "This affects Mercurial's choice of branch name when you merge. After a "
8595 "merge, Mercurial will retain the branch name of the first parent when you "
8596 "commit the result of the merge. If your first parent's branch name is "
8597 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
8598 "name will still be <literal>foo</literal> after you merge."
8599 msgstr ""
8601 #. type: Content of: <book><chapter><sect1><para>
8602 #: ../en/ch07-branch.xml:479
8603 msgid ""
8604 "It's not unusual for a repository to contain multiple heads, each with the "
8605 "same branch name. Let's say I'm working on the <literal>foo</literal> "
8606 "branch, and so are you. We commit different changes; I pull your changes; I "
8607 "now have two heads, each claiming to be on the <literal>foo</literal> "
8608 "branch. The result of a merge will be a single head on the <literal>foo</"
8609 "literal> branch, as you might hope."
8610 msgstr ""
8613 #. type: Content of: <book><chapter><sect1><para>
8614 #: ../en/ch07-branch.xml:487
8615 msgid ""
8616 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
8617 "from the <literal>foo</literal> branch, the result will remain on the "
8618 "<literal>bar</literal> branch."
8619 msgstr ""
8621 #. type: Content of: <book><chapter><sect1><para>
8622 #: ../en/ch07-branch.xml:493
8623 msgid ""
8624 "To give a more concrete example, if I'm working on the <literal>bleeding-"
8625 "edge</literal> branch, and I want to bring in the latest fixes from the "
8626 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
8627 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
8628 "from <literal>stable</literal>."
8629 msgstr ""
8631 #. type: Content of: <book><chapter><sect1><title>
8632 #: ../en/ch07-branch.xml:502
8633 msgid "Branch naming is generally useful"
8634 msgstr "分支名称通常都很有用"
8636 #. type: Content of: <book><chapter><sect1><para>
8637 #: ../en/ch07-branch.xml:504
8638 msgid ""
8639 "You shouldn't think of named branches as applicable only to situations where "
8640 "you have multiple long-lived branches cohabiting in a single repository. "
8641 "They're very useful even in the one-branch-per-repository case."
8642 msgstr ""
8644 #. type: Content of: <book><chapter><sect1><para>
8645 #: ../en/ch07-branch.xml:509
8646 msgid ""
8647 "In the simplest case, giving a name to each branch gives you a permanent "
8648 "record of which branch a changeset originated on. This gives you more "
8649 "context when you're trying to follow the history of a long-lived branchy "
8650 "project."
8651 msgstr ""
8653 #. type: Content of: <book><chapter><sect1><para>
8654 #: ../en/ch07-branch.xml:514
8655 msgid ""
8656 "If you're working with shared repositories, you can set up a <literal role="
8657 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
8658 "changes that have the <quote>wrong</quote> branch name. This provides a "
8659 "simple, but effective, defence against people accidentally pushing changes "
8660 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
8661 "branch. Such a hook might look like this inside the shared repo's <filename "
8662 "role=\"special\"> /.hgrc</filename>."
8663 msgstr ""
8665 #. type: Content of: <book><chapter><title>
8666 #: ../en/ch08-undo.xml:5
8667 msgid "Finding and fixing mistakes"
8668 msgstr "查找和修改错误"
8670 #. type: Content of: <book><chapter><para>
8671 #: ../en/ch08-undo.xml:7
8672 msgid ""
8673 "To err might be human, but to really handle the consequences well takes a top-"
8674 "notch revision control system. In this chapter, we'll discuss some of the "
8675 "techniques you can use when you find that a problem has crept into your "
8676 "project. Mercurial has some highly capable features that will help you to "
8677 "isolate the sources of problems, and to handle them appropriately."
8678 msgstr ""
8680 #. type: Content of: <book><chapter><sect1><title>
8681 #: ../en/ch08-undo.xml:15
8682 msgid "Erasing local history"
8683 msgstr "销毁本地历史"
8685 #. type: Content of: <book><chapter><sect1><sect2><title>
8686 #: ../en/ch08-undo.xml:18
8687 msgid "The accidental commit"
8688 msgstr "意外的提交"
8690 #. type: Content of: <book><chapter><sect1><sect2><para>
8691 #: ../en/ch08-undo.xml:20
8692 msgid ""
8693 "I have the occasional but persistent problem of typing rather more quickly "
8694 "than I can think, which sometimes results in me committing a changeset that "
8695 "is either incomplete or plain wrong. In my case, the usual kind of "
8696 "incomplete changeset is one in which I've created a new source file, but "
8697 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
8698 "wrong</quote> changeset is not as common, but no less annoying."
8699 msgstr ""
8701 #. type: Content of: <book><chapter><sect1><sect2><title>
8702 #: ../en/ch08-undo.xml:31
8703 msgid "Rolling back a transaction"
8704 msgstr "回滚一个事务"
8706 #. type: Content of: <book><chapter><sect1><sect2><para>
8707 #: ../en/ch08-undo.xml:33
8708 msgid ""
8709 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
8710 "each modification of a repository as a <emphasis>transaction</emphasis>. "
8711 "Every time you commit a changeset or pull changes from another repository, "
8712 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
8713 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
8714 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
8715 "\"/> for an important caveat about the use of this command.)"
8716 msgstr ""
8718 #. type: Content of: <book><chapter><sect1><sect2><para>
8719 #: ../en/ch08-undo.xml:43
8720 msgid ""
8721 "Here's a mistake that I often find myself making: committing a change in "
8722 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
8723 "add</command> it."
8724 msgstr ""
8726 #. type: Content of: <book><chapter><sect1><sect2><para>
8727 #: ../en/ch08-undo.xml:50
8728 msgid ""
8729 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
8730 "the commit immediately confirms the error."
8731 msgstr ""
8733 #. type: Content of: <book><chapter><sect1><sect2><para>
8734 #: ../en/ch08-undo.xml:56
8735 msgid ""
8736 "The commit captured the changes to the file <filename>a</filename>, but not "
8737 "the new file <filename>b</filename>. If I were to push this changeset to a "
8738 "repository that I shared with a colleague, the chances are high that "
8739 "something in <filename>a</filename> would refer to <filename>b</filename>, "
8740 "which would not be present in their repository when they pulled my changes. "
8741 "I would thus become the object of some indignation."
8742 msgstr ""
8744 #. type: Content of: <book><chapter><sect1><sect2><para>
8745 #: ../en/ch08-undo.xml:65
8746 msgid ""
8747 "However, luck is with me&emdash;I've caught my error before I pushed the "
8748 "changeset. I use the <command role=\"hg-cmd\">hg rollback</command> command, "
8749 "and Mercurial makes that last changeset vanish."
8750 msgstr ""
8752 #. type: Content of: <book><chapter><sect1><sect2><para>
8753 #: ../en/ch08-undo.xml:72
8754 msgid ""
8755 "Notice that the changeset is no longer present in the repository's history, "
8756 "and the working directory once again thinks that the file <filename>a</"
8757 "filename> is modified. The commit and rollback have left the working "
8758 "directory exactly as it was prior to the commit; the changeset has been "
8759 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
8760 "command> the file <filename>b</filename>, and rerun my commit."
8761 msgstr ""
8763 #. type: Content of: <book><chapter><sect1><sect2><title>
8764 #: ../en/ch08-undo.xml:85
8765 msgid "The erroneous pull"
8766 msgstr "错误的抓取"
8768 #. type: Content of: <book><chapter><sect1><sect2><para>
8769 #: ../en/ch08-undo.xml:87
8770 msgid ""
8771 "It's common practice with Mercurial to maintain separate development branches "
8772 "of a project in different repositories. Your development team might have one "
8773 "shared repository for your project's <quote>0.9</quote> release, and another, "
8774 "containing different changes, for the <quote>1.0</quote> release."
8775 msgstr ""
8777 #. type: Content of: <book><chapter><sect1><sect2><para>
8778 #: ../en/ch08-undo.xml:94
8779 msgid ""
8780 "Given this, you can imagine that the consequences could be messy if you had a "
8781 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
8782 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
8783 "insufficient attention, and push those changes into the shared <quote>0.9</"
8784 "quote> tree, confusing your entire team (but don't worry, we'll return to "
8785 "this horror scenario later). However, it's more likely that you'll notice "
8786 "immediately, because Mercurial will display the URL it's pulling from, or you "
8787 "will see it pull a suspiciously large number of changes into the repository."
8788 msgstr ""
8790 #. type: Content of: <book><chapter><sect1><sect2><para>
8791 #: ../en/ch08-undo.xml:106
8792 msgid ""
8793 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
8794 "to expunge all of the changesets that you just pulled. Mercurial groups all "
8795 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
8796 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
8797 "need to undo this mistake."
8798 msgstr ""
8800 #. type: Content of: <book><chapter><sect1><sect2><title>
8801 #: ../en/ch08-undo.xml:115
8802 msgid "Rolling back is useless once you've pushed"
8803 msgstr "当完成推送后,回滚是无效的"
8805 #. type: Content of: <book><chapter><sect1><sect2><para>
8806 #: ../en/ch08-undo.xml:117
8807 msgid ""
8808 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
8809 "to zero once you've pushed your changes to another repository. Rolling back "
8810 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
8811 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
8812 "command>. Because a rollback eliminates history, there's no way for the "
8813 "disappearance of a change to propagate between repositories."
8814 msgstr ""
8816 #. type: Content of: <book><chapter><sect1><sect2><para>
8817 #: ../en/ch08-undo.xml:126
8818 msgid ""
8819 "If you've pushed a change to another repository&emdash;particularly if it's a "
8820 "shared repository&emdash;it has essentially <quote>escaped into the wild,</"
8821 "quote> and you'll have to recover from your mistake in a different way. What "
8822 "will happen if you push a changeset somewhere, then roll it back, then pull "
8823 "from the repository you pushed to, is that the changeset will reappear in "
8824 "your repository."
8825 msgstr ""
8827 #. type: Content of: <book><chapter><sect1><sect2><para>
8828 #: ../en/ch08-undo.xml:135
8829 msgid ""
8830 "(If you absolutely know for sure that the change you want to roll back is the "
8831 "most recent change in the repository that you pushed to, <emphasis>and</"
8832 "emphasis> you know that nobody else could have pulled it from that "
8833 "repository, you can roll back the changeset there, too, but you really should "
8834 "really not rely on this working reliably. If you do this, sooner or later a "
8835 "change really will make it into a repository that you don't directly control "
8836 "(or have forgotten about), and come back to bite you.)"
8837 msgstr ""
8839 #. type: Content of: <book><chapter><sect1><sect2><title>
8840 #: ../en/ch08-undo.xml:147
8841 msgid "You can only roll back once"
8842 msgstr "你只能回滚一次"
8844 #. type: Content of: <book><chapter><sect1><sect2><para>
8845 #: ../en/ch08-undo.xml:149
8846 msgid ""
8847 "Mercurial stores exactly one transaction in its transaction log; that "
8848 "transaction is the most recent one that occurred in the repository. This "
8849 "means that you can only roll back one transaction. If you expect to be able "
8850 "to roll back one transaction, then its predecessor, this is not the behaviour "
8851 "you will get."
8852 msgstr ""
8854 #. type: Content of: <book><chapter><sect1><sect2><para>
8855 #: ../en/ch08-undo.xml:158
8856 msgid ""
8857 "Once you've rolled back one transaction in a repository, you can't roll back "
8858 "again in that repository until you perform another commit or pull."
8859 msgstr ""
8861 #. type: Content of: <book><chapter><sect1><title>
8862 #: ../en/ch08-undo.xml:165
8863 msgid "Reverting the mistaken change"
8864 msgstr "撤销错误的修改"
8866 #. type: Content of: <book><chapter><sect1><para>
8867 #: ../en/ch08-undo.xml:167
8868 msgid ""
8869 "If you make a modification to a file, and decide that you really didn't want "
8870 "to change the file at all, and you haven't yet committed your changes, the "
8871 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
8872 "It looks at the changeset that's the parent of the working directory, and "
8873 "restores the contents of the file to their state as of that changeset. "
8874 "(That's a long-winded way of saying that, in the normal case, it undoes your "
8875 "modifications.)"
8876 msgstr ""
8878 #. type: Content of: <book><chapter><sect1><para>
8879 #: ../en/ch08-undo.xml:176
8880 msgid ""
8881 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
8882 "works with yet another small example. We'll begin by modifying a file that "
8883 "Mercurial is already tracking."
8884 msgstr ""
8886 #. type: Content of: <book><chapter><sect1><para>
8887 #: ../en/ch08-undo.xml:183
8888 msgid ""
8889 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
8890 "revert</command> the file."
8891 msgstr ""
8893 #. type: Content of: <book><chapter><sect1><para>
8894 #: ../en/ch08-undo.xml:189
8895 msgid ""
8896 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
8897 "extra degree of safety by saving our modified file with a <filename>.orig</"
8898 "filename> extension."
8899 msgstr ""
8901 #. type: Content of: <book><chapter><sect1><para>
8902 #: ../en/ch08-undo.xml:196
8903 msgid ""
8904 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
8905 "command> command can deal with. We will describe each of these in more "
8906 "detail in the section that follows."
8907 msgstr ""
8909 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8910 #: ../en/ch08-undo.xml:201
8911 msgid "If you modify a file, it will restore the file to its unmodified state."
8912 msgstr ""
8914 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8915 #: ../en/ch08-undo.xml:204
8916 msgid ""
8917 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
8918 "<quote>added</quote> state of the file, but leave the file itself untouched."
8919 msgstr ""
8921 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8922 #: ../en/ch08-undo.xml:208
8923 msgid ""
8924 "If you delete a file without telling Mercurial, it will restore the file to "
8925 "its unmodified contents."
8926 msgstr ""
8928 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
8929 #: ../en/ch08-undo.xml:211
8930 msgid ""
8931 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
8932 "a file, it will undo the <quote>removed</quote> state of the file, and "
8933 "restore the file to its unmodified contents."
8934 msgstr ""
8936 #. type: Content of: <book><chapter><sect1><sect2><title>
8937 #: ../en/ch08-undo.xml:218
8938 msgid "File management errors"
8939 msgstr "文件管理错误"
8941 #. type: Content of: <book><chapter><sect1><sect2><para>
8942 #: ../en/ch08-undo.xml:220
8943 msgid ""
8944 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
8945 "than just modified files. It lets you reverse the results of all of "
8946 "Mercurial's file management commands&emdash;<command role=\"hg-cmd\">hg add</"
8947 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
8948 msgstr ""
8951 #. type: Content of: <book><chapter><sect1><sect2><para>
8952 #: ../en/ch08-undo.xml:226
8953 msgid ""
8954 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
8955 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
8956 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
8957 "file in any way. It will just <quote>unmark</quote> the file."
8958 msgstr ""
8960 #. type: Content of: <book><chapter><sect1><sect2><para>
8961 #: ../en/ch08-undo.xml:234
8962 msgid ""
8963 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
8964 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
8965 "restore it to the contents it had as of the parent of the working directory. "
8966 "&interaction.daily.revert.remove; This works just as well for a file that you "
8967 "deleted by hand, without telling Mercurial (recall that in Mercurial "
8968 "terminology, this kind of file is called <quote>missing</quote>)."
8969 msgstr ""
8972 #. type: Content of: <book><chapter><sect1><sect2><para>
8973 #: ../en/ch08-undo.xml:245
8974 msgid ""
8975 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
8976 "file remains in your working directory afterwards, untracked. Since a copy "
8977 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
8978 "with the copied-from file."
8979 msgstr ""
8981 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
8982 #: ../en/ch08-undo.xml:254
8983 msgid "A slightly special case: reverting a rename"
8984 msgstr "一个稍微特别的案例:撤销改名"
8986 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8987 #: ../en/ch08-undo.xml:256
8988 msgid ""
8989 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
8990 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
8991 "revert</command> a rename, it's not enough to provide the name of the renamed-"
8992 "to file, as you can see here."
8993 msgstr ""
8995 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
8996 #: ../en/ch08-undo.xml:264
8997 msgid ""
8998 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
8999 "command>, the renamed-to file is no longer identified as added, but the "
9000 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
9001 "intuitive (at least to me), but at least it's easy to deal with."
9002 msgstr ""
9004 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9005 #: ../en/ch08-undo.xml:273
9006 msgid ""
9007 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
9008 "must provide <emphasis>both</emphasis> the source and destination names."
9009 msgstr ""
9011 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9012 #: ../en/ch08-undo.xml:278
9013 msgid "% TODO: the output doesn't look like it will be removed!"
9014 msgstr ""
9016 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9017 #: ../en/ch08-undo.xml:281
9018 msgid ""
9019 "(By the way, if you rename a file, then modify the renamed-to file, then "
9020 "revert both components of the rename, when Mercurial restores the file that "
9021 "was removed as part of the rename, it will be unmodified. If you need the "
9022 "modifications in the renamed-to file to show up in the renamed-from file, "
9023 "don't forget to copy them over.)"
9024 msgstr ""
9026 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9027 #: ../en/ch08-undo.xml:288
9028 msgid ""
9029 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
9030 "Mercurial."
9031 msgstr ""
9033 #. type: Content of: <book><chapter><sect1><title>
9034 #: ../en/ch08-undo.xml:295
9035 msgid "Dealing with committed changes"
9036 msgstr "处理已经提交的修改"
9038 #. type: Content of: <book><chapter><sect1><para>
9039 #: ../en/ch08-undo.xml:297
9040 msgid ""
9041 "Consider a case where you have committed a change $a$, and another change $b$ "
9042 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
9043 "you <quote>back out</quote> an entire changeset automatically, and building "
9044 "blocks that let you reverse part of a changeset by hand."
9045 msgstr ""
9047 #. type: Content of: <book><chapter><sect1><para>
9048 #: ../en/ch08-undo.xml:303
9049 msgid ""
9050 "Before you read this section, here's something to keep in mind: the <command "
9051 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
9052 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
9053 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
9054 "some change that has catastrophic consequences. To deal with those, see "
9055 "<xref linkend=\"sec:undo:aaaiiieee\"/>."
9056 msgstr ""
9058 #. type: Content of: <book><chapter><sect1><sect2><title>
9059 #: ../en/ch08-undo.xml:312
9060 msgid "Backing out a changeset"
9061 msgstr "恢复一个修改集"
9063 #. type: Content of: <book><chapter><sect1><sect2><para>
9064 #: ../en/ch08-undo.xml:314
9065 msgid ""
9066 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
9067 "<quote>undo</quote> the effects of an entire changeset in an automated "
9068 "fashion. Because Mercurial's history is immutable, this command "
9069 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
9070 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
9071 "effect of the to-be-undone changeset."
9072 msgstr ""
9075 #. type: Content of: <book><chapter><sect1><sect2><para>
9076 #: ../en/ch08-undo.xml:323
9077 msgid ""
9078 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
9079 "a little intricate, so let's illustrate it with some examples. First, we'll "
9080 "create a repository with some simple changes."
9081 msgstr ""
9083 #. type: Content of: <book><chapter><sect1><sect2><para>
9084 #: ../en/ch08-undo.xml:330
9085 msgid ""
9086 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
9087 "changeset ID as its argument; this is the changeset to back out. Normally, "
9088 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
9089 "editor to write a commit message, so you can record why you're backing the "
9090 "change out. In this example, we provide a commit message on the command line "
9091 "using the <option role=\"hg-opt-backout\">-m</option> option."
9092 msgstr ""
9094 #. type: Content of: <book><chapter><sect1><sect2><title>
9095 #: ../en/ch08-undo.xml:341
9096 msgid "Backing out the tip changeset"
9097 msgstr "恢复顶点修改集"
9099 #. type: Content of: <book><chapter><sect1><sect2><para>
9100 #: ../en/ch08-undo.xml:343
9101 msgid "We're going to start by backing out the last changeset we committed."
9102 msgstr ""
9104 #. type: Content of: <book><chapter><sect1><sect2><para>
9105 #: ../en/ch08-undo.xml:348
9106 msgid ""
9107 "You can see that the second line from <filename>myfile</filename> is no "
9108 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
9109 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
9110 "backout</command> command has done. &interaction.backout.simple.log; Notice "
9111 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
9112 "created is a child of the changeset we backed out. It's easier to see this "
9113 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
9114 "the change history. As you can see, the history is nice and linear."
9115 msgstr ""
9117 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9118 #: ../en/ch08-undo.xml:361 ../en/ch08-undo.xml:473
9119 msgid ""
9120 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
9121 "command"
9122 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
9124 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9125 #: ../en/ch08-undo.xml:364
9126 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
9127 msgstr ""
9129 #. type: Content of: <book><chapter><sect1><sect2><title>
9130 #: ../en/ch08-undo.xml:371
9131 msgid "Backing out a non-tip change"
9132 msgstr "恢复非顶点的修改"
9134 #. type: Content of: <book><chapter><sect1><sect2><para>
9135 #: ../en/ch08-undo.xml:373
9136 msgid ""
9137 "If you want to back out a change other than the last one you committed, pass "
9138 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
9139 "role=\"hg-cmd\">hg backout</command> command."
9140 msgstr ""
9142 #. type: Content of: <book><chapter><sect1><sect2><para>
9143 #: ../en/ch08-undo.xml:380
9144 msgid ""
9145 "This makes backing out any changeset a <quote>one-shot</quote> operation "
9146 "that's usually simple and fast."
9147 msgstr ""
9149 #. type: Content of: <book><chapter><sect1><sect2><para>
9150 #: ../en/ch08-undo.xml:386
9151 msgid ""
9152 "If you take a look at the contents of <filename>myfile</filename> after the "
9153 "backout finishes, you'll see that the first and third changes are present, "
9154 "but not the second."
9155 msgstr ""
9157 #. type: Content of: <book><chapter><sect1><sect2><para>
9158 #: ../en/ch08-undo.xml:393
9159 msgid ""
9160 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
9161 "illustrates, Mercurial actually commits <emphasis>two</emphasis> changes in "
9162 "this kind of situation (the box-shaped nodes are the ones that Mercurial "
9163 "commits automatically). Before Mercurial begins the backout process, it "
9164 "first remembers what the current parent of the working directory is. It then "
9165 "backs out the target changeset, and commits that as a changeset. Finally, it "
9166 "merges back to the previous parent of the working directory, and commits the "
9167 "result of the merge."
9168 msgstr ""
9170 #. type: Content of: <book><chapter><sect1><sect2><para>
9171 #: ../en/ch08-undo.xml:404
9172 msgid ""
9173 "% TODO: to me it looks like mercurial doesn't commit the second merge "
9174 "automatically!"
9175 msgstr ""
9177 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9178 #: ../en/ch08-undo.xml:408
9179 msgid ""
9180 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
9181 "backout</command> command"
9182 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
9184 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9185 #: ../en/ch08-undo.xml:411
9186 msgid ""
9187 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
9188 msgstr ""
9190 #. type: Content of: <book><chapter><sect1><sect2><para>
9191 #: ../en/ch08-undo.xml:416
9192 msgid ""
9193 "The result is that you end up <quote>back where you were</quote>, only with "
9194 "some extra history that undoes the effect of the changeset you wanted to back "
9195 "out."
9196 msgstr ""
9198 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
9199 #: ../en/ch08-undo.xml:421
9200 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
9201 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
9203 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
9204 #: ../en/ch08-undo.xml:424
9205 msgid ""
9206 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
9207 "will do the <quote>right thing</quote> whether or not the changeset you're "
9208 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
9209 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
9210 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
9211 msgstr ""
9213 #. type: Content of: <book><chapter><sect1><sect2><title>
9214 #: ../en/ch08-undo.xml:435
9215 msgid "Gaining more control of the backout process"
9216 msgstr "在恢复处理中获得更多控制"
9218 #. type: Content of: <book><chapter><sect1><sect2><para>
9219 #: ../en/ch08-undo.xml:437
9220 msgid ""
9221 "While I've recommended that you always use the <option role=\"hg-opt-backout"
9222 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
9223 "cmd\">hg backout</command> command lets you decide how to merge a backout "
9224 "changeset. Taking control of the backout process by hand is something you "
9225 "will rarely need to do, but it can be useful to understand what the <command "
9226 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
9227 "To illustrate this, let's clone our first repository, but omit the backout "
9228 "change that it contains."
9229 msgstr ""
9231 #. type: Content of: <book><chapter><sect1><sect2><para>
9232 #: ../en/ch08-undo.xml:450
9233 msgid ""
9234 "As with our earlier example, We'll commit a third changeset, then back out "
9235 "its parent, and see what happens."
9236 msgstr ""
9238 #. type: Content of: <book><chapter><sect1><sect2><para>
9239 #: ../en/ch08-undo.xml:456
9240 msgid ""
9241 "Our new changeset is again a descendant of the changeset we backout out; it's "
9242 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
9243 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
9244 "quite explicit in telling us this."
9245 msgstr ""
9247 #. type: Content of: <book><chapter><sect1><sect2><para>
9248 #: ../en/ch08-undo.xml:464
9249 msgid ""
9250 "Again, it's easier to see what has happened by looking at a graph of the "
9251 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
9252 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
9253 "back out a change other than the tip, Mercurial adds a new head to the "
9254 "repository (the change it committed is box-shaped)."
9255 msgstr ""
9257 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9258 #: ../en/ch08-undo.xml:476
9259 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
9260 msgstr ""
9262 #. type: Content of: <book><chapter><sect1><sect2><para>
9263 #: ../en/ch08-undo.xml:481
9264 msgid ""
9265 "After the <command role=\"hg-cmd\">hg backout</command> command has "
9266 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
9267 "of the working directory."
9268 msgstr ""
9270 #. type: Content of: <book><chapter><sect1><sect2><para>
9271 #: ../en/ch08-undo.xml:488
9272 msgid "Now we have two isolated sets of changes."
9273 msgstr ""
9275 #. type: Content of: <book><chapter><sect1><sect2><para>
9276 #: ../en/ch08-undo.xml:492
9277 msgid ""
9278 "Let's think about what we expect to see as the contents of <filename>myfile</"
9279 "filename> now. The first change should be present, because we've never "
9280 "backed it out. The second change should be missing, as that's the change we "
9281 "backed out. Since the history graph shows the third change as a separate "
9282 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
9283 "<filename>myfile</filename>."
9284 msgstr ""
9286 #. type: Content of: <book><chapter><sect1><sect2><para>
9287 #: ../en/ch08-undo.xml:502
9288 msgid ""
9289 "To get the third change back into the file, we just do a normal merge of our "
9290 "two heads."
9291 msgstr ""
9293 #. type: Content of: <book><chapter><sect1><sect2><para>
9294 #: ../en/ch08-undo.xml:507
9295 msgid ""
9296 "Afterwards, the graphical history of our repository looks like <xref linkend="
9297 "\"fig:undo:backout-manual-merge\"/>."
9298 msgstr ""
9300 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
9301 #: ../en/ch08-undo.xml:512
9302 msgid "Manually merging a backout change"
9303 msgstr "手工合并恢复修改"
9305 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
9306 #: ../en/ch08-undo.xml:514
9307 msgid ""
9308 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
9309 msgstr ""
9311 #. type: Content of: <book><chapter><sect1><sect2><title>
9312 #: ../en/ch08-undo.xml:521
9313 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
9314 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
9316 #. type: Content of: <book><chapter><sect1><sect2><para>
9317 #: ../en/ch08-undo.xml:524
9318 msgid ""
9319 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
9320 "command> command works."
9321 msgstr ""
9323 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9324 #: ../en/ch08-undo.xml:527
9325 msgid ""
9326 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
9327 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
9328 msgstr ""
9330 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9331 #: ../en/ch08-undo.xml:531
9332 msgid ""
9333 "It remembers the current parent of the working directory. Let's call this "
9334 "changeset <literal>orig</literal>"
9335 msgstr ""
9337 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9338 #: ../en/ch08-undo.xml:535
9339 msgid ""
9340 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
9341 "sync the working directory to the changeset you want to back out. Let's call "
9342 "this changeset <literal>backout</literal>"
9343 msgstr ""
9345 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9346 #: ../en/ch08-undo.xml:540
9347 msgid ""
9348 "It finds the parent of that changeset. Let's call that changeset "
9349 "<literal>parent</literal>."
9350 msgstr ""
9352 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9353 #: ../en/ch08-undo.xml:543
9354 msgid ""
9355 "For each file that the <literal>backout</literal> changeset affected, it does "
9356 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
9357 "that file, to restore it to the contents it had before that changeset was "
9358 "committed."
9359 msgstr ""
9361 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9362 #: ../en/ch08-undo.xml:550
9363 msgid ""
9364 "It commits the result as a new changeset. This changeset has "
9365 "<literal>backout</literal> as its parent."
9366 msgstr ""
9368 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9369 #: ../en/ch08-undo.xml:554
9370 msgid ""
9371 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
9372 "command line, it merges with <literal>orig</literal>, and commits the result "
9373 "of the merge."
9374 msgstr ""
9376 #. type: Content of: <book><chapter><sect1><sect2><para>
9377 #: ../en/ch08-undo.xml:560
9378 msgid ""
9379 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
9380 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
9381 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
9382 "patch\">--reverse</option> option to the <command>patch</command> command to "
9383 "reverse the effect of the change without fiddling with the working "
9384 "directory. This sounds much simpler, but it would not work nearly as well."
9385 msgstr ""
9387 #. type: Content of: <book><chapter><sect1><sect2><para>
9388 #: ../en/ch08-undo.xml:570
9389 msgid ""
9390 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
9391 "a commit, a merge, and another commit is to give the merge machinery the best "
9392 "chance to do a good job when dealing with all the changes <emphasis>between</"
9393 "emphasis> the change you're backing out and the current tip."
9394 msgstr ""
9396 #. type: Content of: <book><chapter><sect1><sect2><para>
9397 #: ../en/ch08-undo.xml:577
9398 msgid ""
9399 "If you're backing out a changeset that's 100 revisions back in your project's "
9400 "history, the chances that the <command>patch</command> command will be able "
9401 "to apply a reverse diff cleanly are not good, because intervening changes are "
9402 "likely to have <quote>broken the context</quote> that <command>patch</"
9403 "command> uses to determine whether it can apply a patch (if this sounds like "
9404 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
9405 "<command>patch</command> command). Also, Mercurial's merge machinery will "
9406 "handle files and directories being renamed, permission changes, and "
9407 "modifications to binary files, none of which <command>patch</command> can "
9408 "deal with."
9409 msgstr ""
9411 #. type: Content of: <book><chapter><sect1><title>
9412 #: ../en/ch08-undo.xml:594
9413 msgid "Changes that should never have been"
9414 msgstr "不该发生的修改"
9416 #. type: Content of: <book><chapter><sect1><para>
9417 #: ../en/ch08-undo.xml:596
9418 msgid ""
9419 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
9420 "is exactly what you need if you want to undo the effects of a change. It "
9421 "leaves a permanent record of exactly what you did, both when committing the "
9422 "original changeset and when you cleaned up after it."
9423 msgstr ""
9425 #. type: Content of: <book><chapter><sect1><para>
9426 #: ../en/ch08-undo.xml:602
9427 msgid ""
9428 "On rare occasions, though, you may find that you've committed a change that "
9429 "really should not be present in the repository at all. For example, it would "
9430 "be very unusual, and usually considered a mistake, to commit a software "
9431 "project's object files as well as its source files. Object files have almost "
9432 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
9433 "the size of the repository and the amount of time it takes to clone or pull "
9434 "changes."
9435 msgstr ""
9437 #. type: Content of: <book><chapter><sect1><para>
9438 #: ../en/ch08-undo.xml:611
9439 msgid ""
9440 "Before I discuss the options that you have if you commit a <quote>brown paper "
9441 "bag</quote> change (the kind that's so bad that you want to pull a brown "
9442 "paper bag over your head), let me first discuss some approaches that probably "
9443 "won't work."
9444 msgstr ""
9446 #. type: Content of: <book><chapter><sect1><para>
9447 #: ../en/ch08-undo.xml:616
9448 msgid ""
9449 "Since Mercurial treats history as accumulative&emdash;every change builds on "
9450 "top of all changes that preceded it&emdash;you generally can't just make "
9451 "disastrous changes disappear. The one exception is when you've just "
9452 "committed a change, and it hasn't been pushed or pulled into another "
9453 "repository. That's when you can safely use the <command role=\"hg-cmd\">hg "
9454 "rollback</command> command, as I detailed in <xref linkend=\"sec:undo:rollback"
9455 "\"/>."
9456 msgstr ""
9458 #. type: Content of: <book><chapter><sect1><para>
9459 #: ../en/ch08-undo.xml:625
9460 msgid ""
9461 "After you've pushed a bad change to another repository, you <emphasis>could</"
9462 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
9463 "your local copy of the change disappear, but it won't have the consequences "
9464 "you want. The change will still be present in the remote repository, so it "
9465 "will reappear in your local repository the next time you pull."
9466 msgstr ""
9468 #. type: Content of: <book><chapter><sect1><para>
9469 #: ../en/ch08-undo.xml:633
9470 msgid ""
9471 "If a situation like this arises, and you know which repositories your bad "
9472 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
9473 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
9474 "is, of course, not a satisfactory solution: if you miss even a single "
9475 "repository while you're expunging, the change is still <quote>in the wild</"
9476 "quote>, and could propagate further."
9477 msgstr ""
9479 #. type: Content of: <book><chapter><sect1><para>
9480 #: ../en/ch08-undo.xml:641
9481 msgid ""
9482 "If you've committed one or more changes <emphasis>after</emphasis> the change "
9483 "that you'd like to see disappear, your options are further reduced. Mercurial "
9484 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
9485 "changesets intact."
9486 msgstr ""
9488 #. type: Content of: <book><chapter><sect1><para>
9489 #: ../en/ch08-undo.xml:647
9490 msgid ""
9491 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
9492 "<literal>examples</literal> directory works, but doesn't handle merge "
9493 "changesets. Kind of an important omission."
9494 msgstr ""
9496 #. type: Content of: <book><chapter><sect1><sect2><title>
9497 #: ../en/ch08-undo.xml:653
9498 msgid "Protect yourself from <quote>escaped</quote> changes"
9499 msgstr "使用<quote>校验</quote>修改来保护你自己"
9501 #. type: Content of: <book><chapter><sect1><sect2><para>
9502 #: ../en/ch08-undo.xml:656
9503 msgid ""
9504 "If you've committed some changes to your local repository and they've been "
9505 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
9506 "protect yourself ahead of time against some classes of bad changeset. This "
9507 "is particularly easy if your team usually pulls changes from a central "
9508 "repository."
9509 msgstr ""
9511 #. type: Content of: <book><chapter><sect1><sect2><para>
9512 #: ../en/ch08-undo.xml:663
9513 msgid ""
9514 "By configuring some hooks on that repository to validate incoming changesets "
9515 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
9516 "some kinds of bad changeset from being pushed to the central repository at "
9517 "all. With such a configuration in place, some kinds of bad changeset will "
9518 "naturally tend to <quote>die out</quote> because they can't propagate into "
9519 "the central repository. Better yet, this happens without any need for "
9520 "explicit intervention."
9521 msgstr ""
9523 #. type: Content of: <book><chapter><sect1><sect2><para>
9524 #: ../en/ch08-undo.xml:673
9525 msgid ""
9526 "For instance, an incoming change hook that verifies that a changeset will "
9527 "actually compile can prevent people from inadvertantly <quote>breaking the "
9528 "build</quote>."
9529 msgstr ""
9531 #. type: Content of: <book><chapter><sect1><title>
9532 #: ../en/ch08-undo.xml:680
9533 msgid "Finding the source of a bug"
9534 msgstr "查找问题的根源"
9536 #. type: Content of: <book><chapter><sect1><para>
9537 #: ../en/ch08-undo.xml:682
9538 msgid ""
9539 "While it's all very well to be able to back out a changeset that introduced a "
9540 "bug, this requires that you know which changeset to back out. Mercurial "
9541 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
9542 "command>, that helps you to automate this process and accomplish it very "
9543 "efficiently."
9544 msgstr ""
9546 #. type: Content of: <book><chapter><sect1><para>
9547 #: ../en/ch08-undo.xml:689
9548 msgid ""
9549 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
9550 "that a changeset has introduced some change of behaviour that you can "
9551 "identify with a simple binary test. You don't know which piece of code "
9552 "introduced the change, but you know how to test for the presence of the bug. "
9553 "The <command role=\"hg-cmd\">hg bisect</command> command uses your test to "
9554 "direct its search for the changeset that introduced the code that caused the "
9555 "bug."
9556 msgstr ""
9558 #. type: Content of: <book><chapter><sect1><para>
9559 #: ../en/ch08-undo.xml:698
9560 msgid ""
9561 "Here are a few scenarios to help you understand how you might apply this "
9562 "command."
9563 msgstr ""
9565 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9566 #: ../en/ch08-undo.xml:701
9567 msgid ""
9568 "The most recent version of your software has a bug that you remember wasn't "
9569 "present a few weeks ago, but you don't know when it was introduced. Here, "
9570 "your binary test checks for the presence of that bug."
9571 msgstr ""
9573 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9574 #: ../en/ch08-undo.xml:706
9575 msgid ""
9576 "You fixed a bug in a rush, and now it's time to close the entry in your "
9577 "team's bug database. The bug database requires a changeset ID when you close "
9578 "an entry, but you don't remember which changeset you fixed the bug in. Once "
9579 "again, your binary test checks for the presence of the bug."
9580 msgstr ""
9582 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9583 #: ../en/ch08-undo.xml:713
9584 msgid ""
9585 "Your software works correctly, but runs 15% slower than the last time you "
9586 "measured it. You want to know which changeset introduced the performance "
9587 "regression. In this case, your binary test measures the performance of your "
9588 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
9589 msgstr ""
9591 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
9592 #: ../en/ch08-undo.xml:720
9593 msgid ""
9594 "The sizes of the components of your project that you ship exploded recently, "
9595 "and you suspect that something changed in the way you build your project."
9596 msgstr ""
9598 #. type: Content of: <book><chapter><sect1><para>
9599 #: ../en/ch08-undo.xml:725
9600 msgid ""
9601 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
9602 "bisect</command> command is not useful only for finding the sources of bugs. "
9603 "You can use it to find any <quote>emergent property</quote> of a repository "
9604 "(anything that you can't find from a simple text search of the files in the "
9605 "tree) for which you can write a binary test."
9606 msgstr ""
9608 #. type: Content of: <book><chapter><sect1><para>
9609 #: ../en/ch08-undo.xml:732
9610 msgid ""
9611 "We'll introduce a little bit of terminology here, just to make it clear which "
9612 "parts of the search process are your responsibility, and which are "
9613 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
9614 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
9615 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
9616 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
9617 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
9618 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
9619 "command> command</quote>."
9620 msgstr ""
9622 #. type: Content of: <book><chapter><sect1><para>
9623 #: ../en/ch08-undo.xml:745
9624 msgid ""
9625 "One simple way to automate the searching process would be simply to probe "
9626 "every changeset. However, this scales poorly. If it took ten minutes to "
9627 "test a single changeset, and you had 10,000 changesets in your repository, "
9628 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
9629 "find the changeset that introduced a bug. Even if you knew that the bug was "
9630 "introduced by one of the last 500 changesets, and limited your search to "
9631 "those, you'd still be looking at over 40 hours to find the changeset that "
9632 "introduced your bug."
9633 msgstr ""
9635 #. type: Content of: <book><chapter><sect1><para>
9636 #: ../en/ch08-undo.xml:755
9637 msgid ""
9638 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
9639 "knowledge of the <quote>shape</quote> of your project's revision history to "
9640 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
9641 "of the number of changesets to check (the kind of search it performs is "
9642 "called a dichotomic search). With this approach, searching through 10,000 "
9643 "changesets will take less than three hours, even at ten minutes per test (the "
9644 "search will require about 14 tests). Limit your search to the last hundred "
9645 "changesets, and it will take only about an hour (roughly seven tests)."
9646 msgstr ""
9648 #. type: Content of: <book><chapter><sect1><para>
9649 #: ../en/ch08-undo.xml:766
9650 msgid ""
9651 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
9652 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
9653 "it has no problems dealing with branches, merges, or multiple heads in a "
9654 "repository. It can prune entire branches of history with a single probe, "
9655 "which is how it operates so efficiently."
9656 msgstr ""
9658 #. type: Content of: <book><chapter><sect1><sect2><title>
9659 #: ../en/ch08-undo.xml:774
9660 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
9661 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
9663 #. type: Content of: <book><chapter><sect1><sect2><para>
9664 #: ../en/ch08-undo.xml:777
9665 msgid ""
9666 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
9667 msgstr ""
9669 #. type: Content of: <book><chapter><sect1><sect2><note><para>
9670 #: ../en/ch08-undo.xml:781
9671 msgid ""
9672 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
9673 "bisect</command> was not a core command: it was distributed with Mercurial as "
9674 "an extension. This section describes the built-in command, not the old "
9675 "extension."
9676 msgstr ""
9678 #. type: Content of: <book><chapter><sect1><sect2><para>
9679 #: ../en/ch08-undo.xml:788
9680 msgid ""
9681 "Now let's create a repository, so that we can try out the <command role=\"hg-"
9682 "cmd\">hg bisect</command> command in isolation."
9683 msgstr ""
9685 #. type: Content of: <book><chapter><sect1><sect2><para>
9686 #: ../en/ch08-undo.xml:794
9687 msgid ""
9688 "We'll simulate a project that has a bug in it in a simple-minded way: create "
9689 "trivial changes in a loop, and nominate one specific change that will have "
9690 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
9691 "single file to the repository. We'll represent our <quote>bug</quote> with a "
9692 "file that contains the text <quote>i have a gub</quote>."
9693 msgstr ""
9695 #. type: Content of: <book><chapter><sect1><sect2><para>
9696 #: ../en/ch08-undo.xml:804
9697 msgid ""
9698 "The next thing that we'd like to do is figure out how to use the <command "
9699 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
9700 "built-in help mechanism for this."
9701 msgstr ""
9703 #. type: Content of: <book><chapter><sect1><sect2><para>
9704 #: ../en/ch08-undo.xml:811
9705 msgid ""
9706 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
9707 "Each step proceeds as follows."
9708 msgstr ""
9710 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9711 #: ../en/ch08-undo.xml:814
9712 msgid "You run your binary test."
9713 msgstr ""
9715 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
9716 #: ../en/ch08-undo.xml:816
9717 msgid ""
9718 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
9719 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
9720 msgstr ""
9722 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
9723 #: ../en/ch08-undo.xml:821
9724 msgid ""
9725 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
9726 "command."
9727 msgstr ""
9729 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9730 #: ../en/ch08-undo.xml:825
9731 msgid ""
9732 "The command uses your information to decide which changeset to test next."
9733 msgstr ""
9735 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
9736 #: ../en/ch08-undo.xml:828
9737 msgid ""
9738 "It updates the working directory to that changeset, and the process begins "
9739 "again."
9740 msgstr ""
9742 #. type: Content of: <book><chapter><sect1><sect2><para>
9743 #: ../en/ch08-undo.xml:831
9744 msgid ""
9745 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
9746 "a unique changeset that marks the point where your test transitioned from "
9747 "<quote>succeeding</quote> to <quote>failing</quote>."
9748 msgstr ""
9751 #. type: Content of: <book><chapter><sect1><sect2><para>
9752 #: ../en/ch08-undo.xml:836
9753 msgid ""
9754 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
9755 "reset</command> command."
9756 msgstr ""
9758 #. type: Content of: <book><chapter><sect1><sect2><para>
9759 #: ../en/ch08-undo.xml:841
9760 msgid ""
9761 "In our case, the binary test we use is simple: we check to see if any file in "
9762 "the repository contains the string <quote>i have a gub</quote>. If it does, "
9763 "this changeset contains the change that <quote>caused the bug</quote>. By "
9764 "convention, a changeset that has the property we're searching for is "
9765 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
9766 msgstr ""
9768 #. type: Content of: <book><chapter><sect1><sect2><para>
9769 #: ../en/ch08-undo.xml:849
9770 msgid ""
9771 "Most of the time, the revision to which the working directory is synced "
9772 "(usually the tip) already exhibits the problem introduced by the buggy "
9773 "change, so we'll mark it as <quote>bad</quote>."
9774 msgstr ""
9777 #. type: Content of: <book><chapter><sect1><sect2><para>
9778 #: ../en/ch08-undo.xml:856
9779 msgid ""
9780 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
9781 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
9782 "command will <quote>bracket</quote> its search between the first pair of good "
9783 "and bad changesets. In our case, we know that revision 10 didn't have the "
9784 "bug. (I'll have more words about choosing the first <quote>good</quote> "
9785 "changeset later.)"
9786 msgstr ""
9788 #. type: Content of: <book><chapter><sect1><sect2><para>
9789 #: ../en/ch08-undo.xml:866
9790 msgid "Notice that this command printed some output."
9791 msgstr ""
9793 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9794 #: ../en/ch08-undo.xml:868
9795 msgid ""
9796 "It told us how many changesets it must consider before it can identify the "
9797 "one that introduced the bug, and how many tests that will require."
9798 msgstr ""
9800 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9801 #: ../en/ch08-undo.xml:872
9802 msgid ""
9803 "It updated the working directory to the next changeset to test, and told us "
9804 "which changeset it's testing."
9805 msgstr ""
9807 #. type: Content of: <book><chapter><sect1><sect2><para>
9808 #: ../en/ch08-undo.xml:877
9809 msgid ""
9810 "We now run our test in the working directory. We use the <command>grep</"
9811 "command> command to see if our <quote>bad</quote> file is present in the "
9812 "working directory. If it is, this revision is bad; if not, this revision is "
9813 "good. &interaction.bisect.search.step1;"
9814 msgstr ""
9816 #. type: Content of: <book><chapter><sect1><sect2><para>
9817 #: ../en/ch08-undo.xml:883
9818 msgid ""
9819 "This test looks like a perfect candidate for automation, so let's turn it "
9820 "into a shell function."
9821 msgstr ""
9823 #. type: Content of: <book><chapter><sect1><sect2><para>
9824 #: ../en/ch08-undo.xml:887
9825 msgid ""
9826 "We can now run an entire test step with a single command, <literal>mytest</"
9827 "literal>."
9828 msgstr ""
9830 #. type: Content of: <book><chapter><sect1><sect2><para>
9831 #: ../en/ch08-undo.xml:892
9832 msgid "A few more invocations of our canned test step command, and we're done."
9833 msgstr ""
9835 #. type: Content of: <book><chapter><sect1><sect2><para>
9836 #: ../en/ch08-undo.xml:897
9837 msgid ""
9838 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
9839 "\">hg bisect</command> command let us find the changeset that introduced our "
9840 "<quote>bug</quote> with only five tests. Because the number of tests that "
9841 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
9842 "logarithmically with the number of changesets to search, the advantage that "
9843 "it has over the <quote>brute force</quote> search approach increases with "
9844 "every changeset you add."
9845 msgstr ""
9847 #. type: Content of: <book><chapter><sect1><sect2><title>
9848 #: ../en/ch08-undo.xml:908
9849 msgid "Cleaning up after your search"
9850 msgstr "搜索后的清理"
9853 #. type: Content of: <book><chapter><sect1><sect2><para>
9854 #: ../en/ch08-undo.xml:910
9855 msgid ""
9856 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
9857 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
9858 "reset</command> command to drop the information it was using to drive your "
9859 "search. The command doesn't use much space, so it doesn't matter if you "
9860 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
9861 "command> won't let you start a new search in that repository until you do a "
9862 "<command role=\"hg-cmd\">hg bisect reset</command>."
9863 msgstr ""
9865 #. type: Content of: <book><chapter><sect1><title>
9866 #: ../en/ch08-undo.xml:925
9867 msgid "Tips for finding bugs effectively"
9868 msgstr "有效查找问题的技巧"
9870 #. type: Content of: <book><chapter><sect1><sect2><title>
9871 #: ../en/ch08-undo.xml:928
9872 msgid "Give consistent input"
9873 msgstr "给出一致的输入"
9875 #. type: Content of: <book><chapter><sect1><sect2><para>
9876 #: ../en/ch08-undo.xml:930
9877 msgid ""
9878 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
9879 "correctly report the result of every test you perform. If you tell it that a "
9880 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
9881 "to detect the inconsistency. If it can identify an inconsistency in your "
9882 "reports, it will tell you that a particular changeset is both good and bad. "
9883 "However, it can't do this perfectly; it's about as likely to report the wrong "
9884 "changeset as the source of the bug."
9885 msgstr ""
9887 #. type: Content of: <book><chapter><sect1><sect2><title>
9888 #: ../en/ch08-undo.xml:942
9889 msgid "Automate as much as possible"
9890 msgstr "尽量自动"
9892 #. type: Content of: <book><chapter><sect1><sect2><para>
9893 #: ../en/ch08-undo.xml:944
9894 msgid ""
9895 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
9896 "command, I tried a few times to run my tests by hand, on the command line. "
9897 "This is an approach that I, at least, am not suited to. After a few tries, I "
9898 "found that I was making enough mistakes that I was having to restart my "
9899 "searches several times before finally getting correct results."
9900 msgstr ""
9902 #. type: Content of: <book><chapter><sect1><sect2><para>
9903 #: ../en/ch08-undo.xml:952
9904 msgid ""
9905 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
9906 "command> command by hand occurred even with simple searches on small "
9907 "repositories; if the problem you're looking for is more subtle, or the number "
9908 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
9909 "increases, the likelihood of operator error ruining the search is much "
9910 "higher. Once I started automating my tests, I had much better results."
9911 msgstr ""
9913 #. type: Content of: <book><chapter><sect1><sect2><para>
9914 #: ../en/ch08-undo.xml:961
9915 msgid "The key to automated testing is twofold:"
9916 msgstr ""
9918 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9919 #: ../en/ch08-undo.xml:963
9920 msgid "always test for the same symptom, and"
9921 msgstr ""
9923 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9924 #: ../en/ch08-undo.xml:965
9925 msgid ""
9926 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
9927 "command> command."
9928 msgstr ""
9930 #. type: Content of: <book><chapter><sect1><sect2><para>
9931 #: ../en/ch08-undo.xml:968
9932 msgid ""
9933 "In my tutorial example above, the <command>grep</command> command tests for "
9934 "the symptom, and the <literal>if</literal> statement takes the result of this "
9935 "check and ensures that we always feed the same input to the <command role="
9936 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
9937 "function marries these together in a reproducible way, so that every test is "
9938 "uniform and consistent."
9939 msgstr ""
9941 #. type: Content of: <book><chapter><sect1><sect2><title>
9942 #: ../en/ch08-undo.xml:978
9943 msgid "Check your results"
9944 msgstr "检查你的结果"
9946 #. type: Content of: <book><chapter><sect1><sect2><para>
9947 #: ../en/ch08-undo.xml:980
9948 msgid ""
9949 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
9950 "is only as good as the input you give it, don't take the changeset it reports "
9951 "as the absolute truth. A simple way to cross-check its report is to manually "
9952 "run your test at each of the following changesets:"
9953 msgstr ""
9955 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9956 #: ../en/ch08-undo.xml:986
9957 msgid ""
9958 "The changeset that it reports as the first bad revision. Your test should "
9959 "still report this as bad."
9960 msgstr ""
9962 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9963 #: ../en/ch08-undo.xml:990
9964 msgid ""
9965 "The parent of that changeset (either parent, if it's a merge). Your test "
9966 "should report this changeset as good."
9967 msgstr ""
9969 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
9970 #: ../en/ch08-undo.xml:994
9971 msgid ""
9972 "A child of that changeset. Your test should report this changeset as bad."
9973 msgstr ""
9975 #. type: Content of: <book><chapter><sect1><sect2><title>
9976 #: ../en/ch08-undo.xml:1000
9977 msgid "Beware interference between bugs"
9978 msgstr "谨防问题之间的冲突"
9980 #. type: Content of: <book><chapter><sect1><sect2><para>
9981 #: ../en/ch08-undo.xml:1002
9982 msgid ""
9983 "It's possible that your search for one bug could be disrupted by the presence "
9984 "of another. For example, let's say your software crashes at revision 100, "
9985 "and worked correctly at revision 50. Unknown to you, someone else introduced "
9986 "a different crashing bug at revision 60, and fixed it at revision 80. This "
9987 "could distort your results in one of several ways."
9988 msgstr ""
9990 #. type: Content of: <book><chapter><sect1><sect2><para>
9991 #: ../en/ch08-undo.xml:1010
9992 msgid ""
9993 "It is possible that this other bug completely <quote>masks</quote> yours, "
9994 "which is to say that it occurs before your bug has a chance to manifest "
9995 "itself. If you can't avoid that other bug (for example, it prevents your "
9996 "project from building), and so can't tell whether your bug is present in a "
9997 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
9998 "command cannot help you directly. Instead, you can mark a changeset as "
9999 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
10000 msgstr ""
10002 #. type: Content of: <book><chapter><sect1><sect2><para>
10003 #: ../en/ch08-undo.xml:1020
10004 msgid ""
10005 "A different problem could arise if your test for a bug's presence is not "
10006 "specific enough. If you check for <quote>my program crashes</quote>, then "
10007 "both your crashing bug and an unrelated crashing bug that masks it will look "
10008 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
10009 msgstr ""
10011 #. type: Content of: <book><chapter><sect1><sect2><para>
10012 #: ../en/ch08-undo.xml:1027
10013 msgid ""
10014 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
10015 "skip</command> is if you can't test a revision because your project was in a "
10016 "broken and hence untestable state at that revision, perhaps because someone "
10017 "checked in a change that prevented the project from building."
10018 msgstr ""
10020 #. type: Content of: <book><chapter><sect1><sect2><title>
10021 #: ../en/ch08-undo.xml:1036
10022 msgid "Bracket your search lazily"
10023 msgstr "减少你的查找工作"
10025 #. type: Content of: <book><chapter><sect1><sect2><para>
10026 #: ../en/ch08-undo.xml:1038
10027 msgid ""
10028 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
10029 "will mark the end points of your search is often easy, but it bears a little "
10030 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
10031 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
10032 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
10033 msgstr ""
10035 #. type: Content of: <book><chapter><sect1><sect2><para>
10036 #: ../en/ch08-undo.xml:1046
10037 msgid ""
10038 "If you're having trouble remembering when a suitable <quote>good</quote> "
10039 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
10040 "command>, you could do worse than testing changesets at random. Just "
10041 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
10042 "because the feature with the bug isn't present yet) and those where another "
10043 "problem masks the bug (as I discussed above)."
10044 msgstr ""
10046 #. type: Content of: <book><chapter><sect1><sect2><para>
10047 #: ../en/ch08-undo.xml:1055
10048 msgid ""
10049 "Even if you end up <quote>early</quote> by thousands of changesets or months "
10050 "of history, you will only add a handful of tests to the total number that "
10051 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
10052 "logarithmic behaviour."
10053 msgstr ""
10055 #. type: Content of: <book><chapter><title>
10056 #: ../en/ch09-hook.xml:5
10057 msgid "Handling repository events with hooks"
10058 msgstr "使用钩子处理版本库事件"
10060 #. type: Content of: <book><chapter><para>
10061 #: ../en/ch09-hook.xml:7
10062 msgid ""
10063 "Mercurial offers a powerful mechanism to let you perform automated actions in "
10064 "response to events that occur in a repository. In some cases, you can even "
10065 "control Mercurial's response to those events."
10066 msgstr ""
10068 #. type: Content of: <book><chapter><para>
10069 #: ../en/ch09-hook.xml:12
10070 msgid ""
10071 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
10072 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
10073 "systems, but the two names refer to the same idea."
10074 msgstr ""
10076 #. type: Content of: <book><chapter><sect1><title>
10077 #: ../en/ch09-hook.xml:18
10078 msgid "An overview of hooks in Mercurial"
10079 msgstr "Mercurial 钩子概述"
10081 #. type: Content of: <book><chapter><sect1><para>
10082 #: ../en/ch09-hook.xml:20
10083 msgid ""
10084 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
10085 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
10086 msgstr ""
10088 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10089 #: ../en/ch09-hook.xml:25
10090 msgid ""
10091 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
10092 "changesets has been brought into the repository from elsewhere."
10093 msgstr ""
10095 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10096 #: ../en/ch09-hook.xml:29
10097 msgid ""
10098 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
10099 "has been created in the local repository."
10100 msgstr ""
10102 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10103 #: ../en/ch09-hook.xml:33
10104 msgid ""
10105 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
10106 "changeset that is brought into the repository from elsewhere. Notice the "
10107 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
10108 "once per <emphasis>group</emphasis> of changesets brought in."
10109 msgstr ""
10111 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10112 #: ../en/ch09-hook.xml:40
10113 msgid ""
10114 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
10115 "changesets has been transmitted from this repository."
10116 msgstr ""
10118 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10119 #: ../en/ch09-hook.xml:44
10120 msgid ""
10121 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
10122 "to bring a group of changesets into the repository."
10123 msgstr ""
10125 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10126 #: ../en/ch09-hook.xml:49
10127 msgid ""
10128 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
10129 "starting a commit."
10130 msgstr ""
10132 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10133 #: ../en/ch09-hook.xml:53
10134 msgid ""
10135 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
10136 "starting to transmit a group of changesets from this repository."
10137 msgstr ""
10139 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10140 #: ../en/ch09-hook.xml:58
10141 msgid ""
10142 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
10143 "creating a tag."
10144 msgstr ""
10146 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10147 #: ../en/ch09-hook.xml:62
10148 msgid ""
10149 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
10150 "after a group of changesets has been brought into the local repository from "
10151 "another, but before the transaction completes that will make the changes "
10152 "permanent in the repository."
10153 msgstr ""
10155 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10156 #: ../en/ch09-hook.xml:70
10157 msgid ""
10158 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
10159 "a new changeset has been created in the local repository, but before the "
10160 "transaction completes that will make it permanent."
10161 msgstr ""
10163 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10164 #: ../en/ch09-hook.xml:76
10165 msgid ""
10166 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
10167 "starting an update or merge of the working directory."
10168 msgstr ""
10170 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10171 #: ../en/ch09-hook.xml:81
10172 msgid ""
10173 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
10174 msgstr ""
10176 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
10177 #: ../en/ch09-hook.xml:85
10178 msgid ""
10179 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
10180 "of the working directory has finished."
10181 msgstr ""
10183 #. type: Content of: <book><chapter><sect1><para>
10184 #: ../en/ch09-hook.xml:90
10185 msgid ""
10186 "Each of the hooks whose description begins with the word <quote>Controlling</"
10187 "quote> has the ability to determine whether an activity can proceed. If the "
10188 "hook succeeds, the activity may proceed; if it fails, the activity is either "
10189 "not permitted or undone, depending on the hook."
10190 msgstr ""
10192 #. type: Content of: <book><chapter><sect1><title>
10193 #: ../en/ch09-hook.xml:99
10194 msgid "Hooks and security"
10195 msgstr "钩子与安全性"
10197 #. type: Content of: <book><chapter><sect1><sect2><title>
10198 #: ../en/ch09-hook.xml:102
10199 msgid "Hooks are run with your privileges"
10200 msgstr "钩子以你的特权执行"
10202 #. type: Content of: <book><chapter><sect1><sect2><para>
10203 #: ../en/ch09-hook.xml:104
10204 msgid ""
10205 "When you run a Mercurial command in a repository, and the command causes a "
10206 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
10207 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
10208 "privilege level. Since hooks are arbitrary pieces of executable code, you "
10209 "should treat them with an appropriate level of suspicion. Do not install a "
10210 "hook unless you are confident that you know who created it and what it does."
10211 msgstr ""
10213 #. type: Content of: <book><chapter><sect1><sect2><para>
10214 #: ../en/ch09-hook.xml:115
10215 msgid ""
10216 "In some cases, you may be exposed to hooks that you did not install "
10217 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
10218 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
10219 "filename> file."
10220 msgstr ""
10222 #. type: Content of: <book><chapter><sect1><sect2><para>
10223 #: ../en/ch09-hook.xml:122
10224 msgid ""
10225 "If you are working with a repository owned by another user, Mercurial can run "
10226 "hooks defined in that user's repository, but it will still run them as "
10227 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
10228 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
10229 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
10230 "that hook will run under your user account, even though you don't own that "
10231 "repository."
10232 msgstr ""
10234 #. type: Content of: <book><chapter><sect1><sect2><note><para>
10235 #: ../en/ch09-hook.xml:134
10236 msgid ""
10237 "This only applies if you are pulling from a repository on a local or network "
10238 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
10239 "\">outgoing</literal> hook will run under whatever account is executing the "
10240 "server process, on the server."
10241 msgstr ""
10243 #. type: Content of: <book><chapter><sect1><sect2><para>
10244 #: ../en/ch09-hook.xml:142
10245 msgid ""
10246 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
10247 "cmd\">hg config hooks</command> command. If you are working in one "
10248 "repository, but talking to another that you do not own (e.g. using <command "
10249 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
10250 "command>), remember that it is the other repository's hooks you should be "
10251 "checking, not your own."
10252 msgstr ""
10254 #. type: Content of: <book><chapter><sect1><sect2><title>
10255 #: ../en/ch09-hook.xml:153
10256 msgid "Hooks do not propagate"
10257 msgstr "钩子不会传播"
10259 #. type: Content of: <book><chapter><sect1><sect2><para>
10260 #: ../en/ch09-hook.xml:155
10261 msgid ""
10262 "In Mercurial, hooks are not revision controlled, and do not propagate when "
10263 "you clone, or pull from, a repository. The reason for this is simple: a hook "
10264 "is a completely arbitrary piece of executable code. It runs under your user "
10265 "identity, with your privilege level, on your machine."
10266 msgstr ""
10268 #. type: Content of: <book><chapter><sect1><sect2><para>
10269 #: ../en/ch09-hook.xml:162
10270 msgid ""
10271 "It would be extremely reckless for any distributed revision control system to "
10272 "implement revision-controlled hooks, as this would offer an easily "
10273 "exploitable way to subvert the accounts of users of the revision control "
10274 "system."
10275 msgstr ""
10277 #. type: Content of: <book><chapter><sect1><sect2><para>
10278 #: ../en/ch09-hook.xml:168
10279 msgid ""
10280 "Since Mercurial does not propagate hooks, if you are collaborating with other "
10281 "people on a common project, you should not assume that they are using the "
10282 "same Mercurial hooks as you are, or that theirs are correctly configured. "
10283 "You should document the hooks you expect people to use."
10284 msgstr ""
10286 #. type: Content of: <book><chapter><sect1><sect2><para>
10287 #: ../en/ch09-hook.xml:175
10288 msgid ""
10289 "In a corporate intranet, this is somewhat easier to control, as you can for "
10290 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
10291 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
10292 "file to define hooks that all users will see. However, this too has its "
10293 "limits; see below."
10294 msgstr ""
10296 #. type: Content of: <book><chapter><sect1><sect2><title>
10297 #: ../en/ch09-hook.xml:184
10298 msgid "Hooks can be overridden"
10299 msgstr "钩子可以被覆盖"
10301 #. type: Content of: <book><chapter><sect1><sect2><para>
10302 #: ../en/ch09-hook.xml:186
10303 msgid ""
10304 "Mercurial allows you to override a hook definition by redefining the hook. "
10305 "You can disable it by setting its value to the empty string, or change its "
10306 "behaviour as you wish."
10307 msgstr ""
10309 #. type: Content of: <book><chapter><sect1><sect2><para>
10310 #: ../en/ch09-hook.xml:191
10311 msgid ""
10312 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
10313 "filename> file that defines some hooks, you should thus understand that your "
10314 "users can disable or override those hooks."
10315 msgstr ""
10317 #. type: Content of: <book><chapter><sect1><sect2><title>
10318 #: ../en/ch09-hook.xml:199
10319 msgid "Ensuring that critical hooks are run"
10320 msgstr "确保关键钩子的执行"
10322 #. type: Content of: <book><chapter><sect1><sect2><para>
10323 #: ../en/ch09-hook.xml:201
10324 msgid ""
10325 "Sometimes you may want to enforce a policy that you do not want others to be "
10326 "able to work around. For example, you may have a requirement that every "
10327 "changeset must pass a rigorous set of tests. Defining this requirement via a "
10328 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
10329 "for remote users on laptops, and of course local users can subvert it at will "
10330 "by overriding the hook."
10331 msgstr ""
10333 #. type: Content of: <book><chapter><sect1><sect2><para>
10334 #: ../en/ch09-hook.xml:210
10335 msgid ""
10336 "Instead, you can set up your policies for use of Mercurial so that people are "
10337 "expected to propagate changes through a well-known <quote>canonical</quote> "
10338 "server that you have locked down and configured appropriately."
10339 msgstr ""
10341 #. type: Content of: <book><chapter><sect1><sect2><para>
10342 #: ../en/ch09-hook.xml:216
10343 msgid ""
10344 "One way to do this is via a combination of social engineering and "
10345 "technology. Set up a restricted-access account; users can push changes over "
10346 "the network to repositories managed by this account, but they cannot log into "
10347 "the account and run normal shell commands. In this scenario, a user can "
10348 "commit a changeset that contains any old garbage they want."
10349 msgstr ""
10351 #. type: Content of: <book><chapter><sect1><sect2><para>
10352 #: ../en/ch09-hook.xml:225
10353 msgid ""
10354 "When someone pushes a changeset to the server that everyone pulls from, the "
10355 "server will test the changeset before it accepts it as permanent, and reject "
10356 "it if it fails to pass the test suite. If people only pull changes from this "
10357 "filtering server, it will serve to ensure that all changes that people pull "
10358 "have been automatically vetted."
10359 msgstr ""
10361 #. type: Content of: <book><chapter><sect1><title>
10362 #: ../en/ch09-hook.xml:236
10363 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
10364 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
10366 #. type: Content of: <book><chapter><sect1><para>
10367 #: ../en/ch09-hook.xml:239
10368 msgid ""
10369 "If you want to use hooks to do some automated work in a repository that a "
10370 "number of people have shared access to, you need to be careful in how you do "
10371 "this."
10372 msgstr ""
10374 #. type: Content of: <book><chapter><sect1><para>
10375 #: ../en/ch09-hook.xml:244
10376 msgid ""
10377 "Mercurial only locks a repository when it is writing to the repository, and "
10378 "only the parts of Mercurial that write to the repository pay attention to "
10379 "locks. Write locks are necessary to prevent multiple simultaneous writers "
10380 "from scribbling on each other's work, corrupting the repository."
10381 msgstr ""
10383 #. type: Content of: <book><chapter><sect1><para>
10384 #: ../en/ch09-hook.xml:251
10385 msgid ""
10386 "Because Mercurial is careful with the order in which it reads and writes "
10387 "data, it does not need to acquire a lock when it wants to read data from the "
10388 "repository. The parts of Mercurial that read from the repository never pay "
10389 "attention to locks. This lockless reading scheme greatly increases "
10390 "performance and concurrency."
10391 msgstr ""
10393 #. type: Content of: <book><chapter><sect1><para>
10394 #: ../en/ch09-hook.xml:259
10395 msgid ""
10396 "With great performance comes a trade-off, though, one which has the potential "
10397 "to cause you trouble unless you're aware of it. To describe this requires a "
10398 "little detail about how Mercurial adds changesets to a repository and reads "
10399 "those changes."
10400 msgstr ""
10402 #. type: Content of: <book><chapter><sect1><para>
10403 #: ../en/ch09-hook.xml:266
10404 msgid ""
10405 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
10406 "into the destination file. It writes file data first, then manifest data "
10407 "(which contains pointers to the new file data), then changelog data (which "
10408 "contains pointers to the new manifest data). Before the first write to each "
10409 "file, it stores a record of where the end of the file was in its transaction "
10410 "log. If the transaction must be rolled back, Mercurial simply truncates each "
10411 "file back to the size it was before the transaction began."
10412 msgstr ""
10414 #. type: Content of: <book><chapter><sect1><para>
10415 #: ../en/ch09-hook.xml:277
10416 msgid ""
10417 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
10418 "first, then everything else. Since a reader will only access parts of the "
10419 "manifest or file metadata that it can see in the changelog, it can never see "
10420 "partially written data."
10421 msgstr ""
10423 #. type: Content of: <book><chapter><sect1><para>
10424 #: ../en/ch09-hook.xml:283
10425 msgid ""
10426 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
10427 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
10428 "almost complete. All of the metadata has been written, but Mercurial can "
10429 "still roll the transaction back and cause the newly-written data to disappear."
10430 msgstr ""
10432 #. type: Content of: <book><chapter><sect1><para>
10433 #: ../en/ch09-hook.xml:291
10434 msgid ""
10435 "If one of these hooks runs for long, it opens a window of time during which a "
10436 "reader can see the metadata for changesets that are not yet permanent, and "
10437 "should not be thought of as <quote>really there</quote>. The longer the hook "
10438 "runs, the longer that window is open."
10439 msgstr ""
10441 #. type: Content of: <book><chapter><sect1><sect2><title>
10442 #: ../en/ch09-hook.xml:299
10443 msgid "The problem illustrated"
10444 msgstr "问题的演示"
10446 #. type: Content of: <book><chapter><sect1><sect2><para>
10447 #: ../en/ch09-hook.xml:301
10448 msgid ""
10449 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
10450 "literal> hook would be to automatically build and test incoming changes "
10451 "before they are accepted into a central repository. This could let you "
10452 "guarantee that nobody can push changes to this repository that <quote>break "
10453 "the build</quote>. But if a client can pull changes while they're being "
10454 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
10455 "untested changes, potentially breaking their build."
10456 msgstr ""
10458 #. type: Content of: <book><chapter><sect1><sect2><para>
10459 #: ../en/ch09-hook.xml:312
10460 msgid ""
10461 "The safest technological answer to this challenge is to set up such a "
10462 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
10463 "Let it take changes pushed in from the outside, but do not allow anyone to "
10464 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
10465 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
10466 "literal> hook so that if a build or test succeeds, the hook will push the new "
10467 "changes out to another repository that people <emphasis>can</emphasis> pull "
10468 "from."
10469 msgstr ""
10471 #. type: Content of: <book><chapter><sect1><sect2><para>
10472 #: ../en/ch09-hook.xml:324
10473 msgid ""
10474 "In practice, putting a centralised bottleneck like this in place is not often "
10475 "a good idea, and transaction visibility has nothing to do with the problem. "
10476 "As the size of a project&emdash;and the time it takes to build and "
10477 "test&emdash;grows, you rapidly run into a wall with this <quote>try before "
10478 "you buy</quote> approach, where you have more changesets to test than time in "
10479 "which to deal with them. The inevitable result is frustration on the part of "
10480 "all involved."
10481 msgstr ""
10483 #. type: Content of: <book><chapter><sect1><sect2><para>
10484 #: ../en/ch09-hook.xml:335
10485 msgid ""
10486 "An approach that scales better is to get people to build and test before they "
10487 "push, then run automated builds and tests centrally <emphasis>after</"
10488 "emphasis> a push, to be sure all is well. The advantage of this approach is "
10489 "that it does not impose a limit on the rate at which the repository can "
10490 "accept changes."
10491 msgstr ""
10493 #. type: Content of: <book><chapter><sect1><title>
10494 #: ../en/ch09-hook.xml:346
10495 msgid "A short tutorial on using hooks"
10496 msgstr "使用钩子的简短指南"
10498 #. type: Content of: <book><chapter><sect1><para>
10499 #: ../en/ch09-hook.xml:348
10500 msgid ""
10501 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
10502 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
10503 "the hash of the changeset you just created. The hook is called <literal role="
10504 "\"hook\">commit</literal>."
10505 msgstr ""
10507 #. type: Content of: <book><chapter><sect1><para>
10508 #: ../en/ch09-hook.xml:355
10509 msgid "All hooks follow the pattern in this example."
10510 msgstr ""
10512 #. type: Content of: <book><chapter><sect1><para>
10513 #: ../en/ch09-hook.xml:359
10514 msgid ""
10515 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
10516 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
10517 "of the event to trigger on; on the right is the action to take. As you can "
10518 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
10519 "extra information to the hook using environment variables (look for "
10520 "<envar>HG_NODE</envar> in the example)."
10521 msgstr ""
10523 #. type: Content of: <book><chapter><sect1><sect2><title>
10524 #: ../en/ch09-hook.xml:369
10525 msgid "Performing multiple actions per event"
10526 msgstr "每个事件执行多个操作"
10528 #. type: Content of: <book><chapter><sect1><sect2><para>
10529 #: ../en/ch09-hook.xml:371
10530 msgid ""
10531 "Quite often, you will want to define more than one hook for a particular kind "
10532 "of event, as shown below."
10533 msgstr ""
10535 #. type: Content of: <book><chapter><sect1><sect2><para>
10536 #: ../en/ch09-hook.xml:376
10537 msgid ""
10538 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
10539 "end of a hook's name. You extend a hook's name by giving the name of the "
10540 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
10541 "character), followed by some more text of your choosing. For example, "
10542 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
10543 "bar</literal> when the <literal>commit</literal> event occurs."
10544 msgstr ""
10546 #. type: Content of: <book><chapter><sect1><sect2><para>
10547 #: ../en/ch09-hook.xml:387
10548 msgid ""
10549 "To give a well-defined order of execution when there are multiple hooks "
10550 "defined for an event, Mercurial sorts hooks by extension, and executes the "
10551 "hook commands in this sorted order. In the above example, it will execute "
10552 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
10553 "<literal>commit</literal> before both."
10554 msgstr ""
10556 #. type: Content of: <book><chapter><sect1><sect2><para>
10557 #: ../en/ch09-hook.xml:396
10558 msgid ""
10559 "It is a good idea to use a somewhat descriptive extension when you define a "
10560 "new hook. This will help you to remember what the hook was for. If the hook "
10561 "fails, you'll get an error message that contains the hook name and extension, "
10562 "so using a descriptive extension could give you an immediate hint as to why "
10563 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
10564 msgstr ""
10566 #. type: Content of: <book><chapter><sect1><sect2><title>
10567 #: ../en/ch09-hook.xml:407
10568 msgid "Controlling whether an activity can proceed"
10569 msgstr "控制处理的活动"
10571 #. type: Content of: <book><chapter><sect1><sect2><para>
10572 #: ../en/ch09-hook.xml:409
10573 msgid ""
10574 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
10575 "hook, which is run after a commit has completed. This is one of several "
10576 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
10577 "of influencing the activity itself."
10578 msgstr ""
10580 #. type: Content of: <book><chapter><sect1><sect2><para>
10581 #: ../en/ch09-hook.xml:416
10582 msgid ""
10583 "Mercurial defines a number of events that occur before an activity starts; or "
10584 "after it starts, but before it finishes. Hooks that trigger on these events "
10585 "have the added ability to choose whether the activity can continue, or will "
10586 "abort."
10587 msgstr ""
10589 #. type: Content of: <book><chapter><sect1><sect2><para>
10590 #: ../en/ch09-hook.xml:422
10591 msgid ""
10592 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
10593 "has all but completed. In other words, the metadata representing the "
10594 "changeset has been written out to disk, but the transaction has not yet been "
10595 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
10596 "has the ability to decide whether the transaction can complete, or must be "
10597 "rolled back."
10598 msgstr ""
10600 #. type: Content of: <book><chapter><sect1><sect2><para>
10601 #: ../en/ch09-hook.xml:431
10602 msgid ""
10603 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
10604 "code of zero, the transaction is allowed to complete; the commit finishes; "
10605 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
10606 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
10607 "the transaction is rolled back; the metadata representing the changeset is "
10608 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
10609 msgstr ""
10611 #. type: Content of: <book><chapter><sect1><sect2><para>
10612 #: ../en/ch09-hook.xml:443
10613 msgid ""
10614 "The hook in the example above checks that a commit comment contains a bug "
10615 "ID. If it does, the commit can complete. If not, the commit is rolled back."
10616 msgstr ""
10618 #. type: Content of: <book><chapter><sect1><title>
10619 #: ../en/ch09-hook.xml:451
10620 msgid "Writing your own hooks"
10621 msgstr "编写钩子"
10623 #. type: Content of: <book><chapter><sect1><para>
10624 #: ../en/ch09-hook.xml:453
10625 msgid ""
10626 "When you are writing a hook, you might find it useful to run Mercurial either "
10627 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
10628 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
10629 "When you do so, Mercurial will print a message before it calls each hook."
10630 msgstr ""
10632 #. type: Content of: <book><chapter><sect1><sect2><title>
10633 #: ../en/ch09-hook.xml:462
10634 msgid "Choosing how your hook should run"
10635 msgstr "选择钩子的执行方式"
10637 #. type: Content of: <book><chapter><sect1><sect2><para>
10638 #: ../en/ch09-hook.xml:464
10639 msgid ""
10640 "You can write a hook either as a normal program&emdash;typically a shell "
10641 "script&emdash;or as a Python function that is executed within the Mercurial "
10642 "process."
10643 msgstr ""
10645 #. type: Content of: <book><chapter><sect1><sect2><para>
10646 #: ../en/ch09-hook.xml:469
10647 msgid ""
10648 "Writing a hook as an external program has the advantage that it requires no "
10649 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
10650 "to get any added information you need. The trade-off is that external hooks "
10651 "are slower than in-process hooks."
10652 msgstr ""
10654 #. type: Content of: <book><chapter><sect1><sect2><para>
10655 #: ../en/ch09-hook.xml:476
10656 msgid ""
10657 "An in-process Python hook has complete access to the Mercurial API, and does "
10658 "not <quote>shell out</quote> to another process, so it is inherently faster "
10659 "than an external hook. It is also easier to obtain much of the information "
10660 "that a hook requires by using the Mercurial API than by running Mercurial "
10661 "commands."
10662 msgstr ""
10664 #. type: Content of: <book><chapter><sect1><sect2><para>
10665 #: ../en/ch09-hook.xml:484
10666 msgid ""
10667 "If you are comfortable with Python, or require high performance, writing your "
10668 "hooks in Python may be a good choice. However, when you have a "
10669 "straightforward hook to write and you don't need to care about performance "
10670 "(probably the majority of hooks), a shell script is perfectly fine."
10671 msgstr ""
10673 #. type: Content of: <book><chapter><sect1><sect2><title>
10674 #: ../en/ch09-hook.xml:493
10675 msgid "Hook parameters"
10676 msgstr "钩子的参数"
10678 #. type: Content of: <book><chapter><sect1><sect2><para>
10679 #: ../en/ch09-hook.xml:495
10680 msgid ""
10681 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
10682 "a parameter is passed as a keyword argument to your hook function. For an "
10683 "external program, a parameter is passed as an environment variable."
10684 msgstr ""
10686 #. type: Content of: <book><chapter><sect1><sect2><para>
10687 #: ../en/ch09-hook.xml:501
10688 msgid ""
10689 "Whether your hook is written in Python or as a shell script, the hook-"
10690 "specific parameter names and values will be the same. A boolean parameter "
10691 "will be represented as a boolean value in Python, but as the number 1 (for "
10692 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
10693 "variable for an external hook. If a hook parameter is named <literal>foo</"
10694 "literal>, the keyword argument for a Python hook will also be named "
10695 "<literal>foo</literal>, while the environment variable for an external hook "
10696 "will be named <literal>HG_FOO</literal>."
10697 msgstr ""
10699 #. type: Content of: <book><chapter><sect1><sect2><title>
10700 #: ../en/ch09-hook.xml:515
10701 msgid "Hook return values and activity control"
10702 msgstr "钩子的返回值与活动控制"
10704 #. type: Content of: <book><chapter><sect1><sect2><para>
10705 #: ../en/ch09-hook.xml:517
10706 msgid ""
10707 "A hook that executes successfully must exit with a status of zero if "
10708 "external, or return boolean <quote>false</quote> if in-process. Failure is "
10709 "indicated with a non-zero exit status from an external hook, or an in-process "
10710 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
10711 "exception, the hook is considered to have failed."
10712 msgstr ""
10714 #. type: Content of: <book><chapter><sect1><sect2><para>
10715 #: ../en/ch09-hook.xml:525
10716 msgid ""
10717 "For a hook that controls whether an activity can proceed, zero/false means "
10718 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
10719 msgstr ""
10721 #. type: Content of: <book><chapter><sect1><sect2><title>
10722 #: ../en/ch09-hook.xml:532
10723 msgid "Writing an external hook"
10724 msgstr "编写外部钩子"
10726 #. type: Content of: <book><chapter><sect1><sect2><para>
10727 #: ../en/ch09-hook.xml:534
10728 msgid ""
10729 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
10730 "filename> and the hook is run, its value is passed to your shell, which "
10731 "interprets it. This means that you can use normal shell constructs in the "
10732 "body of the hook."
10733 msgstr ""
10735 #. type: Content of: <book><chapter><sect1><sect2><para>
10736 #: ../en/ch09-hook.xml:541
10737 msgid ""
10738 "An executable hook is always run with its current directory set to a "
10739 "repository's root directory."
10740 msgstr ""
10742 #. type: Content of: <book><chapter><sect1><sect2><para>
10743 #: ../en/ch09-hook.xml:545
10744 msgid ""
10745 "Each hook parameter is passed in as an environment variable; the name is "
10746 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
10747 "quote>."
10748 msgstr ""
10750 #. type: Content of: <book><chapter><sect1><sect2><para>
10751 #: ../en/ch09-hook.xml:550
10752 msgid ""
10753 "With the exception of hook parameters, Mercurial does not set or modify any "
10754 "environment variables when running a hook. This is useful to remember if you "
10755 "are writing a site-wide hook that may be run by a number of different users "
10756 "with differing environment variables set. In multi-user situations, you "
10757 "should not rely on environment variables being set to the values you have in "
10758 "your environment when testing the hook."
10759 msgstr ""
10761 #. type: Content of: <book><chapter><sect1><sect2><title>
10762 #: ../en/ch09-hook.xml:561
10763 msgid "Telling Mercurial to use an in-process hook"
10764 msgstr "让 Mercurial 使用进程内钩子"
10766 #. type: Content of: <book><chapter><sect1><sect2><para>
10767 #: ../en/ch09-hook.xml:563
10768 msgid ""
10769 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
10770 "process hook is slightly different than for an executable hook. The value of "
10771 "the hook must start with the text <quote><literal>python:</literal></quote>, "
10772 "and continue with the fully-qualified name of a callable object to use as the "
10773 "hook's value."
10774 msgstr ""
10776 #. type: Content of: <book><chapter><sect1><sect2><para>
10777 #: ../en/ch09-hook.xml:571
10778 msgid ""
10779 "The module in which a hook lives is automatically imported when a hook is "
10780 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
10781 "right, it should <quote>just work</quote>."
10782 msgstr ""
10784 #. type: Content of: <book><chapter><sect1><sect2><para>
10785 #: ../en/ch09-hook.xml:577
10786 msgid ""
10787 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
10788 "illustrates the syntax and meaning of the notions we just described."
10789 msgstr ""
10791 #. type: Content of: <book><chapter><sect1><sect2><para>
10792 #: ../en/ch09-hook.xml:583
10793 msgid ""
10794 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
10795 "<literal>mymodule.submodule</literal>, looks for the callable object named "
10796 "<literal>myhook</literal>, and calls it."
10797 msgstr ""
10799 #. type: Content of: <book><chapter><sect1><sect2><title>
10800 #: ../en/ch09-hook.xml:591
10801 msgid "Writing an in-process hook"
10802 msgstr "编写进程内钩子"
10804 #. type: Content of: <book><chapter><sect1><sect2><para>
10805 #: ../en/ch09-hook.xml:593
10806 msgid ""
10807 "The simplest in-process hook does nothing, but illustrates the basic shape of "
10808 "the hook API:"
10809 msgstr ""
10811 #. type: Content of: <book><chapter><sect1><sect2><para>
10812 #: ../en/ch09-hook.xml:598
10813 msgid ""
10814 "The first argument to a Python hook is always a <literal role=\"py-mod-"
10815 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
10816 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
10817 "localrepo\">localrepository</literal>. Following these two arguments are "
10818 "other keyword arguments. Which ones are passed in depends on the hook being "
10819 "called, but a hook can ignore arguments it doesn't care about by dropping "
10820 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
10821 msgstr ""
10823 #. type: Content of: <book><chapter><sect1><title>
10824 #: ../en/ch09-hook.xml:613
10825 msgid "Some hook examples"
10826 msgstr "钩子样例"
10828 #. type: Content of: <book><chapter><sect1><sect2><title>
10829 #: ../en/ch09-hook.xml:616
10830 msgid "Writing meaningful commit messages"
10831 msgstr "编写有意义的提交日志"
10833 #. type: Content of: <book><chapter><sect1><sect2><para>
10834 #: ../en/ch09-hook.xml:618
10835 msgid ""
10836 "It's hard to imagine a useful commit message being very short. The simple "
10837 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
10838 "prevent you from committing a changeset with a message that is less than ten "
10839 "bytes long."
10840 msgstr ""
10842 #. type: Content of: <book><chapter><sect1><sect2><title>
10843 #: ../en/ch09-hook.xml:628
10844 msgid "Checking for trailing whitespace"
10845 msgstr "检查行尾空格"
10847 #. type: Content of: <book><chapter><sect1><sect2><para>
10848 #: ../en/ch09-hook.xml:630
10849 msgid ""
10850 "An interesting use of a commit-related hook is to help you to write cleaner "
10851 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
10852 "change should not add any new lines of text that contain <quote>trailing "
10853 "whitespace</quote>. Trailing whitespace is a series of space and tab "
10854 "characters at the end of a line of text. In most cases, trailing whitespace "
10855 "is unnecessary, invisible noise, but it is occasionally problematic, and "
10856 "people often prefer to get rid of it."
10857 msgstr ""
10859 #. type: Content of: <book><chapter><sect1><sect2><para>
10860 #: ../en/ch09-hook.xml:641
10861 msgid ""
10862 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
10863 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
10864 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
10865 "literal> hook, the hook will not know which files you are committing, so it "
10866 "will have to check every modified file in the repository for trailing white "
10867 "space. If you want to commit a change to just the file <filename>foo</"
10868 "filename>, but the file <filename>bar</filename> contains trailing "
10869 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
10870 "hook will prevent you from committing <filename>foo</filename> due to the "
10871 "problem with <filename>bar</filename>. This doesn't seem right."
10872 msgstr ""
10874 #. type: Content of: <book><chapter><sect1><sect2><para>
10875 #: ../en/ch09-hook.xml:657
10876 msgid ""
10877 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
10878 "check won't occur until just before the transaction for the commit "
10879 "completes. This will allow you to check for problems only the exact files "
10880 "that are being committed. However, if you entered the commit message "
10881 "interactively and the hook fails, the transaction will roll back; you'll have "
10882 "to re-enter the commit message after you fix the trailing whitespace and run "
10883 "<command role=\"hg-cmd\">hg commit</command> again."
10884 msgstr ""
10886 #. type: Content of: <book><chapter><sect1><sect2><para>
10887 #: ../en/ch09-hook.xml:670
10888 msgid ""
10889 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
10890 "literal> hook that checks for trailing whitespace. This hook is short, but "
10891 "not very helpful. It exits with an error status if a change adds a line with "
10892 "trailing whitespace to any file, but does not print any information that "
10893 "might help us to identify the offending file or line. It also has the nice "
10894 "property of not paying attention to unmodified lines; only lines that "
10895 "introduce new trailing whitespace cause problems."
10896 msgstr ""
10898 #. type: Content of: <book><chapter><sect1><sect2><para>
10899 #: ../en/ch09-hook.xml:681
10900 msgid ""
10901 "The above version is much more complex, but also more useful. It parses a "
10902 "unified diff to see if any lines add trailing whitespace, and prints the name "
10903 "of the file and the line number of each such occurrence. Even better, if the "
10904 "change adds trailing whitespace, this hook saves the commit comment and "
10905 "prints the name of the save file before exiting and telling Mercurial to roll "
10906 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
10907 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
10908 "reuse the saved commit message once you've corrected the problem."
10909 msgstr ""
10911 #. type: Content of: <book><chapter><sect1><sect2><para>
10912 #: ../en/ch09-hook.xml:695
10913 msgid ""
10914 "As a final aside, note in the example above the use of <command>perl</"
10915 "command>'s in-place editing feature to get rid of trailing whitespace from a "
10916 "file. This is concise and useful enough that I will reproduce it here."
10917 msgstr ""
10919 #. type: Content of: <book><chapter><sect1><title>
10920 #: ../en/ch09-hook.xml:705
10921 msgid "Bundled hooks"
10922 msgstr "内置的钩子"
10924 #. type: Content of: <book><chapter><sect1><para>
10925 #: ../en/ch09-hook.xml:707
10926 msgid ""
10927 "Mercurial ships with several bundled hooks. You can find them in the "
10928 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
10929 "source tree. If you are using a Mercurial binary package, the hooks will be "
10930 "located in the <filename class=\"directory\">hgext</filename> directory of "
10931 "wherever your package installer put Mercurial."
10932 msgstr ""
10934 #. type: Content of: <book><chapter><sect1><sect2><title>
10935 #: ../en/ch09-hook.xml:716
10936 msgid ""
10937 "<literal role=\"hg-ext\">acl</literal>&emdash;access control for parts of a "
10938 "repository"
10939 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
10941 #. type: Content of: <book><chapter><sect1><sect2><para>
10942 #: ../en/ch09-hook.xml:719
10943 msgid ""
10944 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
10945 "remote users are allowed to push changesets to a networked server. You can "
10946 "protect any portion of a repository (including the entire repo), so that a "
10947 "specific remote user can push changes that do not affect the protected "
10948 "portion."
10949 msgstr ""
10951 #. type: Content of: <book><chapter><sect1><sect2><para>
10952 #: ../en/ch09-hook.xml:727
10953 msgid ""
10954 "This extension implements access control based on the identity of the user "
10955 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
10956 "they're pushing. It makes sense to use this hook only if you have a locked-"
10957 "down server environment that authenticates remote users, and you want to be "
10958 "sure that only specific users are allowed to push changes to that server."
10959 msgstr ""
10961 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
10962 #: ../en/ch09-hook.xml:737
10963 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
10964 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
10966 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10967 #: ../en/ch09-hook.xml:740
10968 msgid ""
10969 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
10970 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
10971 "literal> hook. This lets it see which files are modified by each incoming "
10972 "changeset, and roll back a group of changesets if they modify "
10973 "<quote>forbidden</quote> files. Example:"
10974 msgstr ""
10976 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10977 #: ../en/ch09-hook.xml:750
10978 msgid ""
10979 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
10980 "three sections."
10981 msgstr ""
10983 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
10984 #: ../en/ch09-hook.xml:754
10985 msgid ""
10986 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
10987 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
10988 "changesets that the hook should pay attention to. You don't normally need to "
10989 "configure this section."
10990 msgstr ""
10992 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
10993 #: ../en/ch09-hook.xml:761
10994 msgid ""
10995 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
10996 "are arriving from a remote repository over http or ssh. This is the default "
10997 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
10998 "setting you'll need for this configuration item."
10999 msgstr ""
11001 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11002 #: ../en/ch09-hook.xml:769
11003 msgid ""
11004 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
11005 "are arriving via a pull from a local repository."
11006 msgstr ""
11008 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11009 #: ../en/ch09-hook.xml:774
11010 msgid ""
11011 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
11012 "are arriving via a push from a local repository."
11013 msgstr ""
11015 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11016 #: ../en/ch09-hook.xml:779
11017 msgid ""
11018 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
11019 "are arriving from another repository via a bundle."
11020 msgstr ""
11022 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11023 #: ../en/ch09-hook.xml:785
11024 msgid ""
11025 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
11026 "users that are allowed to add changesets to the repository. If this section "
11027 "is not present, all users that are not explicitly denied are allowed. If "
11028 "this section is present, all users that are not explicitly allowed are denied "
11029 "(so an empty section means that all users are denied)."
11030 msgstr ""
11032 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11033 #: ../en/ch09-hook.xml:794
11034 msgid ""
11035 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
11036 "users are denied from adding changesets to the repository. If this section "
11037 "is not present or is empty, no users are denied."
11038 msgstr ""
11040 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11041 #: ../en/ch09-hook.xml:800
11042 msgid ""
11043 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
11044 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
11045 "the left of each entry is a glob pattern that matches files or directories, "
11046 "relative to the root of the repository; on the right, a user name."
11047 msgstr ""
11049 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11050 #: ../en/ch09-hook.xml:808
11051 msgid ""
11052 "In the following example, the user <literal>docwriter</literal> can only push "
11053 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
11054 "repository, while <literal>intern</literal> can push changes to any file or "
11055 "directory except <filename class=\"directory\">source/sensitive</filename>."
11056 msgstr ""
11058 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11059 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1279
11060 msgid "Testing and troubleshooting"
11061 msgstr "测试与问题处理"
11063 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11064 #: ../en/ch09-hook.xml:824
11065 msgid ""
11066 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
11067 "with Mercurial's debugging output enabled. Since you'll probably be running "
11068 "it on a server where it's not convenient (or sometimes possible) to pass in "
11069 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
11070 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
11071 "filename>:"
11072 msgstr ""
11074 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11075 #: ../en/ch09-hook.xml:835
11076 msgid ""
11077 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
11078 "enough information to let you figure out why it is allowing or forbidding "
11079 "pushes from specific users."
11080 msgstr ""
11082 #. type: Content of: <book><chapter><sect1><sect2><title>
11083 #: ../en/ch09-hook.xml:844
11084 msgid ""
11085 "<literal role=\"hg-ext\">bugzilla</literal>&emdash;integration with Bugzilla"
11086 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
11088 #. type: Content of: <book><chapter><sect1><sect2><para>
11089 #: ../en/ch09-hook.xml:848
11090 msgid ""
11091 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
11092 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
11093 "comment. You can install this hook on a shared server, so that any time a "
11094 "remote user pushes changes to this server, the hook gets run."
11095 msgstr ""
11097 #. type: Content of: <book><chapter><sect1><sect2><para>
11098 #: ../en/ch09-hook.xml:855
11099 msgid ""
11100 "It adds a comment to the bug that looks like this (you can configure the "
11101 "contents of the comment&emdash;see below):"
11102 msgstr ""
11104 #. type: Content of: <book><chapter><sect1><sect2><para>
11105 #: ../en/ch09-hook.xml:864
11106 msgid ""
11107 "The value of this hook is that it automates the process of updating a bug any "
11108 "time a changeset refers to it. If you configure the hook properly, it makes "
11109 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
11110 "refers to that bug."
11111 msgstr ""
11113 #. type: Content of: <book><chapter><sect1><sect2><para>
11114 #: ../en/ch09-hook.xml:871
11115 msgid ""
11116 "You can use the code in this hook as a starting point for some more exotic "
11117 "Bugzilla integration recipes. Here are a few possibilities:"
11118 msgstr ""
11120 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11121 #: ../en/ch09-hook.xml:876
11122 msgid ""
11123 "Require that every changeset pushed to the server have a valid bug ID in its "
11124 "commit comment. In this case, you'd want to configure the hook as a <literal "
11125 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
11126 "reject changes that didn't contain bug IDs."
11127 msgstr ""
11129 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11130 #: ../en/ch09-hook.xml:884
11131 msgid ""
11132 "Allow incoming changesets to automatically modify the <emphasis>state</"
11133 "emphasis> of a bug, as well as simply adding a comment. For example, the "
11134 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
11135 "that it should update the state of bug 31337 to <quote>requires testing</"
11136 "quote>."
11137 msgstr ""
11139 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11140 #: ../en/ch09-hook.xml:894
11141 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
11142 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
11144 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11145 #: ../en/ch09-hook.xml:897
11146 msgid ""
11147 "You should configure this hook in your server's <filename role=\"special\">~/."
11148 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
11149 "example as follows:"
11150 msgstr ""
11152 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11153 #: ../en/ch09-hook.xml:905
11154 msgid ""
11155 "Because of the specialised nature of this hook, and because Bugzilla was not "
11156 "written with this kind of integration in mind, configuring this hook is a "
11157 "somewhat involved process."
11158 msgstr ""
11160 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11161 #: ../en/ch09-hook.xml:911
11162 msgid ""
11163 "Before you begin, you must install the MySQL bindings for Python on the host"
11164 "(s) where you'll be running the hook. If this is not available as a binary "
11165 "package for your system, you can download it from <citation>web:mysql-python</"
11166 "citation>."
11167 msgstr ""
11169 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11170 #: ../en/ch09-hook.xml:918
11171 msgid ""
11172 "Configuration information for this hook lives in the <literal role=\"rc-"
11173 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
11174 "hgrc</filename>."
11175 msgstr ""
11177 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11178 #: ../en/ch09-hook.xml:923
11179 msgid ""
11180 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
11181 "installed on the server. The database schema that Bugzilla uses changes "
11182 "occasionally, so this hook has to know exactly which schema to use. At the "
11183 "moment, the only version supported is <literal>2.16</literal>."
11184 msgstr ""
11186 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11187 #: ../en/ch09-hook.xml:932
11188 msgid ""
11189 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
11190 "server that stores your Bugzilla data. The database must be configured to "
11191 "allow connections from whatever host you are running the <literal role=\"hook"
11192 "\">bugzilla</literal> hook on."
11193 msgstr ""
11195 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11196 #: ../en/ch09-hook.xml:939
11197 msgid ""
11198 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
11199 "connect to the MySQL server. The database must be configured to allow this "
11200 "user to connect from whatever host you are running the <literal role=\"hook"
11201 "\">bugzilla</literal> hook on. This user must be able to access and modify "
11202 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
11203 "which is the standard name of the Bugzilla user in a MySQL database."
11204 msgstr ""
11206 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11207 #: ../en/ch09-hook.xml:950
11208 msgid ""
11209 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
11210 "user you configured above. This is stored as plain text, so you should make "
11211 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
11212 "hgrc</filename> file where you store this information."
11213 msgstr ""
11215 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11216 #: ../en/ch09-hook.xml:959
11217 msgid ""
11218 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
11219 "database on the MySQL server. The default value of this item is "
11220 "<literal>bugs</literal>, which is the standard name of the MySQL database "
11221 "where Bugzilla stores its data."
11222 msgstr ""
11224 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11225 #: ../en/ch09-hook.xml:966
11226 msgid ""
11227 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
11228 "out a notification email to subscribers after this hook has added a comment "
11229 "to a bug, you will need this hook to run a command whenever it updates the "
11230 "database. The command to run depends on where you have installed Bugzilla, "
11231 "but it will typically look something like this, if you have Bugzilla "
11232 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
11233 msgstr ""
11235 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11236 #: ../en/ch09-hook.xml:979
11237 msgid ""
11238 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
11239 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
11240 "and an email address. It also expects to be able to write to some files in "
11241 "the directory that it runs in. If Bugzilla and this hook are not installed "
11242 "on the same machine, you will need to find a way to run <literal>processmail</"
11243 "literal> on the server where Bugzilla is installed."
11244 msgstr ""
11246 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11247 #: ../en/ch09-hook.xml:994
11248 msgid "Mapping committer names to Bugzilla user names"
11249 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
11251 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11252 #: ../en/ch09-hook.xml:996
11253 msgid ""
11254 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
11255 "the email address of a changeset's committer as the Bugzilla user name with "
11256 "which to update a bug. If this does not suit your needs, you can map "
11257 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
11258 "usermap\">usermap</literal> section."
11259 msgstr ""
11261 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11262 #: ../en/ch09-hook.xml:1005
11263 msgid ""
11264 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
11265 "contains an email address on the left, and a Bugzilla user name on the right."
11266 msgstr ""
11268 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11269 #: ../en/ch09-hook.xml:1012
11270 msgid ""
11271 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
11272 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
11273 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
11274 "an external <filename>usermap</filename> file. In the latter case, you can "
11275 "store <filename>usermap</filename> data by itself in (for example) a user-"
11276 "modifiable repository. This makes it possible to let your users maintain "
11277 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
11278 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
11279 msgstr ""
11281 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11282 #: ../en/ch09-hook.xml:1028
11283 msgid ""
11284 "While the <filename>usermap</filename> file that it refers to might look like "
11285 "this:"
11286 msgstr ""
11288 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11289 #: ../en/ch09-hook.xml:1036
11290 msgid "Configuring the text that gets added to a bug"
11291 msgstr "配置增加到问题中的正文"
11293 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11294 #: ../en/ch09-hook.xml:1038
11295 msgid ""
11296 "You can configure the text that this hook adds as a comment; you specify it "
11297 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
11298 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
11299 "literal> section) control this behaviour."
11300 msgstr ""
11302 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11303 #: ../en/ch09-hook.xml:1045
11304 msgid ""
11305 "<literal>strip</literal>: The number of leading path elements to strip from a "
11306 "repository's path name to construct a partial path for a URL. For example, if "
11307 "the repositories on your server live under <filename class=\"directory\">/"
11308 "home/hg/repos</filename>, and you have a repository whose path is <filename "
11309 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
11310 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
11311 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
11312 "partial path available when expanding a template, as <literal>webroot</"
11313 "literal>."
11314 msgstr ""
11316 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11317 #: ../en/ch09-hook.xml:1059
11318 msgid ""
11319 "<literal>template</literal>: The text of the template to use. In addition to "
11320 "the usual changeset-related variables, this template can use <literal>hgweb</"
11321 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
11322 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
11323 "literal> above)."
11324 msgstr ""
11326 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11327 #: ../en/ch09-hook.xml:1069
11328 msgid ""
11329 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
11330 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
11331 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
11332 "literal> hook will make this available when expanding a template, as the base "
11333 "string to use when constructing a URL that will let users browse from a "
11334 "Bugzilla comment to view a changeset. Example:"
11335 msgstr ""
11337 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11338 #: ../en/ch09-hook.xml:1081
11339 msgid ""
11340 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
11341 "config information."
11342 msgstr ""
11344 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11345 #: ../en/ch09-hook.xml:1091
11346 msgid ""
11347 "The most common problems with configuring the <literal role=\"hg-ext"
11348 "\">bugzilla</literal> hook relate to running Bugzilla's "
11349 "<filename>processmail</filename> script and mapping committer names to user "
11350 "names."
11351 msgstr ""
11353 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11354 #: ../en/ch09-hook.xml:1097
11355 msgid ""
11356 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
11357 "that runs the Mercurial process on the server is also the one that will run "
11358 "the <filename>processmail</filename> script. The <filename>processmail</"
11359 "filename> script sometimes causes Bugzilla to write to files in its "
11360 "configuration directory, and Bugzilla's configuration files are usually owned "
11361 "by the user that your web server runs under."
11362 msgstr ""
11364 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11365 #: ../en/ch09-hook.xml:1108
11366 msgid ""
11367 "You can cause <filename>processmail</filename> to be run with the suitable "
11368 "user's identity using the <command>sudo</command> command. Here is an "
11369 "example entry for a <filename>sudoers</filename> file."
11370 msgstr ""
11372 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11373 #: ../en/ch09-hook.xml:1115
11374 msgid ""
11375 "This allows the <literal>hg_user</literal> user to run a "
11376 "<filename>processmail-wrapper</filename> program under the identity of "
11377 "<literal>httpd_user</literal>."
11378 msgstr ""
11380 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11381 #: ../en/ch09-hook.xml:1120
11382 msgid ""
11383 "This indirection through a wrapper script is necessary, because "
11384 "<filename>processmail</filename> expects to be run with its current directory "
11385 "set to wherever you installed Bugzilla; you can't specify that kind of "
11386 "constraint in a <filename>sudoers</filename> file. The contents of the "
11387 "wrapper script are simple:"
11388 msgstr ""
11390 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11391 #: ../en/ch09-hook.xml:1129
11392 msgid ""
11393 "It doesn't seem to matter what email address you pass to "
11394 "<filename>processmail</filename>."
11395 msgstr ""
11397 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11398 #: ../en/ch09-hook.xml:1133
11399 msgid ""
11400 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
11401 "correctly, users will see an error message from the <literal role=\"hg-ext"
11402 "\">bugzilla</literal> hook when they push changes to the server. The error "
11403 "message will look like this:"
11404 msgstr ""
11406 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11407 #: ../en/ch09-hook.xml:1140
11408 msgid ""
11409 "What this means is that the committer's address, <literal>john.q."
11410 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
11411 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
11412 "maps it to a valid Bugzilla user name."
11413 msgstr ""
11415 #. type: Content of: <book><chapter><sect1><sect2><title>
11416 #: ../en/ch09-hook.xml:1150
11417 msgid ""
11418 "<literal role=\"hg-ext\">notify</literal>&emdash;send email notifications"
11419 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
11421 #. type: Content of: <book><chapter><sect1><sect2><para>
11422 #: ../en/ch09-hook.xml:1153
11423 msgid ""
11424 "Although Mercurial's built-in web server provides RSS feeds of changes in "
11425 "every repository, many people prefer to receive change notifications via "
11426 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
11427 "notifications to a set of email addresses whenever changesets arrive that "
11428 "those subscribers are interested in."
11429 msgstr ""
11431 #. type: Content of: <book><chapter><sect1><sect2><para>
11432 #: ../en/ch09-hook.xml:1161
11433 msgid ""
11434 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
11435 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
11436 "customise the contents of the notification messages that it sends."
11437 msgstr ""
11439 #. type: Content of: <book><chapter><sect1><sect2><para>
11440 #: ../en/ch09-hook.xml:1167
11441 msgid ""
11442 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
11443 "diff of every changeset that it sends out; you can limit the size of the "
11444 "diff, or turn this feature off entirely. It is useful for letting "
11445 "subscribers review changes immediately, rather than clicking to follow a URL."
11446 msgstr ""
11448 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11449 #: ../en/ch09-hook.xml:1175
11450 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
11451 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
11453 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11454 #: ../en/ch09-hook.xml:1178
11455 msgid ""
11456 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
11457 "email message per incoming changeset, or one per incoming group of changesets "
11458 "(all those that arrived in a single pull or push)."
11459 msgstr ""
11461 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11462 #: ../en/ch09-hook.xml:1190
11463 msgid ""
11464 "Configuration information for this hook lives in the <literal role=\"rc-notify"
11465 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
11466 "filename> file."
11467 msgstr ""
11469 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11470 #: ../en/ch09-hook.xml:1195
11471 msgid ""
11472 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
11473 "send out email at all; instead, it prints the message that it "
11474 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
11475 "to allow email to be sent. The reason that sending of email is turned off by "
11476 "default is that it takes several tries to configure this extension exactly as "
11477 "you would like, and it would be bad form to spam subscribers with a number of "
11478 "<quote>broken</quote> notifications while you debug your configuration."
11479 msgstr ""
11481 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11482 #: ../en/ch09-hook.xml:1207
11483 msgid ""
11484 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
11485 "file that contains subscription information. This is kept separate from the "
11486 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
11487 "it in a repository of its own. People can then clone that repository, update "
11488 "their subscriptions, and push the changes back to your server."
11489 msgstr ""
11491 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11492 #: ../en/ch09-hook.xml:1216
11493 msgid ""
11494 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
11495 "separator characters to strip from a repository's path, when deciding whether "
11496 "a repository has subscribers. For example, if the repositories on your "
11497 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
11498 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
11499 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
11500 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
11501 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
11502 "down to <filename class=\"directory\">shared/test</filename>, and it will "
11503 "match subscribers against that."
11504 msgstr ""
11506 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11507 #: ../en/ch09-hook.xml:1233
11508 msgid ""
11509 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
11510 "when sending messages. This specifies both the contents of the message "
11511 "header and its body."
11512 msgstr ""
11514 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11515 #: ../en/ch09-hook.xml:1239
11516 msgid ""
11517 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
11518 "of diff data to append to the end of a message. If a diff is longer than "
11519 "this, it is truncated. By default, this is set to 300. Set this to "
11520 "<literal>0</literal> to omit diffs from notification emails."
11521 msgstr ""
11523 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11524 #: ../en/ch09-hook.xml:1248
11525 msgid ""
11526 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
11527 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
11528 "literal> to only sending out email about changes that remote users pushed "
11529 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
11530 "sources\"/> for the sources you can specify here."
11531 msgstr ""
11533 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11534 #: ../en/ch09-hook.xml:1259
11535 msgid ""
11536 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
11537 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
11538 "it will be available as <literal>webroot</literal>."
11539 msgstr ""
11541 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11542 #: ../en/ch09-hook.xml:1265
11543 msgid ""
11544 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
11545 "configuration information."
11546 msgstr ""
11548 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11549 #: ../en/ch09-hook.xml:1271
11550 msgid "This will produce a message that looks like the following:"
11551 msgstr ""
11553 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11554 #: ../en/ch09-hook.xml:1281
11555 msgid ""
11556 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
11557 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
11558 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
11559 "to <literal>false</literal>. Until you do that, it simply prints the message "
11560 "it <emphasis>would</emphasis> send."
11561 msgstr ""
11563 #. type: Content of: <book><chapter><sect1><title>
11564 #: ../en/ch09-hook.xml:1293
11565 msgid "Information for writers of hooks"
11566 msgstr "编写钩子的信息"
11568 #. type: Content of: <book><chapter><sect1><sect2><title>
11569 #: ../en/ch09-hook.xml:1296
11570 msgid "In-process hook execution"
11571 msgstr "进程内钩子的执行"
11573 #. type: Content of: <book><chapter><sect1><sect2><para>
11574 #: ../en/ch09-hook.xml:1298
11575 msgid "An in-process hook is called with arguments of the following form:"
11576 msgstr ""
11578 #. type: Content of: <book><chapter><sect1><sect2><para>
11579 #: ../en/ch09-hook.xml:1302
11580 msgid ""
11581 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
11582 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
11583 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
11584 "names and values of the <literal>**kwargs</literal> parameters depend on the "
11585 "hook being invoked, with the following common features:"
11586 msgstr ""
11588 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11589 #: ../en/ch09-hook.xml:1311
11590 msgid ""
11591 "If a parameter is named <literal>node</literal> or <literal>parentN</"
11592 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
11593 "used to represent <quote>null changeset ID</quote> instead of a string of "
11594 "zeroes."
11595 msgstr ""
11597 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11598 #: ../en/ch09-hook.xml:1318
11599 msgid ""
11600 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
11601 "remote repository, if that can be determined."
11602 msgstr ""
11604 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11605 #: ../en/ch09-hook.xml:1323
11606 msgid ""
11607 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
11608 "objects."
11609 msgstr ""
11611 #. type: Content of: <book><chapter><sect1><sect2><para>
11612 #: ../en/ch09-hook.xml:1328
11613 msgid ""
11614 "An in-process hook is called without a change to the process's working "
11615 "directory (unlike external hooks, which are run in the root of the "
11616 "repository). It must not change the process's working directory, or it will "
11617 "cause any calls it makes into the Mercurial API to fail."
11618 msgstr ""
11620 #. type: Content of: <book><chapter><sect1><sect2><para>
11621 #: ../en/ch09-hook.xml:1335
11622 msgid ""
11623 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
11624 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
11625 "an exception, it is considered to have failed. A useful way to think of the "
11626 "calling convention is <quote>tell me if you fail</quote>."
11627 msgstr ""
11629 #. type: Content of: <book><chapter><sect1><sect2><para>
11630 #: ../en/ch09-hook.xml:1342
11631 msgid ""
11632 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
11633 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
11634 "from hex to binary, use the <literal>bin</literal> function."
11635 msgstr ""
11637 #. type: Content of: <book><chapter><sect1><sect2><title>
11638 #: ../en/ch09-hook.xml:1350
11639 msgid "External hook execution"
11640 msgstr "外部钩子的执行"
11642 #. type: Content of: <book><chapter><sect1><sect2><para>
11643 #: ../en/ch09-hook.xml:1352
11644 msgid ""
11645 "An external hook is passed to the shell of the user running Mercurial. "
11646 "Features of that shell, such as variable substitution and command "
11647 "redirection, are available. The hook is run in the root directory of the "
11648 "repository (unlike in-process hooks, which are run in the same directory that "
11649 "Mercurial was run in)."
11650 msgstr ""
11652 #. type: Content of: <book><chapter><sect1><sect2><para>
11653 #: ../en/ch09-hook.xml:1360
11654 msgid ""
11655 "Hook parameters are passed to the hook as environment variables. Each "
11656 "environment variable's name is converted in upper case and prefixed with the "
11657 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
11658 "parameter is <quote><literal>node</literal></quote>, the name of the "
11659 "environment variable representing that parameter will be "
11660 "<quote><literal>HG_NODE</literal></quote>."
11661 msgstr ""
11663 #. type: Content of: <book><chapter><sect1><sect2><para>
11664 #: ../en/ch09-hook.xml:1369
11665 msgid ""
11666 "A boolean parameter is represented as the string <quote><literal>1</literal></"
11667 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
11668 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
11669 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
11670 "changeset ID represented as a hexadecimal string. The empty string is used "
11671 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
11672 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
11673 "the URL of a remote repository, if that can be determined."
11674 msgstr ""
11676 #. type: Content of: <book><chapter><sect1><sect2><para>
11677 #: ../en/ch09-hook.xml:1381
11678 msgid ""
11679 "If a hook exits with a status of zero, it is considered to have succeeded. "
11680 "If it exits with a non-zero status, it is considered to have failed."
11681 msgstr ""
11683 #. type: Content of: <book><chapter><sect1><sect2><title>
11684 #: ../en/ch09-hook.xml:1388
11685 msgid "Finding out where changesets come from"
11686 msgstr "检查修改集来自何处"
11688 #. type: Content of: <book><chapter><sect1><sect2><para>
11689 #: ../en/ch09-hook.xml:1390
11690 msgid ""
11691 "A hook that involves the transfer of changesets between a local repository "
11692 "and another may be able to find out information about the <quote>far side</"
11693 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
11694 "transferred, and in many cases <emphasis>where</emphasis> they are being "
11695 "transferred to or from."
11696 msgstr ""
11698 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11699 #: ../en/ch09-hook.xml:1399
11700 msgid "Sources of changesets"
11701 msgstr "修改集的来源"
11703 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11704 #: ../en/ch09-hook.xml:1401
11705 msgid ""
11706 "Mercurial will tell a hook what means are, or were, used to transfer "
11707 "changesets between repositories. This is provided by Mercurial in a Python "
11708 "parameter named <literal>source</literal>, or an environment variable named "
11709 "<envar>HG_SOURCE</envar>."
11710 msgstr ""
11712 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11713 #: ../en/ch09-hook.xml:1409
11714 msgid ""
11715 "<literal>serve</literal>: Changesets are transferred to or from a remote "
11716 "repository over http or ssh."
11717 msgstr ""
11719 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11720 #: ../en/ch09-hook.xml:1414
11721 msgid ""
11722 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
11723 "repository into another."
11724 msgstr ""
11726 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11727 #: ../en/ch09-hook.xml:1419
11728 msgid ""
11729 "<literal>push</literal>: Changesets are being transferred via a push from one "
11730 "repository into another."
11731 msgstr ""
11733 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11734 #: ../en/ch09-hook.xml:1424
11735 msgid ""
11736 "<literal>bundle</literal>: Changesets are being transferred to or from a "
11737 "bundle."
11738 msgstr ""
11740 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
11741 #: ../en/ch09-hook.xml:1431
11742 msgid "Where changes are going&emdash;remote repository URLs"
11743 msgstr "修改集要到哪里—远程版本库的地址"
11745 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11746 #: ../en/ch09-hook.xml:1434
11747 msgid ""
11748 "When possible, Mercurial will tell a hook the location of the <quote>far "
11749 "side</quote> of an activity that transfers changeset data between "
11750 "repositories. This is provided by Mercurial in a Python parameter named "
11751 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
11752 "envar>."
11753 msgstr ""
11755 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
11756 #: ../en/ch09-hook.xml:1442
11757 msgid ""
11758 "This information is not always known. If a hook is invoked in a repository "
11759 "that is being served via http or ssh, Mercurial cannot tell where the remote "
11760 "repository is, but it may know where the client is connecting from. In such "
11761 "cases, the URL will take one of the following forms:"
11762 msgstr ""
11764 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11765 #: ../en/ch09-hook.xml:1449
11766 msgid ""
11767 "<literal>remote:ssh:1.2.3.4</literal>&emdash;remote ssh client, at the IP "
11768 "address <literal>1.2.3.4</literal>."
11769 msgstr ""
11771 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11772 #: ../en/ch09-hook.xml:1454
11773 msgid ""
11774 "<literal>remote:http:1.2.3.4</literal>&emdash;remote http client, at the IP "
11775 "address <literal>1.2.3.4</literal>. If the client is using SSL, this will be "
11776 "of the form <literal>remote:https:1.2.3.4</literal>."
11777 msgstr ""
11779 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
11780 #: ../en/ch09-hook.xml:1461
11781 msgid "Empty&emdash;no information could be discovered about the remote client."
11782 msgstr ""
11784 #. type: Content of: <book><chapter><sect1><title>
11785 #: ../en/ch09-hook.xml:1470
11786 msgid "Hook reference"
11787 msgstr "钩子参考"
11789 #. type: Content of: <book><chapter><sect1><sect2><title>
11790 #: ../en/ch09-hook.xml:1473
11791 msgid ""
11792 "<literal role=\"hook\">changegroup</literal>&emdash;after remote changesets "
11793 "added"
11794 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
11796 #. type: Content of: <book><chapter><sect1><sect2><para>
11797 #: ../en/ch09-hook.xml:1476
11798 msgid ""
11799 "This hook is run after a group of pre-existing changesets has been added to "
11800 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
11801 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
11802 "operation that added one or more changesets. This is in contrast to the "
11803 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
11804 "changeset, regardless of whether the changesets arrive in a group."
11805 msgstr ""
11807 #. type: Content of: <book><chapter><sect1><sect2><para>
11808 #: ../en/ch09-hook.xml:1486
11809 msgid ""
11810 "Some possible uses for this hook include kicking off an automated build or "
11811 "test of the added changesets, updating a bug database, or notifying "
11812 "subscribers that a repository contains new changes."
11813 msgstr ""
11815 #. type: Content of: <book><chapter><sect1><sect2><para>
11816 #: ../en/ch09-hook.xml:1492 ../en/ch09-hook.xml:1532 ../en/ch09-hook.xml:1576
11817 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
11818 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1783 ../en/ch09-hook.xml:1846
11819 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1940 ../en/ch09-hook.xml:1967
11820 msgid "Parameters to this hook:"
11821 msgstr ""
11823 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11824 #: ../en/ch09-hook.xml:1495 ../en/ch09-hook.xml:1849
11825 msgid ""
11826 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
11827 "changeset in the group that was added. All changesets between this and "
11828 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
11829 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
11830 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
11831 msgstr ""
11833 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11834 #: ../en/ch09-hook.xml:1504 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
11835 #: ../en/ch09-hook.xml:1859
11836 msgid ""
11837 "<literal>source</literal>: A string. The source of these changes. See <xref "
11838 "linkend=\"sec:hook:sources\"/> for details."
11839 msgstr ""
11841 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11842 #: ../en/ch09-hook.xml:1509 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
11843 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1762 ../en/ch09-hook.xml:1864
11844 msgid ""
11845 "<literal>url</literal>: A URL. The location of the remote repository, if "
11846 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
11847 msgstr ""
11849 #. type: Content of: <book><chapter><sect1><sect2><para>
11850 #: ../en/ch09-hook.xml:1515
11851 msgid ""
11852 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
11853 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
11854 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
11855 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
11856 msgstr ""
11858 #. type: Content of: <book><chapter><sect1><sect2><title>
11859 #: ../en/ch09-hook.xml:1526
11860 msgid ""
11861 "<literal role=\"hook\">commit</literal>&emdash;after a new changeset is "
11862 "created"
11863 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
11865 #. type: Content of: <book><chapter><sect1><sect2><para>
11866 #: ../en/ch09-hook.xml:1529
11867 msgid "This hook is run after a new changeset has been created."
11868 msgstr ""
11870 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11871 #: ../en/ch09-hook.xml:1535 ../en/ch09-hook.xml:1907
11872 msgid ""
11873 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
11874 "committed changeset."
11875 msgstr ""
11877 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11878 #: ../en/ch09-hook.xml:1539 ../en/ch09-hook.xml:1911
11879 msgid ""
11880 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
11881 "parent of the newly committed changeset."
11882 msgstr ""
11884 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11885 #: ../en/ch09-hook.xml:1544 ../en/ch09-hook.xml:1916
11886 msgid ""
11887 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
11888 "parent of the newly committed changeset."
11889 msgstr ""
11891 #. type: Content of: <book><chapter><sect1><sect2><para>
11892 #: ../en/ch09-hook.xml:1550
11893 msgid ""
11894 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
11895 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
11896 "linkend=\"sec:hook:pretxncommit\"/>)"
11897 msgstr ""
11899 #. type: Content of: <book><chapter><sect1><sect2><title>
11900 #: ../en/ch09-hook.xml:1559
11901 msgid ""
11902 "<literal role=\"hook\">incoming</literal>&emdash;after one remote changeset "
11903 "is added"
11904 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
11906 #. type: Content of: <book><chapter><sect1><sect2><para>
11907 #: ../en/ch09-hook.xml:1562
11908 msgid ""
11909 "This hook is run after a pre-existing changeset has been added to the "
11910 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
11911 "a group of changesets was added in a single operation, this hook is called "
11912 "once for each added changeset."
11913 msgstr ""
11915 #. type: Content of: <book><chapter><sect1><sect2><para>
11916 #: ../en/ch09-hook.xml:1569
11917 msgid ""
11918 "You can use this hook for the same purposes as the <literal role=\"hook"
11919 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
11920 "it's simply more convenient sometimes to run a hook once per group of "
11921 "changesets, while other times it's handier once per changeset."
11922 msgstr ""
11924 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11925 #: ../en/ch09-hook.xml:1579
11926 msgid ""
11927 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
11928 msgstr ""
11930 #. type: Content of: <book><chapter><sect1><sect2><para>
11931 #: ../en/ch09-hook.xml:1594
11932 msgid ""
11933 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
11934 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
11935 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
11936 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
11937 ">)"
11938 msgstr ""
11940 #. type: Content of: <book><chapter><sect1><sect2><title>
11941 #: ../en/ch09-hook.xml:1605
11942 msgid ""
11943 "<literal role=\"hook\">outgoing</literal>&emdash;after changesets are "
11944 "propagated"
11945 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
11947 #. type: Content of: <book><chapter><sect1><sect2><para>
11948 #: ../en/ch09-hook.xml:1608
11949 msgid ""
11950 "This hook is run after a group of changesets has been propagated out of this "
11951 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
11952 "<command role=\"hg-cmd\">hg bundle</command> command."
11953 msgstr ""
11955 #. type: Content of: <book><chapter><sect1><sect2><para>
11956 #: ../en/ch09-hook.xml:1614
11957 msgid ""
11958 "One possible use for this hook is to notify administrators that changes have "
11959 "been pulled."
11960 msgstr ""
11962 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11963 #: ../en/ch09-hook.xml:1621
11964 msgid ""
11965 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
11966 "changeset of the group that was sent."
11967 msgstr ""
11969 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
11970 #: ../en/ch09-hook.xml:1626
11971 msgid ""
11972 "<literal>source</literal>: A string. The source of the of the operation (see "
11973 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
11974 "from this repository, <literal>source</literal> will be <literal>serve</"
11975 "literal>. If the client that obtained changes from this repository was "
11976 "local, <literal>source</literal> will be <literal>bundle</literal>, "
11977 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
11978 "operation the client performed."
11979 msgstr ""
11981 #. type: Content of: <book><chapter><sect1><sect2><para>
11982 #: ../en/ch09-hook.xml:1645
11983 msgid ""
11984 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
11985 "hook:preoutgoing\"/>)"
11986 msgstr ""
11988 #. type: Content of: <book><chapter><sect1><sect2><title>
11989 #: ../en/ch09-hook.xml:1652
11990 msgid ""
11991 "<literal role=\"hook\">prechangegroup</literal>&emdash;before starting to add "
11992 "remote changesets"
11993 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
11995 #. type: Content of: <book><chapter><sect1><sect2><para>
11996 #: ../en/ch09-hook.xml:1656
11997 msgid ""
11998 "This controlling hook is run before Mercurial begins to add a group of "
11999 "changesets from another repository."
12000 msgstr ""
12002 #. type: Content of: <book><chapter><sect1><sect2><para>
12003 #: ../en/ch09-hook.xml:1660
12004 msgid ""
12005 "This hook does not have any information about the changesets to be added, "
12006 "because it is run before transmission of those changesets is allowed to "
12007 "begin. If this hook fails, the changesets will not be transmitted."
12008 msgstr ""
12010 #. type: Content of: <book><chapter><sect1><sect2><para>
12011 #: ../en/ch09-hook.xml:1666
12012 msgid ""
12013 "One use for this hook is to prevent external changes from being added to a "
12014 "repository. For example, you could use this to <quote>freeze</quote> a "
12015 "server-hosted branch temporarily or permanently so that users cannot push to "
12016 "it, while still allowing a local administrator to modify the repository."
12017 msgstr ""
12019 #. type: Content of: <book><chapter><sect1><sect2><para>
12020 #: ../en/ch09-hook.xml:1687
12021 msgid ""
12022 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12023 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12024 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
12025 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
12026 msgstr ""
12028 #. type: Content of: <book><chapter><sect1><sect2><title>
12029 #: ../en/ch09-hook.xml:1698
12030 msgid ""
12031 "<literal role=\"hook\">precommit</literal>&emdash;before starting to commit a "
12032 "changeset"
12033 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
12035 #. type: Content of: <book><chapter><sect1><sect2><para>
12036 #: ../en/ch09-hook.xml:1701
12037 msgid ""
12038 "This hook is run before Mercurial begins to commit a new changeset. It is run "
12039 "before Mercurial has any of the metadata for the commit, such as the files to "
12040 "be committed, the commit message, or the commit date."
12041 msgstr ""
12043 #. type: Content of: <book><chapter><sect1><sect2><para>
12044 #: ../en/ch09-hook.xml:1707
12045 msgid ""
12046 "One use for this hook is to disable the ability to commit new changesets, "
12047 "while still allowing incoming changesets. Another is to run a build or test, "
12048 "and only allow the commit to begin if the build or test succeeds."
12049 msgstr ""
12051 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12052 #: ../en/ch09-hook.xml:1716
12053 msgid ""
12054 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
12055 "parent of the working directory."
12056 msgstr ""
12058 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12059 #: ../en/ch09-hook.xml:1721
12060 msgid ""
12061 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
12062 "parent of the working directory."
12063 msgstr ""
12065 #. type: Content of: <book><chapter><sect1><sect2><para>
12066 #: ../en/ch09-hook.xml:1726
12067 msgid ""
12068 "If the commit proceeds, the parents of the working directory will become the "
12069 "parents of the new changeset."
12070 msgstr ""
12072 #. type: Content of: <book><chapter><sect1><sect2><para>
12073 #: ../en/ch09-hook.xml:1730
12074 msgid ""
12075 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
12076 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
12077 "\"sec:hook:pretxncommit\"/>)"
12078 msgstr ""
12080 #. type: Content of: <book><chapter><sect1><sect2><title>
12081 #: ../en/ch09-hook.xml:1738
12082 msgid ""
12083 "<literal role=\"hook\">preoutgoing</literal>&emdash;before starting to "
12084 "propagate changesets"
12085 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
12087 #. type: Content of: <book><chapter><sect1><sect2><para>
12088 #: ../en/ch09-hook.xml:1741
12089 msgid ""
12090 "This hook is invoked before Mercurial knows the identities of the changesets "
12091 "to be transmitted."
12092 msgstr ""
12094 #. type: Content of: <book><chapter><sect1><sect2><para>
12095 #: ../en/ch09-hook.xml:1745
12096 msgid ""
12097 "One use for this hook is to prevent changes from being transmitted to another "
12098 "repository."
12099 msgstr ""
12101 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12102 #: ../en/ch09-hook.xml:1752
12103 msgid ""
12104 "<literal>source</literal>: A string. The source of the operation that is "
12105 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
12106 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
12107 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
12108 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
12109 msgstr ""
12111 #. type: Content of: <book><chapter><sect1><sect2><para>
12112 #: ../en/ch09-hook.xml:1768
12113 msgid ""
12114 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
12115 "outgoing\"/>)"
12116 msgstr ""
12118 #. type: Content of: <book><chapter><sect1><sect2><title>
12119 #: ../en/ch09-hook.xml:1775
12120 msgid ""
12121 "<literal role=\"hook\">pretag</literal>&emdash;before tagging a changeset"
12122 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
12124 #. type: Content of: <book><chapter><sect1><sect2><para>
12125 #: ../en/ch09-hook.xml:1778
12126 msgid ""
12127 "This controlling hook is run before a tag is created. If the hook succeeds, "
12128 "creation of the tag proceeds. If the hook fails, the tag is not created."
12129 msgstr ""
12131 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12132 #: ../en/ch09-hook.xml:1786
12133 msgid ""
12134 "<literal>local</literal>: A boolean. Whether the tag is local to this "
12135 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
12136 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
12137 "hgtags</filename>)."
12138 msgstr ""
12140 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12141 #: ../en/ch09-hook.xml:1793
12142 msgid ""
12143 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
12144 "tagged."
12145 msgstr ""
12147 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12148 #: ../en/ch09-hook.xml:1797
12149 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
12150 msgstr ""
12152 #. type: Content of: <book><chapter><sect1><sect2><para>
12153 #: ../en/ch09-hook.xml:1802
12154 msgid ""
12155 "If the tag to be created is revision-controlled, the <literal role=\"hook"
12156 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
12157 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
12158 "pretxncommit\"/>) will also be run."
12159 msgstr ""
12161 #. type: Content of: <book><chapter><sect1><sect2><para>
12162 #: ../en/ch09-hook.xml:1810
12163 msgid ""
12164 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
12165 "\"/>)"
12166 msgstr ""
12168 #. type: Content of: <book><chapter><sect1><sect2><title>
12169 #: ../en/ch09-hook.xml:1815
12170 msgid ""
12171 "<literal role=\"hook\">pretxnchangegroup</literal>&emdash;before completing "
12172 "addition of remote changesets"
12173 msgstr ""
12174 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
12176 #. type: Content of: <book><chapter><sect1><sect2><para>
12177 #: ../en/ch09-hook.xml:1819
12178 msgid ""
12179 "This controlling hook is run before a transaction&emdash;that manages the "
12180 "addition of a group of new changesets from outside the repository&emdash;"
12181 "completes. If the hook succeeds, the transaction completes, and all of the "
12182 "changesets become permanent within this repository. If the hook fails, the "
12183 "transaction is rolled back, and the data for the changesets is erased."
12184 msgstr ""
12186 #. type: Content of: <book><chapter><sect1><sect2><para>
12187 #: ../en/ch09-hook.xml:1828
12188 msgid ""
12189 "This hook can access the metadata associated with the almost-added "
12190 "changesets, but it should not do anything permanent with this data. It must "
12191 "also not modify the working directory."
12192 msgstr ""
12194 #. type: Content of: <book><chapter><sect1><sect2><para>
12195 #: ../en/ch09-hook.xml:1834
12196 msgid ""
12197 "While this hook is running, if other Mercurial processes access this "
12198 "repository, they will be able to see the almost-added changesets as if they "
12199 "are permanent. This may lead to race conditions if you do not take steps to "
12200 "avoid them."
12201 msgstr ""
12203 #. type: Content of: <book><chapter><sect1><sect2><para>
12204 #: ../en/ch09-hook.xml:1841
12205 msgid ""
12206 "This hook can be used to automatically vet a group of changesets. If the "
12207 "hook fails, all of the changesets are <quote>rejected</quote> when the "
12208 "transaction rolls back."
12209 msgstr ""
12211 #. type: Content of: <book><chapter><sect1><sect2><para>
12212 #: ../en/ch09-hook.xml:1870
12213 msgid ""
12214 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
12215 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
12216 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
12217 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
12218 msgstr ""
12220 #. type: Content of: <book><chapter><sect1><sect2><title>
12221 #: ../en/ch09-hook.xml:1881
12222 msgid ""
12223 "<literal role=\"hook\">pretxncommit</literal>&emdash;before completing commit "
12224 "of new changeset"
12225 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
12227 #. type: Content of: <book><chapter><sect1><sect2><para>
12228 #: ../en/ch09-hook.xml:1884
12229 msgid ""
12230 "This controlling hook is run before a transaction&emdash;that manages a new "
12231 "commit&emdash;completes. If the hook succeeds, the transaction completes and "
12232 "the changeset becomes permanent within this repository. If the hook fails, "
12233 "the transaction is rolled back, and the commit data is erased."
12234 msgstr ""
12236 #. type: Content of: <book><chapter><sect1><sect2><para>
12237 #: ../en/ch09-hook.xml:1892
12238 msgid ""
12239 "This hook can access the metadata associated with the almost-new changeset, "
12240 "but it should not do anything permanent with this data. It must also not "
12241 "modify the working directory."
12242 msgstr ""
12244 #. type: Content of: <book><chapter><sect1><sect2><para>
12245 #: ../en/ch09-hook.xml:1898
12246 msgid ""
12247 "While this hook is running, if other Mercurial processes access this "
12248 "repository, they will be able to see the almost-new changeset as if it is "
12249 "permanent. This may lead to race conditions if you do not take steps to "
12250 "avoid them."
12251 msgstr ""
12253 #. type: Content of: <book><chapter><sect1><sect2><para>
12254 #: ../en/ch09-hook.xml:1922
12255 msgid ""
12256 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
12257 "hook:precommit\"/>)"
12258 msgstr ""
12259 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
12260 "precommit\"/>)"
12262 #. type: Content of: <book><chapter><sect1><sect2><title>
12263 #: ../en/ch09-hook.xml:1929
12264 msgid ""
12265 "<literal role=\"hook\">preupdate</literal>&emdash;before updating or merging "
12266 "working directory"
12267 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
12269 #. type: Content of: <book><chapter><sect1><sect2><para>
12270 #: ../en/ch09-hook.xml:1932
12271 msgid ""
12272 "This controlling hook is run before an update or merge of the working "
12273 "directory begins. It is run only if Mercurial's normal pre-update checks "
12274 "determine that the update or merge can proceed. If the hook succeeds, the "
12275 "update or merge may proceed; if it fails, the update or merge does not start."
12276 msgstr ""
12278 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12279 #: ../en/ch09-hook.xml:1943
12280 msgid ""
12281 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12282 "working directory is to be updated to. If the working directory is being "
12283 "merged, it will not change this parent."
12284 msgstr ""
12286 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12287 #: ../en/ch09-hook.xml:1949
12288 msgid ""
12289 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
12290 "is being merged. The ID of the revision that the working directory is being "
12291 "merged with."
12292 msgstr ""
12294 #. type: Content of: <book><chapter><sect1><sect2><para>
12295 #: ../en/ch09-hook.xml:1956
12296 msgid ""
12297 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
12298 "update\"/>)"
12299 msgstr ""
12301 #. type: Content of: <book><chapter><sect1><sect2><title>
12302 #: ../en/ch09-hook.xml:1961
12303 msgid "<literal role=\"hook\">tag</literal>&emdash;after tagging a changeset"
12304 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
12306 #. type: Content of: <book><chapter><sect1><sect2><para>
12307 #: ../en/ch09-hook.xml:1964
12308 msgid "This hook is run after a tag has been created."
12309 msgstr ""
12311 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12312 #: ../en/ch09-hook.xml:1970
12313 msgid ""
12314 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
12315 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
12316 "localtags</filename>) or managed by Mercurial (stored in <filename role="
12317 "\"special\">.hgtags</filename>)."
12318 msgstr ""
12320 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12321 #: ../en/ch09-hook.xml:1978
12322 msgid ""
12323 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
12324 "tagged."
12325 msgstr ""
12327 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12328 #: ../en/ch09-hook.xml:1982
12329 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
12330 msgstr ""
12332 #. type: Content of: <book><chapter><sect1><sect2><para>
12333 #: ../en/ch09-hook.xml:1987
12334 msgid ""
12335 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
12336 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
12337 "this hook."
12338 msgstr ""
12340 #. type: Content of: <book><chapter><sect1><sect2><para>
12341 #: ../en/ch09-hook.xml:1992
12342 msgid ""
12343 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
12344 "pretag\"/>)"
12345 msgstr ""
12346 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
12347 "\"/>)"
12349 #. type: Content of: <book><chapter><sect1><sect2><title>
12350 #: ../en/ch09-hook.xml:1998
12351 msgid ""
12352 "<literal role=\"hook\">update</literal>&emdash;after updating or merging "
12353 "working directory"
12354 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
12356 #. type: Content of: <book><chapter><sect1><sect2><para>
12357 #: ../en/ch09-hook.xml:2001
12358 msgid ""
12359 "This hook is run after an update or merge of the working directory "
12360 "completes. Since a merge can fail (if the external <command>hgmerge</"
12361 "command> command fails to resolve conflicts in a file), this hook "
12362 "communicates whether the update or merge completed cleanly."
12363 msgstr ""
12365 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12366 #: ../en/ch09-hook.xml:2009
12367 msgid ""
12368 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
12369 "completed successfully."
12370 msgstr ""
12372 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12373 #: ../en/ch09-hook.xml:2014
12374 msgid ""
12375 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
12376 "working directory was updated to. If the working directory was merged, it "
12377 "will not have changed this parent."
12378 msgstr ""
12380 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
12381 #: ../en/ch09-hook.xml:2020
12382 msgid ""
12383 "<literal>parent2</literal>: A changeset ID. Only set if the working "
12384 "directory was merged. The ID of the revision that the working directory was "
12385 "merged with."
12386 msgstr ""
12388 #. type: Content of: <book><chapter><sect1><sect2><para>
12389 #: ../en/ch09-hook.xml:2026
12390 msgid ""
12391 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
12392 "hook:preupdate\"/>)"
12393 msgstr ""
12395 #. type: Content of: <book><chapter><title>
12396 #: ../en/ch10-template.xml:5
12397 msgid "Customising the output of Mercurial"
12398 msgstr "定制 Mercurial 的输出"
12400 #. type: Content of: <book><chapter><para>
12401 #: ../en/ch10-template.xml:7
12402 msgid ""
12403 "Mercurial provides a powerful mechanism to let you control how it displays "
12404 "information. The mechanism is based on templates. You can use templates to "
12405 "generate specific output for a single command, or to customise the entire "
12406 "appearance of the built-in web interface."
12407 msgstr ""
12409 #. type: Content of: <book><chapter><sect1><title>
12410 #: ../en/ch10-template.xml:14
12411 msgid "Using precanned output styles"
12412 msgstr "使用预定义的输出样式"
12414 #. type: Content of: <book><chapter><sect1><para>
12415 #: ../en/ch10-template.xml:16
12416 msgid ""
12417 "Packaged with Mercurial are some output styles that you can use immediately. "
12418 "A style is simply a precanned template that someone wrote and installed "
12419 "somewhere that Mercurial can find."
12420 msgstr ""
12422 #. type: Content of: <book><chapter><sect1><para>
12423 #: ../en/ch10-template.xml:21
12424 msgid ""
12425 "Before we take a look at Mercurial's bundled styles, let's review its normal "
12426 "output."
12427 msgstr ""
12429 #. type: Content of: <book><chapter><sect1><para>
12430 #: ../en/ch10-template.xml:26
12431 msgid ""
12432 "This is somewhat informative, but it takes up a lot of space&emdash;five "
12433 "lines of output per changeset. The <literal>compact</literal> style reduces "
12434 "this to three lines, presented in a sparse manner."
12435 msgstr ""
12437 #. type: Content of: <book><chapter><sect1><para>
12438 #: ../en/ch10-template.xml:33
12439 msgid ""
12440 "The <literal>changelog</literal> style hints at the expressive power of "
12441 "Mercurial's templating engine. This style attempts to follow the GNU "
12442 "Project's changelog guidelines<citation>web:changelog</citation>."
12443 msgstr ""
12445 #. type: Content of: <book><chapter><sect1><para>
12446 #: ../en/ch10-template.xml:40
12447 msgid ""
12448 "You will not be shocked to learn that Mercurial's default output style is "
12449 "named <literal>default</literal>."
12450 msgstr ""
12452 #. type: Content of: <book><chapter><sect1><sect2><title>
12453 #: ../en/ch10-template.xml:44
12454 msgid "Setting a default style"
12455 msgstr "设置默认样式"
12457 #. type: Content of: <book><chapter><sect1><sect2><para>
12458 #: ../en/ch10-template.xml:46
12459 msgid ""
12460 "You can modify the output style that Mercurial will use for every command by "
12461 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
12462 "style you would prefer to use."
12463 msgstr ""
12465 #. type: Content of: <book><chapter><sect1><sect2><para>
12466 #: ../en/ch10-template.xml:54
12467 msgid ""
12468 "If you write a style of your own, you can use it by either providing the path "
12469 "to your style file, or copying your style file into a location where "
12470 "Mercurial can find it (typically the <literal>templates</literal> "
12471 "subdirectory of your Mercurial install directory)."
12472 msgstr ""
12474 #. type: Content of: <book><chapter><sect1><title>
12475 #: ../en/ch10-template.xml:63
12476 msgid "Commands that support styles and templates"
12477 msgstr "支持样式和模版的命令"
12479 #. type: Content of: <book><chapter><sect1><para>
12480 #: ../en/ch10-template.xml:65
12481 msgid ""
12482 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
12483 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
12484 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
12485 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
12486 msgstr ""
12488 #. type: Content of: <book><chapter><sect1><para>
12489 #: ../en/ch10-template.xml:72
12490 msgid ""
12491 "As I write this manual, these are so far the only commands that support "
12492 "styles and templates. Since these are the most important commands that need "
12493 "customisable output, there has been little pressure from the Mercurial user "
12494 "community to add style and template support to other commands."
12495 msgstr ""
12497 #. type: Content of: <book><chapter><sect1><title>
12498 #: ../en/ch10-template.xml:80
12499 msgid "The basics of templating"
12500 msgstr "模版基础"
12502 #. type: Content of: <book><chapter><sect1><para>
12503 #: ../en/ch10-template.xml:82
12504 msgid ""
12505 "At its simplest, a Mercurial template is a piece of text. Some of the text "
12506 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
12507 "replaced with new text, when necessary."
12508 msgstr ""
12510 #. type: Content of: <book><chapter><sect1><para>
12511 #: ../en/ch10-template.xml:87
12512 msgid ""
12513 "Before we continue, let's look again at a simple example of Mercurial's "
12514 "normal output."
12515 msgstr ""
12517 #. type: Content of: <book><chapter><sect1><para>
12518 #: ../en/ch10-template.xml:92
12519 msgid ""
12520 "Now, let's run the same command, but using a template to change its output."
12521 msgstr ""
12523 #. type: Content of: <book><chapter><sect1><para>
12524 #: ../en/ch10-template.xml:97
12525 msgid ""
12526 "The example above illustrates the simplest possible template; it's just a "
12527 "piece of static text, printed once for each changeset. The <option role=\"hg-"
12528 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
12529 "command> command tells Mercurial to use the given text as the template when "
12530 "printing each changeset."
12531 msgstr ""
12533 #. type: Content of: <book><chapter><sect1><para>
12534 #: ../en/ch10-template.xml:105
12535 msgid ""
12536 "Notice that the template string above ends with the text <quote><literal>\\n</"
12537 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
12538 "Mercurial to print a newline at the end of each template item. If you omit "
12539 "this newline, Mercurial will run each piece of output together. See <xref "
12540 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
12541 msgstr ""
12543 #. type: Content of: <book><chapter><sect1><para>
12544 #: ../en/ch10-template.xml:113
12545 msgid ""
12546 "A template that prints a fixed string of text all the time isn't very useful; "
12547 "let's try something a bit more complex."
12548 msgstr ""
12550 #. type: Content of: <book><chapter><sect1><para>
12551 #: ../en/ch10-template.xml:119
12552 msgid ""
12553 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
12554 "template has been replaced in the output with the description of each "
12555 "changeset. Every time Mercurial finds text enclosed in curly braces "
12556 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
12557 "quote>), it will try to replace the braces and text with the expansion of "
12558 "whatever is inside. To print a literal curly brace, you must escape it, as "
12559 "described in <xref linkend=\"sec:template:escape\"/>."
12560 msgstr ""
12562 #. type: Content of: <book><chapter><sect1><title>
12563 #: ../en/ch10-template.xml:131
12564 msgid "Common template keywords"
12565 msgstr "模版关键字"
12567 #. type: Content of: <book><chapter><sect1><para>
12568 #: ../en/ch10-template.xml:133
12569 msgid ""
12570 "You can start writing simple templates immediately using the keywords below."
12571 msgstr ""
12573 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12574 #: ../en/ch10-template.xml:137
12575 msgid ""
12576 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
12577 "author of the changeset."
12578 msgstr ""
12580 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12581 #: ../en/ch10-template.xml:141
12582 msgid ""
12583 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
12584 "the branch on which the changeset was committed. Will be empty if the branch "
12585 "name was <literal>default</literal>."
12586 msgstr ""
12588 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12589 #: ../en/ch10-template.xml:147
12590 msgid ""
12591 "<literal role=\"template-keyword\">date</literal>: Date information. The "
12592 "date when the changeset was committed. This is <emphasis>not</emphasis> "
12593 "human-readable; you must pass it through a filter that will render it "
12594 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
12595 "information on filters. The date is expressed as a pair of numbers. The "
12596 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
12597 "second is the offset of the committer's timezone from UTC, in seconds."
12598 msgstr ""
12600 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12601 #: ../en/ch10-template.xml:158
12602 msgid ""
12603 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
12604 "changeset description."
12605 msgstr ""
12607 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12608 #: ../en/ch10-template.xml:161
12609 msgid ""
12610 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
12611 "files modified, added, or removed by this changeset."
12612 msgstr ""
12614 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12615 #: ../en/ch10-template.xml:166
12616 msgid ""
12617 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
12618 "Files added by this changeset."
12619 msgstr ""
12621 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12622 #: ../en/ch10-template.xml:170
12623 msgid ""
12624 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
12625 "Files removed by this changeset."
12626 msgstr ""
12628 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12629 #: ../en/ch10-template.xml:174
12630 msgid ""
12631 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
12632 "identification hash, as a 40-character hexadecimal string."
12633 msgstr ""
12635 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12636 #: ../en/ch10-template.xml:178
12637 msgid ""
12638 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
12639 "parents of the changeset."
12640 msgstr ""
12642 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12643 #: ../en/ch10-template.xml:182
12644 msgid ""
12645 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
12646 "local changeset revision number."
12647 msgstr ""
12649 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12650 #: ../en/ch10-template.xml:186
12651 msgid ""
12652 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
12653 "associated with the changeset."
12654 msgstr ""
12656 #. type: Content of: <book><chapter><sect1><para>
12657 #: ../en/ch10-template.xml:191
12658 msgid ""
12659 "A few simple experiments will show us what to expect when we use these "
12660 "keywords; you can see the results below."
12661 msgstr ""
12663 #. type: Content of: <book><chapter><sect1><para>
12664 #: ../en/ch10-template.xml:196
12665 msgid ""
12666 "As we noted above, the date keyword does not produce human-readable output, "
12667 "so we must treat it specially. This involves using a <emphasis>filter</"
12668 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
12669 msgstr ""
12671 #. type: Content of: <book><chapter><sect1><title>
12672 #: ../en/ch10-template.xml:205
12673 msgid "Escape sequences"
12674 msgstr "转义序列"
12676 #. type: Content of: <book><chapter><sect1><para>
12677 #: ../en/ch10-template.xml:207
12678 msgid ""
12679 "Mercurial's templating engine recognises the most commonly used escape "
12680 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
12681 "literal></quote>) character, it looks at the following character and "
12682 "substitutes the two characters with a single replacement, as described below."
12683 msgstr ""
12685 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12686 #: ../en/ch10-template.xml:214
12687 msgid ""
12688 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
12689 "134."
12690 msgstr ""
12692 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12693 #: ../en/ch10-template.xml:218
12694 msgid "<literal>\\n</literal>: Newline, ASCII 12."
12695 msgstr ""
12697 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12698 #: ../en/ch10-template.xml:221
12699 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
12700 msgstr ""
12702 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12703 #: ../en/ch10-template.xml:224
12704 msgid "<literal>\\t</literal>: Tab, ASCII 11."
12705 msgstr ""
12707 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12708 #: ../en/ch10-template.xml:227
12709 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
12710 msgstr ""
12712 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12713 #: ../en/ch10-template.xml:230
12714 msgid ""
12715 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
12716 "ASCII 173."
12717 msgstr ""
12719 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12720 #: ../en/ch10-template.xml:234
12721 msgid ""
12722 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
12723 "ASCII 175."
12724 msgstr ""
12726 #. type: Content of: <book><chapter><sect1><para>
12727 #: ../en/ch10-template.xml:239
12728 msgid ""
12729 "As indicated above, if you want the expansion of a template to contain a "
12730 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
12731 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
12732 msgstr ""
12734 #. type: Content of: <book><chapter><sect1><title>
12735 #: ../en/ch10-template.xml:247
12736 msgid "Filtering keywords to change their results"
12737 msgstr "通过过滤关键字来修改输出结果"
12739 #. type: Content of: <book><chapter><sect1><para>
12740 #: ../en/ch10-template.xml:249
12741 msgid ""
12742 "Some of the results of template expansion are not immediately easy to use. "
12743 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
12744 "to modify the result of expanding a keyword. You have already seen a common "
12745 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
12746 "above, to make a date readable."
12747 msgstr ""
12749 #. type: Content of: <book><chapter><sect1><para>
12750 #: ../en/ch10-template.xml:256
12751 msgid ""
12752 "Below is a list of the most commonly used filters that Mercurial supports. "
12753 "While some filters can be applied to any text, others can only be used in "
12754 "specific circumstances. The name of each filter is followed first by an "
12755 "indication of where it can be used, then a description of its effect."
12756 msgstr ""
12758 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12759 #: ../en/ch10-template.xml:263
12760 msgid ""
12761 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
12762 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
12763 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
12764 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
12765 msgstr ""
12767 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12768 #: ../en/ch10-template.xml:270
12769 msgid ""
12770 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
12771 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
12772 "relative to the current time. Yields a string like <quote><literal>10 "
12773 "minutes</literal></quote>."
12774 msgstr ""
12776 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12777 #: ../en/ch10-template.xml:277
12778 msgid ""
12779 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
12780 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
12781 "its relatives. Treat the text as a path, and return the basename. For "
12782 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
12783 "<quote><literal>baz</literal></quote>."
12784 msgstr ""
12786 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12787 #: ../en/ch10-template.xml:286
12788 msgid ""
12789 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
12790 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
12791 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
12792 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
12793 "15:13:13 2006 -0700</literal></quote>."
12794 msgstr ""
12796 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12797 #: ../en/ch10-template.xml:294
12798 msgid ""
12799 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
12800 "most useful for the <literal role=\"template-keyword\">author</literal> "
12801 "keyword. Finds the first string that looks like an email address, and "
12802 "extract just the domain component. For example, <quote><literal>Bryan "
12803 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
12804 "<quote><literal>serpentine.com</literal></quote>."
12805 msgstr ""
12807 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12808 #: ../en/ch10-template.xml:304
12809 msgid ""
12810 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
12811 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
12812 "Extract the first string that looks like an email address. For example, "
12813 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
12814 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
12815 msgstr ""
12817 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12818 #: ../en/ch10-template.xml:313
12819 msgid ""
12820 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
12821 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
12822 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
12823 "quote> with XML entities."
12824 msgstr ""
12826 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12827 #: ../en/ch10-template.xml:321
12828 msgid ""
12829 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
12830 "to fit in 68 columns. This is useful before you pass text through the "
12831 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
12832 "it to fit in an 80-column fixed-font window."
12833 msgstr ""
12835 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12836 #: ../en/ch10-template.xml:329
12837 msgid ""
12838 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
12839 "to fit in 76 columns."
12840 msgstr ""
12842 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12843 #: ../en/ch10-template.xml:333
12844 msgid ""
12845 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
12846 "first line of text, without any trailing newlines."
12847 msgstr ""
12849 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12850 #: ../en/ch10-template.xml:338
12851 msgid ""
12852 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
12853 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
12854 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
12855 "literal></quote>."
12856 msgstr ""
12858 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12859 #: ../en/ch10-template.xml:345
12860 msgid ""
12861 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
12862 "\"template-keyword\">date</literal> keyword. Render the date as a text "
12863 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
12864 "15:13:13 -0700</literal></quote>."
12865 msgstr ""
12867 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12868 #: ../en/ch10-template.xml:352
12869 msgid ""
12870 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
12871 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
12872 "Yield the input text rendered as a sequence of XML entities. This helps to "
12873 "defeat some particularly stupid screen-scraping email harvesting spambots."
12874 msgstr ""
12876 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12877 #: ../en/ch10-template.xml:360
12878 msgid ""
12879 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
12880 "most useful for the <literal role=\"template-keyword\">author</literal> "
12881 "keyword. Yield the text before an email address. For example, "
12882 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
12883 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
12884 msgstr ""
12886 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12887 #: ../en/ch10-template.xml:369
12888 msgid ""
12889 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
12890 "\"template-keyword\">date</literal> keyword. Render a date using the same "
12891 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
12892 "Sep 2006 15:13:13 -0700</literal></quote>."
12893 msgstr ""
12895 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12896 #: ../en/ch10-template.xml:376
12897 msgid ""
12898 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
12899 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
12900 "string."
12901 msgstr ""
12903 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12904 #: ../en/ch10-template.xml:381
12905 msgid ""
12906 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
12907 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
12908 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
12909 "quote>."
12910 msgstr ""
12912 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12913 #: ../en/ch10-template.xml:387
12914 msgid ""
12915 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
12916 "leading and trailing whitespace from the string."
12917 msgstr ""
12919 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12920 #: ../en/ch10-template.xml:391
12921 msgid ""
12922 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
12923 "text, with every line except the first starting with a tab character."
12924 msgstr ""
12926 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12927 #: ../en/ch10-template.xml:396
12928 msgid ""
12929 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
12930 "characters that are considered <quote>special</quote> by URL parsers. For "
12931 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
12932 msgstr ""
12934 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
12935 #: ../en/ch10-template.xml:403
12936 msgid ""
12937 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
12938 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
12939 "Return the <quote>user</quote> portion of an email address. For example, "
12940 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
12941 "becomes <quote><literal>bos</literal></quote>."
12942 msgstr ""
12944 #. type: Content of: <book><chapter><sect1><note><para>
12945 #: ../en/ch10-template.xml:416
12946 msgid ""
12947 "If you try to apply a filter to a piece of data that it cannot process, "
12948 "Mercurial will fail and print a Python exception. For example, trying to run "
12949 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
12950 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
12951 "not a good idea."
12952 msgstr ""
12954 #. type: Content of: <book><chapter><sect1><sect2><title>
12955 #: ../en/ch10-template.xml:425
12956 msgid "Combining filters"
12957 msgstr "组合过滤器"
12959 #. type: Content of: <book><chapter><sect1><sect2><para>
12960 #: ../en/ch10-template.xml:427
12961 msgid ""
12962 "It is easy to combine filters to yield output in the form you would like. "
12963 "The following chain of filters tidies up a description, then makes sure that "
12964 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
12965 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
12966 "wide)."
12967 msgstr ""
12969 #. type: Content of: <book><chapter><sect1><sect2><para>
12970 #: ../en/ch10-template.xml:436
12971 msgid ""
12972 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
12973 "the template to force the first line to be indented; this is necessary since "
12974 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
12975 "<emphasis>except</emphasis> the first."
12976 msgstr ""
12978 #. type: Content of: <book><chapter><sect1><sect2><para>
12979 #: ../en/ch10-template.xml:442
12980 msgid ""
12981 "Keep in mind that the order of filters in a chain is significant. The first "
12982 "filter is applied to the result of the keyword; the second to the result of "
12983 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
12984 "literal> gives very different results from <literal>tabindent|fill68</"
12985 "literal>."
12986 msgstr ""
12988 #. type: Content of: <book><chapter><sect1><title>
12989 #: ../en/ch10-template.xml:453
12990 msgid "From templates to styles"
12991 msgstr "从模版到样式"
12993 #. type: Content of: <book><chapter><sect1><para>
12994 #: ../en/ch10-template.xml:455
12995 msgid ""
12996 "A command line template provides a quick and simple way to format some "
12997 "output. Templates can become verbose, though, and it's useful to be able to "
12998 "give a template a name. A style file is a template with a name, stored in a "
12999 "file."
13000 msgstr ""
13002 #. type: Content of: <book><chapter><sect1><para>
13003 #: ../en/ch10-template.xml:460
13004 msgid ""
13005 "More than that, using a style file unlocks the power of Mercurial's "
13006 "templating engine in ways that are not possible using the command line "
13007 "<option role=\"hg-opt-log\">--template</option> option."
13008 msgstr ""
13010 #. type: Content of: <book><chapter><sect1><sect2><title>
13011 #: ../en/ch10-template.xml:466
13012 msgid "The simplest of style files"
13013 msgstr "最简单的样式文件"
13015 #. type: Content of: <book><chapter><sect1><sect2><para>
13016 #: ../en/ch10-template.xml:468
13017 msgid "Our simple style file contains just one line:"
13018 msgstr ""
13020 #. type: Content of: <book><chapter><sect1><sect2><para>
13021 #: ../en/ch10-template.xml:472
13022 msgid ""
13023 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
13024 "the right as the template</quote>."
13025 msgstr ""
13027 #. type: Content of: <book><chapter><sect1><sect2><title>
13028 #: ../en/ch10-template.xml:478
13029 msgid "Style file syntax"
13030 msgstr "样式文件语法"
13032 #. type: Content of: <book><chapter><sect1><sect2><para>
13033 #: ../en/ch10-template.xml:480
13034 msgid "The syntax rules for a style file are simple."
13035 msgstr ""
13037 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13038 #: ../en/ch10-template.xml:483
13039 msgid "The file is processed one line at a time."
13040 msgstr ""
13042 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13043 #: ../en/ch10-template.xml:486
13044 msgid "Leading and trailing white space are ignored."
13045 msgstr ""
13047 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13048 #: ../en/ch10-template.xml:489
13049 msgid "Empty lines are skipped."
13050 msgstr ""
13052 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13053 #: ../en/ch10-template.xml:491
13054 msgid ""
13055 "If a line starts with either of the characters <quote><literal>#</literal></"
13056 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
13057 "a comment, and skipped as if empty."
13058 msgstr ""
13060 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13061 #: ../en/ch10-template.xml:496
13062 msgid ""
13063 "A line starts with a keyword. This must start with an alphabetic character "
13064 "or underscore, and can subsequently contain any alphanumeric character or "
13065 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
13066 "Za-z0-9_]*</literal>.)"
13067 msgstr ""
13069 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13070 #: ../en/ch10-template.xml:502
13071 msgid ""
13072 "The next element must be an <quote><literal>=</literal></quote> character, "
13073 "which can be preceded or followed by an arbitrary amount of white space."
13074 msgstr ""
13076 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13077 #: ../en/ch10-template.xml:507
13078 msgid ""
13079 "If the rest of the line starts and ends with matching quote characters "
13080 "(either single or double quote), it is treated as a template body."
13081 msgstr ""
13083 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13084 #: ../en/ch10-template.xml:511
13085 msgid ""
13086 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
13087 "character, it is treated as the name of a file; the contents of this file "
13088 "will be read and used as a template body."
13089 msgstr ""
13091 #. type: Content of: <book><chapter><sect1><title>
13092 #: ../en/ch10-template.xml:520
13093 msgid "Style files by example"
13094 msgstr "样式文件例子"
13096 #. type: Content of: <book><chapter><sect1><para>
13097 #: ../en/ch10-template.xml:522
13098 msgid ""
13099 "To illustrate how to write a style file, we will construct a few by example. "
13100 "Rather than provide a complete style file and walk through it, we'll mirror "
13101 "the usual process of developing a style file by starting with something very "
13102 "simple, and walking through a series of successively more complete examples."
13103 msgstr ""
13105 #. type: Content of: <book><chapter><sect1><sect2><title>
13106 #: ../en/ch10-template.xml:529
13107 msgid "Identifying mistakes in style files"
13108 msgstr "在样式文件中定位错误"
13110 #. type: Content of: <book><chapter><sect1><sect2><para>
13111 #: ../en/ch10-template.xml:531
13112 msgid ""
13113 "If Mercurial encounters a problem in a style file you are working on, it "
13114 "prints a terse error message that, once you figure out what it means, is "
13115 "actually quite useful."
13116 msgstr ""
13118 #. type: Content of: <book><chapter><sect1><sect2><para>
13119 #: ../en/ch10-template.xml:537
13120 msgid ""
13121 "Notice that <filename>broken.style</filename> attempts to define a "
13122 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
13123 "When instructed to use this style file, Mercurial promptly complains."
13124 msgstr ""
13126 #. type: Content of: <book><chapter><sect1><sect2><para>
13127 #: ../en/ch10-template.xml:544
13128 msgid "This error message looks intimidating, but it is not too hard to follow."
13129 msgstr ""
13131 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13132 #: ../en/ch10-template.xml:548
13133 msgid ""
13134 "The first component is simply Mercurial's way of saying <quote>I am giving "
13135 "up</quote>."
13136 msgstr ""
13138 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13139 #: ../en/ch10-template.xml:552
13140 msgid "Next comes the name of the style file that contains the error."
13141 msgstr ""
13143 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13144 #: ../en/ch10-template.xml:556
13145 msgid ""
13146 "Following the file name is the line number where the error was encountered."
13147 msgstr ""
13149 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13150 #: ../en/ch10-template.xml:560
13151 msgid "Finally, a description of what went wrong."
13152 msgstr ""
13154 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13155 #: ../en/ch10-template.xml:564
13156 msgid ""
13157 "The description of the problem is not always clear (as in this case), but "
13158 "even when it is cryptic, it is almost always trivial to visually inspect the "
13159 "offending line in the style file and see what is wrong."
13160 msgstr ""
13162 #. type: Content of: <book><chapter><sect1><sect2><title>
13163 #: ../en/ch10-template.xml:572
13164 msgid "Uniquely identifying a repository"
13165 msgstr "版本库的唯一标识"
13167 #. type: Content of: <book><chapter><sect1><sect2><para>
13168 #: ../en/ch10-template.xml:574
13169 msgid ""
13170 "If you would like to be able to identify a Mercurial repository <quote>fairly "
13171 "uniquely</quote> using a short string as an identifier, you can use the first "
13172 "revision in the repository."
13173 msgstr ""
13175 #. type: Content of: <book><chapter><sect1><sect2><para>
13176 #: ../en/ch10-template.xml:581
13177 msgid ""
13178 "This is not guaranteed to be unique, but it is nevertheless useful in many "
13179 "cases."
13180 msgstr ""
13182 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13183 #: ../en/ch10-template.xml:584
13184 msgid ""
13185 "It will not work in a completely empty repository, because such a repository "
13186 "does not have a revision zero."
13187 msgstr ""
13189 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13190 #: ../en/ch10-template.xml:588
13191 msgid ""
13192 "Neither will it work in the (extremely rare) case where a repository is a "
13193 "merge of two or more formerly independent repositories, and you still have "
13194 "those repositories around."
13195 msgstr ""
13197 #. type: Content of: <book><chapter><sect1><sect2><para>
13198 #: ../en/ch10-template.xml:593
13199 msgid "Here are some uses to which you could put this identifier:"
13200 msgstr ""
13202 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13203 #: ../en/ch10-template.xml:596
13204 msgid ""
13205 "As a key into a table for a database that manages repositories on a server."
13206 msgstr ""
13208 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13209 #: ../en/ch10-template.xml:599
13210 msgid ""
13211 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
13212 "emphasis>} tuple. Save this information away when you run an automated build "
13213 "or other activity, so that you can <quote>replay</quote> the build later if "
13214 "necessary."
13215 msgstr ""
13217 #. type: Content of: <book><chapter><sect1><sect2><title>
13218 #: ../en/ch10-template.xml:608
13219 msgid "Mimicking Subversion's output"
13220 msgstr "模仿 Subversion 的输出"
13223 #. type: Content of: <book><chapter><sect1><sect2><para>
13224 #: ../en/ch10-template.xml:610
13225 msgid ""
13226 "Let's try to emulate the default output format used by another revision "
13227 "control tool, Subversion."
13228 msgstr ""
13231 #. type: Content of: <book><chapter><sect1><sect2><para>
13232 #: ../en/ch10-template.xml:615
13233 msgid ""
13234 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
13235 "paste a hunk of its output into a file, and replace the text produced above "
13236 "by Subversion with the template values we'd like to see expanded."
13237 msgstr ""
13239 #. type: Content of: <book><chapter><sect1><sect2><para>
13240 #: ../en/ch10-template.xml:622
13241 msgid ""
13242 "There are a few small ways in which this template deviates from the output "
13243 "produced by Subversion."
13244 msgstr ""
13246 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13247 #: ../en/ch10-template.xml:625
13248 msgid ""
13249 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
13250 "Sep 2006</literal></quote> in the example output above) in parentheses. "
13251 "Mercurial's templating engine does not provide a way to display a date in "
13252 "this format without also printing the time and time zone."
13253 msgstr ""
13255 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13256 #: ../en/ch10-template.xml:632
13257 msgid ""
13258 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
13259 "<quote><literal>-</literal></quote> characters by ending the template with "
13260 "such a line. We use the templating engine's <literal role=\"template-keyword"
13261 "\">header</literal> keyword to print a separator line as the first line of "
13262 "output (see below), thus achieving similar output to Subversion."
13263 msgstr ""
13265 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13266 #: ../en/ch10-template.xml:641
13267 msgid ""
13268 "Subversion's output includes a count in the header of the number of lines in "
13269 "the commit message. We cannot replicate this in Mercurial; the templating "
13270 "engine does not currently provide a filter that counts the number of lines "
13271 "the template generates."
13272 msgstr ""
13275 #. type: Content of: <book><chapter><sect1><sect2><para>
13276 #: ../en/ch10-template.xml:647
13277 msgid ""
13278 "It took me no more than a minute or two of work to replace literal text from "
13279 "an example of Subversion's output with some keywords and filters to give the "
13280 "template above. The style file simply refers to the template."
13281 msgstr ""
13283 #. type: Content of: <book><chapter><sect1><sect2><para>
13284 #: ../en/ch10-template.xml:654
13285 msgid ""
13286 "We could have included the text of the template file directly in the style "
13287 "file by enclosing it in quotes and replacing the newlines with "
13288 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
13289 "style file too difficult to read. Readability is a good guide when you're "
13290 "trying to decide whether some text belongs in a style file, or in a template "
13291 "file that the style file points to. If the style file will look too big or "
13292 "cluttered if you insert a literal piece of text, drop it into a template "
13293 "instead."
13294 msgstr ""
13296 #. type: Content of: <book><chapter><title>
13297 #: ../en/ch11-mq.xml:5
13298 msgid "Managing change with Mercurial Queues"
13299 msgstr "使用 MQ 管理修改"
13301 #. type: Content of: <book><chapter><sect1><title>
13302 #: ../en/ch11-mq.xml:8
13303 msgid "The patch management problem"
13304 msgstr "补丁的管理问题"
13306 #. type: Content of: <book><chapter><sect1><para>
13307 #: ../en/ch11-mq.xml:10
13308 msgid ""
13309 "Here is a common scenario: you need to install a software package from "
13310 "source, but you find a bug that you must fix in the source before you can "
13311 "start using the package. You make your changes, forget about the package for "
13312 "a while, and a few months later you need to upgrade to a newer version of the "
13313 "package. If the newer version of the package still has the bug, you must "
13314 "extract your fix from the older source tree and apply it against the newer "
13315 "version. This is a tedious task, and it's easy to make mistakes."
13316 msgstr ""
13318 #. type: Content of: <book><chapter><sect1><para>
13319 #: ../en/ch11-mq.xml:20
13320 msgid ""
13321 "This is a simple case of the <quote>patch management</quote> problem. You "
13322 "have an <quote>upstream</quote> source tree that you can't change; you need "
13323 "to make some local changes on top of the upstream tree; and you'd like to be "
13324 "able to keep those changes separate, so that you can apply them to newer "
13325 "versions of the upstream source."
13326 msgstr ""
13328 #. type: Content of: <book><chapter><sect1><para>
13329 #: ../en/ch11-mq.xml:27
13330 msgid ""
13331 "The patch management problem arises in many situations. Probably the most "
13332 "visible is that a user of an open source software project will contribute a "
13333 "bug fix or new feature to the project's maintainers in the form of a patch."
13334 msgstr ""
13336 #. type: Content of: <book><chapter><sect1><para>
13337 #: ../en/ch11-mq.xml:32
13338 msgid ""
13339 "Distributors of operating systems that include open source software often "
13340 "need to make changes to the packages they distribute so that they will build "
13341 "properly in their environments."
13342 msgstr ""
13344 #. type: Content of: <book><chapter><sect1><para>
13345 #: ../en/ch11-mq.xml:37
13346 msgid ""
13347 "When you have few changes to maintain, it is easy to manage a single patch "
13348 "using the standard <command>diff</command> and <command>patch</command> "
13349 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
13350 "tools). Once the number of changes grows, it starts to make sense to maintain "
13351 "patches as discrete <quote>chunks of work,</quote> so that for example a "
13352 "single patch will contain only one bug fix (the patch might modify several "
13353 "files, but it's doing <quote>only one thing</quote>), and you may have a "
13354 "number of such patches for different bugs you need fixed and local changes "
13355 "you require. In this situation, if you submit a bug fix patch to the "
13356 "upstream maintainers of a package and they include your fix in a subsequent "
13357 "release, you can simply drop that single patch when you're updating to the "
13358 "newer release."
13359 msgstr ""
13361 #. type: Content of: <book><chapter><sect1><para>
13362 #: ../en/ch11-mq.xml:52
13363 msgid ""
13364 "Maintaining a single patch against an upstream tree is a little tedious and "
13365 "error-prone, but not difficult. However, the complexity of the problem grows "
13366 "rapidly as the number of patches you have to maintain increases. With more "
13367 "than a tiny number of patches in hand, understanding which ones you have "
13368 "applied and maintaining them moves from messy to overwhelming."
13369 msgstr ""
13371 #. type: Content of: <book><chapter><sect1><para>
13372 #: ../en/ch11-mq.xml:59
13373 msgid ""
13374 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
13375 "simply <quote>MQ</quote>), that massively simplifies the patch management "
13376 "problem."
13377 msgstr ""
13379 #. type: Content of: <book><chapter><sect1><title>
13380 #: ../en/ch11-mq.xml:65
13381 msgid "The prehistory of Mercurial Queues"
13382 msgstr "MQ 的历史"
13384 #. type: Content of: <book><chapter><sect1><para>
13385 #: ../en/ch11-mq.xml:67
13386 msgid ""
13387 "During the late 1990s, several Linux kernel developers started to maintain "
13388 "<quote>patch series</quote> that modified the behaviour of the Linux kernel. "
13389 "Some of these series were focused on stability, some on feature coverage, and "
13390 "others were more speculative."
13391 msgstr ""
13393 #. type: Content of: <book><chapter><sect1><para>
13394 #: ../en/ch11-mq.xml:73
13395 msgid ""
13396 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
13397 "published some shell scripts he had been using to automate the task of "
13398 "managing his patch queues. Andrew was successfully using these scripts to "
13399 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
13400 msgstr ""
13402 #. type: Content of: <book><chapter><sect1><sect2><title>
13403 #: ../en/ch11-mq.xml:80
13404 msgid "A patchwork quilt"
13405 msgstr ""
13407 #. type: Content of: <book><chapter><sect1><sect2><para>
13408 #: ../en/ch11-mq.xml:82
13409 msgid ""
13410 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
13411 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
13412 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
13413 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
13414 "quilt substantially automated patch management, it rapidly gained a large "
13415 "following among open source software developers."
13416 msgstr ""
13418 #. type: Content of: <book><chapter><sect1><sect2><para>
13419 #: ../en/ch11-mq.xml:91
13420 msgid ""
13421 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
13422 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
13423 "files you want to manage; it stores away the names and contents of those "
13424 "files. To fix a bug, you create a new patch (using a single command), edit "
13425 "the files you need to fix, then <quote>refresh</quote> the patch."
13426 msgstr ""
13428 #. type: Content of: <book><chapter><sect1><sect2><para>
13429 #: ../en/ch11-mq.xml:99
13430 msgid ""
13431 "The refresh step causes quilt to scan the directory tree; it updates the "
13432 "patch with all of the changes you have made. You can create another patch on "
13433 "top of the first, which will track the changes required to modify the tree "
13434 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
13435 "patches applied</quote>."
13436 msgstr ""
13438 #. type: Content of: <book><chapter><sect1><sect2><para>
13439 #: ../en/ch11-mq.xml:106
13440 msgid ""
13441 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
13442 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
13443 "from the directory tree. Quilt remembers which patches you have popped, "
13444 "though, so you can <quote>push</quote> a popped patch again, and the "
13445 "directory tree will be restored to contain the modifications in the patch. "
13446 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
13447 "and the topmost applied patch will be updated. This means that you can, at "
13448 "any time, change both which patches are applied and what modifications those "
13449 "patches make."
13450 msgstr ""
13452 #. type: Content of: <book><chapter><sect1><sect2><para>
13453 #: ../en/ch11-mq.xml:118
13454 msgid ""
13455 "Quilt knows nothing about revision control tools, so it works equally well on "
13456 "top of an unpacked tarball or a Subversion working copy."
13457 msgstr ""
13459 #. type: Content of: <book><chapter><sect1><sect2><title>
13460 #: ../en/ch11-mq.xml:124
13461 msgid "From patchwork quilt to Mercurial Queues"
13462 msgstr "从 patchwork quilt 到 MQ"
13464 #. type: Content of: <book><chapter><sect1><sect2><para>
13465 #: ../en/ch11-mq.xml:126
13466 msgid ""
13467 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
13468 "that he called Mercurial Queues, which added quilt-like behaviour to "
13469 "Mercurial."
13470 msgstr ""
13472 #. type: Content of: <book><chapter><sect1><sect2><para>
13473 #: ../en/ch11-mq.xml:130
13474 msgid ""
13475 "The key difference between quilt and MQ is that quilt knows nothing about "
13476 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
13477 "Mercurial. Each patch that you push is represented as a Mercurial "
13478 "changeset. Pop a patch, and the changeset goes away."
13479 msgstr ""
13481 #. type: Content of: <book><chapter><sect1><sect2><para>
13482 #: ../en/ch11-mq.xml:136
13483 msgid ""
13484 "Because quilt does not care about revision control tools, it is still a "
13485 "tremendously useful piece of software to know about for situations where you "
13486 "cannot use Mercurial and MQ."
13487 msgstr ""
13489 #. type: Content of: <book><chapter><sect1><title>
13490 #: ../en/ch11-mq.xml:144
13491 msgid "The huge advantage of MQ"
13492 msgstr "MQ 的巨大优势"
13494 #. type: Content of: <book><chapter><sect1><para>
13495 #: ../en/ch11-mq.xml:146
13496 msgid ""
13497 "I cannot overstate the value that MQ offers through the unification of "
13498 "patches and revision control."
13499 msgstr ""
13501 #. type: Content of: <book><chapter><sect1><para>
13502 #: ../en/ch11-mq.xml:149
13503 msgid ""
13504 "A major reason that patches have persisted in the free software and open "
13505 "source world&emdash;in spite of the availability of increasingly capable "
13506 "revision control tools over the years&emdash;is the <emphasis>agility</"
13507 "emphasis> they offer."
13508 msgstr ""
13510 #. type: Content of: <book><chapter><sect1><para>
13511 #: ../en/ch11-mq.xml:155
13512 msgid ""
13513 "Traditional revision control tools make a permanent, irreversible record of "
13514 "everything that you do. While this has great value, it's also somewhat "
13515 "stifling. If you want to perform a wild-eyed experiment, you have to be "
13516 "careful in how you go about it, or you risk leaving unneeded&emdash;or worse, "
13517 "misleading or destabilising&emdash;traces of your missteps and errors in the "
13518 "permanent revision record."
13519 msgstr ""
13521 #. type: Content of: <book><chapter><sect1><para>
13522 #: ../en/ch11-mq.xml:163
13523 msgid ""
13524 "By contrast, MQ's marriage of distributed revision control with patches makes "
13525 "it much easier to isolate your work. Your patches live on top of normal "
13526 "revision history, and you can make them disappear or reappear at will. If "
13527 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
13528 "it to be, simply fix it&emdash;as many times as you need to, until you have "
13529 "refined it into the form you desire."
13530 msgstr ""
13532 #. type: Content of: <book><chapter><sect1><para>
13533 #: ../en/ch11-mq.xml:171
13534 msgid ""
13535 "As an example, the integration of patches with revision control makes "
13536 "understanding patches and debugging their effects&emdash;and their interplay "
13537 "with the code they're based on&emdash;<emphasis>enormously</emphasis> easier. "
13538 "Since every applied patch has an associated changeset, you can give <command "
13539 "role=\"hg-cmd\">hg log</command> a file name to see which changesets and "
13540 "patches affected the file. You can use the <command role=\"hg-cmd\">hg "
13541 "bisect</command> command to binary-search through all changesets and applied "
13542 "patches to see where a bug got introduced or fixed. You can use the <command "
13543 "role=\"hg-cmd\">hg annotate</command> command to see which changeset or patch "
13544 "modified a particular line of a source file. And so on."
13545 msgstr ""
13547 #. type: Content of: <book><chapter><sect1><para>
13548 #: ../en/ch11-mq.xml:189
13549 msgid ""
13550 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
13551 "understand what patches are, and a little about the tools that work with them."
13552 msgstr ""
13554 #. type: Content of: <book><chapter><sect1><para>
13555 #: ../en/ch11-mq.xml:193
13556 msgid ""
13557 "The traditional Unix <command>diff</command> command compares two files, and "
13558 "prints a list of differences between them. The <command>patch</command> "
13559 "command understands these differences as <emphasis>modifications</emphasis> "
13560 "to make to a file. Take a look below for a simple example of these commands "
13561 "in action."
13562 msgstr ""
13564 #. type: Content of: <book><chapter><sect1><para>
13565 #: ../en/ch11-mq.xml:202
13566 msgid ""
13567 "The type of file that <command>diff</command> generates (and <command>patch</"
13568 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
13569 "quote>; there is no difference between a patch and a diff. (We'll use the "
13570 "term <quote>patch</quote>, since it's more commonly used.)"
13571 msgstr ""
13573 #. type: Content of: <book><chapter><sect1><para>
13574 #: ../en/ch11-mq.xml:208
13575 msgid ""
13576 "A patch file can start with arbitrary text; the <command>patch</command> "
13577 "command ignores this text, but MQ uses it as the commit message when creating "
13578 "changesets. To find the beginning of the patch content, <command>patch</"
13579 "command> searches for the first line that starts with the string "
13580 "<quote><literal>diff -</literal></quote>."
13581 msgstr ""
13583 #. type: Content of: <book><chapter><sect1><para>
13584 #: ../en/ch11-mq.xml:215
13585 msgid ""
13586 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
13587 "can accept several other diff formats, but MQ doesn't). A unified diff "
13588 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
13589 "the file being modified; it contains the name of the file to modify. When "
13590 "<command>patch</command> sees a new file header, it looks for a file with "
13591 "that name to start modifying."
13592 msgstr ""
13594 #. type: Content of: <book><chapter><sect1><para>
13595 #: ../en/ch11-mq.xml:223
13596 msgid ""
13597 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
13598 "hunk starts with a header; this identifies the range of line numbers within "
13599 "the file that the hunk should modify. Following the header, a hunk starts "
13600 "and ends with a few (usually three) lines of text from the unmodified file; "
13601 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
13602 "only a small amount of context between successive hunks, <command>diff</"
13603 "command> doesn't print a new hunk header; it just runs the hunks together, "
13604 "with a few lines of context between modifications."
13605 msgstr ""
13607 #. type: Content of: <book><chapter><sect1><para>
13608 #: ../en/ch11-mq.xml:235
13609 msgid ""
13610 "Each line of context begins with a space character. Within the hunk, a line "
13611 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
13612 "line,</quote> while a line that begins with <quote><literal>+</literal></"
13613 "quote> means <quote>insert this line.</quote> For example, a line that is "
13614 "modified is represented by one deletion and one insertion."
13615 msgstr ""
13617 #. type: Content of: <book><chapter><sect1><para>
13618 #: ../en/ch11-mq.xml:243
13619 msgid ""
13620 "We will return to some of the more subtle aspects of patches later (in <xref "
13621 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
13622 "to use MQ."
13623 msgstr ""
13625 #. type: Content of: <book><chapter><sect1><title>
13626 #: ../en/ch11-mq.xml:250
13627 msgid "Getting started with Mercurial Queues"
13628 msgstr "开始使用 MQ"
13630 #. type: Content of: <book><chapter><sect1><para>
13631 #: ../en/ch11-mq.xml:252
13632 msgid ""
13633 "Because MQ is implemented as an extension, you must explicitly enable before "
13634 "you can use it. (You don't need to download anything; MQ ships with the "
13635 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
13636 "\"home\">~/.hgrc</filename> file, and add the lines below."
13637 msgstr ""
13639 #. type: Content of: <book><chapter><sect1><para>
13640 #: ../en/ch11-mq.xml:262
13641 msgid ""
13642 "Once the extension is enabled, it will make a number of new commands "
13643 "available. To verify that the extension is working, you can use <command "
13644 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
13645 "\">qinit</command> command is now available."
13646 msgstr ""
13648 #. type: Content of: <book><chapter><sect1><para>
13649 #: ../en/ch11-mq.xml:270
13650 msgid ""
13651 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
13652 "commands only operate within that repository. To get started, simply prepare "
13653 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
13654 msgstr ""
13656 #. type: Content of: <book><chapter><sect1><para>
13657 #: ../en/ch11-mq.xml:277
13658 msgid ""
13659 "This command creates an empty directory called <filename role=\"special\" "
13660 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
13661 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
13662 "command> command prints nothing if it succeeds."
13663 msgstr ""
13665 #. type: Content of: <book><chapter><sect1><sect2><title>
13666 #: ../en/ch11-mq.xml:284
13667 msgid "Creating a new patch"
13668 msgstr "创建新补丁"
13670 #. type: Content of: <book><chapter><sect1><sect2><para>
13671 #: ../en/ch11-mq.xml:286
13672 msgid ""
13673 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
13674 "command> command. This command takes one argument, the name of the patch to "
13675 "create."
13676 msgstr ""
13678 #. type: Content of: <book><chapter><sect1><sect2><para>
13679 #: ../en/ch11-mq.xml:290
13680 msgid ""
13681 "MQ will use this as the name of an actual file in the <filename role=\"special"
13682 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
13683 msgstr ""
13685 #. type: Content of: <book><chapter><sect1><sect2><para>
13686 #: ../en/ch11-mq.xml:297
13687 msgid ""
13688 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
13689 "patches</filename> directory are two other files, <filename role=\"special"
13690 "\">series</filename> and <filename role=\"special\">status</filename>. The "
13691 "<filename role=\"special\">series</filename> file lists all of the patches "
13692 "that MQ knows about for this repository, with one patch per line. Mercurial "
13693 "uses the <filename role=\"special\">status</filename> file for internal book-"
13694 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
13695 "emphasis> in this repository."
13696 msgstr ""
13698 #. type: Content of: <book><chapter><sect1><sect2><note><para>
13699 #: ../en/ch11-mq.xml:309
13700 msgid ""
13701 "You may sometimes want to edit the <filename role=\"special\">series</"
13702 "filename> file by hand; for example, to change the sequence in which some "
13703 "patches are applied. However, manually editing the <filename role=\"special"
13704 "\">status</filename> file is almost always a bad idea, as it's easy to "
13705 "corrupt MQ's idea of what is happening."
13706 msgstr ""
13708 #. type: Content of: <book><chapter><sect1><sect2><para>
13709 #: ../en/ch11-mq.xml:318
13710 msgid ""
13711 "Once you have created your new patch, you can edit files in the working "
13712 "directory as you usually would. All of the normal Mercurial commands, such "
13713 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
13714 "annotate</command>, work exactly as they did before."
13715 msgstr ""
13717 #. type: Content of: <book><chapter><sect1><sect2><title>
13718 #: ../en/ch11-mq.xml:326
13719 msgid "Refreshing a patch"
13720 msgstr "刷新补丁"
13722 #. type: Content of: <book><chapter><sect1><sect2><para>
13723 #: ../en/ch11-mq.xml:328
13724 msgid ""
13725 "When you reach a point where you want to save your work, use the <command "
13726 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
13727 "working on."
13728 msgstr ""
13730 #. type: Content of: <book><chapter><sect1><sect2><para>
13731 #: ../en/ch11-mq.xml:334
13732 msgid ""
13733 "This command folds the changes you have made in the working directory into "
13734 "your patch, and updates its corresponding changeset to contain those changes."
13735 msgstr ""
13737 #. type: Content of: <book><chapter><sect1><sect2><para>
13738 #: ../en/ch11-mq.xml:338
13739 msgid ""
13740 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
13741 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
13742 "your patch at an opportune time; try an experiment; and if the experiment "
13743 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
13744 "modifications back to the last time you refreshed."
13745 msgstr ""
13747 #. type: Content of: <book><chapter><sect1><sect2><title>
13748 #: ../en/ch11-mq.xml:349
13749 msgid "Stacking and tracking patches"
13750 msgstr "堆叠和跟踪补丁"
13752 #. type: Content of: <book><chapter><sect1><sect2><para>
13753 #: ../en/ch11-mq.xml:351
13754 msgid ""
13755 "Once you have finished working on a patch, or need to work on another, you "
13756 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
13757 "create a new patch. Mercurial will apply this patch on top of your existing "
13758 "patch."
13759 msgstr ""
13761 #. type: Content of: <book><chapter><sect1><sect2><para>
13762 #: ../en/ch11-mq.xml:358
13763 msgid ""
13764 "Notice that the patch contains the changes in our prior patch as part of its "
13765 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
13766 "\">hg annotate</command>)."
13767 msgstr ""
13769 #. type: Content of: <book><chapter><sect1><sect2><para>
13770 #: ../en/ch11-mq.xml:363
13771 msgid ""
13772 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
13773 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
13774 "use regular Mercurial commands. However, MQ provides many commands that are "
13775 "easier to use when you are thinking about patches, as illustrated below."
13776 msgstr ""
13778 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13779 #: ../en/ch11-mq.xml:373
13780 msgid ""
13781 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
13782 "that MQ knows about in this repository, from oldest to newest (most recently "
13783 "<emphasis>created</emphasis>)."
13784 msgstr ""
13786 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
13787 #: ../en/ch11-mq.xml:379
13788 msgid ""
13789 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
13790 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
13791 "oldest to newest (most recently applied)."
13792 msgstr ""
13794 #. type: Content of: <book><chapter><sect1><sect2><title>
13795 #: ../en/ch11-mq.xml:388
13796 msgid "Manipulating the patch stack"
13797 msgstr "操作补丁堆栈"
13799 #. type: Content of: <book><chapter><sect1><sect2><para>
13800 #: ../en/ch11-mq.xml:390
13801 msgid ""
13802 "The previous discussion implied that there must be a difference between "
13803 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
13804 "can manage a patch without it being applied in the repository."
13805 msgstr ""
13807 #. type: Content of: <book><chapter><sect1><sect2><para>
13808 #: ../en/ch11-mq.xml:395
13809 msgid ""
13810 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
13811 "repository, and the effects of the patch and changeset are visible in the "
13812 "working directory. You can undo the application of a patch using the "
13813 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
13814 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
13815 "corresponding changeset in the repository, and the working directory does not "
13816 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
13817 "illustrates the difference between applied and tracked patches."
13818 msgstr ""
13820 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
13821 #: ../en/ch11-mq.xml:408
13822 msgid "Applied and unapplied patches in the MQ patch stack"
13823 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
13825 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
13826 #: ../en/ch11-mq.xml:411
13827 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
13828 msgstr ""
13830 #. type: Content of: <book><chapter><sect1><sect2><para>
13831 #: ../en/ch11-mq.xml:416
13832 msgid ""
13833 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
13834 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
13835 "to the patch, and the patch's changes once again become present in the "
13836 "working directory. See below for examples of <command role=\"hg-ext-mq"
13837 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
13838 msgstr ""
13840 #. type: Content of: <book><chapter><sect1><sect2><para>
13841 #: ../en/ch11-mq.xml:425
13842 msgid ""
13843 "Notice that once we have popped a patch or two patches, the output of "
13844 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
13845 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
13846 msgstr ""
13848 #. type: Content of: <book><chapter><sect1><sect2><title>
13849 #: ../en/ch11-mq.xml:433
13850 msgid "Pushing and popping many patches"
13851 msgstr "压入或弹出多个补丁"
13853 #. type: Content of: <book><chapter><sect1><sect2><para>
13854 #: ../en/ch11-mq.xml:435
13855 msgid ""
13856 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
13857 "mq\">qpop</command> each operate on a single patch at a time by default, you "
13858 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
13859 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
13860 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
13861 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
13862 "command> causes it to pop all applied patches. (For some more ways to push "
13863 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
13864 msgstr ""
13866 #. type: Content of: <book><chapter><sect1><sect2><title>
13867 #: ../en/ch11-mq.xml:451
13868 msgid "Safety checks, and overriding them"
13869 msgstr "安全的检查,然后覆盖它们"
13871 #. type: Content of: <book><chapter><sect1><sect2><para>
13872 #: ../en/ch11-mq.xml:453
13873 msgid ""
13874 "Several MQ commands check the working directory before they do anything, and "
13875 "fail if they find any modifications. They do this to ensure that you won't "
13876 "lose any changes that you have made, but not yet incorporated into a patch. "
13877 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
13878 "command> command will not create a new patch if there are outstanding "
13879 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
13880 "of <filename>file3</filename>."
13881 msgstr ""
13883 #. type: Content of: <book><chapter><sect1><sect2><para>
13884 #: ../en/ch11-mq.xml:465
13885 msgid ""
13886 "Commands that check the working directory all take an <quote>I know what I'm "
13887 "doing</quote> option, which is always named <option>-f</option>. The exact "
13888 "meaning of <option>-f</option> depends on the command. For example, <command "
13889 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
13890 "option></command> will incorporate any outstanding changes into the new patch "
13891 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
13892 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
13893 "affected by the patch that it is popping. Be sure to read the documentation "
13894 "for a command's <option>-f</option> option before you use it!"
13895 msgstr ""
13897 #. type: Content of: <book><chapter><sect1><sect2><title>
13898 #: ../en/ch11-mq.xml:480
13899 msgid "Working on several patches at once"
13900 msgstr "同时处理多个补丁"
13902 #. type: Content of: <book><chapter><sect1><sect2><para>
13903 #: ../en/ch11-mq.xml:482
13904 msgid ""
13905 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
13906 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
13907 "suspend work on one patch (by refreshing it), pop or push to make a different "
13908 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
13909 msgstr ""
13911 #. type: Content of: <book><chapter><sect1><sect2><para>
13912 #: ../en/ch11-mq.xml:489
13913 msgid ""
13914 "Here's an example that illustrates how you can use this ability. Let's say "
13915 "you're developing a new feature as two patches. The first is a change to the "
13916 "core of your software, and the second&emdash;layered on top of the "
13917 "first&emdash;changes the user interface to use the code you just added to the "
13918 "core. If you notice a bug in the core while you're working on the UI patch, "
13919 "it's easy to fix the core. Simply <command role=\"hg-ext-mq\">qrefresh</"
13920 "command> the UI patch to save your in-progress changes, and <command role="
13921 "\"hg-ext-mq\">qpop</command> down to the core patch. Fix the core bug, "
13922 "<command role=\"hg-ext-mq\">qrefresh</command> the core patch, and <command "
13923 "role=\"hg-ext-mq\">qpush</command> back to the UI patch to continue where you "
13924 "left off."
13925 msgstr ""
13927 #. type: Content of: <book><chapter><sect1><title>
13928 #: ../en/ch11-mq.xml:506
13929 msgid "More about patches"
13930 msgstr "关于补丁的更多信息"
13932 #. type: Content of: <book><chapter><sect1><para>
13933 #: ../en/ch11-mq.xml:508
13934 msgid ""
13935 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
13936 "helpful to know a few more detailed aspects of how <command>patch</command> "
13937 "works, and about patches themselves."
13938 msgstr ""
13940 #. type: Content of: <book><chapter><sect1><sect2><title>
13941 #: ../en/ch11-mq.xml:514
13942 msgid "The strip count"
13943 msgstr "修剪计数"
13945 #. type: Content of: <book><chapter><sect1><sect2><para>
13946 #: ../en/ch11-mq.xml:516
13947 msgid ""
13948 "If you look at the file headers in a patch, you will notice that the "
13949 "pathnames usually have an extra component on the front that isn't present in "
13950 "the actual path name. This is a holdover from the way that people used to "
13951 "generate patches (people still do this, but it's somewhat rare with modern "
13952 "revision control tools)."
13953 msgstr ""
13955 #. type: Content of: <book><chapter><sect1><sect2><para>
13956 #: ../en/ch11-mq.xml:523
13957 msgid ""
13958 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
13959 "create a patch. So she'd rename her working directory, unpack the tarball "
13960 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
13961 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
13962 "<command>diff</command> to recursively generate a patch between the "
13963 "unmodified directory and the modified one. The result would be that the name "
13964 "of the unmodified directory would be at the front of the left-hand path in "
13965 "every file header, and the name of the modified directory would be at the "
13966 "front of the right-hand path."
13967 msgstr ""
13969 #. type: Content of: <book><chapter><sect1><sect2><para>
13970 #: ../en/ch11-mq.xml:536
13971 msgid ""
13972 "Since someone receiving a patch from the Alices of the net would be unlikely "
13973 "to have unmodified and modified directories with exactly the same names, the "
13974 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
13975 "option> option that indicates the number of leading path name components to "
13976 "strip when trying to apply a patch. This number is called the "
13977 "<emphasis>strip count</emphasis>."
13978 msgstr ""
13980 #. type: Content of: <book><chapter><sect1><sect2><para>
13981 #: ../en/ch11-mq.xml:544
13982 msgid ""
13983 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
13984 "count of one</quote>. If <command>patch</command> sees a file name "
13985 "<filename>foo/bar/baz</filename> in a file header, it will strip "
13986 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
13987 "filename>. (Strictly speaking, the strip count refers to the number of "
13988 "<emphasis>path separators</emphasis> (and the components that go with them ) "
13989 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
13990 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
13991 "leading slash) into <filename>foo/bar</filename>.)"
13992 msgstr ""
13994 #. type: Content of: <book><chapter><sect1><sect2><para>
13995 #: ../en/ch11-mq.xml:557
13996 msgid ""
13997 "The <quote>standard</quote> strip count for patches is one; almost all "
13998 "patches contain one leading path name component that needs to be stripped. "
13999 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
14000 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
14001 "command and MQ expect patches to have a strip count of one."
14002 msgstr ""
14004 #. type: Content of: <book><chapter><sect1><sect2><para>
14005 #: ../en/ch11-mq.xml:565
14006 msgid ""
14007 "If you receive a patch from someone that you want to add to your patch queue, "
14008 "and the patch needs a strip count other than one, you cannot just <command "
14009 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
14010 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
14011 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
14012 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
14013 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
14014 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
14015 "command> to pick up any files added or removed by the patch, followed by "
14016 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
14017 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
14018 "mercurial/bts/issue311\">issue 311</ulink> for details."
14019 msgstr ""
14021 #. type: Content of: <book><chapter><sect1><sect2><title>
14022 #: ../en/ch11-mq.xml:584
14023 msgid "Strategies for applying a patch"
14024 msgstr "应用补丁的策略"
14026 #. type: Content of: <book><chapter><sect1><sect2><para>
14027 #: ../en/ch11-mq.xml:586
14028 msgid ""
14029 "When <command>patch</command> applies a hunk, it tries a handful of "
14030 "successively less accurate strategies to try to make the hunk apply. This "
14031 "falling-back technique often makes it possible to take a patch that was "
14032 "generated against an old version of a file, and apply it against a newer "
14033 "version of that file."
14034 msgstr ""
14036 #. type: Content of: <book><chapter><sect1><sect2><para>
14037 #: ../en/ch11-mq.xml:593
14038 msgid ""
14039 "First, <command>patch</command> tries an exact match, where the line numbers, "
14040 "the context, and the text to be modified must apply exactly. If it cannot "
14041 "make an exact match, it tries to find an exact match for the context, without "
14042 "honouring the line numbering information. If this succeeds, it prints a line "
14043 "of output saying that the hunk was applied, but at some <emphasis>offset</"
14044 "emphasis> from the original line number."
14045 msgstr ""
14047 #. type: Content of: <book><chapter><sect1><sect2><para>
14048 #: ../en/ch11-mq.xml:602
14049 msgid ""
14050 "If a context-only match fails, <command>patch</command> removes the first and "
14051 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
14052 "only match. If the hunk with reduced context succeeds, it prints a message "
14053 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
14054 "number after the fuzz factor indicates how many lines of context "
14055 "<command>patch</command> had to trim before the patch applied)."
14056 msgstr ""
14058 #. type: Content of: <book><chapter><sect1><sect2><para>
14059 #: ../en/ch11-mq.xml:611
14060 msgid ""
14061 "When neither of these techniques works, <command>patch</command> prints a "
14062 "message saying that the hunk in question was rejected. It saves rejected "
14063 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
14064 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
14065 "also saves an unmodified copy of the file with a <filename role=\"special\">."
14066 "orig</filename> extension; the copy of the file without any extensions will "
14067 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
14068 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
14069 "hunks, and one of them fails to apply, you will have: an unmodified "
14070 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
14071 "hunk, and <filename>foo</filename>, containing the changes made by the five "
14072 "successful hunks."
14073 msgstr ""
14075 #. type: Content of: <book><chapter><sect1><sect2><title>
14076 #: ../en/ch11-mq.xml:629
14077 msgid "Some quirks of patch representation"
14078 msgstr "补丁的一些特性"
14080 #. type: Content of: <book><chapter><sect1><sect2><para>
14081 #: ../en/ch11-mq.xml:631
14082 msgid ""
14083 "There are a few useful things to know about how <command>patch</command> "
14084 "works with files."
14085 msgstr ""
14087 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14088 #: ../en/ch11-mq.xml:634
14089 msgid ""
14090 "This should already be obvious, but <command>patch</command> cannot handle "
14091 "binary files."
14092 msgstr ""
14094 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14095 #: ../en/ch11-mq.xml:638
14096 msgid ""
14097 "Neither does it care about the executable bit; it creates new files as "
14098 "readable, but not executable."
14099 msgstr ""
14101 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14102 #: ../en/ch11-mq.xml:642
14103 msgid ""
14104 "<command>patch</command> treats the removal of a file as a diff between the "
14105 "file to be removed and the empty file. So your idea of <quote>I deleted this "
14106 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
14107 "a patch."
14108 msgstr ""
14110 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14111 #: ../en/ch11-mq.xml:648
14112 msgid ""
14113 "It treats the addition of a file as a diff between the empty file and the "
14114 "file to be added. So in a patch, your idea of <quote>I added this file</"
14115 "quote> looks like <quote>every line of this file was added</quote>."
14116 msgstr ""
14118 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14119 #: ../en/ch11-mq.xml:654
14120 msgid ""
14121 "It treats a renamed file as the removal of the old name, and the addition of "
14122 "the new name. This means that renamed files have a big footprint in "
14123 "patches. (Note also that Mercurial does not currently try to infer when "
14124 "files have been renamed or copied in a patch.)"
14125 msgstr ""
14127 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14128 #: ../en/ch11-mq.xml:660
14129 msgid ""
14130 "<command>patch</command> cannot represent empty files, so you cannot use a "
14131 "patch to represent the notion <quote>I added this empty file to the tree</"
14132 "quote>."
14133 msgstr ""
14135 #. type: Content of: <book><chapter><sect1><sect2><title>
14136 #: ../en/ch11-mq.xml:667
14137 msgid "Beware the fuzz"
14138 msgstr "当心毛刺"
14140 #. type: Content of: <book><chapter><sect1><sect2><para>
14141 #: ../en/ch11-mq.xml:669
14142 msgid ""
14143 "While applying a hunk at an offset, or with a fuzz factor, will often be "
14144 "completely successful, these inexact techniques naturally leave open the "
14145 "possibility of corrupting the patched file. The most common cases typically "
14146 "involve applying a patch twice, or at an incorrect location in the file. If "
14147 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
14148 "mentions an offset or fuzz factor, you should make sure that the modified "
14149 "files are correct afterwards."
14150 msgstr ""
14152 #. type: Content of: <book><chapter><sect1><sect2><para>
14153 #: ../en/ch11-mq.xml:679
14154 msgid ""
14155 "It's often a good idea to refresh a patch that has applied with an offset or "
14156 "fuzz factor; refreshing the patch generates new context information that will "
14157 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
14158 "quote> because sometimes refreshing a patch will make it fail to apply "
14159 "against a different revision of the underlying files. In some cases, such as "
14160 "when you're maintaining a patch that must sit on top of multiple versions of "
14161 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
14162 "you've verified the results of the patching process in such cases."
14163 msgstr ""
14165 #. type: Content of: <book><chapter><sect1><sect2><title>
14166 #: ../en/ch11-mq.xml:692
14167 msgid "Handling rejection"
14168 msgstr "处理拒绝"
14170 #. type: Content of: <book><chapter><sect1><sect2><para>
14171 #: ../en/ch11-mq.xml:694
14172 msgid ""
14173 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
14174 "will print an error message and exit. If it has left <filename role=\"special"
14175 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
14176 "hunks before you push more patches or do any further work."
14177 msgstr ""
14179 #. type: Content of: <book><chapter><sect1><sect2><para>
14180 #: ../en/ch11-mq.xml:700
14181 msgid ""
14182 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
14183 "because you've changed the underlying code that your patches are based on, "
14184 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
14185 msgstr ""
14187 #. type: Content of: <book><chapter><sect1><sect2><para>
14188 #: ../en/ch11-mq.xml:705
14189 msgid ""
14190 "Unfortunately, there aren't any great techniques for dealing with rejected "
14191 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
14192 "filename> file and edit the target file, applying the rejected hunks by hand."
14193 msgstr ""
14195 #. type: Content of: <book><chapter><sect1><sect2><para>
14196 #: ../en/ch11-mq.xml:710
14197 msgid ""
14198 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
14199 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
14200 "is more vigorous than <command>patch</command> in its attempts to make a "
14201 "patch apply."
14202 msgstr ""
14204 #. type: Content of: <book><chapter><sect1><sect2><para>
14205 #: ../en/ch11-mq.xml:716
14206 msgid ""
14207 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
14208 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
14209 "citation>, which takes a simple approach to automating the application of "
14210 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
14211 "command can help with four common reasons that a hunk may be rejected:"
14212 msgstr ""
14214 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14215 #: ../en/ch11-mq.xml:725
14216 msgid "The context in the middle of a hunk has changed."
14217 msgstr ""
14219 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14220 #: ../en/ch11-mq.xml:728
14221 msgid "A hunk is missing some context at the beginning or end."
14222 msgstr ""
14224 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14225 #: ../en/ch11-mq.xml:731
14226 msgid ""
14227 "A large hunk might apply better&emdash;either entirely or in part&emdash;if "
14228 "it was broken up into smaller hunks."
14229 msgstr ""
14231 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14232 #: ../en/ch11-mq.xml:735
14233 msgid ""
14234 "A hunk removes lines with slightly different content than those currently "
14235 "present in the file."
14236 msgstr ""
14238 #. type: Content of: <book><chapter><sect1><sect2><para>
14239 #: ../en/ch11-mq.xml:739
14240 msgid ""
14241 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
14242 "be doubly careful to check your results when you're done. In fact, "
14243 "<command>mpatch</command> enforces this method of double-checking the tool's "
14244 "output, by automatically dropping you into a merge program when it has done "
14245 "its job, so that you can verify its work and finish off any remaining merges."
14246 msgstr ""
14248 #. type: Content of: <book><chapter><sect1><title>
14249 #: ../en/ch11-mq.xml:751
14250 msgid "Getting the best performance out of MQ"
14251 msgstr "MQ 的性能"
14253 #. type: Content of: <book><chapter><sect1><para>
14254 #: ../en/ch11-mq.xml:753
14255 msgid ""
14256 "MQ is very efficient at handling a large number of patches. I ran some "
14257 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
14258 "EuroPython conference <citation>web:europython</citation>. I used as my data "
14259 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
14260 "applied these on top of a Linux kernel repository containing all 27,472 "
14261 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
14262 msgstr ""
14264 #. type: Content of: <book><chapter><sect1><para>
14265 #: ../en/ch11-mq.xml:762
14266 msgid ""
14267 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
14268 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
14269 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
14270 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
14271 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
14272 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
14273 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
14274 msgstr ""
14276 #. type: Content of: <book><chapter><sect1><para>
14277 #: ../en/ch11-mq.xml:773
14278 msgid ""
14279 "Clearly, MQ is well suited to working in large trees, but there are a few "
14280 "tricks you can use to get the best performance of it."
14281 msgstr ""
14283 #. type: Content of: <book><chapter><sect1><para>
14284 #: ../en/ch11-mq.xml:777
14285 msgid ""
14286 "First of all, try to <quote>batch</quote> operations together. Every time "
14287 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
14288 "mq\">qpop</command>, these commands scan the working directory once to make "
14289 "sure you haven't made some changes and then forgotten to run <command role="
14290 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
14291 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
14292 "thousands of files), it can take a second or more."
14293 msgstr ""
14295 #. type: Content of: <book><chapter><sect1><para>
14296 #: ../en/ch11-mq.xml:788
14297 msgid ""
14298 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
14299 "\">qpop</command> commands allow you to push and pop multiple patches at a "
14300 "time. You can identify the <quote>destination patch</quote> that you want to "
14301 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
14302 "destination specified, it will push patches until that patch is at the top of "
14303 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
14304 "destination, MQ will pop patches until the destination patch is at the top."
14305 msgstr ""
14307 #. type: Content of: <book><chapter><sect1><para>
14308 #: ../en/ch11-mq.xml:798
14309 msgid ""
14310 "You can identify a destination patch using either the name of the patch, or "
14311 "by number. If you use numeric addressing, patches are counted from zero; "
14312 "this means that the first patch is zero, the second is one, and so on."
14313 msgstr ""
14315 #. type: Content of: <book><chapter><sect1><title>
14316 #: ../en/ch11-mq.xml:805
14317 msgid "Updating your patches when the underlying code changes"
14318 msgstr "当基础代码改变时,更新补丁的方法"
14320 #. type: Content of: <book><chapter><sect1><para>
14321 #: ../en/ch11-mq.xml:808
14322 msgid ""
14323 "It's common to have a stack of patches on top of an underlying repository "
14324 "that you don't modify directly. If you're working on changes to third-party "
14325 "code, or on a feature that is taking longer to develop than the rate of "
14326 "change of the code beneath, you will often need to sync up with the "
14327 "underlying code, and fix up any hunks in your patches that no longer apply. "
14328 "This is called <emphasis>rebasing</emphasis> your patch series."
14329 msgstr ""
14331 #. type: Content of: <book><chapter><sect1><para>
14332 #: ../en/ch11-mq.xml:817
14333 msgid ""
14334 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
14335 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
14336 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
14337 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
14338 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
14339 "stop pushing any time it runs across a patch that fails to apply during "
14340 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
14341 "\">qrefresh</command> the affected patch, and continue pushing until you have "
14342 "fixed your entire stack."
14343 msgstr ""
14345 #. type: Content of: <book><chapter><sect1><para>
14346 #: ../en/ch11-mq.xml:829
14347 msgid ""
14348 "This approach is easy to use and works well if you don't expect changes to "
14349 "the underlying code to affect how well your patches apply. If your patch "
14350 "stack touches code that is modified frequently or invasively in the "
14351 "underlying repository, however, fixing up rejected hunks by hand quickly "
14352 "becomes tiresome."
14353 msgstr ""
14355 #. type: Content of: <book><chapter><sect1><para>
14356 #: ../en/ch11-mq.xml:836
14357 msgid ""
14358 "It's possible to partially automate the rebasing process. If your patches "
14359 "apply cleanly against some revision of the underlying repo, MQ can use this "
14360 "information to help you to resolve conflicts between your patches and a "
14361 "different revision."
14362 msgstr ""
14364 #. type: Content of: <book><chapter><sect1><para>
14365 #: ../en/ch11-mq.xml:842
14366 msgid "The process is a little involved."
14367 msgstr ""
14369 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14370 #: ../en/ch11-mq.xml:844
14371 msgid ""
14372 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
14373 "on top of the revision where you know that they apply cleanly."
14374 msgstr ""
14376 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14377 #: ../en/ch11-mq.xml:848
14378 msgid ""
14379 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
14380 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
14381 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
14382 "of the directory that it has saved the patches in. It will save the patches "
14383 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
14384 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
14385 "commits a <quote>save changeset</quote> on top of your applied patches; this "
14386 "is for internal book-keeping, and records the states of the <filename role="
14387 "\"special\">series</filename> and <filename role=\"special\">status</"
14388 "filename> files."
14389 msgstr ""
14391 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14392 #: ../en/ch11-mq.xml:862
14393 msgid ""
14394 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
14395 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
14396 "command>; see below for why.)"
14397 msgstr ""
14399 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14400 #: ../en/ch11-mq.xml:867
14401 msgid ""
14402 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
14403 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
14404 "you have pushed."
14405 msgstr ""
14407 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
14408 #: ../en/ch11-mq.xml:872
14409 msgid ""
14410 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
14411 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
14412 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
14413 "to apply."
14414 msgstr ""
14416 #. type: Content of: <book><chapter><sect1><para>
14417 #: ../en/ch11-mq.xml:880
14418 msgid ""
14419 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
14420 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
14421 "\"special\">series</filename> file is applied normally. If a patch applies "
14422 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
14423 "\">qsave</command>d, and performs a three-way merge with the corresponding "
14424 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
14425 "up a GUI merge tool to help you to resolve problems."
14426 msgstr ""
14428 #. type: Content of: <book><chapter><sect1><para>
14429 #: ../en/ch11-mq.xml:890
14430 msgid ""
14431 "When you finish resolving the effects of a patch, MQ refreshes your patch "
14432 "based on the result of the merge."
14433 msgstr ""
14435 #. type: Content of: <book><chapter><sect1><para>
14436 #: ../en/ch11-mq.xml:893
14437 msgid ""
14438 "At the end of this process, your repository will have one extra head from the "
14439 "old patch queue, and a copy of the old patch queue will be in <filename role="
14440 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
14441 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
14442 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
14443 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
14444 "sure that you no longer need it as a backup."
14445 msgstr ""
14447 #. type: Content of: <book><chapter><sect1><title>
14448 #: ../en/ch11-mq.xml:905
14449 msgid "Identifying patches"
14450 msgstr "标识补丁"
14452 #. type: Content of: <book><chapter><sect1><para>
14453 #: ../en/ch11-mq.xml:907
14454 msgid ""
14455 "MQ commands that work with patches let you refer to a patch either by using "
14456 "its name or by a number. By name is obvious enough; pass the name "
14457 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
14458 "command>, for example, and it will push patches until <filename>foo.patch</"
14459 "filename> is applied."
14460 msgstr ""
14462 #. type: Content of: <book><chapter><sect1><para>
14463 #: ../en/ch11-mq.xml:914
14464 msgid ""
14465 "As a shortcut, you can refer to a patch using both a name and a numeric "
14466 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
14467 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
14468 "means <quote>four patches after <literal>bar.patch</literal></quote>."
14469 msgstr ""
14471 #. type: Content of: <book><chapter><sect1><para>
14472 #: ../en/ch11-mq.xml:920
14473 msgid ""
14474 "Referring to a patch by index isn't much different. The first patch printed "
14475 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
14476 "(yes, it's one of those start-at-zero counting systems); the second is patch "
14477 "one; and so on."
14478 msgstr ""
14480 #. type: Content of: <book><chapter><sect1><para>
14481 #: ../en/ch11-mq.xml:926
14482 msgid ""
14483 "MQ also makes it easy to work with patches when you are using normal "
14484 "Mercurial commands. Every command that accepts a changeset ID will also "
14485 "accept the name of an applied patch. MQ augments the tags normally in the "
14486 "repository with an eponymous one for each applied patch. In addition, the "
14487 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
14488 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
14489 "patches, respectively."
14490 msgstr ""
14492 #. type: Content of: <book><chapter><sect1><para>
14493 #: ../en/ch11-mq.xml:936
14494 msgid ""
14495 "These additions to Mercurial's normal tagging capabilities make dealing with "
14496 "patches even more of a breeze."
14497 msgstr ""
14499 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14500 #: ../en/ch11-mq.xml:939
14501 msgid "Want to patchbomb a mailing list with your latest series of changes?"
14502 msgstr ""
14504 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14505 #: ../en/ch11-mq.xml:942
14506 msgid ""
14507 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
14508 "hgext:patchbomb\"/>.)"
14509 msgstr ""
14511 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14512 #: ../en/ch11-mq.xml:945
14513 msgid ""
14514 "Need to see all of the patches since <literal>foo.patch</literal> that have "
14515 "touched files in a subdirectory of your tree?"
14516 msgstr ""
14518 #. type: Content of: <book><chapter><sect1><para>
14519 #: ../en/ch11-mq.xml:952
14520 msgid ""
14521 "Because MQ makes the names of patches available to the rest of Mercurial "
14522 "through its normal internal tag machinery, you don't need to type in the "
14523 "entire name of a patch when you want to identify it by name."
14524 msgstr ""
14526 #. type: Content of: <book><chapter><sect1><para>
14527 #: ../en/ch11-mq.xml:957
14528 msgid ""
14529 "Another nice consequence of representing patch names as tags is that when you "
14530 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
14531 "patch's name as a tag, simply as part of its normal output. This makes it "
14532 "easy to visually distinguish applied patches from underlying <quote>normal</"
14533 "quote> revisions. The following example shows a few normal Mercurial "
14534 "commands in use with applied patches."
14535 msgstr ""
14537 #. type: Content of: <book><chapter><sect1><title>
14538 #: ../en/ch11-mq.xml:970
14539 msgid "Useful things to know about"
14540 msgstr "其它需要了解的东西"
14542 #. type: Content of: <book><chapter><sect1><para>
14543 #: ../en/ch11-mq.xml:972
14544 msgid ""
14545 "There are a number of aspects of MQ usage that don't fit tidily into sections "
14546 "of their own, but that are good to know. Here they are, in one place."
14547 msgstr ""
14549 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14550 #: ../en/ch11-mq.xml:977
14551 msgid ""
14552 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
14553 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
14554 "represents the patch after the pop/push will have a <emphasis>different "
14555 "identity</emphasis> than the changeset that represented the hash beforehand. "
14556 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
14557 msgstr ""
14559 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
14560 #: ../en/ch11-mq.xml:986
14561 msgid ""
14562 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
14563 "from another branch with a patch changeset, at least if you want to maintain "
14564 "the <quote>patchiness</quote> of that changeset and changesets below it on "
14565 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
14566 "will become confused."
14567 msgstr ""
14569 #. type: Content of: <book><chapter><sect1><title>
14570 #: ../en/ch11-mq.xml:997
14571 msgid "Managing patches in a repository"
14572 msgstr "在版本库管理补丁"
14574 #. type: Content of: <book><chapter><sect1><para>
14575 #: ../en/ch11-mq.xml:999
14576 msgid ""
14577 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
14578 "filename> directory resides outside a Mercurial repository's working "
14579 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
14580 "about the management or presence of patches."
14581 msgstr ""
14583 #. type: Content of: <book><chapter><sect1><para>
14584 #: ../en/ch11-mq.xml:1005
14585 msgid ""
14586 "This presents the interesting possibility of managing the contents of the "
14587 "patch directory as a Mercurial repository in its own right. This can be a "
14588 "useful way to work. For example, you can work on a patch for a while, "
14589 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
14590 "\">hg commit</command> the current state of the patch. This lets you "
14591 "<quote>roll back</quote> to that version of the patch later on."
14592 msgstr ""
14594 #. type: Content of: <book><chapter><sect1><para>
14595 #: ../en/ch11-mq.xml:1014
14596 msgid ""
14597 "You can then share different versions of the same patch stack among multiple "
14598 "underlying repositories. I use this when I am developing a Linux kernel "
14599 "feature. I have a pristine copy of my kernel sources for each of several CPU "
14600 "architectures, and a cloned repository under each that contains the patches I "
14601 "am working on. When I want to test a change on a different architecture, I "
14602 "push my current patches to the patch repository associated with that kernel "
14603 "tree, pop and push all of my patches, and build and test that kernel."
14604 msgstr ""
14606 #. type: Content of: <book><chapter><sect1><para>
14607 #: ../en/ch11-mq.xml:1024
14608 msgid ""
14609 "Managing patches in a repository makes it possible for multiple developers to "
14610 "work on the same patch series without colliding with each other, all on top "
14611 "of an underlying source base that they may or may not control."
14612 msgstr ""
14614 #. type: Content of: <book><chapter><sect1><sect2><title>
14615 #: ../en/ch11-mq.xml:1030
14616 msgid "MQ support for patch repositories"
14617 msgstr "MQ 支持补丁版本库"
14619 #. type: Content of: <book><chapter><sect1><sect2><para>
14620 #: ../en/ch11-mq.xml:1032
14621 msgid ""
14622 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
14623 "hg/patches</filename> directory as a repository; when you prepare a "
14624 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
14625 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
14626 "option> option to create the <filename role=\"special\" class=\"directory\">."
14627 "hg/patches</filename> directory as a Mercurial repository."
14628 msgstr ""
14630 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14631 #: ../en/ch11-mq.xml:1042
14632 msgid ""
14633 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
14634 "option> option, you can simply go into the <filename role=\"special\" class="
14635 "\"directory\">.hg/patches</filename> directory at any time and run <command "
14636 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
14637 "<filename role=\"special\">status</filename> file to the <filename role="
14638 "\"special\">.hgignore</filename> file, though"
14639 msgstr ""
14641 #. type: Content of: <book><chapter><sect1><sect2><note><para>
14642 #: ../en/ch11-mq.xml:1051
14643 msgid ""
14644 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
14645 "\">hg -c</option></command> does this for you automatically); you "
14646 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
14647 "\">status</filename> file."
14648 msgstr ""
14650 #. type: Content of: <book><chapter><sect1><sect2><para>
14651 #: ../en/ch11-mq.xml:1058
14652 msgid ""
14653 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
14654 "patches</filename> directory is a repository, it will automatically <command "
14655 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
14656 msgstr ""
14658 #. type: Content of: <book><chapter><sect1><sect2><para>
14659 #: ../en/ch11-mq.xml:1063
14660 msgid ""
14661 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
14662 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
14663 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
14664 "directory. This saves some bothersome typing."
14665 msgstr ""
14667 #. type: Content of: <book><chapter><sect1><sect2><para>
14668 #: ../en/ch11-mq.xml:1069
14669 msgid ""
14670 "Finally, as a convenience to manage the patch directory, you can define the "
14671 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
14672 "using the <command>bash</command> shell, you can include the following "
14673 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
14674 msgstr ""
14676 #. type: Content of: <book><chapter><sect1><sect2><para>
14677 #: ../en/ch11-mq.xml:1078
14678 msgid ""
14679 "You can then issue commands of the form <command>mq pull</command> from the "
14680 "main repository."
14681 msgstr ""
14683 #. type: Content of: <book><chapter><sect1><sect2><title>
14684 #: ../en/ch11-mq.xml:1083
14685 msgid "A few things to watch out for"
14686 msgstr "需要注意的事情"
14688 #. type: Content of: <book><chapter><sect1><sect2><para>
14689 #: ../en/ch11-mq.xml:1085
14690 msgid ""
14691 "MQ's support for working with a repository full of patches is limited in a "
14692 "few small respects."
14693 msgstr ""
14695 #. type: Content of: <book><chapter><sect1><sect2><para>
14696 #: ../en/ch11-mq.xml:1088
14697 msgid ""
14698 "MQ cannot automatically detect changes that you make to the patch directory. "
14699 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
14700 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
14701 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
14702 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
14703 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
14704 "opt\">hg -a</option></command> in the underlying repository to see those "
14705 "changes show up there. If you forget to do this, you can confuse MQ's idea "
14706 "of which patches are applied."
14707 msgstr ""
14709 #. type: Content of: <book><chapter><sect1><title>
14710 #: ../en/ch11-mq.xml:1104
14711 msgid "Third party tools for working with patches"
14712 msgstr "操作补丁的第三方工具"
14714 #. type: Content of: <book><chapter><sect1><para>
14715 #: ../en/ch11-mq.xml:1106
14716 msgid ""
14717 "Once you've been working with patches for a while, you'll find yourself "
14718 "hungry for tools that will help you to understand and manipulate the patches "
14719 "you're dealing with."
14720 msgstr ""
14722 #. type: Content of: <book><chapter><sect1><para>
14723 #: ../en/ch11-mq.xml:1110
14724 msgid ""
14725 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
14726 "generates a histogram of the modifications made to each file in a patch. It "
14727 "provides a good way to <quote>get a sense of</quote> a patch&emdash;which "
14728 "files it affects, and how much change it introduces to each file and as a "
14729 "whole. (I find that it's a good idea to use <command>diffstat</command>'s "
14730 "<option role=\"cmd-opt-diffstat\">-p</option> option as a matter of course, "
14731 "as otherwise it will try to do clever things with prefixes of file names that "
14732 "inevitably confuse at least me.)"
14733 msgstr ""
14735 #. type: Content of: <book><chapter><sect1><para>
14736 #: ../en/ch11-mq.xml:1124
14737 msgid ""
14738 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
14739 "patchutils</citation> is invaluable. It provides a set of small utilities "
14740 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
14741 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
14742 "use most is <command>filterdiff</command>, which extracts subsets from a "
14743 "patch file. For example, given a patch that modifies hundreds of files "
14744 "across dozens of directories, a single invocation of <command>filterdiff</"
14745 "command> can generate a smaller patch that only touches files whose names "
14746 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
14747 "\"/> for another example."
14748 msgstr ""
14750 #. type: Content of: <book><chapter><sect1><title>
14751 #: ../en/ch11-mq.xml:1140
14752 msgid "Good ways to work with patches"
14753 msgstr "操作补丁的好习惯"
14755 #. type: Content of: <book><chapter><sect1><para>
14756 #: ../en/ch11-mq.xml:1142
14757 msgid ""
14758 "Whether you are working on a patch series to submit to a free software or "
14759 "open source project, or a series that you intend to treat as a sequence of "
14760 "regular changesets when you're done, you can use some simple techniques to "
14761 "keep your work well organised."
14762 msgstr ""
14764 #. type: Content of: <book><chapter><sect1><para>
14765 #: ../en/ch11-mq.xml:1148
14766 msgid ""
14767 "Give your patches descriptive names. A good name for a patch might be "
14768 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
14769 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
14770 "problem; you won't be typing the names often, but you <emphasis>will</"
14771 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
14772 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
14773 "naming becomes especially important when you have a number of patches to work "
14774 "with, or if you are juggling a number of different tasks and your patches "
14775 "only get a fraction of your attention."
14776 msgstr ""
14778 #. type: Content of: <book><chapter><sect1><para>
14779 #: ../en/ch11-mq.xml:1160
14780 msgid ""
14781 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
14782 "\">qtop</command> command and skim over the text of your patches "
14783 "frequently&emdash;for example, using <command role=\"hg-cmd\">hg tip <option "
14784 "role=\"hg-opt-tip\">-p</option></command>)&emdash;to be sure of where you "
14785 "stand. I have several times worked on and <command role=\"hg-ext-mq"
14786 "\">qrefresh</command>ed a patch other than the one I intended, and it's often "
14787 "tricky to migrate changes into the right patch after making them in the wrong "
14788 "one."
14789 msgstr ""
14791 #. type: Content of: <book><chapter><sect1><para>
14792 #: ../en/ch11-mq.xml:1170
14793 msgid ""
14794 "For this reason, it is very much worth investing a little time to learn how "
14795 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
14796 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
14797 "command>. The former will give you a quick idea of what changes your patch "
14798 "is making, while the latter makes it easy to splice hunks selectively out of "
14799 "one patch and into another."
14800 msgstr ""
14802 #. type: Content of: <book><chapter><sect1><title>
14803 #: ../en/ch11-mq.xml:1181
14804 msgid "MQ cookbook"
14805 msgstr "MQ 手册"
14807 #. type: Content of: <book><chapter><sect1><sect2><title>
14808 #: ../en/ch11-mq.xml:1184
14809 msgid "Manage <quote>trivial</quote> patches"
14810 msgstr "管理<quote>琐碎的</quote>补丁"
14812 #. type: Content of: <book><chapter><sect1><sect2><para>
14813 #: ../en/ch11-mq.xml:1186
14814 msgid ""
14815 "Because the overhead of dropping files into a new Mercurial repository is so "
14816 "low, it makes a lot of sense to manage patches this way even if you simply "
14817 "want to make a few changes to a source tarball that you downloaded."
14818 msgstr ""
14821 #. type: Content of: <book><chapter><sect1><sect2><para>
14822 #: ../en/ch11-mq.xml:1191
14823 msgid ""
14824 "Begin by downloading and unpacking the source tarball, and turning it into a "
14825 "Mercurial repository."
14826 msgstr ""
14828 #. type: Content of: <book><chapter><sect1><sect2><para>
14829 #: ../en/ch11-mq.xml:1196
14830 msgid "Continue by creating a patch stack and making your changes."
14831 msgstr ""
14833 #. type: Content of: <book><chapter><sect1><sect2><para>
14834 #: ../en/ch11-mq.xml:1201
14835 msgid ""
14836 "Let's say a few weeks or months pass, and your package author releases a new "
14837 "version. First, bring their changes into the repository."
14838 msgstr ""
14840 #. type: Content of: <book><chapter><sect1><sect2><para>
14841 #: ../en/ch11-mq.xml:1207
14842 msgid ""
14843 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
14844 "deletes all files in the working directory, so that <command role=\"hg-cmd"
14845 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
14846 "option can actually tell which files have really been removed in the newer "
14847 "version of the source."
14848 msgstr ""
14850 #. type: Content of: <book><chapter><sect1><sect2><para>
14851 #: ../en/ch11-mq.xml:1215
14852 msgid "Finally, you can apply your patches on top of the new tree."
14853 msgstr ""
14855 #. type: Content of: <book><chapter><sect1><sect2><title>
14856 #: ../en/ch11-mq.xml:1222
14857 msgid "Combining entire patches"
14858 msgstr "组合全部的补丁"
14860 #. type: Content of: <book><chapter><sect1><sect2><para>
14861 #: ../en/ch11-mq.xml:1224
14862 msgid ""
14863 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
14864 "you combine entire patches. This <quote>folds</quote> the patches you name, "
14865 "in the order you name them, into the topmost applied patch, and concatenates "
14866 "their descriptions onto the end of its description. The patches that you "
14867 "fold must be unapplied before you fold them."
14868 msgstr ""
14870 #. type: Content of: <book><chapter><sect1><sect2><para>
14871 #: ../en/ch11-mq.xml:1232
14872 msgid ""
14873 "The order in which you fold patches matters. If your topmost applied patch "
14874 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
14875 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
14876 "end up with a patch that has the same effect as if you applied first "
14877 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
14878 "<literal>quux</literal>."
14879 msgstr ""
14881 #. type: Content of: <book><chapter><sect1><sect2><title>
14882 #: ../en/ch11-mq.xml:1243
14883 msgid "Merging part of one patch into another"
14884 msgstr "合并补丁的部分内容到其它补丁"
14886 #. type: Content of: <book><chapter><sect1><sect2><para>
14887 #: ../en/ch11-mq.xml:1245
14888 msgid ""
14889 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
14890 "than combining entire patches."
14891 msgstr ""
14893 #. type: Content of: <book><chapter><sect1><sect2><para>
14894 #: ../en/ch11-mq.xml:1249
14895 msgid ""
14896 "If you want to move changes to entire files, you can use <command>filterdiff</"
14897 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
14898 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
14899 "snip out of one patch, concatenating its output onto the end of the patch you "
14900 "want to merge into. You usually won't need to modify the patch you've merged "
14901 "the changes from. Instead, MQ will report some rejected hunks when you "
14902 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
14903 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
14904 "command> the patch to drop the duplicate hunks."
14905 msgstr ""
14907 #. type: Content of: <book><chapter><sect1><sect2><para>
14908 #: ../en/ch11-mq.xml:1262
14909 msgid ""
14910 "If you have a patch that has multiple hunks modifying a file, and you only "
14911 "want to move a few of those hunks, the job becomes more messy, but you can "
14912 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
14913 "metadata about the patch."
14914 msgstr ""
14916 #. type: Content of: <book><chapter><sect1><sect2><para>
14917 #: ../en/ch11-mq.xml:1270
14918 msgid "This command prints three different kinds of number:"
14919 msgstr ""
14921 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14922 #: ../en/ch11-mq.xml:1273
14923 msgid ""
14924 "(in the first column) a <emphasis>file number</emphasis> to identify each "
14925 "file modified in the patch;"
14926 msgstr ""
14928 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14929 #: ../en/ch11-mq.xml:1277
14930 msgid ""
14931 "(on the next line, indented) the line number within a modified file where a "
14932 "hunk starts; and"
14933 msgstr ""
14935 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
14936 #: ../en/ch11-mq.xml:1280
14937 msgid ""
14938 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
14939 msgstr ""
14941 #. type: Content of: <book><chapter><sect1><sect2><para>
14942 #: ../en/ch11-mq.xml:1284
14943 msgid ""
14944 "You'll have to use some visual inspection, and reading of the patch, to "
14945 "identify the file and hunk numbers you'll want, but you can then pass them to "
14946 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
14947 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
14948 "options, to select exactly the file and hunk you want to extract."
14949 msgstr ""
14951 #. type: Content of: <book><chapter><sect1><sect2><para>
14952 #: ../en/ch11-mq.xml:1292
14953 msgid ""
14954 "Once you have this hunk, you can concatenate it onto the end of your "
14955 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
14956 "combine\"/>."
14957 msgstr ""
14959 #. type: Content of: <book><chapter><sect1><title>
14960 #: ../en/ch11-mq.xml:1299
14961 msgid "Differences between quilt and MQ"
14962 msgstr "MQ 与 quilt 的区别"
14964 #. type: Content of: <book><chapter><sect1><para>
14965 #: ../en/ch11-mq.xml:1301
14966 msgid ""
14967 "If you are already familiar with quilt, MQ provides a similar command set. "
14968 "There are a few differences in the way that it works."
14969 msgstr ""
14971 #. type: Content of: <book><chapter><sect1><para>
14972 #: ../en/ch11-mq.xml:1305
14973 msgid ""
14974 "You will already have noticed that most quilt commands have MQ counterparts "
14975 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
14976 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
14977 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
14978 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
14979 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
14980 "command."
14981 msgstr ""
14983 #. type: Content of: <book><chapter><title>
14984 #: ../en/ch12-mq-collab.xml:5
14985 msgid "Advanced uses of Mercurial Queues"
14986 msgstr "MQ 的高级用法"
14988 #. type: Content of: <book><chapter><para>
14989 #: ../en/ch12-mq-collab.xml:7
14990 msgid ""
14991 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
14992 "little discipline and some of MQ's less frequently used capabilities makes it "
14993 "possible to work in complicated development environments."
14994 msgstr ""
14996 #. type: Content of: <book><chapter><para>
14997 #: ../en/ch12-mq-collab.xml:12
14998 msgid ""
14999 "In this chapter, I will use as an example a technique I have used to manage "
15000 "the development of an Infiniband device driver for the Linux kernel. The "
15001 "driver in question is large (at least as drivers go), with 25,000 lines of "
15002 "code spread across 35 source files. It is maintained by a small team of "
15003 "developers."
15004 msgstr ""
15006 #. type: Content of: <book><chapter><para>
15007 #: ../en/ch12-mq-collab.xml:18
15008 msgid ""
15009 "While much of the material in this chapter is specific to Linux, the same "
15010 "principles apply to any code base for which you're not the primary owner, and "
15011 "upon which you need to do a lot of development."
15012 msgstr ""
15014 #. type: Content of: <book><chapter><sect1><title>
15015 #: ../en/ch12-mq-collab.xml:24
15016 msgid "The problem of many targets"
15017 msgstr "多个目标的问题"
15019 #. type: Content of: <book><chapter><sect1><para>
15020 #: ../en/ch12-mq-collab.xml:26
15021 msgid ""
15022 "The Linux kernel changes rapidly, and has never been internally stable; "
15023 "developers frequently make drastic changes between releases. This means that "
15024 "a version of the driver that works well with a particular released version of "
15025 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
15026 "typically, any other version."
15027 msgstr ""
15029 #. type: Content of: <book><chapter><sect1><para>
15030 #: ../en/ch12-mq-collab.xml:33
15031 msgid ""
15032 "To maintain a driver, we have to keep a number of distinct versions of Linux "
15033 "in mind."
15034 msgstr ""
15036 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15037 #: ../en/ch12-mq-collab.xml:36
15038 msgid ""
15039 "One target is the main Linux kernel development tree. Maintenance of the code "
15040 "is in this case partly shared by other developers in the kernel community, "
15041 "who make <quote>drive-by</quote> modifications to the driver as they develop "
15042 "and refine kernel subsystems."
15043 msgstr ""
15045 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15046 #: ../en/ch12-mq-collab.xml:42
15047 msgid ""
15048 "We also maintain a number of <quote>backports</quote> to older versions of "
15049 "the Linux kernel, to support the needs of customers who are running older "
15050 "Linux distributions that do not incorporate our drivers. (To "
15051 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
15052 "older version of its target environment than the version it was developed "
15053 "for.)"
15054 msgstr ""
15056 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15057 #: ../en/ch12-mq-collab.xml:50
15058 msgid ""
15059 "Finally, we make software releases on a schedule that is necessarily not "
15060 "aligned with those used by Linux distributors and kernel developers, so that "
15061 "we can deliver new features to customers without forcing them to upgrade "
15062 "their entire kernels or distributions."
15063 msgstr ""
15065 #. type: Content of: <book><chapter><sect1><sect2><title>
15066 #: ../en/ch12-mq-collab.xml:58
15067 msgid "Tempting approaches that don't work well"
15068 msgstr "工作不好的诱人方法"
15070 #. type: Content of: <book><chapter><sect1><sect2><para>
15071 #: ../en/ch12-mq-collab.xml:60
15072 msgid ""
15073 "There are two <quote>standard</quote> ways to maintain a piece of software "
15074 "that has to target many different environments."
15075 msgstr ""
15077 #. type: Content of: <book><chapter><sect1><sect2><para>
15078 #: ../en/ch12-mq-collab.xml:64
15079 msgid ""
15080 "The first is to maintain a number of branches, each intended for a single "
15081 "target. The trouble with this approach is that you must maintain iron "
15082 "discipline in the flow of changes between repositories. A new feature or bug "
15083 "fix must start life in a <quote>pristine</quote> repository, then percolate "
15084 "out to every backport repository. Backport changes are more limited in the "
15085 "branches they should propagate to; a backport change that is applied to a "
15086 "branch where it doesn't belong will probably stop the driver from compiling."
15087 msgstr ""
15089 #. type: Content of: <book><chapter><sect1><sect2><para>
15090 #: ../en/ch12-mq-collab.xml:74
15091 msgid ""
15092 "The second is to maintain a single source tree filled with conditional "
15093 "statements that turn chunks of code on or off depending on the intended "
15094 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
15095 "kernel tree, a manual or automatic process must be followed to strip them out "
15096 "and yield a clean tree. A code base maintained in this fashion rapidly "
15097 "becomes a rat's nest of conditional blocks that are difficult to understand "
15098 "and maintain."
15099 msgstr ""
15101 #. type: Content of: <book><chapter><sect1><sect2><para>
15102 #: ../en/ch12-mq-collab.xml:83
15103 msgid ""
15104 "Neither of these approaches is well suited to a situation where you don't "
15105 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
15106 "Linux driver that is distributed with the standard kernel, Linus's tree "
15107 "contains the copy of the code that will be treated by the world as "
15108 "canonical. The upstream version of <quote>my</quote> driver can be modified "
15109 "by people I don't know, without me even finding out about it until after the "
15110 "changes show up in Linus's tree."
15111 msgstr ""
15113 #. type: Content of: <book><chapter><sect1><sect2><para>
15114 #: ../en/ch12-mq-collab.xml:93
15115 msgid ""
15116 "These approaches have the added weakness of making it difficult to generate "
15117 "well-formed patches to submit upstream."
15118 msgstr ""
15120 #. type: Content of: <book><chapter><sect1><sect2><para>
15121 #: ../en/ch12-mq-collab.xml:97
15122 msgid ""
15123 "In principle, Mercurial Queues seems like a good candidate to manage a "
15124 "development scenario such as the above. While this is indeed the case, MQ "
15125 "contains a few added features that make the job more pleasant."
15126 msgstr ""
15128 #. type: Content of: <book><chapter><sect1><title>
15129 #: ../en/ch12-mq-collab.xml:105
15130 msgid "Conditionally applying patches with guards"
15131 msgstr "有条件的应用补丁"
15133 #. type: Content of: <book><chapter><sect1><para>
15134 #: ../en/ch12-mq-collab.xml:107
15135 msgid ""
15136 "Perhaps the best way to maintain sanity with so many targets is to be able to "
15137 "choose specific patches to apply for a given situation. MQ provides a "
15138 "feature called <quote>guards</quote> (which originates with quilt's "
15139 "<literal>guards</literal> command) that does just this. To start off, let's "
15140 "create a simple repository for experimenting in."
15141 msgstr ""
15143 #. type: Content of: <book><chapter><sect1><para>
15144 #: ../en/ch12-mq-collab.xml:116
15145 msgid ""
15146 "This gives us a tiny repository that contains two patches that don't have any "
15147 "dependencies on each other, because they touch different files."
15148 msgstr ""
15150 #. type: Content of: <book><chapter><sect1><para>
15151 #: ../en/ch12-mq-collab.xml:120
15152 msgid ""
15153 "The idea behind conditional application is that you can <quote>tag</quote> a "
15154 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
15155 "your choosing, then tell MQ to select specific guards to use when applying "
15156 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
15157 "on the guards that you have selected."
15158 msgstr ""
15160 #. type: Content of: <book><chapter><sect1><para>
15161 #: ../en/ch12-mq-collab.xml:127
15162 msgid ""
15163 "A patch can have an arbitrary number of guards; each one is "
15164 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
15165 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
15166 "this guard is selected</quote>). A patch with no guards is always applied."
15167 msgstr ""
15169 #. type: Content of: <book><chapter><sect1><title>
15170 #: ../en/ch12-mq-collab.xml:135
15171 msgid "Controlling the guards on a patch"
15172 msgstr "控制补丁的应用条件"
15174 #. type: Content of: <book><chapter><sect1><para>
15175 #: ../en/ch12-mq-collab.xml:137
15176 msgid ""
15177 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
15178 "which guards should apply to a patch, or display the guards that are already "
15179 "in effect. Without any arguments, it displays the guards on the current "
15180 "topmost patch."
15181 msgstr ""
15183 #. type: Content of: <book><chapter><sect1><para>
15184 #: ../en/ch12-mq-collab.xml:144
15185 msgid ""
15186 "To set a positive guard on a patch, prefix the name of the guard with a "
15187 "<quote><literal>+</literal></quote>."
15188 msgstr ""
15190 #. type: Content of: <book><chapter><sect1><para>
15191 #: ../en/ch12-mq-collab.xml:149
15192 msgid ""
15193 "To set a negative guard on a patch, prefix the name of the guard with a "
15194 "<quote><literal>-</literal></quote>."
15195 msgstr ""
15197 #. type: Content of: <book><chapter><sect1><note><para>
15198 #: ../en/ch12-mq-collab.xml:156
15199 msgid ""
15200 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
15201 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
15202 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
15203 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
15204 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
15205 "set on it afterwards is <literal>+c</literal>."
15206 msgstr ""
15209 #. type: Content of: <book><chapter><sect1><para>
15210 #: ../en/ch12-mq-collab.xml:165
15211 msgid ""
15212 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
15213 "file; the form in which they are stored is easy both to understand and to "
15214 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
15215 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
15216 "edit the <filename role=\"special\">series</filename> file.)"
15217 msgstr ""
15219 #. type: Content of: <book><chapter><sect1><title>
15220 #: ../en/ch12-mq-collab.xml:177
15221 msgid "Selecting the guards to use"
15222 msgstr "选择使用的条件"
15224 #. type: Content of: <book><chapter><sect1><para>
15225 #: ../en/ch12-mq-collab.xml:179
15226 msgid ""
15227 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
15228 "guards are active at a given time. The effect of this is to determine which "
15229 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
15230 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
15231 "anything to patches that are already applied."
15232 msgstr ""
15234 #. type: Content of: <book><chapter><sect1><para>
15235 #: ../en/ch12-mq-collab.xml:186
15236 msgid ""
15237 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
15238 "lists the guards currently in effect, one per line of output. Each argument "
15239 "is treated as the name of a guard to apply."
15240 msgstr ""
15242 #. type: Content of: <book><chapter><sect1><para>
15243 #: ../en/ch12-mq-collab.xml:193
15244 msgid ""
15245 "In case you're interested, the currently selected guards are stored in the "
15246 "<filename role=\"special\">guards</filename> file."
15247 msgstr ""
15249 #. type: Content of: <book><chapter><sect1><para>
15250 #: ../en/ch12-mq-collab.xml:198
15251 msgid ""
15252 "We can see the effect the selected guards have when we run <command role=\"hg-"
15253 "ext-mq\">qpush</command>."
15254 msgstr ""
15256 #. type: Content of: <book><chapter><sect1><para>
15257 #: ../en/ch12-mq-collab.xml:203
15258 msgid ""
15259 "A guard cannot start with a <quote><literal>+</literal></quote> or "
15260 "<quote><literal>-</literal></quote> character. The name of a guard must not "
15261 "contain white space, but most other characters are acceptable. If you try to "
15262 "use a guard with an invalid name, MQ will complain:"
15263 msgstr ""
15265 #. type: Content of: <book><chapter><sect1><para>
15266 #: ../en/ch12-mq-collab.xml:212
15267 msgid "Changing the selected guards changes the patches that are applied."
15268 msgstr ""
15270 #. type: Content of: <book><chapter><sect1><para>
15271 #: ../en/ch12-mq-collab.xml:217
15272 msgid ""
15273 "You can see in the example below that negative guards take precedence over "
15274 "positive guards."
15275 msgstr ""
15277 #. type: Content of: <book><chapter><sect1><title>
15278 #: ../en/ch12-mq-collab.xml:224
15279 msgid "MQ's rules for applying patches"
15280 msgstr "MQ 应用补丁的规则"
15282 #. type: Content of: <book><chapter><sect1><para>
15283 #: ../en/ch12-mq-collab.xml:226
15284 msgid ""
15285 "The rules that MQ uses when deciding whether to apply a patch are as follows."
15286 msgstr ""
15288 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15289 #: ../en/ch12-mq-collab.xml:229
15290 msgid "A patch that has no guards is always applied."
15291 msgstr ""
15293 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15294 #: ../en/ch12-mq-collab.xml:232
15295 msgid ""
15296 "If the patch has any negative guard that matches any currently selected "
15297 "guard, the patch is skipped."
15298 msgstr ""
15300 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15301 #: ../en/ch12-mq-collab.xml:235
15302 msgid ""
15303 "If the patch has any positive guard that matches any currently selected "
15304 "guard, the patch is applied."
15305 msgstr ""
15307 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15308 #: ../en/ch12-mq-collab.xml:238
15309 msgid ""
15310 "If the patch has positive or negative guards, but none matches any currently "
15311 "selected guard, the patch is skipped."
15312 msgstr ""
15314 #. type: Content of: <book><chapter><sect1><title>
15315 #: ../en/ch12-mq-collab.xml:245
15316 msgid "Trimming the work environment"
15317 msgstr "修剪工作环境"
15319 #. type: Content of: <book><chapter><sect1><para>
15320 #: ../en/ch12-mq-collab.xml:247
15321 msgid ""
15322 "In working on the device driver I mentioned earlier, I don't apply the "
15323 "patches to a normal Linux kernel tree. Instead, I use a repository that "
15324 "contains only a snapshot of the source files and headers that are relevant to "
15325 "Infiniband development. This repository is 1% the size of a kernel "
15326 "repository, so it's easier to work with."
15327 msgstr ""
15329 #. type: Content of: <book><chapter><sect1><para>
15330 #: ../en/ch12-mq-collab.xml:254
15331 msgid ""
15332 "I then choose a <quote>base</quote> version on top of which the patches are "
15333 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
15334 "choosing. When I take the snapshot, I record the changeset ID from the "
15335 "kernel repository in the commit message. Since the snapshot preserves the "
15336 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
15337 "can apply my patches on top of either my tiny repository or a normal kernel "
15338 "tree."
15339 msgstr ""
15341 #. type: Content of: <book><chapter><sect1><para>
15342 #: ../en/ch12-mq-collab.xml:263
15343 msgid ""
15344 "Normally, the base tree atop which the patches apply should be a snapshot of "
15345 "a very recent upstream tree. This best facilitates the development of "
15346 "patches that can easily be submitted upstream with few or no modifications."
15347 msgstr ""
15349 #. type: Content of: <book><chapter><sect1><title>
15350 #: ../en/ch12-mq-collab.xml:270
15351 msgid "Dividing up the <filename role=\"special\">series</filename> file"
15352 msgstr "分类补丁<filename role=\"special\">系列</filename>"
15354 #. type: Content of: <book><chapter><sect1><para>
15355 #: ../en/ch12-mq-collab.xml:273
15356 msgid ""
15357 "I categorise the patches in the <filename role=\"special\">series</filename> "
15358 "file into a number of logical groups. Each section of like patches begins "
15359 "with a block of comments that describes the purpose of the patches that "
15360 "follow."
15361 msgstr ""
15363 #. type: Content of: <book><chapter><sect1><para>
15364 #: ../en/ch12-mq-collab.xml:279
15365 msgid ""
15366 "The sequence of patch groups that I maintain follows. The ordering of these "
15367 "groups is important; I'll describe why after I introduce the groups."
15368 msgstr ""
15370 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15371 #: ../en/ch12-mq-collab.xml:283
15372 msgid ""
15373 "The <quote>accepted</quote> group. Patches that the development team has "
15374 "submitted to the maintainer of the Infiniband subsystem, and which he has "
15375 "accepted, but which are not present in the snapshot that the tiny repository "
15376 "is based on. These are <quote>read only</quote> patches, present only to "
15377 "transform the tree into a similar state as it is in the upstream maintainer's "
15378 "repository."
15379 msgstr ""
15381 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15382 #: ../en/ch12-mq-collab.xml:291
15383 msgid ""
15384 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
15385 "upstream maintainer has requested modifications to before he will accept them."
15386 msgstr ""
15388 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15389 #: ../en/ch12-mq-collab.xml:296
15390 msgid ""
15391 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
15392 "the upstream maintainer, but which we have finished working on. These will be "
15393 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
15394 "them upon submission, I'll move them to the end of the <quote>accepted</"
15395 "quote> group. If he requests that I modify any, I'll move them to the "
15396 "beginning of the <quote>rework</quote> group."
15397 msgstr ""
15399 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15400 #: ../en/ch12-mq-collab.xml:305
15401 msgid ""
15402 "The <quote>in progress</quote> group. Patches that are actively being "
15403 "developed, and should not be submitted anywhere yet."
15404 msgstr ""
15406 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15407 #: ../en/ch12-mq-collab.xml:309
15408 msgid ""
15409 "The <quote>backport</quote> group. Patches that adapt the source tree to "
15410 "older versions of the kernel tree."
15411 msgstr ""
15413 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15414 #: ../en/ch12-mq-collab.xml:313
15415 msgid ""
15416 "The <quote>do not ship</quote> group. Patches that for some reason should "
15417 "never be submitted upstream. For example, one such patch might change "
15418 "embedded driver identification strings to make it easier to distinguish, in "
15419 "the field, between an out-of-tree version of the driver and a version shipped "
15420 "by a distribution vendor."
15421 msgstr ""
15423 #. type: Content of: <book><chapter><sect1><para>
15424 #: ../en/ch12-mq-collab.xml:321
15425 msgid ""
15426 "Now to return to the reasons for ordering groups of patches in this way. We "
15427 "would like the lowest patches in the stack to be as stable as possible, so "
15428 "that we will not need to rework higher patches due to changes in context. "
15429 "Putting patches that will never be changed first in the <filename role="
15430 "\"special\">series</filename> file serves this purpose."
15431 msgstr ""
15433 #. type: Content of: <book><chapter><sect1><para>
15434 #: ../en/ch12-mq-collab.xml:329
15435 msgid ""
15436 "We would also like the patches that we know we'll need to modify to be "
15437 "applied on top of a source tree that resembles the upstream tree as closely "
15438 "as possible. This is why we keep accepted patches around for a while."
15439 msgstr ""
15441 #. type: Content of: <book><chapter><sect1><para>
15442 #: ../en/ch12-mq-collab.xml:334
15443 msgid ""
15444 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
15445 "the end of the <filename role=\"special\">series</filename> file. The "
15446 "backport patches must be applied on top of all other patches, and the "
15447 "<quote>do not ship</quote> patches might as well stay out of harm's way."
15448 msgstr ""
15450 #. type: Content of: <book><chapter><sect1><title>
15451 #: ../en/ch12-mq-collab.xml:343
15452 msgid "Maintaining the patch series"
15453 msgstr "维护补丁系列"
15455 #. type: Content of: <book><chapter><sect1><para>
15456 #: ../en/ch12-mq-collab.xml:345
15457 msgid ""
15458 "In my work, I use a number of guards to control which patches are to be "
15459 "applied."
15460 msgstr ""
15462 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15463 #: ../en/ch12-mq-collab.xml:349
15464 msgid ""
15465 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
15466 "literal>. I enable this guard most of the time. When I'm applying the "
15467 "patches on top of a tree where the patches are already present, I can turn "
15468 "this patch off, and the patches that follow it will apply cleanly."
15469 msgstr ""
15471 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15472 #: ../en/ch12-mq-collab.xml:356
15473 msgid ""
15474 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
15475 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
15476 "don't need to enable any guards in order to get a reasonably safe source tree."
15477 msgstr ""
15479 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15480 #: ../en/ch12-mq-collab.xml:362
15481 msgid ""
15482 "Those patches that need reworking before being resubmitted are guarded with "
15483 "<literal>rework</literal>."
15484 msgstr ""
15486 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15487 #: ../en/ch12-mq-collab.xml:366
15488 msgid ""
15489 "For those patches that are still under development, I use <literal>devel</"
15490 "literal>."
15491 msgstr ""
15493 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15494 #: ../en/ch12-mq-collab.xml:369
15495 msgid ""
15496 "A backport patch may have several guards, one for each version of the kernel "
15497 "to which it applies. For example, a patch that backports a piece of code to "
15498 "2.6.9 will have a <literal>2.6.9</literal> guard."
15499 msgstr ""
15501 #. type: Content of: <book><chapter><sect1><para>
15502 #: ../en/ch12-mq-collab.xml:374
15503 msgid ""
15504 "This variety of guards gives me considerable flexibility in determining what "
15505 "kind of source tree I want to end up with. For most situations, the "
15506 "selection of appropriate guards is automated during the build process, but I "
15507 "can manually tune the guards to use for less common circumstances."
15508 msgstr ""
15510 #. type: Content of: <book><chapter><sect1><sect2><title>
15511 #: ../en/ch12-mq-collab.xml:381
15512 msgid "The art of writing backport patches"
15513 msgstr "编写向后移植补丁的艺术"
15515 #. type: Content of: <book><chapter><sect1><sect2><para>
15516 #: ../en/ch12-mq-collab.xml:383
15517 msgid ""
15518 "Using MQ, writing a backport patch is a simple process. All such a patch has "
15519 "to do is modify a piece of code that uses a kernel feature not present in the "
15520 "older version of the kernel, so that the driver continues to work correctly "
15521 "under that older version."
15522 msgstr ""
15524 #. type: Content of: <book><chapter><sect1><sect2><para>
15525 #: ../en/ch12-mq-collab.xml:389
15526 msgid ""
15527 "A useful goal when writing a good backport patch is to make your code look as "
15528 "if it was written for the older version of the kernel you're targeting. The "
15529 "less obtrusive the patch, the easier it will be to understand and maintain. "
15530 "If you're writing a collection of backport patches to avoid the <quote>rat's "
15531 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
15532 "code that are only used conditionally) in your code, don't introduce version-"
15533 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
15534 "several patches, each of which makes unconditional changes, and control their "
15535 "application using guards."
15536 msgstr ""
15538 #. type: Content of: <book><chapter><sect1><sect2><para>
15539 #: ../en/ch12-mq-collab.xml:402
15540 msgid ""
15541 "There are two reasons to divide backport patches into a distinct group, away "
15542 "from the <quote>regular</quote> patches whose effects they modify. The first "
15543 "is that intermingling the two makes it more difficult to use a tool like the "
15544 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
15545 "process of submitting the patches to an upstream maintainer. The second is "
15546 "that a backport patch could perturb the context in which a subsequent regular "
15547 "patch is applied, making it impossible to apply the regular patch cleanly "
15548 "<emphasis>without</emphasis> the earlier backport patch already being applied."
15549 msgstr ""
15551 #. type: Content of: <book><chapter><sect1><title>
15552 #: ../en/ch12-mq-collab.xml:417
15553 msgid "Useful tips for developing with MQ"
15554 msgstr "使用 MQ 开发的技巧"
15556 #. type: Content of: <book><chapter><sect1><sect2><title>
15557 #: ../en/ch12-mq-collab.xml:420
15558 msgid "Organising patches in directories"
15559 msgstr "将补丁放到几个目录中"
15561 #. type: Content of: <book><chapter><sect1><sect2><para>
15562 #: ../en/ch12-mq-collab.xml:422
15563 msgid ""
15564 "If you're working on a substantial project with MQ, it's not difficult to "
15565 "accumulate a large number of patches. For example, I have one patch "
15566 "repository that contains over 250 patches."
15567 msgstr ""
15569 #. type: Content of: <book><chapter><sect1><sect2><para>
15570 #: ../en/ch12-mq-collab.xml:427
15571 msgid ""
15572 "If you can group these patches into separate logical categories, you can if "
15573 "you like store them in different directories; MQ has no problems with patch "
15574 "names that contain path separators."
15575 msgstr ""
15577 #. type: Content of: <book><chapter><sect1><sect2><title>
15578 #: ../en/ch12-mq-collab.xml:434
15579 msgid "Viewing the history of a patch"
15580 msgstr "察看补丁的历史"
15582 #. type: Content of: <book><chapter><sect1><sect2><para>
15583 #: ../en/ch12-mq-collab.xml:436
15584 msgid ""
15585 "If you're developing a set of patches over a long time, it's a good idea to "
15586 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
15587 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
15588 "cmd\">hg diff</command> command to look at the history of changes to a patch "
15589 "is unworkable. This is in part because you're looking at the second "
15590 "derivative of the real code (a diff of a diff), but also because MQ adds "
15591 "noise to the process by modifying time stamps and directory names when it "
15592 "updates a patch."
15593 msgstr ""
15595 #. type: Content of: <book><chapter><sect1><sect2><para>
15596 #: ../en/ch12-mq-collab.xml:448
15597 msgid ""
15598 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
15599 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
15600 "a patch into something readable. To do this, you will need a third-party "
15601 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
15602 "patchutils</citation>. This provides a command named <command>interdiff</"
15603 "command>, which shows the differences between two diffs as a diff. Used on "
15604 "two versions of the same diff, it generates a diff that represents the diff "
15605 "from the first to the second version."
15606 msgstr ""
15608 #. type: Content of: <book><chapter><sect1><sect2><para>
15609 #: ../en/ch12-mq-collab.xml:459
15610 msgid ""
15611 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
15612 "the usual way, by adding a line to the <literal role=\"rc-extensions"
15613 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
15614 "filename>."
15615 msgstr ""
15618 #. &example.hg-interdiff;
15619 #. type: Content of: <book><chapter><sect1><sect2><para>
15620 #: ../en/ch12-mq-collab.xml:466
15621 msgid ""
15622 "The <command>interdiff</command> command expects to be passed the names of "
15623 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
15624 "passes the program it runs a pair of directories, each of which can contain "
15625 "an arbitrary number of files. We thus need a small program that will run "
15626 "<command>interdiff</command> on each pair of files in these two directories. "
15627 "This program is available as <filename role=\"special\">hg-interdiff</"
15628 "filename> in the <filename class=\"directory\">examples</filename> directory "
15629 "of the source code repository that accompanies this book."
15630 msgstr ""
15632 #. type: Content of: <book><chapter><sect1><sect2><para>
15633 #: ../en/ch12-mq-collab.xml:478
15634 msgid ""
15635 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
15636 "shell's search path, you can run it as follows, from inside an MQ patch "
15637 "directory:"
15638 msgstr ""
15640 #. type: Content of: <book><chapter><sect1><sect2><para>
15641 #: ../en/ch12-mq-collab.xml:482
15642 msgid ""
15643 "Since you'll probably want to use this long-winded command a lot, you can get "
15644 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
15645 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
15646 "filename>."
15647 msgstr ""
15649 #. type: Content of: <book><chapter><sect1><sect2><para>
15650 #: ../en/ch12-mq-collab.xml:489
15651 msgid ""
15652 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
15653 "<literal>interdiff</literal> command available, so you can now shorten the "
15654 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
15655 "something a little more wieldy."
15656 msgstr ""
15658 #. type: Content of: <book><chapter><sect1><sect2><note><para>
15659 #: ../en/ch12-mq-collab.xml:497
15660 msgid ""
15661 "The <command>interdiff</command> command works well only if the underlying "
15662 "files against which versions of a patch are generated remain the same. If "
15663 "you create a patch, modify the underlying files, and then regenerate the "
15664 "patch, <command>interdiff</command> may not produce useful output."
15665 msgstr ""
15667 #. type: Content of: <book><chapter><sect1><sect2><para>
15668 #: ../en/ch12-mq-collab.xml:505
15669 msgid ""
15670 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
15671 "than merely improving the presentation of MQ patches. To read more about it, "
15672 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
15673 msgstr ""
15675 #. type: Content of: <book><chapter><title>
15676 #: ../en/ch13-hgext.xml:5
15677 msgid "Adding functionality with extensions"
15678 msgstr "使用扩展增加功能"
15680 #. type: Content of: <book><chapter><para>
15681 #: ../en/ch13-hgext.xml:7
15682 msgid ""
15683 "While the core of Mercurial is quite complete from a functionality "
15684 "standpoint, it's deliberately shorn of fancy features. This approach of "
15685 "preserving simplicity keeps the software easy to deal with for both "
15686 "maintainers and users."
15687 msgstr ""
15689 #. type: Content of: <book><chapter><para>
15690 #: ../en/ch13-hgext.xml:12
15691 msgid ""
15692 "However, Mercurial doesn't box you in with an inflexible command set: you can "
15693 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
15694 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
15695 "extensions in earlier chapters."
15696 msgstr ""
15698 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15699 #: ../en/ch13-hgext.xml:18
15700 msgid ""
15701 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
15702 "\">fetch</literal> extension; this combines pulling new changes and merging "
15703 "them with local changes into a single command, <command role=\"hg-ext-fetch"
15704 "\">fetch</command>."
15705 msgstr ""
15707 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15708 #: ../en/ch13-hgext.xml:24
15709 msgid ""
15710 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
15711 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
15712 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
15713 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
15714 "\">notify</literal> sends notification emails on new changes."
15715 msgstr ""
15717 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15718 #: ../en/ch13-hgext.xml:33
15719 msgid ""
15720 "The Mercurial Queues patch management extension is so invaluable that it "
15721 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
15722 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
15723 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
15724 msgstr ""
15726 #. type: Content of: <book><chapter><para>
15727 #: ../en/ch13-hgext.xml:43
15728 msgid ""
15729 "In this chapter, we'll cover some of the other extensions that are available "
15730 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
15731 "about if you want to write an extension of your own."
15732 msgstr ""
15734 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
15735 #: ../en/ch13-hgext.xml:48
15736 msgid ""
15737 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
15738 "<emphasis>huge</emphasis> performance improvements using the <literal role="
15739 "\"hg-ext\">inotify</literal> extension."
15740 msgstr ""
15742 #. type: Content of: <book><chapter><sect1><title>
15743 #: ../en/ch13-hgext.xml:55
15744 msgid ""
15745 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
15746 "extension"
15747 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
15749 #. type: Content of: <book><chapter><sect1><para>
15750 #: ../en/ch13-hgext.xml:58
15751 msgid ""
15752 "Are you interested in having some of the most common Mercurial operations run "
15753 "as much as a hundred times faster? Read on!"
15754 msgstr ""
15756 #. type: Content of: <book><chapter><sect1><para>
15757 #: ../en/ch13-hgext.xml:62
15758 msgid ""
15759 "Mercurial has great performance under normal circumstances. For example, "
15760 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
15761 "Mercurial has to scan almost every directory and file in your repository so "
15762 "that it can display file status. Many other Mercurial commands need to do "
15763 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
15764 "diff</command> command uses the status machinery to avoid doing an expensive "
15765 "comparison operation on files that obviously haven't changed."
15766 msgstr ""
15768 #. type: Content of: <book><chapter><sect1><para>
15769 #: ../en/ch13-hgext.xml:72
15770 msgid ""
15771 "Because obtaining file status is crucial to good performance, the authors of "
15772 "Mercurial have optimised this code to within an inch of its life. However, "
15773 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
15774 "status</command>, Mercurial is going to have to perform at least one "
15775 "expensive system call for each managed file to determine whether it's changed "
15776 "since the last time Mercurial checked. For a sufficiently large repository, "
15777 "this can take a long time."
15778 msgstr ""
15780 #. type: Content of: <book><chapter><sect1><para>
15781 #: ../en/ch13-hgext.xml:82
15782 msgid ""
15783 "To put a number on the magnitude of this effect, I created a repository "
15784 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
15785 "status</command> as taking ten seconds to run, even when <emphasis>none</"
15786 "emphasis> of those files had been modified."
15787 msgstr ""
15789 #. type: Content of: <book><chapter><sect1><para>
15790 #: ../en/ch13-hgext.xml:88
15791 msgid ""
15792 "Many modern operating systems contain a file notification facility. If a "
15793 "program signs up to an appropriate service, the operating system will notify "
15794 "it every time a file of interest is created, modified, or deleted. On Linux "
15795 "systems, the kernel component that does this is called <literal>inotify</"
15796 "literal>."
15797 msgstr ""
15799 #. type: Content of: <book><chapter><sect1><para>
15800 #: ../en/ch13-hgext.xml:95
15801 msgid ""
15802 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
15803 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
15804 "cmd\">hg status</command> commands. The extension has two components. A "
15805 "daemon sits in the background and receives notifications from the "
15806 "<literal>inotify</literal> subsystem. It also listens for connections from a "
15807 "regular Mercurial command. The extension modifies Mercurial's behaviour so "
15808 "that instead of scanning the filesystem, it queries the daemon. Since the "
15809 "daemon has perfect information about the state of the repository, it can "
15810 "respond with a result instantaneously, avoiding the need to scan every "
15811 "directory and file in the repository."
15812 msgstr ""
15814 #. type: Content of: <book><chapter><sect1><para>
15815 #: ../en/ch13-hgext.xml:108
15816 msgid ""
15817 "Recall the ten seconds that I measured plain Mercurial as taking to run "
15818 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
15819 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
15820 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
15821 "faster."
15822 msgstr ""
15824 #. type: Content of: <book><chapter><sect1><para>
15825 #: ../en/ch13-hgext.xml:115
15826 msgid "Before we continue, please pay attention to some caveats."
15827 msgstr ""
15829 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15830 #: ../en/ch13-hgext.xml:118
15831 msgid ""
15832 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
15833 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
15834 "literal> subsystem, it does not work on other operating systems."
15835 msgstr ""
15837 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15838 #: ../en/ch13-hgext.xml:123
15839 msgid ""
15840 "It should work on any Linux distribution that was released after early 2005. "
15841 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
15842 "literal>, or a version of <literal>glibc</literal> that does not have the "
15843 "necessary interfacing support."
15844 msgstr ""
15846 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
15847 #: ../en/ch13-hgext.xml:130
15848 msgid ""
15849 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
15850 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
15851 "starter, for example, particularly if you're running Mercurial on several "
15852 "systems, all mounting the same network filesystem. The kernel's "
15853 "<literal>inotify</literal> system has no way of knowing about changes made on "
15854 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
15855 "work fine."
15856 msgstr ""
15858 #. type: Content of: <book><chapter><sect1><para>
15859 #: ../en/ch13-hgext.xml:141
15860 msgid ""
15861 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
15862 "with Mercurial as of May 2007, so it's a little more involved to set up than "
15863 "other extensions. But the performance improvement is worth it!"
15864 msgstr ""
15866 #. type: Content of: <book><chapter><sect1><para>
15867 #: ../en/ch13-hgext.xml:146
15868 msgid ""
15869 "The extension currently comes in two parts: a set of patches to the Mercurial "
15870 "source code, and a library of Python bindings to the <literal>inotify</"
15871 "literal> subsystem."
15872 msgstr ""
15874 #. type: Content of: <book><chapter><sect1><note><para>
15875 #: ../en/ch13-hgext.xml:150
15876 msgid ""
15877 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
15878 "libraries. One of them is called <literal>pyinotify</literal>, and is "
15879 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
15880 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
15881 "inefficient to be practical."
15882 msgstr ""
15884 #. type: Content of: <book><chapter><sect1><para>
15885 #: ../en/ch13-hgext.xml:157
15886 msgid ""
15887 "To get going, it's best to already have a functioning copy of Mercurial "
15888 "installed."
15889 msgstr ""
15891 #. type: Content of: <book><chapter><sect1><note><para>
15892 #: ../en/ch13-hgext.xml:160
15893 msgid ""
15894 "If you follow the instructions below, you'll be <emphasis>replacing</"
15895 "emphasis> and overwriting any existing installation of Mercurial that you "
15896 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
15897 "code. Don't say you weren't warned!"
15898 msgstr ""
15900 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15901 #: ../en/ch13-hgext.xml:167
15902 msgid ""
15903 "Clone the Python <literal>inotify</literal> binding repository. Build and "
15904 "install it."
15905 msgstr ""
15907 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15908 #: ../en/ch13-hgext.xml:174
15909 msgid ""
15910 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
15911 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
15912 "repository so that Mercurial Queues will be able to apply patches to your "
15913 "cope of the <filename class=\"directory\">crew</filename> repository."
15914 msgstr ""
15916 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15917 #: ../en/ch13-hgext.xml:184
15918 msgid ""
15919 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
15920 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
15921 "mq:start\"/> to get started quickly."
15922 msgstr ""
15924 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15925 #: ../en/ch13-hgext.xml:190
15926 msgid ""
15927 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
15928 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
15929 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
15930 "<command role=\"hg-ext-mq\">qpush</command> command."
15931 msgstr ""
15933 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15934 #: ../en/ch13-hgext.xml:199
15935 msgid ""
15936 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
15937 "you should not continue. Instead, ask for help."
15938 msgstr ""
15940 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
15941 #: ../en/ch13-hgext.xml:203
15942 msgid "Build and install the patched version of Mercurial."
15943 msgstr ""
15945 #. type: Content of: <book><chapter><sect1><para>
15946 #: ../en/ch13-hgext.xml:209
15947 msgid ""
15948 "Once you've build a suitably patched version of Mercurial, all you need to do "
15949 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
15950 "entry to your <filename role=\"special\">~/.hgrc</filename>."
15951 msgstr ""
15953 #. type: Content of: <book><chapter><sect1><para>
15954 #: ../en/ch13-hgext.xml:214
15955 msgid ""
15956 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
15957 "Mercurial will automatically and transparently start the status daemon the "
15958 "first time you run a command that needs status in a repository. It runs one "
15959 "status daemon per repository."
15960 msgstr ""
15962 #. type: Content of: <book><chapter><sect1><para>
15963 #: ../en/ch13-hgext.xml:220
15964 msgid ""
15965 "The status daemon is started silently, and runs in the background. If you "
15966 "look at a list of running processes after you've enabled the <literal role="
15967 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
15968 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
15969 "around, waiting for updates from the kernel and queries from Mercurial."
15970 msgstr ""
15972 #. type: Content of: <book><chapter><sect1><para>
15973 #: ../en/ch13-hgext.xml:228
15974 msgid ""
15975 "The first time you run a Mercurial command in a repository when you have the "
15976 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
15977 "with about the same performance as a normal Mercurial command. This is "
15978 "because the status daemon needs to perform a normal status scan so that it "
15979 "has a baseline against which to apply later updates from the kernel. "
15980 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
15981 "status check should be noticeably faster on repositories of even fairly "
15982 "modest size. Better yet, the bigger your repository is, the greater a "
15983 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
15984 "literal> daemon makes status operations almost instantaneous on repositories "
15985 "of all sizes!"
15986 msgstr ""
15988 #. type: Content of: <book><chapter><sect1><para>
15989 #: ../en/ch13-hgext.xml:242
15990 msgid ""
15991 "If you like, you can manually start a status daemon using the <command role="
15992 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
15993 "control over how the daemon ought to run. This command will of course only "
15994 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
15995 "enabled."
15996 msgstr ""
15998 #. type: Content of: <book><chapter><sect1><para>
15999 #: ../en/ch13-hgext.xml:249
16000 msgid ""
16001 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
16002 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
16003 "behaviour, with the sole exception of status-related commands running a whole "
16004 "lot faster than they used to. You should specifically expect that commands "
16005 "will not print different output; neither should they give different results. "
16006 "If either of these situations occurs, please report a bug."
16007 msgstr ""
16009 #. type: Content of: <book><chapter><sect1><title>
16010 #: ../en/ch13-hgext.xml:260
16011 msgid ""
16012 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
16013 "extension"
16014 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
16016 #. type: Content of: <book><chapter><sect1><para>
16017 #: ../en/ch13-hgext.xml:263
16018 msgid ""
16019 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
16020 "outputs plaintext unified diffs."
16021 msgstr ""
16022 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
16023 "不同。"
16025 #. type: Content of: <book><chapter><sect1><para>
16026 #: ../en/ch13-hgext.xml:268
16027 msgid ""
16028 "If you would like to use an external tool to display modifications, you'll "
16029 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
16030 "will let you use, for example, a graphical diff tool."
16031 msgstr ""
16033 #. type: Content of: <book><chapter><sect1><para>
16034 #: ../en/ch13-hgext.xml:273
16035 msgid ""
16036 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
16037 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
16038 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
16039 "filename>, simply add a one-line entry to enable the extension."
16040 msgstr ""
16042 #. type: Content of: <book><chapter><sect1><para>
16043 #: ../en/ch13-hgext.xml:280
16044 msgid ""
16045 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
16046 "command>, which by default uses your system's <command>diff</command> command "
16047 "to generate a unified diff in the same form as the built-in <command role="
16048 "\"hg-cmd\">hg diff</command> command."
16049 msgstr ""
16051 #. type: Content of: <book><chapter><sect1><para>
16052 #: ../en/ch13-hgext.xml:288
16053 msgid ""
16054 "The result won't be exactly the same as with the built-in <command role=\"hg-"
16055 "cmd\">hg diff</command> variations, because the output of <command>diff</"
16056 "command> varies from one system to another, even when passed the same options."
16057 msgstr ""
16059 #. type: Content of: <book><chapter><sect1><para>
16060 #: ../en/ch13-hgext.xml:293
16061 msgid ""
16062 "As the <quote><literal>making snapshot</literal></quote> lines of output "
16063 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
16064 "works by creating two snapshots of your source tree. The first snapshot is "
16065 "of the source revision; the second, of the target revision or working "
16066 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
16067 "generates these snapshots in a temporary directory, passes the name of each "
16068 "directory to an external diff viewer, then deletes the temporary directory. "
16069 "For efficiency, it only snapshots the directories and files that have changed "
16070 "between the two revisions."
16071 msgstr ""
16073 #. type: Content of: <book><chapter><sect1><para>
16074 #: ../en/ch13-hgext.xml:306
16075 msgid ""
16076 "Snapshot directory names have the same base name as your repository. If your "
16077 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
16078 "then <filename class=\"directory\">foo</filename> will be the name of each "
16079 "snapshot directory. Each snapshot directory name has its changeset ID "
16080 "appended, if appropriate. If a snapshot is of revision "
16081 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
16082 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
16083 "directory won't have a changeset ID appended, so it would just be <filename "
16084 "class=\"directory\">foo</filename> in this example. To see what this looks "
16085 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
16086 "command> example above. Notice that the diff has the snapshot directory "
16087 "names embedded in its header."
16088 msgstr ""
16090 #. type: Content of: <book><chapter><sect1><para>
16091 #: ../en/ch13-hgext.xml:322
16092 msgid ""
16093 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
16094 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
16095 "option> option lets you choose a program to view differences with, instead of "
16096 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
16097 "opt\">hg -o</option> option, you can change the options that <command role="
16098 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
16099 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
16100 "you're running <command>diff</command>). In other respects, the <command "
16101 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
16102 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
16103 "option names, syntax, and arguments to specify the revisions you want, the "
16104 "files you want, and so on."
16105 msgstr ""
16108 #. type: Content of: <book><chapter><sect1><para>
16109 #: ../en/ch13-hgext.xml:339
16110 msgid ""
16111 "As an example, here's how to run the normal system <command>diff</command> "
16112 "command, getting it to generate context diffs (using the <option role=\"cmd-"
16113 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
16114 "context instead of the default three (passing <literal>5</literal> as the "
16115 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
16116 msgstr ""
16118 #. type: Content of: <book><chapter><sect1><para>
16119 #: ../en/ch13-hgext.xml:348
16120 msgid ""
16121 "Launching a visual diff tool is just as easy. Here's how to launch the "
16122 "<command>kdiff3</command> viewer."
16123 msgstr ""
16125 #. type: Content of: <book><chapter><sect1><para>
16126 #: ../en/ch13-hgext.xml:352
16127 msgid ""
16128 "If your diff viewing command can't deal with directories, you can easily work "
16129 "around this with a little scripting. For an example of such scripting in "
16130 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
16131 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
16132 "interdiff\"/>."
16133 msgstr ""
16135 #. type: Content of: <book><chapter><sect1><sect2><title>
16136 #: ../en/ch13-hgext.xml:360
16137 msgid "Defining command aliases"
16138 msgstr "定义命令的别名"
16140 #. type: Content of: <book><chapter><sect1><sect2><para>
16141 #: ../en/ch13-hgext.xml:362
16142 msgid ""
16143 "It can be cumbersome to remember the options to both the <command role=\"hg-"
16144 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
16145 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
16146 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
16147 "exactly the right options."
16148 msgstr ""
16150 #. type: Content of: <book><chapter><sect1><sect2><para>
16151 #: ../en/ch13-hgext.xml:369
16152 msgid ""
16153 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
16154 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
16155 "literal>. Inside this section, you can define multiple commands. Here's how "
16156 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
16157 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
16158 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
16159 "you."
16160 msgstr ""
16162 #. type: Content of: <book><chapter><sect1><sect2><para>
16163 #: ../en/ch13-hgext.xml:379
16164 msgid ""
16165 "If you leave the right hand side of the definition empty, as above, the "
16166 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
16167 "command you defined as the name of the external program to run. But these "
16168 "names don't have to be the same. Here, we define a command named "
16169 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
16170 "command>."
16171 msgstr ""
16173 #. type: Content of: <book><chapter><sect1><sect2><para>
16174 #: ../en/ch13-hgext.xml:389
16175 msgid ""
16176 "You can also specify the default options that you want to invoke your diff "
16177 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
16178 "quote>, followed by the name of the command to which the options apply. This "
16179 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
16180 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
16181 msgstr ""
16183 #. type: Content of: <book><chapter><sect1><title>
16184 #: ../en/ch13-hgext.xml:403
16185 msgid ""
16186 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
16187 "extension"
16188 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
16190 #. type: Content of: <book><chapter><sect1><para>
16191 #: ../en/ch13-hgext.xml:406
16192 msgid "Need to have a long chat with Brendan about this."
16193 msgstr ""
16195 #. type: Content of: <book><chapter><sect1><title>
16196 #: ../en/ch13-hgext.xml:410
16197 msgid ""
16198 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
16199 "extension"
16200 msgstr ""
16201 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
16203 #. type: Content of: <book><chapter><sect1><para>
16204 #: ../en/ch13-hgext.xml:413
16205 msgid ""
16206 "Many projects have a culture of <quote>change review</quote>, in which people "
16207 "send their modifications to a mailing list for others to read and comment on "
16208 "before they commit the final version to a shared repository. Some projects "
16209 "have people who act as gatekeepers; they apply changes from other people to a "
16210 "repository to which those others don't have access."
16211 msgstr ""
16213 #. type: Content of: <book><chapter><sect1><para>
16214 #: ../en/ch13-hgext.xml:421
16215 msgid ""
16216 "Mercurial makes it easy to send changes over email for review or application, "
16217 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
16218 "extension is so named because changes are formatted as patches, and it's "
16219 "usual to send one changeset per email message. Sending a long series of "
16220 "changes by email is thus much like <quote>bombing</quote> the recipient's "
16221 "inbox, hence <quote>patchbomb</quote>."
16222 msgstr ""
16224 #. type: Content of: <book><chapter><sect1><para>
16225 #: ../en/ch13-hgext.xml:429
16226 msgid ""
16227 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
16228 "literal> extension takes just one or two lines in your <filename role="
16229 "\"special\"> /.hgrc</filename>."
16230 msgstr ""
16232 #. type: Content of: <book><chapter><sect1><para>
16233 #: ../en/ch13-hgext.xml:435
16234 msgid ""
16235 "Once you've enabled the extension, you will have a new command available, "
16236 "named <command role=\"hg-ext-patchbomb\">email</command>."
16237 msgstr ""
16239 #. type: Content of: <book><chapter><sect1><para>
16240 #: ../en/ch13-hgext.xml:439
16241 msgid ""
16242 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
16243 "\">email</command> command is to <emphasis>always</emphasis> run it first "
16244 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
16245 "option. This will show you what the command <emphasis>would</emphasis> send, "
16246 "without actually sending anything. Once you've had a quick glance over the "
16247 "changes and verified that you are sending the right ones, you can rerun the "
16248 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
16249 "option> option removed."
16250 msgstr ""
16252 #. type: Content of: <book><chapter><sect1><para>
16253 #: ../en/ch13-hgext.xml:450
16254 msgid ""
16255 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
16256 "same kind of revision syntax as every other Mercurial command. For example, "
16257 "this command will send every revision between 7 and <literal>tip</literal>, "
16258 "inclusive."
16259 msgstr ""
16261 #. type: Content of: <book><chapter><sect1><para>
16262 #: ../en/ch13-hgext.xml:455
16263 msgid ""
16264 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
16265 "you provide a repository but no revisions, the <command role=\"hg-ext-"
16266 "patchbomb\">email</command> command will send all revisions in the local "
16267 "repository that are not present in the remote repository. If you "
16268 "additionally specify revisions or a branch name (the latter using the <option "
16269 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
16270 "constrain the revisions sent."
16271 msgstr ""
16273 #. type: Content of: <book><chapter><sect1><para>
16274 #: ../en/ch13-hgext.xml:464
16275 msgid ""
16276 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
16277 "command> command without the names of the people you want to send to: if you "
16278 "do this, it will just prompt you for those values interactively. (If you're "
16279 "using a Linux or Unix-like system, you should have enhanced "
16280 "<literal>readline</literal>-style editing capabilities when entering those "
16281 "headers, too, which is useful.)"
16282 msgstr ""
16284 #. type: Content of: <book><chapter><sect1><para>
16285 #: ../en/ch13-hgext.xml:472
16286 msgid ""
16287 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
16288 "\">email</command> command will by default use the first line of the "
16289 "changeset description as the subject of the single email message it sends."
16290 msgstr ""
16292 #. type: Content of: <book><chapter><sect1><para>
16293 #: ../en/ch13-hgext.xml:477
16294 msgid ""
16295 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
16296 "command> command will usually send one message per changeset. It will "
16297 "preface the series with an introductory message, in which you should describe "
16298 "the purpose of the series of changes you're sending."
16299 msgstr ""
16301 #. type: Content of: <book><chapter><sect1><sect2><title>
16302 #: ../en/ch13-hgext.xml:484
16303 msgid "Changing the behaviour of patchbombs"
16304 msgstr "修改 patchbomb 的行为"
16306 #. type: Content of: <book><chapter><sect1><sect2><para>
16307 #: ../en/ch13-hgext.xml:486
16308 msgid ""
16309 "Not every project has exactly the same conventions for sending changes in "
16310 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
16311 "accommodate a number of variations through command line options."
16312 msgstr ""
16314 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16315 #: ../en/ch13-hgext.xml:492
16316 msgid ""
16317 "You can write a subject for the introductory message on the command line "
16318 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
16319 "option. This takes one argument, the text of the subject to use."
16320 msgstr ""
16322 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16323 #: ../en/ch13-hgext.xml:498
16324 msgid ""
16325 "To change the email address from which the messages originate, use the "
16326 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
16327 "takes one argument, the email address to use."
16328 msgstr ""
16330 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16331 #: ../en/ch13-hgext.xml:504
16332 msgid ""
16333 "The default behaviour is to send unified diffs (see <xref linkend=\"sec:mq:"
16334 "patch\"/> for a description of the format), one per message. You can send a "
16335 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
16336 "\">hg -b</option> option."
16337 msgstr ""
16339 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16340 #: ../en/ch13-hgext.xml:512
16341 msgid ""
16342 "Unified diffs are normally prefaced with a metadata header. You can omit "
16343 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
16344 "email-opt\">hg --plain</option> option."
16345 msgstr ""
16347 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16348 #: ../en/ch13-hgext.xml:518
16349 msgid ""
16350 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
16351 "description of a patch. This makes it easiest for the largest number of "
16352 "readers to quote and respond to parts of a diff, as some mail clients will "
16353 "only quote the first MIME body part in a message. If you'd prefer to send the "
16354 "description and the diff in separate body parts, use the <option role=\"hg-"
16355 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
16356 msgstr ""
16358 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16359 #: ../en/ch13-hgext.xml:528
16360 msgid ""
16361 "Instead of sending mail messages, you can write them to an <literal>mbox</"
16362 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
16363 "email-opt\">hg -m</option> option. That option takes one argument, the name "
16364 "of the file to write to."
16365 msgstr ""
16367 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
16368 #: ../en/ch13-hgext.xml:535
16369 msgid ""
16370 "If you would like to add a <command>diffstat</command>-format summary to each "
16371 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
16372 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
16373 "command> command displays a table containing the name of each file patched, "
16374 "the number of lines affected, and a histogram showing how much each file is "
16375 "modified. This gives readers a qualitative glance at how complex a patch is."
16376 msgstr ""